akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
const string pattern[] = {"A", "KIH", "A", "B", "A", "R", "A"};
string str;

set<string> s;

int bit(int k, int x)
{
    return (x >> k & 1);
}

void init()
{
    for(int mask = 0; mask < (1 << 7); ++mask)
    {
        if(!bit(1, mask) || !bit(3, mask) || !bit(5, mask)) continue;
        string t = "";
        for(int k = 0; k < 7; ++k)
            if(bit(k, mask)) t = t + pattern[k];
        s.insert(t);
    }
}

void read_input()
{
    cin >> str;
}

bool can(string str)
{
    return s.find(str) != s.end();
}

void solve()
{
    if(can(str)) cout << "YES\n";
    else cout << "NO\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    init();
    read_input();
    solve();
}


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

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

using namespace std;

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a+b+c>=22)cout<<"bust";
  else cout<<"win";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define pll pair<ll,ll>
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 1e5+10,MAX = 2e5+10;

// A B C D H F E I G K L M N P S O Q R J U Z Y X T V W
int main()
{
    SPEED
    int n,i,j,k;
    cin>>n>>k;
    int a[n],dp[n];
    f(n) dp[i] = INT_MAX;
    f(n)cin>>a[i];
    dp[1] = abs(a[0]-a[1]),dp[0]=0;
    for(i=2;i<n;i++)
    {
        for(j=max(0,i-k);j<i;j++)
        dp[i] = min(dp[i],dp[j]+abs(a[j]-a[i]));
    }
    cout<<dp[n-1]<<"\n";
}

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


int main() {
    int A, B;
    cin >> A >> B;
    cout << ((B-1)+(A-2))/(A-1) << endl;
}



Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;
const int MAX_N = 105;
const int MAX_K = 100005;

int n, k;
int a[MAX_N];
ll dp[MAX_N][MAX_K];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	dp[0][0] = 1;
	dp[0][1] = -1;
	for (int i = 0; i <= n; i++)
	{
		//cout << "i = " << i << endl;
		for (int j = 0; j <= k; j++)
		{
			if (j != 0)
				dp[i][j] += dp[i][j - 1];
			while (dp[i][j] < 0)
				dp[i][j] += MOD;
			while (dp[i][j] >= MOD)
				dp[i][j] -= MOD;
			//cout << dp[i][j] << " ";

			if (i != n)
			{
				dp[i + 1][j] += dp[i][j];
				while (dp[i + 1][j] < 0)
					dp[i + 1][j] += MOD;
				while (dp[i + 1][j] >= MOD)
					dp[i + 1][j] -= MOD;

				if (j + a[i] < k)
				{
					dp[i + 1][j + a[i] + 1] -= dp[i][j];
					while (dp[i + 1][j + a[i] + 1] < 0)
						dp[i + 1][j + a[i] + 1] += MOD;
					while (dp[i + 1][j + a[i] + 1] >= MOD)
						dp[i + 1][j + a[i] + 1] -= MOD;
				}
			}
		}
		//cout << endl;
	}

	cout << dp[n][k] << endl;
}

Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<list>
#include<algorithm>
using namespace std;

long long GCD(const long long x ,const long long y){
  if (y==0) return x;
  return GCD(y,x % y);
}
int main () {
  int K;
  cin >> K ;
  long long sum=0;
  int gcd2=0;
  for (int a=1;a<=K;a++){
    for (int b=1;b<=K;b++) {
      gcd2=GCD(a,b);
      for (int c=1;c<=K;c++){
        sum+=GCD(gcd2,c);
      }
    }
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	while(a%2==0 && b%2==0 &&c%2==0 ){
		if(a == b && b == c){
			ans = -1;
			break;
		}
		int aa = b/2 + c/2;
		int bb = a/2 + c/2;
		int cc = a/2 + b/2;
		a = aa;
		b = bb;
		c = cc;
		ans++;
	}
	cout << ans;
}

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

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

  if (a.back() == b[0] and b.back() == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

int main(){
    int n;
    double m;
    cin >> n >> m;
    int a[n];
    int i;
    double all=0;
    for (i = 0; i<n ; i++){
        cin >> a[i];
        all += a[i];
    }
    
    double bunki=all / 4.0 / m;
    sort(a, a+n, std::greater<>());
    for (i = 0; i<m; i++){
        if(a[i] < bunki){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}

Measured memory_bytes: 3720
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();

        var similar = s[2] == s[3] && s[4] == s[5];
        
        Console.WriteLine(similar ? "Yes" : "No");
    }
}


Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            String[] S = new String[N];
            for (int i = 0; i < N; i++) {
                S[i] = sc.next();
            }

            HashMap<String, Integer> sToNumber = new HashMap<String, Integer>();
            for (int i = 0; i < N; i++) {
                Integer number = sToNumber.get(S[i]);
                sToNumber.put(S[i], 1 + (number == null ? 0 : number.intValue()));
            }

            ArrayList<String> list = new ArrayList<>();
            int max = 0;
            for (String key : sToNumber.keySet()) {
                int number = sToNumber.get(key).intValue();
                if (number >= max) {
                    if (number > max) {
                        max = number;
                        list.clear();
                    }
                    list.add(key);
                }
            }
            Collections.sort(list);

            for (int i = 0; i < list.size(); i++) {
                System.out.println(list.get(i));
            }
        }
    }
}

Measured memory_bytes: 73592
import java.util.*;

public class Main {
    public static Long getMin(Long x, Long y){
        return (x < y)? x : y;
    }

    public static Long getMax(Long x, Long y){
        return (x > y)? x : y;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Long h = sc.nextLong();
        Long w = sc.nextLong();
        Long ans = 0L;

        if(h % 3 != 0 && w % 3 != 0){
            if(h > w){
                Long tmp = h;
                h = w;
                w = tmp;
            }
            //System.out.println("h = " + h + ", w = " + w);
            Long s = h * w;
            Long smax, smin;
            Long min_h_loop = s;
            for(Long h_loop = 1L; h_loop < h; h_loop++){
                Long s_a = h_loop * w;
                Long s_b = ((h - h_loop) % 2L == 0L)? ((h - h_loop) / 2L) * w : (h - h_loop) * (w / 2L);
                Long s_c = s - s_a - s_b;
                smax = getMax(getMax(s_a, s_b), s_c);
                smin = getMin(getMin(s_a, s_b), s_c);
                min_h_loop = getMin(min_h_loop, smax - smin);
            }
            ans = min_h_loop;

            if(h < w){
                Long min_w_loop = s;
                for(Long w_loop = 1L; w_loop < w; w_loop++){
                    Long s_a = w_loop * h;
                    Long s_b = ((w - w_loop) % 2L == 0L)? ((w - w_loop) / 2L) * h : (w - w_loop) * (h / 2L);
                    Long s_c = s - s_a - s_b;
                    smax = getMax(getMax(s_a, s_b), s_c);
                    smin = getMin(getMin(s_a, s_b), s_c);
                    min_w_loop = getMin(min_w_loop, smax - smin);
                }
                ans = getMin(ans, min_w_loop);
            }
        }

        System.out.println(ans);
    }    
}

Measured memory_bytes: 37580
import java.util.Scanner;

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

		// 入力値の取得
		String S = sc.next();
		
		// 結果の出力
		if (S.equals("RRR")) {
			System.out.println(3);
		}
		else if (S.equals("RRS") || S.equals("SRR")) {
			System.out.println(2);
		}
		else if (S.equals("SSS")) {
			System.out.println(0);
		}
		else {
			System.out.println(1);
		}
		
		sc.close();
	}
}


Measured memory_bytes: 26988
n = int(input())
l = list(map(int, input().split()))

from collections import Counter
c = Counter(l)

total = 0
for i in c.values():
    if i != 1:
        total += i*(i-1)//2 # 組み合わせ_重複なしの数の公式を整理

for j in range(n): # 影響する部分のみ再計算(引く→足す)する
    tmp = c[l[j]]
    before = tmp*(tmp-1)//2 
    after = (tmp-1)*(tmp-2)//2
    print(total - before + after)


Measured memory_bytes: 32232
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string key = "keyence";
  int co = 0;
  rep(i, key.size()){
    if(s.at(i) != key.at(i)) break;
    co++;
  }
  string ss = s.substr(s.size()-(key.size()-co));
  string skey = key.substr(key.size()-(key.size()-co));
  // cerr << co << " " << ss << " " << skey << endl;
  if(ss == skey){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define MAXN 200005
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define int long long
#define endl '\n'

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// auto timer_start = chrono::steady_clock::now().time_since_epoch().count();

struct line {
    ll m, b;
    ll get(ll x){
        return m * x + b;
    }
};

struct node {
    ll i, j, mid;
    line res;
    node * l, * r;
    node(ll i, ll j, line res) : l(NULL), r(NULL), i(i), j(j), res(res), mid(i + (j - i) / 2){ }
} * seg;

void update(node * &seg, line v){
    bool checkL = seg->res.get(seg->i) > v.get(seg->i);
    bool checkM = seg->res.get(seg->mid) > v.get(seg->mid);

    if(checkM) swap(seg->res, v);
    if(seg->i == seg->j) return;

    if(checkL != checkM){
        if(!seg->l) seg->l = new node(seg->i, seg->mid, v);
        else update(seg->l, v);
    } else {
        if(!seg->r) seg->r = new node(seg->mid + 1, seg->j, v);
        else update(seg->r, v);
    }
}

ll query(node * seg, ll x){
    ll v = seg->res.get(x);
    if(seg->i == seg->j) return v;
    if(x <= seg->mid){
        if(seg->l) return min(v, query(seg->l, x));
    } else if(seg->r){
        return min(v, query(seg->r, x));
    }
    return v;
}

int n, c;

int32_t main(){
    fastio
    cin >> n >> c;
    int aux, res = INF;
    for(int i = 1; i <= n; i++){
        cin >> aux;
        if(i == 1){
            seg = new node(-1e9, 1e9, {-2 * aux, aux * aux});
        } else {
            res = c + aux * aux + query(seg, aux);
            update(seg, {-2 * aux, res + aux * aux});
        }
    }
    cout << res << endl;

    return 0;
}


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

using namespace std;

int main() {
    /* 入力受け取り */
    int n, Q;
    cin >> n >> Q;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];

    /* Q 回分のクエリを処理 */
    for (int j = 0; j < Q; ++j) {
        long long x; cin >> x; // 各クエリ x

        /* 合計値 */
        long long res = 0;

        /* 区間の左端 left で場合分け */
        int right = 0;     // 毎回 right を使い回すようにする
        long long sum = 0; // sum も使い回す
        for (int left = 0; left < n; ++left) {
            /* sum に a[right] を加えても大丈夫なら right を動かす */
            while (right < n && sum + a[right] <= x) {
                sum += a[right];
                ++right;
            }

            /* break した状態で right は条件を満たす最大 */
            res += (right - left);

            /* left をインクリメントする準備 */
            if (right == left) ++right; // right が left に重なったら right も動かす
            else sum -= a[left]; // left のみがインクリメントされるので sum から a[left] を引く
        }

        cout << res << endl;
    }
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 2019;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    ll L,R;
    cin >> L >> R;
    ll l = L % MOD;
    ll r = R % MOD;
    ll ans = INF;
    if (l < r) {
        for (int i = l; i <= r; i++) {
            for (int j = l+1; j <= r; j++) {
                if (i == j) continue;
                ans = min(ans, (i) * (j) % MOD);
            }
        }
    }
    else {
        ans = 0;
    }
    if (R-L >= 2019) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v) (int)v.size()
#define debug(var) cout << #var << ": " << var << endl;
using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct p2 {
    int x, y;
    friend p2 operator+(const p2 &a, const p2 &b) {
        return {a.x + b.x, a.y + b.y};
    }
    friend bool operator==(const p2 &a, const p2 &b) {
        return tie(a.x, a.y) == tie(b.x, b.y);
    }
    friend bool operator<(const p2 &a, const p2 &b) {
        return tie(a.x, a.y) < tie(b.x, b.y);
    }
};

vector<p2> step0, step1;
void init_step() {
    step0 = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

    constexpr int len = 5;
    int lo = -len / 2;
    for (int i = 0; i < len; i++)
        for (int j = 0; j < len; j++)
            step1.push_back({i + lo, j + lo});
}

int main() {
    init_step();
    int h, w;
    cin >> h >> w;
    p2 c, d;
    cin >> c.x >> c.y;
    cin >> d.x >> d.y;
    vector<vector<char>> a(h + 1, vector<char>(w + 1));
    for (int i = 1; i <= h; i++) {
        getchar();
        for (int j = 1; j <= w; j++)
            cin >> a[i][j];
    }

    int ans = -1;
    queue<tuple<int, p2>> Q0, Q1;
    vector<vector<int>> vis(h + 1, vector<int>(w + 1));
    tuple<int, p2> temp = {0, c};
    Q0.push(temp);
    vis[c.x][c.y] = 1;
    while (!Q0.empty() || !Q1.empty()) {
        int exit = 0;
        while (!Q0.empty()) {
            auto [level, u] = Q0.front();
            Q0.pop();
            Q1.push({level, u});

            // cout << "0: " << u.x << " " << u.y << endl;

            if (u == d) {
                ans = level;
                exit = 1;
                break;
            }

            for (auto delta : step0) {
                p2 v = u + delta;
                int x = v.x, y = v.y;
                if (1 <= x && x <= h && 1 <= y && y <= w && a[x][y] == '.' &&
                    !vis[x][y]) {
                    Q0.push({level, v});
                    vis[x][y] = 1;
                }
            }
        }
        if (exit) break;

        while (!Q1.empty()) {
            auto [level, u] = Q1.front();
            Q1.pop();

            // cout << "1: " << u.x << " " << u.y << endl;

            if (u == d) {
                ans = level;
                exit = 1;
                break;
            }

            for (auto delta : step1) {
                p2 v = u + delta;
                int x = v.x, y = v.y;
                if (1 <= x && x <= h && 1 <= y && y <= w && a[x][y] == '.' &&
                    !vis[x][y]) {
                    Q0.push({level + 1, v});
                    vis[x][y] = 1;
                }
            }
        }
        if (exit) break;
    }

    cout << ans;
}

Measured memory_bytes: 8688
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        
        if ((n - 1) % (k - 1) == 0) {
            ans = (n - 1) / (k - 1);
        } else {
            ans = (n - 1) / (k - 1) + 1;
        }
        System.out.println(ans);
    }    
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a;
  for(int i=0;i<4;i++){
    a.push_back(n%10);
    n/=10;
  }
  if(a.at(0)==a.at(1) && a.at(1)==a.at(2)){
    cout<<"Yes"<<endl;
  }else if(a.at(1)==a.at(2) && a.at(2)==a.at(3)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main() {
	int c[5];
	while (scanf("%d,%d,%d,%d,%d", &c[0], &c[1], &c[2], &c[3], &c[4]) != EOF) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j<4; j++) {
				if (c[j] > c[j + 1]) {
					int tmp = c[j];
					c[j] = c[j + 1];
					c[j + 1] = tmp;
				}
			}
		}
		if ((c[0]==c[1]&&c[1]==c[2]&&c[2]==c[3])||(c[1]==c[2]&&c[2]==c[3]&&c[3]==c[4]))cout << "four card" << endl;
		else if ((c[0]==c[1]&&c[1]==c[2]&&c[3]==c[4])||(c[0]==c[1]&&c[2]==c[3]&&c[3]==c[4]))cout << "full house" << endl;
		else if ((c[0]==1&&c[1]==10&&c[2]==11&&c[3]==12&&c[4]==13)||(c[0]+1==c[1]&&c[0]+2==c[2]&&c[0]+3==c[3]&&c[0]+4==c[4]))cout << "straight" << endl;
		else if ((c[0]==c[1]&&c[1]==c[2])||(c[1]==c[2]&&c[2]==c[3])||(c[2]==c[3]&&c[3]==c[4]))cout << "three card" << endl;
		else if ((c[0]==c[1]&&c[2]==c[3])||(c[1]==c[2]&&c[3]==c[4])||(c[0]==c[1]&&c[3]==c[4]))cout << "two pair" << endl;
		else if ((c[0] == c[1]) || (c[1] == c[2]) || (c[2] == c[3]) || (c[3] == c[4]))cout << "one pair" << endl;
		else cout << "null" << endl;
	}
}


Measured memory_bytes: 3128
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int n = int.Parse(str1);

            int i;
            char suit;
            int card_num;
            bool[] S_cards = new bool[13] { true, true, true, true, true, true, true, true, true, true, true, true, true };
            bool[] H_cards = new bool[13] { true, true, true, true, true, true, true, true, true, true, true, true, true };
            bool[] C_cards = new bool[13] { true, true, true, true, true, true, true, true, true, true, true, true, true };
            bool[] D_cards = new bool[13] { true, true, true, true, true, true, true, true, true, true, true, true, true };

            for (i = 0; i < n; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                suit = char.Parse(str2[0]);
                card_num = int.Parse(str2[1]);
                switch(suit)
                {
                    case 'S':
                        S_cards[card_num - 1] = false;
                        break;
                    case 'H':
                        H_cards[card_num - 1] = false;
                        break;
                    case 'C':
                        C_cards[card_num - 1] = false;
                        break;
                    case 'D':
                        D_cards[card_num - 1] = false;
                        break;
                }
            }

            for (i = 0; i < 13; i++)
            {
                if (S_cards[i])
                    Console.WriteLine("S {0}", i + 1);
            }

            for (i = 0; i < 13; i++)
            {
                if (H_cards[i])
                    Console.WriteLine("H {0}", i + 1);
            }

            for (i = 0; i < 13; i++)
            {
                if (C_cards[i])
                    Console.WriteLine("C {0}", i + 1);
            }

            for (i = 0; i < 13; i++)
            {
                if (D_cards[i])
                    Console.WriteLine("D {0}", i + 1);
            }
        }
    }
}

Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<char,int> p;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		p[s[i]]++;
	}
	if(p.size()!=2){
		cout<<"No"<<endl;
		return 0;
	}
	else{
		for(auto x:p){
			if(x.second!=2){
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string s;
string t;

int main(){
    cin >> s;
    cin >> t;
    //cout << s << endl;
    //cout << t << endl;

    bool flag;

    for(int i = s.size() -t.size() ; i >= 0 ; i--){
      	flag = 1;
        // cout << s[i] << endl;
        if(s[i] == t[0] || s[i] == '?'){
            flag = 0;
            for(int j = 0; j < t.size(); j++){
                if(s[i+j] != '?' && s[i+j] != t[j]){
                    flag = 1;
                    break;
                } 
            }
        }
        if(flag == 0){
            for(int n = 0; n < t.size(); n++) s[i + n] = t[n];
            for(int m = 0; m < s.size(); m++){
                if(s[m] == '?') s[m] = 'a';
            }
            break;
        }
    }
    if(flag == 1){
       //  cout << s << endl;
         cout << "UNRESTORABLE" << endl;
    }
    else cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main()
{
	// 文字列の入力
	string s;
	cin >> s;

	if ((int)s.find("C") >= 0 && (int)s.find("F", (int)s.find("C"))>=1)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	// 出力
	return 0;
}

Measured memory_bytes: 256
// D - Triangles
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int solve(int N, vi &L){
	int ans = 0;
	rp(ia, 0, N-2){
		int a = L[ia];
		rp(ib, ia+1, N-1){
			int b = L[ib];
			rp(ic, ib+1, N){
				int c = L[ic];
				int minL = min({a,b,c});
				int maxL = max({a,b,c});
				int midL = a+b+c-minL-maxL;
				if(maxL < minL+midL ){
					ans++;
				}
			}
		}
	}
	return ans;
}

int main(){
	int N; cin>>N;
	vi L(N);
	rp(i, 0, N) cin>>L[i];
	cout<< solve(N, L) <<endl;
}

Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: A,B,N
      integer(16) :: maxB,i,ans,buffer,x
      real(16) :: reA,reB,reX
      
      read*,A,B,N
      
      maxB = (N/B) * B
 !     maxB = maxB - B !念のため
      
 !     maxB = max( maxB,N-10**7 )
      if( maxB<0 ) maxB = 0
      
      ans = 0
 !     do i = N,maxB,-1
 !       
 !       buffer = floor( real(A*i)/real(B) ) - A*floor(real(i)/real(B))
 !       ans = max( ans ,buffer )
 !     end do
      
      reA = real(A)
      reB = real(B)
      
     ! reX = real(maxB-1)
     ! buffer = int( floor( reA*reX/reB) - A*floor( reX/reB ) )
     ! ans = max( ans,buffer )
     ! reX = real( min(N,B-1))
     ! buffer = int( floor( reA*reX/reB) ) - A*int(floor( reX/reB ) )
      
      x = min( N,B-1 )
      if( x<0 ) x = N
      buffer = A*X/B - A*(X/B)
      ans = max( ans,buffer )
      
      print*,ans
      
      END PROGRAM

Measured memory_bytes: 2760
using System;

namespace AtCoder {
    class Lamps {
        public static void Main(string[] args) {
            var parts = Console.ReadLine().Split(' ');
            int N = int.Parse(parts[0]);
            int K = int.Parse(parts[1]);
            int[] A = new int[N];
            parts = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++) {
                A[i] = int.Parse(parts[i]);
            }
            for (int k = 0; k < K; k++) {
                int[] add = new int[N + 1];
                for (int i = 0; i < N; i++) {
                    int from = Math.Max(0, i - A[i]);
                    int to = Math.Min(N - 1, i + A[i]);
                    add[from]++;
                    add[to + 1]--;
                }
                int cur = 0;
                bool anySmall = false;
                for (int i = 0; i < N; i++) {
                    cur += add[i];
                    A[i] = cur;
                    if (A[i] < N) {
                        anySmall = true;
                    }
                }
                if (!anySmall) {
                    break;
                }
            }
            for (int i = 0; i < N; i++) {
                Console.Write(A[i] + " ");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 49516
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define rrep(i,a,b)for(int i=a;i<b;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
int n;
ll a[400000];
ll a1[400000];
ll a2[400000];
priority_queue<ll,vector<ll>,greater<ll> >q1;
priority_queue<ll>q2;
ll s1,s2;
int main(){
	cin>>n;
	rep(i,3*n)cin>>a[i];
	
	rep(i,n){s1+=a[i];q1.push(a[i]);}
	a1[0]=s1;
	q1.push(a[n]);
	s1+=a[n];

	rrep(i,2*n,3*n){s2+=a[i];q2.push(a[i]);}
	a2[n]=s2;
	q2.push(a[2*n-1]);
	s2+=a[2*n-1];

	for(int i=2*n-2;i>=n-1;i--){
		ll tmp=q2.top();
		q2.pop();
		s2-=tmp;
		//cout<<i-n+1<<" "<<s2<<endl;
		a2[i-n+1]=s2;
		s2+=a[i];
		q2.push(a[i]);
	}


	rrep(i,n+1,2*n+1){
		ll tmp=q1.top();
		q1.pop();
		s1-=tmp;
		//cout<<i-n<<" "<<s1<<endl;
		a1[i-n]=s1;
		s1+=a[i];
		q1.push(a[i]);
	}
	ll ans=a1[0]-a2[0];
	rep(i,n+1)ans=max(ans,a1[i]-a2[i]);
	cout<<ans<<endl;
	return 0;
}




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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef unsigned long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans = 0;
  rep(i, 62) {
    if ((1LL << i) * x <= y)
      ans++;
    else
      break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[555][555];
void sv(int x, int y, int s){
    if(x==y)
        return;
    int m=(x+y)/2;
    for(int i=x; i<=m; ++i){
        for(int j=m+1; j<=y; ++j){
            a[i][j]=s;
        }
    }
    sv(x, m, s+1);
    sv(m+1, y, s+1);
}
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        sv(1, n, 1);
        for(int i=1; i<n; ++i){
            for(int j=i+1; j<=n; ++j){
                printf("%d ",a[i][j]);
            }
            printf("\n");
        }
    }
  return 0;
}




Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<ll> ans(N+1, 0);
    rep(i, 2, N+1){
        ll a;
        cin >> a;
        ans[a]++;
    }
    rep(i, 1, N+1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
n = int(input())
a = map(int, input().split())
ans_lst = []
for ai in a:
    if ai == 1:
        ans_lst.append([1])
    else:
        for ans in ans_lst:
            if ans[-1] == ai - 1:
                ans.append(ai)
if len(ans_lst) == 0:
    print(-1)
else:
    min = 200001
    for i in range(len(ans_lst)):
        if min > len(ans_lst[i]):
            min = len(ans_lst[i])
    print(n - min)

Measured memory_bytes: 25800
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < s.size() / 2;  ++i) {
        if (s[i] != s[s.size() - i - 1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  while(true){
    int X,Y;
    int ans = 0;
    cin >> X >> Y;
    if( X == Y && Y == 0 ) break;
    if( Y > X ) swap( X, Y );

    do{
      X=X%Y;
      swap(X,Y);
      ++ans;
    }while(Y!=0);

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

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  int a[30],b[30];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  int res=0;
  for(int i=0;i<n;i++){
    if(a[i]-b[i]>=0)res+=a[i]-b[i];
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
H, N = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

inf = 10 ** 9
dp = [0] + [inf] * H

for h in range(1, H + 1):
    for n in range(1, N + 1):
        a, b = List[n - 1]
        ref = h - a
        if ref < 0: ref = 0
        dp[h] = min(dp[h], dp[ref] + b)
        

print(dp[H])


Measured memory_bytes: 74120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }

    int ans = n;
    sort(s.begin(), s.end());
    for (int i = 0; i < n - 1; i++)
    {
        if (s.at(i) == s.at(i + 1))
        {
            ans--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9600
import java.util.Scanner;

class Main {
    static int serialNum;
    static String[] charList = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    static String output ="";
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        sc.close();
        convertChar(n);
        System.out.println(output);

    }

    static long convertChar(long num){
        if(num==0){
            return 0;
        }
        output = charList[(int) ((num-1)%26)] + output;
        return convertChar((num-1)/26);
    }
}

Measured memory_bytes: 39244
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

ll N;
ll L[100];
bool seen[100] = {false};
ll Lucas(int i){
  if(seen[i] == true || i < 2) return L[i];
  seen[i] = true;
  L[i] = Lucas(i-1) + Lucas(i-2);
  return L[i];
}

int main(){
  cin >> N;
  L[0] = 2; L[1] = 1;
  if(N >= 2) L[N] = Lucas(N-1) + Lucas(N-2);
  cout << L[N] << endl;
  return 0;
}


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

const double pi = acos(-1);

int main() {
    int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;
    printf("%d\n", c*60+d-a*60-b-k);
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> B(n - 1);
    for(int i = 0; i < n - 1; i++){
        cin >> B[i];
    }

    vector<int> A(n + 10, 0);
    for(int i = 0; i < n - 1; i++){
        if(i == 0){
            A[i] = B[i];
            A[i + 1] = B[i];
        }else{
            if(A[i] > B[i]){
                A[i] = B[i];
                A[i + 1] = B[i]; 
            }else{
                // A[i] = B[i];
                A[i + 1] = B[i];
            }
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    if sum(A) < sum(B):
        print(-1)
        return

    plus = []
    totalsa = 0
    ans = 0
    for i in range(N):
        if A[i] > B[i]:
            plus.append(A[i] - B[i])
        elif A[i] < B[i]:
            totalsa += B[i] - A[i]
            ans += 1

    plus.sort(reverse=True)

    t = 0
    for i in range(len(plus)):
        if t >= totalsa:
            break
        ans += 1
        t += plus[i]

    print(ans)


if __name__ == '__main__':
    main()


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

void input(int& rnSwitchSiz, 
             vector<vector<int>>& rvvnLightSw, vector<int>& rvnReslt)
{
  int  nLightSiz;
  cin >> rnSwitchSiz >> nLightSiz;
  rvvnLightSw.resize(nLightSiz);

  for (int i = 0; i < rvvnLightSw.size(); i++)
  {
    int nLightSwSiz;
    cin >> nLightSwSiz;
    rvvnLightSw[i].resize(nLightSwSiz);

    for (int j = 0; j < rvvnLightSw[i].size(); j++)
      cin >> rvvnLightSw[i][j];
  }

  rvnReslt.resize(nLightSiz);
  for (int& rnReslt : rvnReslt)
    cin >> rnReslt;
}

bool canLightSwitch(const vector<vector<int>>& cnrvvnLightSw,
                  const vector<int>& cnrvnSwitch,
                  const vector<int>& cnrvnReslt)
{
  for (int i = 0; i < cnrvvnLightSw.size(); i++)
  {
    int nLightUpCnt = 0;

    for (int j = 0; j < cnrvvnLightSw[i].size(); j++)
      nLightUpCnt += cnrvnSwitch[ cnrvvnLightSw[i][j] - 1 ];

    if (nLightUpCnt % 2 != cnrvnReslt[i])
      return false;
  }
  return true;
}

int calcNumOfCase(int nSwitchSiz,
                const vector<vector<int>>& cnrvvnLightSw, 
                const vector<int>& cnrvnReslt)
{
  int nNumOfCase = 0;
  vector<int> vnSwitch(nSwitchSiz);

  for (int nCtl = 0; nCtl < ( 1 << nSwitchSiz ); nCtl++)
  {
    for (int nEach = 0; nEach < nSwitchSiz; nEach++)
      if (nCtl & ( 1 << nEach ))
        vnSwitch[nEach] = 1;
      else
        vnSwitch[nEach] = 0;

    if (canLightSwitch(cnrvvnLightSw, vnSwitch, cnrvnReslt))
      nNumOfCase++;
  }
  return nNumOfCase;
}
  
int main()
{
  int nSwitchSiz;
  vector<vector<int>> vvnLightSw;
  vector<int> vnReslt;

  input(nSwitchSiz, vvnLightSw, vnReslt);
  cout << calcNumOfCase(nSwitchSiz, vvnLightSw, vnReslt) << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    ll N,M;
    cin>>N>>M;
    ll a=1900*M+100*(N-M);
    cout<<a*pow(2,M)<<endl;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

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

struct Combinatorics {
  using int64 = long long;
  const int64 mod = 1e9+7;
  int64 fact[1002020];
  int64 invfact[1002020];
  Combinatorics() {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 1002020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
}C;

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

  int N, M, K;
  cin >> N >> M >> K;
  vint dp(N+M+K+1);
  dp[0] = 1;
  for(int i = 0; i < N+M+K; ++i) {
    dp[i+1] = dp[i]*2 + mod-C.C(i, M) + mod-C.C(i, K);
    dp[i+1] %= mod;
  }
  vint pow3(N+M+K+1);
  pow3[0] = 1;
  for(int i = 0; i < N+M+K; ++i) pow3[i+1] = pow3[i]*3%mod;
  int ans = 0;
  for(int i = N; i <= N+M+K; ++i) {
    ans += C.C(i-1, N-1)*pow3[N+M+K-i]%mod*dp[i-N]%mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 29952
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();
        long[] x = new long[N];
        long[] xsum = new long[N + 1];
        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
            xsum[i + 1] = xsum[i] + x[i];
        }
        long ans = X * N + 5 * xsum[N];
        for (int i = 1; i < N; i++) {
            long cost = X * i + 5 * (xsum[N] - xsum[N - i]);
            for (int j = 5, k = N - i; k >= 0; j += 2, k -= i) {
                if (cost > ans) {
                    break;
                }
                cost += j * (xsum[k] - xsum[Math.max(k - i, 0)]);
            }
            ans = Math.min(ans, cost);
        }
        System.out.println(ans + N * X);
    }
}

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

int main() {
	vector<int> data(3);
	for (int i = 0; i<3; i++) {
		cin >> data[i];
	}
	sort(data.begin(),data.end());
	cout << data[2] * 10 + data[1] + data[0];
}


Measured memory_bytes: 256
S = input()
if "S" in S and "N" not in S:
  print("No")
elif "N" in S and "S" not in S:
  print("No")
elif "E" in S and "W" not in S:
  print("No")
elif "W" in S and "E" not in S:
  print("No")
else:
  print("Yes")

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

int main() {
  int N;
  cin >> N;
  int countA =0;
  int countB =9999999999999;
  for ( int i = 0 ; i < N ; i++) {
    int x;
    cin >> x;
    while ( x % 2 == 0) {
      countA += 1;
      x /= 2 ;
    }
    if ( countA < countB ){
      countB = countA;
    }
    countA = 0;
      }
  cout << countB << endl;
  // ここにプログラムを追記
}


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

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

const long long INF = 1LL << 60;
const double PI = 3.14159;

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

  cout << PI * 2 * r << endl;

  return 0;
}


Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int digi(long long int v) {
  int i = 0;
  while (v > 0) {
    v /= 10;
    i++;
  }
  return i;
}

int main(int argc, char *argv[])
{
  long long int N;
  int minv = 100;
  cin >> N;

  for (long long int i = 1; i <= sqrt(N); i++) {
    if (N % i == 0) {
      minv = min(minv, min(digi(N), digi(N/i)));
    }
  }

  printf("%d\n", minv);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;	
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
    return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if (cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if(t==nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	nil->next->prev = x;
	x->next = nil->next;
	//nil->next->prev = x;
    x->prev = nil;
	nil->next = x;
    //x->prev = nil;	
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
    int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i=0; i<n; i++) {
		scanf("%s%d", com, &key);
		if(com[0] == 'i') {
			insert(key);
			np++;
			size++;
		} else if(com[0] == 'd'){
			if(strlen(com) > 6) {
				if(com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast(); 
			} else {
				deleteKey(key);
			}
			nd++;
			size++;
		}
	}
	
	printList();
    
	return 0;	
	
}

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

vector<int> edge[150];
bool come[150];
int dfs(int x, int k, int p = 1){
	if(k == x && p != 0)return -1;
	if(come[x])return 0;
	come[x] = true;
	for(int i = 0;i < edge[x].size();i++){
		if(dfs(edge[x][i], k) == -1)return -1;
	}
	return 0;
}

bool ok(){
	for(int i = 'a';i <= 'z';i++){
		fill(come, come + 150, false);
		if(dfs(i, i, 0) == -1)return false;
	}
	return true;
}

int main(){
	int n;
	string str, last;
	while(cin >> n, n){
	
		bool fail = false;
		for(int i = 'a';i <= 'z';i++)edge[i].clear();
		for(int i = 0;i < n;i++){
			cin >> str;
			if(i){
				for(int i = 0;i < last.size();i++){
					if(i == str.size()){
						fail = true;
						break;
					}
					if(str[i] != last[i]){
						edge[last[i]].push_back(str[i]);
						break;
					}
				}
			}
			last = str;
		}
		
		cout << ((!fail&&ok())?"yes":"no") << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    string s, t;
    cin >> s >> t;

    REP(i, s.size()){
        if(s == t){
            yOUT;
            return 0;
        }
        char tmp = s.back();
        s.pop_back();
        s = tmp + s;
    }

    nOUT;

}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())
X = []
for i in range(N):
  x = list(map(int, input().split()))
  X.append(x)
  
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    total = 0
    for k in range(D):
      total += (X[i][k] - X[j][k]) ** 2
    if math.sqrt(total).is_integer():
      ans += 1
      
print(ans)

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

int N, M;
vector<vector<int>> G;
vector<int> dp;

int dfs(int i) {
    if (dp[i] != -1)return dp[i];
    int ret = 0;
    for (int to : G[i]) {
        ret = max(ret, dfs(to) + 1);
    }
    return dp[i] = ret;
}


int main() {
    cin >> N >> M;
    dp.resize(N, -1);
    G.assign(N, vector<int>());
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
    }

    int ans = 0;
    for (int i = 0; i < N; i++)ans = max(ans, dfs(i));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int main(){
    cin >> N;
    int X[N], Y[N];
    rep(i, N){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y, Y + N);
    rep(i, N){
        if(X[i] >= Y[N / 2])
            cout << Y[N / 2 - 1] << endl;
        else
            cout << Y[N / 2] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

#define INF 10001

class UnionFind
{
public:
	vector<int> data;
	UnionFind(int size):data(size, -1){}
	
	bool unionSet(int x, int y)
	{
		x = root(x); y=root(y);
		if(x != y)
		{
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	
	int root(int x)
	{
		return data[x] < 0 ? x:data[x]=root(data[x]);
	}
};

class Edge
{
public:
	int s,d,c;
	
	Edge(int s, int d, int c)
	:s(s), d(d), c(c)
	{}
	
	bool operator<(const Edge& a) const
	{
		return (c>a.c);
	}
};

int kruskal(int n, int& hi, int& lo,priority_queue<Edge>& q)
{
	UnionFind uf(n);
	int cnted=0;
	int cst=0;
	hi=-1, lo=INF;
	
	while(cnted != n-1)
	{
		if(q.empty()) break;

		Edge e = q.top(); q.pop();
		
		if(uf.unionSet(e.s, e.d))
		{
			hi=max(hi,e.c);
			lo=min(lo,e.c);
			cst+=e.c;
			cnted++;
		}
	}

	if(cnted != n-1) return -1;

	return (hi-lo);
}

int main()
{
	
	int N,M;
	while(cin >> N >> M, (N||M))
	{
		priority_queue<Edge> edges;
		for(int i=0; i<M; i++)
		{
			int a,b,c;
			cin >> a >> b >> c;
			a--; b--;
			edges.push(Edge(a,b,c));
		}

		int ret=-1,hi,lo;
		while(!edges.empty())
		{
			priority_queue<Edge> q(edges);
			int t=kruskal(N,hi,lo,q);
			if(t==-1) break;

			if(ret==-1) ret=t;
			else ret=min(ret, t);

			while(!edges.empty())
			{
				int v=edges.top().c;

				if(v<=lo) edges.pop();
				else break;
			}
		}

		cout << ret << endl;
	}
}

Measured memory_bytes: 1068