akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;


int main () {

    int card[3][3];
    int card2[3][3];

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> card[i][j];
            card2[i][j] = 0;
            // cout << card[i][j] << " ";
        }
        // cout << endl;
    }

    int n; cin >> n;
    int b[101] = {0};
    int aux;
    for(int i = 0; i < n; i++) {
        cin >> aux;
        b[aux] = 1;
    }

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            card2[i][j] = b[card[i][j]];
            // cout << card2[i][j] << " ";
        }
        // cout << endl;
    }

    string ans = "Yes";
           if (card2[0][0] && card2[0][1] && card2[0][2]) {
    } else if (card2[1][0] && card2[1][1] && card2[1][2]) {
    } else if (card2[2][0] && card2[2][1] && card2[2][2]) {
    } else if (card2[0][0] && card2[1][0] && card2[2][0]) {
    } else if (card2[0][1] && card2[1][1] && card2[2][1]) {
    } else if (card2[0][2] && card2[1][2] && card2[2][2]) {
    } else if (card2[0][0] && card2[1][1] && card2[2][2]) {
    } else if (card2[2][0] && card2[1][1] && card2[0][2]) {
    } else {
        ans = "No";
    }

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

Measured memory_bytes: 256
#include<stdio.h>

main()

{
    int i, n, mehrab=0;
    scanf("%d",&n);

    int p[n];

    for(i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
    }

    for(i=0; i<n-2; i++)
    {
        if((p[i+1]>p[i] && p[i+1]<p[i+2]) || (p[i+1]<p[i] && p[i+1]>p[i+2]))
        {
            mehrab++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 1732
//
//  main.cpp
//  B - Golden Coins
//
//  Created by 李远铄 on 2020/7/15.
//  Copyright © 2020 李远铄. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    long x;
    long ans=0;
    cin>>x;
    while (x/500!=0) {
        ans+=1000;
        x-=500;
    }
    while (x/5!=0) {
        ans+=5;
        x-=5;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3184
N = int(input())
A = list(map(int, input().split()))

import sys
from collections import Counter
d = Counter(A)

if d[0] == N:
    print("Yes")
    sys.exit()

if d[0] == N // 3:
    for x in d.keys():
        if d[x] == 2 * N // 3:
            print("Yes")
            sys.exit()

third = N // 3
if len(d.keys()) == 3:
    a, b, c = d.keys()
    if d[a] == d[b] and d[b] == d[c]:
        if a ^ b ^ c == 0:
            print("Yes")
            sys.exit()

print("No")

Measured memory_bytes: 14116
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
                    ans += 1
print(ans)


Measured memory_bytes: 68120
#include <bits/stdc++.h>
#define V_MAX 100000
using namespace std;
struct edgeB{int u,v;}; //u,v???????????????
int V;                  //???????????°
vector <int> G[V_MAX];  //??°???????????£??\??????????????¨???
vector <edgeB> bridges; // ???
int ord[V_MAX];         //?????????????????????????????????
int low[V_MAX];         //
 
void dfs(int u, int p, int &c){
  ord[u] = low[u] = c++;
  for(int i=0;i<G[u].size();i++){
    int v = G[u][i];
    if(v==p)continue;
    
    if(ord[v] == -1){
      dfs(v,u,c);
      low[u] = min(low[u],low[v]);
    }
    else low[u] = min(low[u], ord[v]);
    if(ord[u] < low[v]) bridges.push_back((edgeB){u,v});
  }
}

void bridge(){
  bridges.clear();
  int c = 0;
  memset(ord,-1,sizeof(ord));
  for(int i=0;i<V;i++) if(ord[i]==-1) dfs(i,-1,c);
}

bool compare(edgeB a, edgeB b){
  return a.u==b.u? a.v<b.v:a.u<b.u;
}

int main(){
  int E;
  cin>>V>>E;
  for(int i=0;i<E;i++){
    int s,t;
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  
  bridge();
  for(int i=0;i<bridges.size();i++)
    if(bridges[i].u > bridges[i].v)swap(bridges[i].u, bridges[i].v);
  sort(bridges.begin(),bridges.end(),compare);
  for(int i=0;i<bridges.size();i++) cout << bridges[i].u<<" "<<bridges[i].v<<endl;
  return 0;
}

Measured memory_bytes: 7368
NA, NB, M = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 1_000_000_000
for i in range(M):
    x, y, c = list(map(int, input().split()))
    res = min(A[x - 1] + B[y - 1] - c, res)

res = min(min(A) + min(B), res)
print(res)


Measured memory_bytes: 24768
import math
n, d = map(int, input().split())
x = []
for i in range(n):
    l = list(map(int, input().split()))
    x.append(l)

count = 0
for j in range(n-1):
    for k in range(n-j-1):
        dis = 0
        for l in range(d):
            dis += abs(x[j][l] - x[j+k+1][l]) ** 2

        if math.ceil(math.sqrt(dis)) == int(math.sqrt(dis)):
            count += 1

print(count)
    









                                        




    




        


    







        



Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())

    if A > B:
        print(0)
    elif N == 1:
        if A == B:
            print(1)
        else:
            print(0)
    elif N == 2:
        print(1)
    else:
        print(B * (N-2) - A * (N-2) + 1)


if __name__ == "__main__":
    main()


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

int main(){
  string str;
  cin >> str;
  int a = str.length();
  for(int i=0;i < a;++i){
    if(str[i]=='1'){
      str[i] = '9';    
    }else{
      str[i] = '1';    
    }
  }
  cout << str << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

struct Queue {
	char name[128];
	int time;
};

int head = 0, tail = 0, n;
struct Queue Q[100000];



void enqueue(struct Queue);
struct Queue dequeue();




int main() {
	struct Queue a;
	int q, i, t = 0, cnt = 0;
	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++) scanf("%s %d", Q[i].name, &Q[i].time);
	

while (cnt != n) {
		a = dequeue();
		if (a.time <= q) {
			t += a.time;
			printf("%s %d\n", a.name, t);
			++cnt;
		}
		else {
			t += q;
			a.time -= q;
			enqueue(a);
		}
	}
	return 0;
}



void enqueue(struct Queue a) {
	Q[tail] = a;
	if (tail + 1 == n) tail = 0;
	else ++tail;
}



struct Queue dequeue() {
	struct Queue a;
	a = Q[head];
	if (head + 1 == n) head = 0;
	else ++head;
	return a;
}


Measured memory_bytes: 8224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }

    int ans = 1;
    int stat = 0;

    for (int i = 1; i < n; ++i) {
        if (a[i - 1] == a[i]) {
            continue;
        } else if (a[i - 1] > a[i]) {
            if (stat == 0)
                stat = -1;
            if (stat != -1) {
                ++ans;
                stat = 0;
            }
        } else {
            if (stat == 0)
                stat = 1;
            if (stat != 1) {
                ++ans;
                stat = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int D, N;
    cin >> D >> N;

    int ans = N;
    rep(i, D) ans *= 100;

    if (N == 100) {
        if (D == 0) ans = 101;
        if (D == 1) ans = 10100;
        if (D == 2) ans = 1010000;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
vector<int>v[N];
map<pi,int>mp;
int a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0;
    cin>>n>>m;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        v[l].pb(r);
        v[r].pb(l);
    }
    for(i=1;i<=n;i++)
    {
        int sz=v[i].size();
        if(sz==0)
        {
            s++;
            continue;
        }
        int f=0;
        for(j=0;j<sz;j++)
        {
            l=v[i][j];
            if(a[i]<=a[l])
            {
                f=1;
                break;
            }
        }
        if(f==0)
        {
            s++;
        }
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 11460
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N), accum(N, 0);
  map<ll, ll> m;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0)
      accum[0] = A[0];
    else
      accum[i] = accum[i - 1] + A[i];
    m[accum[i]]++;
  }
  ll ans = m[0];
  for (auto p : m) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  string S;
  cin >> S;
  const char tap[] = {'L', 'R'};
  int i = 0;
  for (; i < S.length(); ++i)
    if (tap[i%2] == S[i])
      break;
  cout << (S.length() == i ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll m = 1e9+7;
ll h,w;
ll a[1010][1010];
ll dp[1010][1010];

signed main()
{
	fast;
	memset(dp , 0, sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> h >> w;

	rep(i,0,h)
	{
		rep(j,0,w)
		{
			char c;
			cin >> c;
			if(c == '.')
				a[i][j] = 1;
			else
				a[i][j] = 0;
		}
	}

	rep(i,0,h)
	{
		if(a[i][0] == 0)
			break;
		else
			dp[i][0] = 1;
	}
	rep(j,0,w)
	{
		if(a[0][j] == 0)
			break;
		else
			dp[0][j] = 1;
	}
	rep(i,1,h)
	{
		rep(j,1,w)
		{
			if(a[i][j] == 0)
				continue;
			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%m;
		}
	}

	cout<<dp[h-1][w-1]<<endl;



////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b;
  cin>>n;
  int c=0;
  string ans="No";
  while(n--)
  {
    cin>>a>>b;
    if(a==b)
      c++;
    else
      c=0;
    if(c>=3){
    	ans="Yes";}
  }
    cout<<ans;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
int n, k;
typedef unsigned long long ull;
struct num{
	unsigned long long up = 0, down = 0;
	void plus(ull u, ull d){
		if(up == 0){
			up = u;
			down = d;
		}
		else{
			unsigned long long gcd = __gcd(down, d);
			u *= down / gcd;
			up *= d / gcd;
			up += u;
			down = down * d / gcd;
		}
	}
	void print(){
		printf("%.15f\n", (double)up / (double)down);
	}
}ans;
int main(){
	cin >> n >> k;
	if(n >= k){
		ans.plus(n - k + 1, n);
	}
	for(int i = 1;i <= min(k - 1, n);++i){
		double dis = log2((double)k / (double)i);
		if(dis != (double)(int)dis)++dis;
		ans.plus(1, (1ull << (ull)dis) * n);
	}
	ans.print();
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split(" ")))
g=0
if n>=3:
  for i in range(n-2):
    for j in range(n-i-1):
      j=j+i+1
      if l[i]!=l[j]:
        for k in range(n-j-1):
          k=j+k+1
          if l[i]!=l[k] and l[k]!=l[j]:
            x=l[i]
            y=l[j]
            z=l[k]
            if x+y>z and x+z>y and y+z>x:
              g=g+1
print(g)   
      

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    deque<int> Q;
    while(q--){
        int u;
        cin >> u;
        if(u == 0){
            int v, x;
            cin >> v >> x;
            if(v == 0) {
                Q.push_front(x);
            }else{
                Q.push_back(x);
            }
        }else if(u == 1) {
            int p;
            cin >> p;
            cout << Q[p] << endl;
        }else{
            int v;
            cin >> v;
            if(v == 0) {
                Q.pop_front();
            }else{
                Q.pop_back();
            }
        }
    }
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

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

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

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


int N;
int a[MN], b[MN];

int main() {
	cin >> N;

	vi aa(N + 1), bb(N + 1);
	int xa = 0, xb = 0;

	rep(i, N) {
		cin >> a[i];
		aa[i] = a[i];
		xa ^= a[i];
	}

	rep(i, N) {
		cin >> b[i];
		bb[i] = b[i];
		xb ^= b[i];		
	}

	a[N] = aa[N] = xa;
	b[N] = bb[N] = xb;

	sort(ALL(aa)); sort(ALL(bb));

	rep(i, aa.size()) {
		if (aa[i] != bb[i]) {
			puts("-1");
			return 0;
		}
	}

	bool diff = (a[N] != b[N]);
	int edge = 0;

	int now = 0;

	map<int, int> ID;

	uf.init(N + 1);

	rep(i, N) {
		if (a[i] != b[i]) {
			if (!ID.count(a[i])) {
				ID[a[i]] = now++;
			}
			if (!ID.count(b[i])) {
				ID[b[i]] = now++;
			}
			uf.unite(ID[a[i]], ID[b[i]]);
			++edge;
		}
	}

	if (!ID.count(a[N])) {
		ID[a[N]] = now++;
	}

	if (!ID.count(b[N])) {
		ID[b[N]] = now++;
	}	

	if (edge == 0) {
		puts("0");
		return 0;
	}

	set<int> st;

	rep(i, now) st.insert(uf.find(i));

	cout << edge + (int)st.size() - 1 << endl;

	return 0;
}

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

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static int[] CountingSort(int[] xs) {
        int k = xs.Max() + 1;
        var ns = new int[k]; // xs[i] ??????????????°
        foreach (int x in xs)
            ns[x]++;

        // ns[i] ??? i ??\????????°??????????????°???????´???????
        for (int i = 1; i < k; i++)
            ns[i] += ns[i-1];

        var ret = new int[xs.Length];
        for (int i = xs.Length-1; i >= 0; i--) {
            int p = ns[xs[i]] - 1;
            ret[p] = xs[i];
            ns[xs[i]]--;
        }
        return ret;
    }

    static void Main() {
        ReadInt();
        var xs = ReadInts();
        var sorted = CountingSort(xs);
        Console.WriteLine(string.Join(" ", sorted.Select(e => e.ToString()).ToArray()));
    }
}

Measured memory_bytes: 207180
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = ll(1e18)+1;
int main(){
    ll n, q;
    cin >> n >> q;
    vector<vector<ll>> xst;
    rep(i, n){
        ll s, t, x;
        cin >> s >> t >> x;
        xst.push_back({x,s,t});
    }
    sort(xst.begin(), xst.end());
    set<P> s;
    rep(i, q){
        ll d;
        cin >> d;
        s.insert(P(d, i));
    }
    vector<ll> ans(q, -1);
    for(auto i:xst){
        int x, l, r;
        x = i[0]; l = i[1]-x; r = i[2]-x;
        auto it = s.lower_bound(P(l, -1));
        while(it != s.end()){
            if(it->first >= r)break;
            else{
                ans[it->second] = x;
                s.erase(it++);
            }
        }
    }
    rep(i, q){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 25004
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    int n,m;
    cin>>n>>m;
    UnionFind uni(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b; a--,b--;
        uni.unite(a,b);
    }
    int ans = 0;
    for(int i=0;i<n;i++)chmax(ans,uni.size(i));
    cout << ans << endl;
}

Measured memory_bytes: 3972
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let a: i32 = vec[0].parse().unwrap();
    let b: i32 = vec[1].parse().unwrap();
    let c: i32 = b - a;
    let mut ans = 0;
    for x in 1..c{
        ans = ans + x;
    }
    println!("{:?}", ans-a);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 310

ll dp[SIZE][SIZE][SIZE]; //現, 変更回数, 一緒の高さ

int main(){
  int N, K, H[SIZE];

  cin >> N >> K;

  for (int i=0; i<N; i++)
    cin >> H[i];
  H[N] = 0;

  for (int i=0; i<=N; i++)
    for (int j=0; j<=K; j++)
      for (int k=0; k<=N; k++)
        dp[i][j][k] = LLINF;

  dp[0][0][N] = 0;

  for (int i=0; i<N; i++) {
    for (int j=0; j<=K; j++) {
      for (int k=0; k<=N; k++) {

        //同じ
        int nextj = j + (H[i] != H[k]);
        dp[i+1][nextj][k] = min(dp[i+1][nextj][k], dp[i][j][k]);

        //異なる
        dp[i+1][j][i] = min(dp[i+1][j][i], dp[i][j][k] + max(0, H[i] - H[k]));
      }
    }
  }

  ll ans = LLINF;

  for (int i=0; i<=K; i++) {
    for (int j=0; j<=N; j++) {
      ans = min(ans, dp[N][i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 227584
#include<bits/stdc++.h> 
using namespace std;
#define square(a) a*a
#define ssquare(a,b) (a+b)*(a+b) 
#define dsquare(a,b) (a+b)*(a-b)
typedef long long ll;
int n;
int cnt[105000]={0};

int main(){
	for(int x=1; x<105; x++) {
		for(int y=1; y<105; y++) {
			for(int z=1; z<105; z++) {
				cnt[x*x+y*y+z*z+x*y+x*z+y*z]++;
			}
		}
	}
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		printf("%d\n",cnt[i]);
	return 0;
}


Measured memory_bytes: 3968
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

mi = min(a, b, c, d, e)
ma = max(a, b, c, d, e)

ans = 'Yay!' if ma - mi <= k else ':('

print(ans)


Measured memory_bytes: 3060
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define INF 1000000000
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	vector<int> cnt(1000005);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		++cnt[k];
	}
	int ans = 0;
	vector<int> vis(1000005, 0);
	for (int i = 1; i <= 1000000; ++i) {
		if (cnt[i] == 0 || vis[i]) {
			continue;
		}
		if (cnt[i] == 1 && !vis[i]) {
			++ans;
		}
		for (int j = i; j <= 1000000; j += i) {	// prime sieve?
			vis[j] = 1;
		}
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 11100
#include <iostream>
#include <list>

const char CHAR_STR = '#';
const char CHAR_END = '.';

const int DIR_X[] = { 1, 0, -1,  0 };
const int DIR_Y[] = { 0, 1,  0, -1 };

typedef struct { int x; int y; } Point;

typedef struct
{
	int  h;
	int  w;
	char map [400][400];
	char flag[400][400];
} Parameter;

long long count_to_goal(Parameter * p, int x, int y)
{
	std::list<Point> stack;
	int num_str = 0;
	int num_end = 0;

	if ( p->flag[y][x] ) return 0;

	stack.push_back((Point){x, y});
	p->flag[y][x] = 1;

	for (; stack.size(); )
	{
		auto cur = stack.front();
		stack.pop_front();

		if ( p->map[cur.y][cur.x] == CHAR_STR ) num_str++;
		else num_end++;

		for (auto i = 0; i < 4; i++)
		{
			auto nex = cur;
			nex.x += DIR_X[i];
			nex.y += DIR_Y[i];

			if ((nex.x < 0) || (nex.x >= p->w) || (nex.y < 0) || (nex.y >= p->h))
				continue;
			if (p->flag[nex.y][nex.x])
				continue;
			if (p->map [nex.y][nex.x] == p->map [cur.y][cur.x] )
				continue;

			stack.push_back(nex);
			p->flag[nex.y][nex.x] = 1;
		}
	}

	return (long long)num_str * num_end;
}

Parameter p = { 0 };

int main(int argc, char * argv[])
{
	long long ret = 0;

	std::cin >> p.h;
	std::cin >> p.w;
	for (int y = 0; y < p.h; y++)
		for (int x = 0; x < p.w; x++)
			std::cin >> p.map[y][x];

	for (int y = 0; y < p.h; y++)
		for (int x = 0; x < p.w; x++)
			if (p.flag[y][x] == 0)
				ret += count_to_goal(&p, x, y);

	std::cout << ret;

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	while(1){int n;cin>>n;
int p=6;int a[11],k=0;
for(int i=0;i<6;i++){a[k]=p;k++;p*=6;}p=9;
for(int i=0;i<5;i++){a[k]=p;k++;p*=9;}
sort(a,a+11);
//for(int i=0;i<11;i++)cout<<a[i]<<" ";cout<<endl;
int dp[n+1];
dp[0]=0;
for(int i=1;i<=n;i++){
	dp[i]=dp[i-1]+1;
	for(int j=0;j<11;j++){
		if(i>=a[j]){dp[i]=min(dp[i],dp[i-a[j]]+1);}
	}//2-th for
}//for
cout<<dp[n]<<endl;
	
	
	return 0;
	
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)


bool check(const vector<int>& h, int k, int x) {
    int sum = 0;
    for (int count: h) {
        sum += min(x, count);
    }
    return (x * k <= sum); 
} 


int solve(const vector<int>& h, int k) 
{
    int minX = 0;
    int maxX = (h[0] * h.size()) / k;

    while (minX < maxX) {
        int x = (minX + maxX + 1) / 2;
        if (check(h, k, x)) {
            // cout << k << ", " << x << " => OK" << endl;
            minX = x;
        } else {
            // cout << k << ", " << x << " => NG" << endl;
            maxX = x-1;
        }
    }

    return minX;
}

int main()
{
    int N;
    cin >> N;
    vector<int> hist(N);
    rep(i, N) {
        int a;
        cin >> a;
        ++hist[a-1];
    }

    sort(hist.begin(), hist.end());

    vector<int> s(N+1);  //! s[i] = sum of hist[0..i) 
    for (int i = 1; i <= N; ++i) {
        s[i] = s[i-1] + hist[i-1];
    }

    int ans = N;
    for (int k = 1; k <= N; ++k) {
        auto check = [&](int c) {
            int i = lower_bound(hist.begin(), hist.end(), c) - hist.begin();
            LL sum = c * (N-i) + s[i];
            bool ret = (c * k <= sum);
            // cout << "check is called with c = " << c << ", k = " << k << ", i = " << i << " => " << (ret ? "true" : "false") << endl;
            return ret;
        };
        while (0 <= ans) {
            if (check(ans)) {
                break;
            } else {
                --ans;
            }
        }
        cout << ans << '\n';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    if (k % 2 == 0)
        cout << a - b << endl;
    else
        cout << b - a << endl;

    return 0;
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int n, p;
	cin >> n;
	for(int i = 1 ; i <= n; i++){
		cin >> p;
		//cout << p << i << endl;
		if(p != i) ans++;
	}
    if(ans <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){

    string s;

    cin >> s;

    if((s[2] == s[3])&&(s[4] == s[5])) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val A1Input  = scala.io.StdIn.readLine()
  val A1Array = A1Input.split(" ").map(_.toInt).toSeq
  val A2Input  = scala.io.StdIn.readLine()
  val A2Array = A2Input.split(" ").map(_.toInt).toSeq
  val A3Input  = scala.io.StdIn.readLine()
  val A3Array = A3Input.split(" ").map(_.toInt).toSeq

  val n = scala.io.StdIn.readInt()
  var bFindArray = Vector.empty[(Int, Int)]

  (1 to n).foreach { _=>
    val b = scala.io.StdIn.readInt()
    if (A1Array.indexOf(b) != -1) {
      bFindArray :+= (1, A1Array.indexOf(b) + 1)
    }
    if (A2Array.indexOf(b) != -1) {
      bFindArray :+= (2, A2Array.indexOf(b) + 1)
    }
    if (A3Array.indexOf(b) != -1) {
      bFindArray :+= (3, A3Array.indexOf(b) + 1)
    }
  }

  if(
    bFindArray.groupBy(b => b._1).map(b => (b._1, b._2.size)).find(b => b._2 >= 3).isDefined ||
    bFindArray.groupBy(b => b._2).map(b => (b._1, b._2.size)).find(b => b._2 >= 3).isDefined ||
    (bFindArray.find(b => b == (1, 1)).isDefined && bFindArray.find(b => b == (2, 2)).isDefined && bFindArray.find(b => b == (3, 3)).isDefined) ||
    (bFindArray.find(b => b == (1, 3)).isDefined && bFindArray.find(b => b == (2, 2)).isDefined && bFindArray.find(b => b == (3, 1)).isDefined)
  ) {
    println("Yes")
  } else {
    println("No")
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main()
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	if (a[2] == a[1] && a[1] == a[0])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

int main(){
  int n, k; cin >> n >> k;
  int arr[1000];
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int s = 0;
  for(int i  = 0; i < k; i++)
    s += arr[i];
  
  cout << s << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
int lis(int n,vector<int>& A){
  vector<int> L(A.size()+1,0);
  L[0]=A[0];
  int length=1;
  for(int i=1;i<n;i++){
    if(L[length-1]<A[i]){
      L[length++]=A[i];
    }else{
      *lower_bound(L.begin(),L.begin()+length,A[i])=A[i];
    }
  }
  return length;
}
//END CUT HERE
signed main(){
  int n;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  cout<<lis(n,A)<<endl;
  return 0;
}
/*
verified on 2017/06/29
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp
*/

Measured memory_bytes: 4416
#include <iostream>
using namespace std;
int main(void){
    char s[10];
	cin>>s;
	int a=0;
	for(int i=0;s[i]!=NULL;i++)
	{
	a++;
	}
	if(a==2){cout<<s[0]<<s[1]<<endl;}
	else if(a==3){cout<<s[2]<<s[1]<<s[0]<<endl;}
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  string s;
  while(cin >> s, s != "#") {
    i64 y, m, d;
    cin >> y >> m >> d;
    bool hatena = (y >= 32 || (y == 31 && m >= 5));
    if(hatena) {
      cout << "? ";
      y -= 30;
    }
    else {
      cout << s << " ";
    }
    cout << y << " " << m << " " << d << endl;
  }
}



Measured memory_bytes: 3160
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	S := nextLine()
	if S[2] == S[3] && S[4] == S[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int n,k,h[200000],dp[200000]={0};
    cin>>n>>k;
    rep(i,n) cin>>h[i];
    rep(i,n-1){
        long long m=dp[i]+abs(h[i]-h[i+1]);
        rep(j,min(i+1,k)){
            long long x=dp[i-j]+abs(h[i-j]-h[i+1]);
            if(x<m) m=x;
        }
        dp[i+1]=m;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1408
def sol(inp=input):
    s=inp()
    u=int(s[:2])
    l=int(s[2:])
    u_is_m=1<=u and u<=12
    l_is_m=1<=l and l<=12
    if u_is_m and l_is_m:
        return 'AMBIGUOUS'
    if u_is_m and not l_is_m:
        return 'MMYY'
    if not u_is_m and l_is_m:
        return 'YYMM'
    return 'NA'
print(sol())

Measured memory_bytes: 38256
import numpy as np
K, N = map(int, input().split(' '))

dis = list(map(int, input().split(' ')))
dis = [__ - dis[0] for __ in dis]
dis.insert(0, 0)
dis = np.array(dis[1:]) - np.array(dis[:-1])
dis = list(dis)
dis.append(K - sum(dis))
#print(dis)
dis = sorted(dis)

print(sum(dis[1:-1]))


Measured memory_bytes: 42844
from heapq import heappush, heappop
def dijkstra(graph:list, node:int, start:int) -> list:
    # graph[node] = [(cost, to)]
    inf = float('inf')
    dist = [inf]*node

    dist[start] = 0
    heap = [(0,start)]
    while heap:
        cost,thisNode = heappop(heap)
        for NextCost,NextNode in graph[thisNode]:
            dist_cand = dist[thisNode]+NextCost
            if dist_cand < dist[NextNode]:
                dist[NextNode] = dist_cand
                heappush(heap,(dist[NextNode],NextNode))
    return dist

n,m,s,t = map(int,input().split())

g_a = [[] for i in range(n)]
g_b = [[] for i in range(n)]

for i in range(m):
    u,v,a,b = map(int,input().split())
    g_a[u-1].append((a,v-1))
    g_a[v-1].append((a,u-1))
    g_b[u-1].append((b,v-1))
    g_b[v-1].append((b,u-1))

d_a = dijkstra(g_a,n,s-1)
d_b = dijkstra(g_b,n,t-1)

d = []
for i in range(n):
    d.append(d_a[i]+d_b[i])

d.reverse()
ans = []
m = float('inf')
for i in range(n):
    m = min(m,d[i])
    ans.append(10**15-m)
ans.reverse()

for i in range(n):
    print(ans[i])

Measured memory_bytes: 122988
import java.util.Scanner;

public class Main {
   
    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int i = 0;
        for(;;i++) {
            if(((int)Math.pow(K, i) <= N) && (N < (int)Math.pow(K, i+1))) {
                System.out.println(i+1);
                break;
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 22740
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();    
    
    int a = x2 - x1;
    int b = y2 - y1;
    
	System.out.println((x2-b) + " " + (y2+a) + " " +  ((x2-b)-a) + " " + ((y2+a)-b));
    }
}


Measured memory_bytes: 39756
s=int(input())
l=[]
l.append(s)
for i in range(1,1000000):
    if l[i-1]%2==0:
        l.append(int(l[i-1]/2))
    else:
        l.append(3*l[i-1]+1)
    if l[i] in l[0:i]:
        print(i+1)
        break

Measured memory_bytes: 61920
function main(input){
    inputI = input.split('\n');
    number = parseInt(inputI[3]);
    inputA = inputI[0].split(' ');
    inputB = inputI[1].split(' ');
    inputC = inputI[2].split(' ');
    out='No';
    for(i=4;i<4+number;i++){
        for(j=0;j<3;j++){
            if(inputA[j]==inputI[i]){
                inputA[j]='x';                
                break;
            }
            if(inputB[j]==inputI[i]){
                inputB[j]='x';                
                break;  
            }
            if(inputC[j]==inputI[i]){
                inputC[j]='x';                
                break;
            }
        }
    }
  

    for(i=0;i<3;i++){
        if(inputA[i]==inputB[i] && inputB[i]==inputC[i]){
            out='Yes';
        }
    }
    if(inputA[0]==inputA[1] && inputA[1]==inputA[2]){
        out='Yes';
    }

    if(inputB[0]==inputB[1] && inputB[1]==inputB[2]){
        out='Yes';
    }

    if(inputC[0]==inputC[1] && inputC[1]==inputC[2]){
        out='Yes';
    }
    if(inputA[0]==inputB[1] && inputB[1]==inputC[2]){
        out='Yes';
    }
  
    if(inputC[0]==inputB[1] && inputB[1]==inputA[2]){
        out='Yes';
    }

    console.log(out);

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int a, b;
  cin >> a >> b;
  cout << a*b << '\n';
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int dx[4]={0,0,1,-1};
constexpr int dy[4]={1,-1,0,0};

int H,W,M,h[300000],w[300000];
pair<int,int>p[300000];

int main(){
	cin>>H>>W>>M;
	for(int i=0;i<M;i++){
		cin>>p[i].first>>p[i].second;
		p[i].first--;
		p[i].second--;
		h[p[i].first]++;
		w[p[i].second]++;
	}
	sort(p,p+M);
	int mxh=0;
	int mxw=0;
	for(int i=0;i<H;i++){
		mxh=max(mxh,h[i]);
	}
	for(int i=0;i<W;i++){
		mxw=max(mxw,w[i]);
	}
	vector<int>hv,wv;
	for(int i=0;i<H;i++){
		if(mxh==h[i])hv.push_back(i);
	}
	for(int i=0;i<W;i++){
		if(mxw==w[i])wv.push_back(i);
	}
	for(int i:hv){
		for(int j:wv){
			if(!binary_search(p,p+M,pair<int,int>{i,j})){
				cout<<mxh+mxw<<endl;
				return 0;
			}
		}
	}
	cout<<mxh+mxw-1<<endl;
}


Measured memory_bytes: 12052
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int A,B;
	public void solve() {
		A = nextInt();
		B = nextInt();

		out.println((A+B)%24);
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 20564
def calc_max_fomula_by_list(numbers: list) -> int:
    sorted_numbers = numbers
    sorted_numbers.sort(reverse=True)
    return sorted_numbers[0] * 10 + sorted_numbers[1] + sorted_numbers[2]
    

def main():
    inputs = list( map(lambda x:int(x), input().split(' ')) )
    print(calc_max_fomula_by_list(inputs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pair<ll, ll>> student(N);
	vector<pair<ll, ll>> check(M);
	for (ll i = 0; i < N; i++)
	{
		cin >> student[i].first >> student[i].second;
	}
	for (ll i = 0; i < M; i++)
	{
		cin >> check[i].first >> check[i].second;
	}
	for (ll i = 0; i < N; i++)
	{
		pair<ll, ll> point = make_pair(abs(student[i].first - check[0].first) + abs(student[i].second - check[0].second), 0);
		for (ll j = 0; j < M; j++)
		{
			ll distance = abs(student[i].first - check[j].first) + abs(student[i].second - check[j].second);
			if (distance < point.first) {
				point = make_pair(distance, j);
			}
		}
		cout << point.second + 1 << endl;
	}
	return 0;
}

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


int main() {
	ll n,mem,joken,ans=100000000;
	vector<ll> x;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> mem;
		x.push_back(mem);
	}
	for (ll i = 0; i < 2001; i++) {
		mem = 0;
		for (ll k = 0; k < n; k++) {
			mem = max(abs(i - x[k]),mem);
		}
		ans = min(ans, mem);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3168
#!/usr/bin/env python3
import sys


def solve(K: int, S: str):
    '''
    >>> solve(1, 'a')
    'a'
    '''
    if len(S) <= K:
        return S
    return S[:K] + '...'


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(solve(K, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    test()
    main()


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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b" << endl;
    } else if (a<b){
        cout << "a < b" << endl;
    } else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

def main():
    N = int(input())
    G = [[] for _ in range(N)]
    dist = []
    for i in range(N):
        route = [int(i) for i in input()]
        for j in range(N):
            if route[j]:
                G[i].append(j)
            elif i != j:
                route[j] = INF
        dist.append(route)
    
    color = [-1]*N
    color[0] = 0
    stack = [0]
    possible = True
    while stack:
        p = stack.pop()
        for e in G[p]:
            if color[e] >= 0:
                if color[e] == color[p]:
                    possible = False
            else:
                color[e] = color[p]^1
                stack.append(e)
        if not possible:
            break
    
    if possible:
        csr = csr_matrix(dist)
        minimum_route = floyd_warshall(csr).astype(int)
        ans = minimum_route.max()
        print(ans + 1)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21300
#include <stdio.h>
int main(){
  int flag=1, i,j,n,a[100],work,count=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
  }
  while(flag){
    flag=0;
    for(j=n-1; j>=1; j--){
      if(a[j] < a[j-1]){
	work=a[j];
	a[j]=a[j-1];
	a[j-1]=work;
	flag=1;
	count++;
      }     
    }
  }
  if(n==1) printf("%d",a[0]);
  else{
    for(i=0; i<n; i++){
      if(i==n-1) printf("%d", a[i]);
      else printf("%d ",a[i]);
    }
  }
  printf("\n%d\n",count);
  return 0;
}


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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x,t,n;
    cin >> n >> x >> t ;
    if(n%x==0){
        cout << (n/x)*t << "\n";
    }else{
        cout << (n/x+1)*t << "\n";
    }

} 

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;

int main(void){
    int n;
    cin >> n;
    unordered_map<int, int> memoB;
    unordered_map<int, int> memoW;
    vector<int> arr = vector<int>(2 * n + 1, 0);
    vector<char> arrc = vector<char>(2 * n + 1, 0);
    vector<vector<int> > costB = vector<vector<int> >(n + 1, vector<int>(n + 1, 0));
    vector<vector<int> > costW = vector<vector<int> >(n + 1, vector<int>(n + 1, 0));
    vector<vector<int> > dy = vector<vector<int> >(n + 1, vector<int>(n + 1, 2100000000));

    for(int i = 1; i <= n * 2; i++) {
        char a;
        int b;
        cin >> a >> b;
        arr[i] = b;
        arrc[i] = a;
        if(a == 'W') memoW[b] = i; else memoB[b] = i;
    }

    for(int i = 0; i < n; i++){
        for(int j = i; j >= 1; j--){
            if(memoB[i + 1] < memoB[j]) costB[i][n]++;
            //else if(arrc[j] == 'W') costB[i][0]++;
        }

        for(int j = n - 1; j >= 0; j--){
            //if (costB[i][j - 1] == 0) break;
            costB[i][j] = costB[i][j + 1];
            if (memoB[i + 1] > memoW[j + 1]) costB[i][j]++;
        }

        for(int j = i; j >= 1; j--){
            if(memoW[i + 1] < memoW[j]) costW[n][i]++;
            //else if(arrc[j] == 'B') costW[0][i]++;
        }

        for(int j = n - 1; j >= 0; j--){
            //if(costW[j - 1][i] == 0) break;
            costW[j][i] = costW[j + 1][i];
            if(memoW[i + 1] > memoB[j + 1]) costW[j][i]++;
        }
    }

    int c1 = 0;
    int c2 = 0;
    //dy[0][0] = 0;

    for(int i = 1; i <= n; i++){
        c1 += costB[i - 1][0];
        c2 += costW[0][i - 1];
        dy[i][0] = c1;
        dy[0][i] = c2;
    }

    /*
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            cout << costB[i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            cout << costW[i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    */

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++){
            if(dy[i][j] > dy[i - 1][j] + costB[i - 1][j]) dy[i][j] = dy[i - 1][j] + costB[i - 1][j];

            if(dy[i][j] > dy[i][j - 1] + costW[i][j - 1]) dy[i][j] = dy[i][j - 1] + costW[i][j - 1];
        }
    }

    /*
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            cout << dy[i][j] << ' ';
        }
        cout << endl;
    }
    cout << endl;
    */

    cout << dy[n][n] << endl;
    
    return 0;

}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

void solve(){
    char s[3];
    scanf("%s",s);
    int ans = 0;
    FOR(i,0,2){
        FOR(j,i,2){
            bool ch = true;
            FOR(k,i,j){
                if(s[k] == 'S'){ ch = false; break; }
            }
            if(ch) ans = max(ans, j-i+1);
        }
    }
    printf("%d",ans);
}

int main(){
    solve();
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

Measured memory_bytes: 3824
#ABC128-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
S=[]
for i in range(m):
    t=IL()
    S.append(t[1:])
P=IL()
ans=0
for i in range(pow(2,n)):
    ok=True
    sl=bin(i)[2:].zfill(n)
    for i in range(m):
        w=0
        for idx in S[i]:
            if sl[idx-1]=="1":
                w+=1
        if w%2!=P[i]:
            ok=False
    if ok:
        ans+=1
print(ans)


Measured memory_bytes: 42480
N = int(input())
M1 = 0
M2 = 0
A_list = []
for _ in range(N):
    A = int(input())
    A_list.append(A)
    if A > M1:
        M2 = M1
        M1 = A
    elif A > M2:
        M2 = A

for a in A_list:
    if a == M1:
        print(M2)
    else:
        print(M1)

Measured memory_bytes: 12532