akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<queue>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//int H,W;
//queue<P>  que;


int bfs(int H, int W,queue<P> que,vector<vector<int> > flag, vector<vector<int> > yoko, vector<vector<int> > tate){
    while(!que.empty()){
        P p = que.front(); que.pop();

        if(p == P(H-1,W-1)){
            return flag[p.first][p.second];
        }

        if(yoko[p.first][p.second] == 0 && 0 <= p.first-1 && flag[p.first-1][p.second] == -1){
            flag[p.first-1][p.second] = flag[p.first][p.second] + 1;
            que.push(P(p.first-1,p.second));
        }
        if(yoko[p.first+1][p.second] == 0 && p.first+1 < H  && flag[p.first+1][p.second] == -1){
            flag[p.first+1][p.second] = flag[p.first][p.second] + 1;
            que.push(P(p.first+1,p.second));
        }
        if(tate[p.first][p.second] == 0 && 0 <= p.second-1 && flag[p.first][p.second-1] == -1){
            flag[p.first][p.second-1] = flag[p.first][p.second] + 1;
            que.push(P(p.first,p.second-1));
        }
        if(tate[p.first][p.second+1] == 0 && p.second+1 < W  && flag[p.first][p.second+1] == -1){
            flag[p.first][p.second+1] = flag[p.first][p.second] + 1;
            que.push(P(p.first,p.second+1));
        }
    }

    return 0;

}

int main(){
    //cin.tie(nullptr);
	//ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    vector<int> ans;
    while(true){
    int W,H;
    queue<P> que;
    vector<vector<int> > flag;
    vector<vector<int> > yoko;
    vector<vector<int> > tate;
    cin>>W>>H;
    if(W == 0 && H == 0) {
        REP(i,ans.size()){
            cout << ans[i] << endl;
        }
        return 0;
    }
    else{
    yoko.resize(H+1,vector<int>(W+1));
    tate.resize(H+1,vector<int>(W+1));
    flag.resize(H,vector<int>(W,-1));
    REP(i,2*H+1){

        if(i % 2 != 0){
            tate[i/2][0] = 1;
            FOR(k,1,W){
                cin >> tate[i/2][k];
            }
            tate[i/2][W] = 1;
        }
        else{
            if(i == 0 || i == 2*H){
                REP(k,W){
                    yoko[i/2][k] = 1;
                }
            }
            else{
                REP(k,W){
                    cin >> yoko[i / 2][k];
                }
            }
        }
    }

    que.push(P(0,0));
    flag[0][0] = 1;
    int a = bfs(H,W,que,flag,yoko,tate);
        ans.push_back(a);

    }
    }
    
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c=0,p=0; cin >>n >>m;
  vector<bool>v(n,0); vector<int>sum(n,0);
  for(int i=0; i<m; i++){
    int p; string s; cin >>p >>s;
    if(!v[p-1]){
      if(s=="WA") sum[p-1]++;
      else{v[p-1]=1; c++;}
    }
  }
  for(int i=0; i<n; i++) if(v[i]) p+=sum[i];
  cout <<c<<" "<<p;
return 0;}

Measured memory_bytes: 640
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: String = input();
    if n.contains('7') {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int f(int n) {
  int a = 1000000000;
  int ans = 0;
  while (a >= 1) {
    ans += n/a;
    n %= a;
    a /= 10;
  }
  return ans;
}

int main(){
  int n;
  cin>>n;
  if ((n % f(n)) == 0) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}



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

l = []
aas = []

for i in range(n):
    a = int(input())
    aas.append(a)
    s = [list(map(int,input().split())) for i in range(a)]
    l.append(s)

for i in range(2**n):
    flag_n = [1]*n
    for j in range(n):
        if ((i >> j)&1):
            flag_n[n-1-j] = 0
    cnt = 0
    for k in range(n):
        if flag_n[k] == 1:
            if all(l[k][m][1] == flag_n[l[k][m][0]-1] for m in range(aas[k])):
                cnt += 1
        if cnt == sum(flag_n):
            print(sum(flag_n))
            exit()

print(0)
        


Measured memory_bytes: 70412
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  vector<vector<ll>> dp(s.size() + 1, vector<ll>(4));
  dp[0][0] = 1;
  ll mod = 1000000007;
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < 4; j++) {
      dp[i + 1][j] += dp[i][j] * (s[i] == '?' ? 3 : 1);
      dp[i + 1][j] %= mod;
      if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j + 1] %= mod;
      }
    }
  }
  cout << dp[s.size()][3] << endl;
  return 0;
}

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

int main()
{
    long long a,b,k;
    cin>>a>>b>>k;
    long long sum=min(a,k);
    k-=sum;
    a-=sum;
    if(k<=0)
    {
        cout<<a<<" "<<b<<endl;
        return 0;
    }

    sum=min(b,k);
    b-=sum;
   // cout<<sum<<endl;
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }
void printArr(int *a, int len){for(int i=0; i<len; i++){if(i)cout << " ";cout << a[i];}cout << endl;}

int main(int argc, const char * argv[]) {
  std::cout << std::fixed << std::setprecision(15);

  ll K; cin >> K;

  ll sum = 0;
  rep2(i, 1, K+1){
    rep2(j, 1, K+1){
      rep2(k, 1, K+1){
        sum += gcd(gcd(i, j), k);
      }
    }
  }

  cout << sum << endl;
}  


Measured memory_bytes: 3632
use proconio::marker::Usize1;
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        ch: Usize1,
        cw: Usize1,
        dh: Usize1,
        dw: Usize1,
        s: [proconio::marker::Bytes;h],
    }
    let mut d=vec![vec![INF;w];h];
    let mut q=std::collections::VecDeque::new();
    q.push_back((ch,cw));
    d[ch][cw]=0;
    while let Some((x,y))=q.pop_front() {
        let v=d[x][y];
        if (dh,dw)==(x,y) {
            println!("{}",v);
            return;
        }
        let dxy=[0,1,0,!0,0];
        for i in 0..4 {
            let x=x.wrapping_add(dxy[i]);
            let y=y.wrapping_add(dxy[i+1]);
            if x<h && y<w && s[x][y]==b'.' && d[x][y]>v {
                q.push_front((x,y));
                d[x][y]=v;
            }
        }
        let v=v+1;
        for dx in -2..3 {
            for dy in -2..3 {
                let x=x.wrapping_add(dx as usize);
                let y=y.wrapping_add(dy as usize);
                if x<h && y<w && s[x][y]==b'.' && d[x][y]>v {
                    q.push_back((x,y));
                    d[x][y]=v;
                }
            }
        }
    }
    println!("-1");
}
const INF: i64=std::i64::MAX;

Measured memory_bytes: 12192
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, K, count = 0;
  cin >> N >> K;
  vector<int> A(N, 0);
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x; x--;
    A.at(x)++;
  }
  for(int i = 0; i < N; i++) {
    if(A.at(i)) count++;
  }
  count -= K;
  sort(A.begin(), A.end());
  int cc = 0, KK = 0;
  for(int i = 0; KK < count; i++) {
    if(A.at(i)) {
      cc += A.at(i); KK++;
    }
  }
  cout << cc << endl;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int n;
VI a;

vector<bool> isprime(300000, true);

void solve() {
	isprime[0] = false;
	isprime[1] = false;

	for (int i = 2; i < 300000; i++) {
		if (!isprime[i])continue;
		for (int j = 2; i*j < 300000; j++) {
			isprime[i*j] = false;
		}
	}
}



int main() {
	
	
	cin >> n;

	REP(i, n) {
		int b;
		cin >> b;
		a.push_back(b);
	}

	reverse(ALL(a));

	VI ans(n+1, 0);
	VI v(n+1, 0);
	int cnt = 0;

	REP(i, n) {
		
		int j = n - i;
		if (v[j]%2 == a[i])continue;
		ans[j] = 1;
		cnt++;
		int k = 1;
		for (; k*k < j; k++) {
			if (j%k == 0) {
				v[j / k]++;
				v[k]++;
			}
		}
		if (k*k == j)v[j / k]++;
	}


	cout << cnt << endl;

	REP(i, n + 1) {
		if (ans[i] == 1)cout << i << ' ';
	}


	
	


	return 0;
}




Measured memory_bytes: 3448
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

int main() {
    ll N;
    cin >> N;
    double sum = 0.0;
    for (ll i = 0; i < N; i++) {
        ll Ai;
        cin >> Ai;
        sum += 1.0 / Ai;
    }
    sum = 1.0 / sum;
    cout << fixed << setprecision(10) << sum << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

int N;
int K;
int h[112345];
int ans = mod;

int main(){
	
	cin>>N>>K;
	K--;
	REP( i, N ) scanf("%d", h+i );
	sort( h, h+N );
	
	REP( i, N-K ) ans = min( ans, h[i+K]-h[i] );
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    map <int, int> mp;
    int a, b, c;
    cin >> a >> b >> c;
    mp[a] ++;
    mp[b] ++;
    mp[c] ++;

    cout << mp.size();
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    private final static Main main = new Main();

    public static void main(String[] args)
    {
        main.contest();
    }

    private void contest()
    {
        Scanner sc = new Scanner(System.in);
        char[] as = sc.nextLine().toCharArray();
        int k = sc.nextInt();
        int n = as.length;

        // まずaにできるやつはaにする
        for(int i=0; i<n; ++i)
        {
            // もともとaのものは無視
            if(as[i] == 'a')
            {
                continue;
            }
            // aにするために必要な操作数
            int action = 'z' - as[i] + 1;
            if(k < action)
            {
                // 残りの操作可能数より多い
                continue;
            }
            k -= action;
            as[i] = 'a';
        }
        char c = (char) (as[n-1] + (k%26));
        as[n-1] = c > 'z' ? (char) ('a' + c-'z') : c;
        System.out.println(as);
    }
}


Measured memory_bytes: 14400
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());

			List<int> list = new List<int>();
			list.Add(1);
			for (int i = 6; i <= n; i *= 6) {
				list.Add(i);
			}
			for (int i = 9; i <= n; i *= 9) {
				list.Add(i);
			}
			list.Sort();
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", list.OrderBy(p => p)));

			// 100000
			int[] dp = new int[n + 2];
			for (int i = 1; i < dp.Length; i++) {
				dp[i] = n;
			}
			for (int i = 1; i <= n; i++) {
				foreach (var j in list) {
					if (i - j >= 0) {
						dp[i] = Math.Min(dp[i], dp[i - j] + 1);
					} else {
						break;
					}
				}
			}
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", dp));
			Console.WriteLine(dp[n]);

		}
	}
}


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

int main() {
	const int m = 1000000007;
	int n;
	string s, t;
	cin >> n >> s >> t;
	vector<bool> a;
	for (int i = 0; i < n; i++) {
		a.push_back(i < n - 1 && s[i] == s[i + 1]);
		if (a.back()) {
			i++;
		}
	}
	long long r = 3;
	for (int i = 0, size = a.size(); i < size; i++) {
		if (i > 0 && a[i - 1] && a[i]) {
			r = r * 3 % m;
		} else if (a[i] || i > 0 && !a[i - 1] && !a[i]) {
			r = r * 2 % m;
		}
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))

int main() {

    int n,m;cin>>n>>m;

    priority_queue<ll> pq;

    rep(i,n) {
        ll a;cin>>a;pq.push(a);
    }

    rep(i,m) {
        ll b = pq.top();pq.pop();
        b/=2;
        pq.push(b);
    }
    ll ans=0;
    rep(i,n) {
        ans+=pq.top();pq.pop();
    }
    cout<<ans<<endl;




}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 200005
int n;
vi e[MN];
int p[MN];
int sz[MN];
int szu[MN];
ll dp[MN];
ll dpu[MN]; //dp from the PARENT, not this
ll ans[MN];
ll gou[MN];

ll fac[MN];
ll ifac[MN];
pll gcd(ll a, ll b){ //a*first+b*second=gcd
    if(a == 0){
        return mp(0, 1);
    }

    pll prev = gcd(b%a, a);

    return mp(prev.s-(b/a)*prev.f, prev.f);
} //using ll's just to be safe wrt overflow issues
ll modInv(ll x){ //return x^-1 % MOD
    pll res = gcd(x, MOD);

    res.f = (res.f+MOD)%MOD;

    //cout << "modinv of " << x << " is " << res.f << "\n";

    return res.f;
}
ll getFacs(){
    fac[0] = 1;
    FOR(i, 1, MN-1){
        fac[i] = (fac[i-1]*i)%MOD;
    }
    ifac[MN-1] = modInv(fac[MN-1]);
    RFOR(i, MN-1, 1){
        ifac[i-1] = (ifac[i]*i)%MOD;
    }
}
ll modDiv(ll x, ll y){
    return (x*modInv(y))%MOD;
}

void dfs1(int cn){
    dp[cn] = 1;
    for(auto nn : e[cn]) if(nn != p[cn]){
        p[nn] = cn;
        dfs1(nn);
        sz[cn] += sz[nn];
        dp[cn] = (dp[cn]*ifac[sz[nn]])%MOD;
        dp[cn] = (dp[cn]*dp[nn])%MOD;
    }
    dp[cn] = (dp[cn]*fac[sz[cn]])%MOD;
    sz[cn]++;
}
void dfs2(int cn){
    if(p[cn] == 0){
        ans[cn] = dp[cn];
        szu[cn] = 0;
        dpu[cn] = 1;
        gou[cn] = 1;
    } else{
        int par = p[cn];
        szu[cn] = n-sz[cn];
        ll rem = modDiv((ifac[sz[par]-1]*fac[sz[cn]])%MOD, dp[cn]);
        ll ad = (gou[par]*fac[szu[cn]-1])%MOD;
        dpu[cn] = ((dp[par]*rem)%MOD*ad)%MOD;

        gou[cn] = (dpu[cn]*ifac[szu[cn]])%MOD;

        ll facts = (fac[n-1]*ifac[sz[cn]-1])%MOD;
        ll logic = gou[cn];
        ans[cn] = ((facts*logic)%MOD*dp[cn])%MOD;
        //cout << cn << " " << rem << " " << ad << " " << facts << " " << logic << " " << gou[cn] << "\n";
    }
    for(auto nn : e[cn]) if(nn != p[cn]){
        dfs2(nn);
    }
}

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

    getFacs();

    cin >> n;
    F0R(i, n-1){
        int a, b;
        cin >> a >> b;
        e[a].pb(b);
        e[b].pb(a);
    }

    dfs1(1);
    dfs2(1);
    FOR(i, 1, n){
        //cout << dp[i] << " " << dpu[i] << "\n";
        cout << ans[i] << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 25716
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    a.push_back(0);
    int cnt = 0;
    rep(i, n) {
        if(a[i] == a[i+1]) i++;
        else cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
    int x, y, z;
    int tmp;
    cin >> x >> y >> z;

    // a swap b
    tmp = x;
    x = y;
    y = tmp;

    // a swap c
    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
}

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

int main(){
  int A,B,N;
  cin>>N>>A>>B;
  
  int sum=0;
  
  for(int j=1;j<=N;j++){
    
    int X=0;
  
  for(int i=0;i<j;i++){
    
    int a=j/pow(10,i);
  
X+=a%10;
    
    if(a==0){
      break;
    }
  }
 
       if(X>=A&&X<=B){
         sum+=j;

       }
       
       }
       
       cout<<sum<<endl;
       }
       
  
  
    

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/25 15:55:04 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	long double	a, b, c;
	cin >> a >> b >> c;

	if (a + b + 2.0 * sqrtl(a * b) < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3 5
0 0 1
0 1 2
0 2 3
1 0 2
1 1 2

output:
1
2
"""

import math
import sys


class SegmentTree(object):
    __slots__ = ('dat', 'tree_range')

    def __init__(self, n):
        """
        Init a SegmentTree with update and find for range minimum queries.
        """
        self.tree_range = pow(2, math.ceil(math.log2(n)))
        self.dat = [float('inf')] * (2 * self.tree_range - 1)

    # let A[k]=a
    def update(self, k, a):
        k += self.tree_range - 1
        self.dat[k] = a
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = min(self.dat[k * 2 + 1], self.dat[k * 2 + 2])

    # get min(A[s] A[s+1] ... A[t])
    def find(self, s, t, k=0, left=0, right=float('inf')):
        if right <= s or t <= left:
            return float('inf')
        elif s <= left <= right <= t:
            return self.dat[k]
        else:
            vl = self.find(s, t, k * 2 + 1, left, (left + right) // 2)
            vr = self.find(s, t, k * 2 + 2, (left + right) // 2, right)
            return min(vl, vr)


def action(cmd_list, n_num):
    case = SegmentTree(n_num)
    end = pow(2, math.ceil(math.log2(n_num)))
    init_max = pow(2, 31) - 1

    for query in cmd_list:
        cmd, ele_1, ele_2 = map(int, query)
        if cmd == 0:
            case.update(ele_1, ele_2)
        elif cmd == 1:
            assert ele_1 <= ele_2
            res = case.find(s=ele_1, t=ele_2 + 1, right=end)
            if math.isinf(res):
                print(init_max)
            else:
                print(res)

    return None


def solve():
    _input = sys.stdin.readlines()
    n_num, q_num = map(int, _input[0].split())
    q_list = map(lambda x: x.split(), _input[1:])

    action(q_list, n_num)
    return None


if __name__ == '__main__':
    solve()

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];
  sort(a, a + 3);
  if (a[0] % 2 == 0 or a[1] % 2 == 0 or a[2] % 2 == 0) cout << 0 << "\n";
  else cout << (long long) a[0] * a[1] << "\n";
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int sec = 0;
        for (int i = 0; i < 4; i++)
            sec += Integer.parseInt(sc.nextLine());
        System.out.println(sec / 60);
        System.out.println(sec % 60);
    }
}

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

int main() {
    int hour, min, sec;
    cin >> sec;
    min = sec / 60;
    sec -= min * 60;
    hour = min / 60;
    min -= hour * 60;
    cout << hour << ":" << min << ":" << sec << endl;

    return 0;
}

Measured memory_bytes: 1168
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"2 ip cc"# => r#"icpc"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize,
        s: chars,
        t: chars,
    }
    let mut ans = "".to_string();

    for i in 0..n {
        ans.push_str(&s[i].to_string());
        ans.push_str(&t[i].to_string());
    }

    ans
}

Measured memory_bytes: 4352
import java.util.Scanner;

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

			int n = sc.nextInt();
			int[] d = new int[n];
			
			for(int i = 0 ; i < n ; i++ ) {
				d[i] = sc.nextInt();
			}
			
			int result = 0;
			
			for(int i = 0 ; i < n ; i++ ) {
				for(int j = i+1 ; j < n ;j++ ) {
					result += d[i] * d[j];
				}
			}
			
			
			System.out.println(result);
			
		}
	}
}



Measured memory_bytes: 21588
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<ll> X(N+3,0);
	for(int i = 1; i <= N; ++i) cin >> X[i];
	ll L; cin >> L;
	X[N+1] = X[N]+1;
	X[N+2] = X[N+1]+L;

	V<V<int>> Y(N+2,V<int>(20));
	for(int i = 1; i <= N; ++i){
		int idx = int(upper_bound(ALL(X),X[i]+L)-X.begin()) - 1;
		Y[i][0] = idx;
	}
	for(int i = 0; i < 20; ++i) Y[N+1][i] = N+1;
	for(int i = 1; i < 20; ++i){
		for(int j = 1; j <= N; ++j){
			Y[j][i] = Y[Y[j][i-1]][i-1];
		}
	}
	int Q; cin >> Q;
	V<int> ans(Q);
	for(int q = 0; q < Q; ++q){
		int a,b; cin >> a >> b;
		if(a>b) swap(a,b);

		int ok = N,ng = 0,md;
		while(ok-ng>1){
			int md = (ok+ng)/2;
			int from = a,to = b;
			for(int i = 0; i < 20; ++i){
				if( !(md & (1<<i)) ) continue;
				from = Y[from][i];
			}
			(from >= to? ok:ng) = md;
		}
		ans[q] = ok;
	}
	for(int i = 0 ; i < Q; ++i) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int m;
string str;
vector<int> G[200005];
vector<int> G2[200005];
bool used[200005];
int a[200005],b[200005];
bool gr[200005];
int cnta[200005];
int cntb[200005];
int cr=0;
bool queueed[2000005];
bool flag;

void dfs(int v,int p){
	used[v]=true;
	if(gr[v])cr++;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!gr[nv])continue;
		if(nv!=p && used[nv]){
			flag=true;
		}
		if(nv!=p && !used[nv]){
			dfs(nv,v);
		}
	}
}

int main(void){
	scanf("%d%d",&n,&m);
	cin >> str;
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	flag=true;
	queue<int> que;
	for(int i=0;i<n;i++){
		int cnt=0;
		for(int j=0;j<G[i].size();j++){
			int v=G[i][j];
			if(str[v]=='A')cnta[i]++;
			if(str[v]=='B')cntb[i]++;
		}
		if(cnta[i]==0 || cntb[i]==0){
			que.push(i);
			queueed[i]=true;
		}
	}
	while(que.size()){
		int v=que.front();
		que.pop();
		for(int i=0;i<G[v].size();i++){
			int nv=G[v][i];
			if(str[v]=='A'){
				cnta[nv]--;
			}else{
				cntb[nv]--;
			}
			if((cnta[nv]==0 || cntb[nv]==0) && !queueed[nv]){
				queueed[nv]=true;
				que.push(nv);
			}
		}
	}
	for(int i=0;i<n;i++){
		if(cnta[i]>0 && cntb[i]>0){
			gr[i]=true;
		}
	}
	flag=false;
	for(int i=0;i<n;i++){
		if(!used[i] && gr[i]){
			cr=0;
			dfs(i,-1);
			if(cr>=2){
				flag=true;
			}
		}
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
} 

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



int main(){
    int n,i=0,t=0;
    cin >> n;
    vector <int> v(n),c(n);
    for (i=0;i<n;i++){
        cin >> v[i];
    }
    for (i=0;i<n;i++){
        cin >> c[i];
    }
    for (i=0;i<n;i++){
        if (v[i]-c[i] >0){
            t= t+ v[i] - c[i];
        }
            
    }

    cout<< t<<endl;
    return 0;
}

Measured memory_bytes: 256
def isPrime(n):
    if n == 2 or n == 3:
        return True
    elif n == 1 or n % 2 == 0 or n % 3 == 0:
        return False
    N = int(n ** 0.5)
    for i in range(5, N + 1, 2):
        if n % i == 0:
            return False
    return True

N = int(input())
ans = 0
for _ in range(N):
    a = int(input())
    ans += 1 if isPrime(a) else 0
print(ans)

Measured memory_bytes: 7708
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      auto A = new long[N];
      foreach (i; 0 .. N) {
        A[i] = readLong();
      }
      auto B = new long[N];
      foreach (i; 0 .. N) {
        B[i] = readLong();
      }
      
      const im = A.maxIndex;
      A = A[im .. N] ~ A[0 .. im + 1];
      B = B[im .. N] ~ B[0 .. im];
      debug {
        writeln("A = ", A);
        writeln("B = ", B);
      }
      
      // fs[i] = -B[i] + (fs[i - 1] + fs[i + 1]) / 2
      auto fs = new long[N + 1];
      foreach (i; 1 .. N) {
        fs[i + 1] = 2 * (fs[i] + B[i]) - fs[i - 1];
      }
      
      auto ys = new long[N + 1];
      foreach (i; 0 .. N + 1) {
        ys[i] = A[i] - fs[i];
      }
      debug {
        writeln("fs = ", fs);
        writeln("ys = ", ys);
      }
      
      long tri(int i0, int i1, int i2) {
        return (i1 - i0) * (ys[i2] - ys[i0]) - (i2 - i0) * (ys[i1] - ys[i0]);
      }
      
      int jsLen;
      auto js = new int[N + 1];
      foreach (i; 0 .. N + 1) {
        for (; jsLen >= 2 && tri(js[jsLen - 2], js[jsLen - 1], i) >= 0; --jsLen) {}
        js[jsLen++] = i;
      }
      debug {
        writeln("js = ", js[0 .. jsLen]);
      }
      
      long ans;
      foreach (k; 0 .. jsLen - 1) {
        const i0 = js[k];
        const i1 = js[k + 1];
        ans += (i1 - i0) * (ys[i0] + ys[i1]);
      }
      foreach (i; 0 .. N) {
        ans += fs[i];
        ans += fs[i + 1];
      }
      writefln("%.20f", ans / 2.0L / N);
    }
  } catch (EOFException e) {
  }
}


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

int main(){
	int data[10];
	for( int i=0; i<10; i++ ){
		cin >> data[i];
	}

	for( int i=0; i<10; i++ ){
		for( int j=9; j>=i; j-- ){
			if( data[j-1] < data[j] ){
				int tmp = data[j-1];
				data[j-1] = data[j];
				data[j] = tmp;
			}
		}
	}

	for( int i=0; i<3; i++ ){
		cout << data[i] << endl;
	}
}

Measured memory_bytes: 0
#include<cstdio>
int f(int n){
    if(n%2==0)return n/2;
    else return 3*n+1;
}
int main(){
    int s;
    scanf("%d",&s);
    if(s==1||s==2||s==4){
        printf("4\n");
        return 0;
    }
    int cnt;
    for(cnt=0;s!=4;cnt++){
        s=f(s);
    }
    printf("%d\n",cnt+4);
    return 0;
}

Measured memory_bytes: 128
m,d=map(int,input().split())
if m in [1,3,5,7,8,10,12] and d==31:
  print(1)
elif m ==2 and d==28:
  print(1)
elif m in [4,6,9,11] and d==30:
  print(1)
else:
  print(0)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long  n,m,ans=0,i;
cin>>n>>m;
for(i=1;i<=m;i++)
{
	long long x;
	cin>>x;
	ans=ans+x;

}
  n=n-ans;
  if(n<0)
  {
   cout<<"-1"<<endl;
  }else
  {
  	cout<<n<<endl;
  }
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll x, y; cin >> x >> y;
    ll x_ = abs(x), y_ = abs(y);
    ll res;
    if(x == -y) res = 1;
    else if(x > y){
        if(x>0 && y>0) res = x-y+2;
        if(x>0 && y<0) res = abs(x_-y_)+1;
        if(x<0 && y<0) res = abs(x_-y_)+2;
        if(x == 0 || y == 0) res = abs(x-y)+1;
    }else{
        if(x>0 && y>0) res = y-x;
        if(x<0 && y>0) res = abs(abs(y)- abs(x))+1;
        if(x<0 && y<0) res = abs(x-y);
        if(x== 0 || y==0) res = abs(x-y);
    }
    cout << res << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;
 
 
int main(){
    int n; cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    int ans=INF;
    rep(i,n-1){
        int l=0; int r=0;
        rep(j,n){
            if(j<=i) l+=w[j];
            else r+=w[j];
        }
        ans=min(ans,abs(l-r));
    }
    cout << ans << endl;
return 0;
}

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

#define int long long int
int i;
main()
{
   int a[123]={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};
int n; cin>>n; cout<<a[n-1]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m; 
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},ans=-1000;
int dis[30][30],vis[30][30];
char a[30][30];
struct fwy{
	int xx,yy;
};
queue<fwy> q;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=m;j++){
    		cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#') continue;
			memset(dis,0,sizeof(dis));
			memset(vis,0,sizeof(vis));
			q.push((fwy){
				i,j
			});
			vis[i][j]=1;
			while(!q.empty()){
				fwy t=q.front();
				q.pop();
				for(int k=0;k<4;k++){
					int tx=t.xx+dx[k],ty=t.yy+dy[k];
					if(a[tx][ty]!='#'&&tx<=n&&tx>=1&&ty<=m&&ty>=1&&!vis[tx][ty]){
						vis[tx][ty]=1;
						dis[tx][ty]=dis[t.xx][t.yy]+1;
						ans=max(ans,dis[tx][ty]);
						q.push((fwy){
							tx,ty
						});
					}
				}
			}
		}
	}
	cout<<ans;
}

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

void solve() {
  string s, t;
  cin >> s >> t;
  set<string> ret;
  for(int i = 0; i <= (int)s.size() - (int)t.size(); i++) {
    bool can = true;
    string cand = "";
    for(int j = 0; j < s.size(); j++) {
      if(j < i || j >= i + t.size()) cand += s[j] == '?' ? 'a' : s[j];
      else {
        int real = j - i;
        if(t[real] != s[j] && s[j] != '?') can = false;
        else cand += t[real];
      }
    }
    if(can) ret.insert(cand);
  }
  if(ret.empty()) ret.insert("UNRESTORABLE");
  cout << *ret.begin() << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


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

int main() {
    long int a, b, c;
    cin >> a >> b >> c;
    if ( (a % 2 == 0) || (b % 2==0) || (c%2==0) ) {
        cout << 0 << endl;
    } else {
        cout << min(a*b, min(b*c, c*a)) << endl;
    }
}

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

struct Card{ char suit,value; };

void bubble(struct Card A[],int N){
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=i+1;j--){
      if(A[j].value<A[j-1].value){
	Card t=A[j]; A[j]=A[j-1]; A[j-1]=t;
      }
    }
  }
}

void selection(struct Card A[],int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
    Card t=A[i]; A[i]=A[minj]; A[minj]=t;
  }
}

void print(struct Card A[],int N){
  for(int i=0;i<N;i++){
    if(i>0)cout<<" ";
    cout<<A[i].suit<<A[i].value;
  }
  cout<<endl;
}

bool isStable(struct Card C1[], struct Card C2[],int N){
  for(int i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit)return false;
  }
  return true;
}

int main(){
  Card C1[100],C2[100];
  int N;
  char ch;

  cin>>N;
  for(int i=0;i<N;i++){
    cin>>C1[i].suit>>C1[i].value;
  }

  for(int i=0;i<N;i++)C2[i]=C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  cout<<"Stable"<<endl;
  print(C2,N);
  if( isStable(C1,C2,N) ){
    cout<<"Stable"<<endl;
  }else{
    cout<<"Not stable"<<endl;
  }
  return 0;
}
    
  
      
  



Measured memory_bytes: 3108
N = int(input())

count = 0
for _ in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
    else:
        count = 0
        continue
    if count == 3:
        break
if count == 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void LCS(char *x, char *y){
	int m = strlen(x+1);
	int n = strlen(y+1);
	int i, j, **c;

	c = malloc(sizeof(int)*(2000));
	for (i = 0; i <= m; i++)
		c[i] = malloc(sizeof(int)*(n+1));
	
	for (i = 0; i <= m; i++){
		for (j = 0; j <= n; j++){
			c[i][j] = 0;
		}
	}
	
	for (i = 1; i <= m; i++){
		for (j = 1; j <= n; j++){
			if (x[i] == y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else
				c[i][j] = c[i][j - 1];
		}
	}
	
	printf("%d\n", c[i-1][j-1]);
	for (i = 0; i < m; i++)free(c[i]);
	free(c);
	
}

int main(){
	int i, n;
	char x[2014], y[2014];

	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%s%s", x + 1, y + 1);
		LCS(x, y);
	}
	return 0;
}

Measured memory_bytes: 4616
#include <iostream>
#include <string>
using namespace std;
int main() {
	string a, b;
	cin >> a;
	cin >> b;
	if (a.size() - b.size() == 0) {
		for (int i = 0; i < a.size(); i++) {
			cout << a[i] << b[i];
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < b.size(); i++) {
			cout << a[i] << b[i];
		}
		cout << a[a.size() - 1] << endl;
	}
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=5e5+5;
char s[N];int n,res,t,fac[N];
int main(){
	scanf("%d%s",&n,s+1);
	t=0,res=1;
	fp(i,1,n<<1){
		if(t&1){
			if(s[i]=='W')++t;
			else res=mul(res,t--);
		}else{
			if(s[i]=='W'){
				if(!t)return puts("0"),0;
				res=mul(res,t--);
			}
			else ++t;
		}
	}
	if(t)return puts("0"),0;
	fp(i,1,n)res=mul(res,i);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384