akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
//****************************************
// Graph template
//****************************************

// status of edge
template <typename X>
struct Edge{
  int from;
  int to;
  X cost;

  Edge() = default;

  Edge(int from, int to, X cost) : from(from), to(to), cost(cost) {}
};

// status of node
template <typename X>
struct Node{ 
  int idx;
  vector<Edge<X>> edge;
  
  Node() = default;

  explicit Node(int idx) : idx(idx) {}
};

template <typename X>
class Graph{
private:
  int n; // number of node
  int m; // number of edge
  vector<Node<X>> node; 

  void Init_Node() {
    rep(i,n) node.emplace_back(i);
  }
public:
  explicit Graph(int n) : n(n) {
    Init_Node();
  }

  // edges have no-weight 
  Graph(int n, int m, vector<int> from, vector<int> to) : n(n), m(m) {
    Init_Node();
    rep(i,m) {
      add_edge(from[i], to[i]);
      add_edge(to[i], from[i]);      
    }
  }  

  // edges have weight
  Graph(int n, int m, vector<int> from, vector<int> to, vector<X> cost) : n(n), m(m) {
    Init_Node();
    rep(i,m) {
      add_edge(from[i], to[i], cost[i]);
      add_edge(to[i], from[i], cost[i]);      
    }
  }

  void add_edge(int from, int to, X cost = 1) {
    node[from].edge.emplace_back(from, to, cost);
  }

  void solve() {
    // bfs
    vector<int> d(n, -1);
    vector<int> res(n);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    while(!q.empty()) {
      int v = q.front(); q.pop();
      for(auto next: node[v].edge) {
	int w = next.to;
	if(d[w] < 0) {
	  d[w] = d[v] + 1;
	  q.push(w);
	  res[w] = v;
	}
      }
    }

    cout << "Yes" << "\n";
    rep1(i,n-1) cout << res[i]+1 << "\n";
    
  }
  
};


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

  Graph<int> gp(n,m,a,b);
  gp.solve();
  
  return 0;
}


Measured memory_bytes: 17320
function main(input) {
const a = input.split(" ").map(Number);
  console.log(a[0]==a[1]&&a[0]==a[2]?"1"
			　:a[0]==a[1]&&a[1]!=a[2]?"2"
			  :a[0]==a[2]&&a[1]!=a[2]?"2"
			  :a[1]==a[2]&&a[0]!=a[2]?"2"
			  :"3");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30468
def main():
	s = input()
	a = int(s[:2])
	b = int(s[2:])
	x = (a == 0 or a > 12)
	y = (b == 0 or b > 12)
	if x and y:
		print("NA")
	elif not x and not y:
		print("AMBIGUOUS")
	elif x:
		print("YYMM")
	else:
		print("MMYY")
	return 0

main()

Measured memory_bytes: 3060
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

const int maxn = 2e5 + 5;
const LL inf = 1e9;
int n, p[maxn];

LL t[maxn], st[maxn], g[maxn];


LL d[maxn][5];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  rep(i, n) cin >> p[i];


  LL res = inf;

  rep(_, 2) {

    rep(i, maxn) rep(j, 5) d[i][j] = inf;

    rep(i, 5) d[0][i] = 0;

    //cout << d[1][0] << endl;

    rep(i, n + 1) rep(j, 5) rep(k, j, 5) {
      if (k == 0 || k == 4) {
        smin(d[i + 1][k], d[i][j] + p[i]);
      }
      else if (k == 2) {
        smin(d[i + 1][k], d[i][j] + (1 - p[i] % 2));
      }
      else {
        smin(d[i + 1][k], d[i][j]  + (p[i] == 0 ? 2 : p[i] % 2));
      }
    }

    rep(i, 5) {
      smin(res, d[n][i]);
    }


    reverse(p, p + n);
  }
  
  cout << res << endl;


  return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin>>N;
  	int64_t a=2,b=1,c=3;
  	
  	for(int i=0;i<N;i++){
     	 a=b;
      	 b=c;
      	 c=a+b;
    }
  	
  
  	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n, a[25], cnt;
int main()
{
    cin >> n;
    for(int j  = 0; j < n; j++){
        cin >> a[j];
    }
    for(int i = 0; i < n - 2; i++){

        if(a[i] < a[i + 1] && a[i + 1] < a[i + 2] || a[i] > a[i + 1] && a[i + 1] > a[i + 2]){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c))
	{
		if(a==5&&b==5&&c==7)
		printf("YES\n");
		else if(a==5&&b==7&&c==5)
		printf("YES\n");
		else if(a==7&&b==5&&c==5)
		printf("YES\n");
		else
		printf("NO\n");
	}
	return 0;
}///

Measured memory_bytes: 128
N, X = map(int, input().split())
b, p = [1], [1]

for i in range(N):
    b.append(b[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
    
def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= b[N-1] + 1:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-b[N-1])
    
print(f(N, X))

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

int N;
int A[210];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    while (true) {
      bool exist_odd = false;
      for (int i = 0; i < N; ++i) {
        if (A[i] % 2 != 0) exist_odd = true;
      }

      if (exist_odd) break;

      for (int i = 0; i < N; ++i) {
        A[i] /= 2;
      }
      ++res;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
ordA = ord("a")
mozilist = [0] * 26
for k in range(26):
    mozilist[k] = [0]*N
for i in range(N):
    S = input()
    for j in range(len(S)):
        mozilist[ord(S[j]) - ordA][i] += 1
ans = ""
for p in range(26):
    numofthealphabet = min(mozilist[p])
    ans += chr(ordA + p) * numofthealphabet
print(ans)


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    double a,b;
    cin>>a>>b;
    double p,q,r;
    cin>>p>>q>>r;
    double now = p*b-(b-a)*q;
    now = b + (now)/(q+r);
    cout << now << endl;
    
}



Measured memory_bytes: 3288
import sys
from math import log, ceil, floor

fin = sys.stdin.readline
A, B = [int(elem) for elem in fin().split()]

def partial_f(n):
    if n == 0:
        return 0
    return ((n + 1) >> 1) & 1 if n & 1 else n | ((n >> 1) & 1)


print(partial_f(A - 1) ^ partial_f(B))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a+b==15) {
			System.out.println("+");
		} else if(a*b==15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}
	}

}


Measured memory_bytes: 20948
n = int(input())
A = list(map(int, input().split()))
A.append(0)
A.insert(0, 0)
ans = 0
for i in range(n + 1):
    ans += abs(A[i+1] - A[i])

for i in range(1, n+1):
    if (A[i-1] <= A[i] <= A[i+1]) or (A[i-1] >= A[i] >= A[i+1]):
        print(ans)
    else:
        print(ans - 2*min(abs(A[i-1] - A[i]), abs(A[i+1] - A[i])))

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    int cnt = 0;
    cin >> h >> w;
    rep (i, h) rep (j, w) {
        char c;
        cin >> c;
        if (c == '#') cnt++;
    }
    if (cnt == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}



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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79924
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if(A1 + A2 + A3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

n = ni()
s = input()
def wid(w):
    return ord(w)-ord("A")
def ws(wid):
    return chr(wid+ord("A"))
ans = ""
for i in range(len(s)):
    id = (wid(s[i])+n)%26
    ans+=ws(id)
print(ans)


Measured memory_bytes: 9516
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){
    
    int N;
    string S;
    cin>>N>>S;
    int max=0,temp=0;
    
    for(int i=0;i<N;i++){
        if(S[i]=='I'){
            temp++;
            if(max<temp){
                max=temp;
            }
        }else{
            temp--;
        }
    }
    
    cout<<max<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			for(int i = 0; i < n; i++){
				int pm = sc.nextInt(), pe = sc.nextInt(), pj = sc.nextInt();
				
				if(Math.max(Math.max(pm, pe), pj) == 100){
					System.out.println("A");
				}else if((pm + pe)/2 >= 90){
					System.out.println("A");
				}else if((pm + pe + pj)/3 >= 80){
					System.out.println("A");
				}else if((pm + pe + pj)/3 >= 70){
					System.out.println("B");
				}else if((pm + pe + pj)/3 >= 50 && Math.max(pm, pe) >= 80){
					System.out.println("B");
				}else{
					System.out.println("C");
				}
			}
			
			
		}

	}

}

Measured memory_bytes: 13000
// たぴたべてやる

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

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

  int64 ret = 0;
  for(int a = 1; a <= N; a++) {
    int less = (K - (a % K)) % K;

    int sz = (N + less) / K;
    if((less + less) % K == 0) {
      ret += 1LL * sz * sz;
    }
  }
  cout << ret << endl;
}




Measured memory_bytes: 256
import java.util.*;

//クラス名をMainに変える
public class Main {
	public static void main(String[] args) {

		// input
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();

		scan.close();

		int res = (a + b) * h / 2;

		// output
		System.out.println(res);
	}
}

Measured memory_bytes: 9940
// g++ -std=c++17 -O2 -Wall D.cpp -o D -D _DEBUG

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

template <unsigned int MOD>
struct mod_int {
    using uint = unsigned int;
    using ull = unsigned long long;
    using ll = long long;
    using M = mod_int;
 
    uint v;
 
    mod_int(ll _v = 0) { set_norm(_v % MOD + MOD); }
    M& set_norm(uint _v) {  //[0, MOD * 2)->[0, MOD)
        v = (_v < MOD) ? _v : _v - MOD;
        return *this;
    }
 
    explicit operator bool() const { return v != 0; }
    M operator+(const M& a) const { return M().set_norm(v + a.v); }
    M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }
    M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }
    M operator/(const M& a) const { return *this * a.inv(); }
    M& operator+=(const M& a) { return *this = *this + a; }
    M& operator-=(const M& a) { return *this = *this - a; }
    M& operator*=(const M& a) { return *this = *this * a; }
    M& operator/=(const M& a) { return *this = *this / a; }
    M operator-() const { return M() - *this; }
    M& operator++(int) { return *this = *this + 1; }
    M& operator--(int) { return *this = *this - 1; }
 
    M pow(ll n) const {
        if (n < 0) return inv().pow(-n);
        M x = *this, res = 1;
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }
 
    M inv() const {
        ll a = v, b = MOD, p = 1, q = 0, t;
        while (b != 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(p -= t * q, q);
        }
        return M(p);
    }
 
    bool operator==(const M& a) const { return v == a.v; }
    bool operator!=(const M& a) const { return v != a.v; }
    friend ostream& operator<<(ostream& os, const M& a) { return os << a.v; }
    static uint get_mod() { return MOD; }
};

using mint = mod_int<998244353>;

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false); 
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> rng;
    for (int i = 0; i < k; i++) {
        int l, r;
        cin >> l >> r;
        r++;
        rng.emplace_back(l, r);
    }

    vector<mint> dp(n);
    dp[0] = 1;
    dp[1] = -1;

    for (int i = 0; i < n; i++) {
        if (i > 0) dp[i] += dp[i - 1];
        for (int j = 0; j < k; j++) {
            auto [l, r] = rng[j];
            if (i + l < n) dp[i + l] += dp[i];
            if (i + r < n) dp[i + r] -= dp[i];
        }
    }
    cout << dp[n - 1].v;
}

Measured memory_bytes: 3956
#include<iostream>
#include<cstdio>
#include<algorithm>

#define INF (1<<29)

using namespace std;

int g[21][21];
int V;

int main(void){

  fill(g[0],g[21],INF);

  int n;
  cin >> V >> n;

  int a,b,c,d;
  for(int i=0;i<n;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    g[a][b]=c,g[b][a]=d;
  }
  int x1,x2,y1,y2;
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
  for(int k=0;k<=V;k++){
    for(int i=0;i<=V;i++){
      for(int j=0;j<=V;j++){
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }

  cout << y1-g[x1][x2]-g[x2][x1]-y2 << endl;

  return 0;
}

Measured memory_bytes: 1244
n = int(input())
data = list(map(int,input().split()))
bool = True
count = 0
while bool:
    for i in range (n):
        if data[i] % 2 != 0:
            bool = False
        data[i] = data[i] // 2
    if bool == False:
        print(count)
    count += 1


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


int main() {
  double A,B,H,M;
  cin>>A>>B>>H>>M;
  double ans,sub;
  if(H*30+M/2>M*6){
    sub=H*30+M/2-M*6;
    if((H*30+M/2-M*6)>180)sub=360-sub;
    ans=sqrt(A*A+B*B-2*A*B*cos(sub*asin(1.0)/90));
  }else{
    sub=M*6-(H*30+M/2);
    if((M*6-(H*30+M/2))>180)sub=360-sub;
    ans=sqrt(A*A+B*B-2*A*B*cos(sub*asin(1.0)/90));
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class UnionFind {
public:
  vector<int> par, siz;
    
  UnionFind(int sz_) {
    init(sz_);
  }

  void init(int sz_) {
    par.resize(sz_);
    siz.resize(sz_, 1);
    rep(i, sz_) par[i] = i;
  }

  int root(int x) { 
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    uf.merge(a, b);
  }

  int ans = 0;
  rep(i, n) chmax(ans, uf.size(i));
  cout << ans << '\n';


  
  return 0;
}

Measured memory_bytes: 4724
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

const MOD: i64 = 1_000_000_007;

fn main() {
    let n: usize = read();

    let mut dp = vec![[[[0; 4]; 4]; 4]; n + 1];

    dp[0][3][3][3] = 1;
    for l in 0..n {
        for c1 in 0..4 {
            for c2 in 0..4 {
                for c3 in 0..4 {
                    for c in 0..4 {
                        if dp[l][c1][c2][c3] == 0
                            || (c == 2 && c1 == 1 && c2 == 0)
                            || (c == 2 && c1 == 0 && c2 == 1)
                            || (c == 1 && c1 == 2 && c2 == 0)
                            || (c == 2 && c1 == 1 && c3 == 0)
                            || (c == 2 && c2 == 1 && c3 == 0)
                        {
                            continue;
                        }
                        dp[l + 1][c][c1][c2] += dp[l][c1][c2][c3];
                        dp[l][c][c1][c2] %= MOD;
                    }
                }
            }
        }
    }

    let mut ans = 0;

    for c1 in 0..4 {
        for c2 in 0..4 {
            for c3 in 0..4 {
                ans += dp[n][c1][c2][c3];
                ans %= MOD;
            }
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main() {
  int N,result=0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  for(int i=0;i<N-2;i++) {
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') {
      result++;
    }
  }
  printf("%d",result);
  return 0;
}

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

using namespace std;

#define ll long long

const ll mod = (ll)1e9 + 7;

//#define TEST

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	if (s[0] != 'B' || s[2* n - 1] != 'B') {
		cout << 0 << endl;
		return 0;
	}

	// n!を求めておく
	ll f = 1;
	for (int i = 1; i <= n; ++i)
		f = (f * i) % mod;

	ll ans = 1;
	ll t = 1;
	for (int i = 1; i < 2 * n; ++i) {
#ifdef TEST
		cout << t << " " << ans << endl;
		cout << s[i] << endl;
#endif
		if (t % 2 == 1) {
			if (s[i] == 'B') {
				ans = (ans * t) % mod;
				--t;
			}
			else {
				++t;
			}
		}
		else {
			if (s[i] == 'B') {
				++t;
			}
			else {
				ans = (ans * t) % mod;
				--t;
			}
		}
		if (t < 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (t != 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans * f % mod << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,t1,ans,a[2010][2010],b[2010][2010],c[2010][2010];
char s[2010];
int geta(int l1,int r1,int l2,int r2){
	return a[l2][r2]-a[l2][r1-1]-a[l1-1][r2]+a[l1-1][r1-1];
}
int getb(int l1,int r1,int l2,int r2){
	return b[l2][r2]-b[l2][r1-1]-b[l1-1][r2]+b[l1-1][r1-1];
}
int getc(int l1,int r1,int l2,int r2){
	return c[l2][r2]-c[l2][r1-1]-c[l1-1][r2]+c[l1-1][r1-1];
}
int main(){
	int i,j,l1,r1,l2,r2;
	scanf("%d%d%d",&n,&m,&t1);
	for(i=1;i<=n;i++){
		scanf("%s",s+1);
		for(j=1;j<=m;j++)a[i][j]=s[j]-'0';
	}
	for(i=1;i<=n;i++)
	 for(j=2;j<=m;j++)if(a[i][j]&&a[i][j-1])b[i][j]=1;
	for(i=2;i<=n;i++)
	 for(j=1;j<=m;j++)if(a[i][j]&&a[i-1][j])c[i][j]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)
	  b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1],
	  c[i][j]=c[i][j]+c[i-1][j]+c[i][j-1]-c[i-1][j-1],
	  a[i][j]=a[i][j]+a[i-1][j]+a[i][j-1]-a[i-1][j-1];
	while(t1--){
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		ans=geta(l1,r1,l2,r2);
		ans-=getb(l1,r1+1,l2,r2);
		ans-=getc(l1+1,r1,l2,r2);
		printf("%d\n",ans);
	}
}
/*
是棵树
那么sz=总-边数
边数就是相邻两个 
*/

Measured memory_bytes: 49024
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,M = map(int,input().split())
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
MOD = 10**9+7
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
for i in range(2, M+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):  #nCr mod m
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

def chofuku(n,r): # nHr mod MOD の計算
    return comb_mod(n+r-1,r)
 
def nPr(n,r,m): #nPr mod m の計算
    return fac[n]*finv[n-r]%m
ans = 0
for i in range(1,N+1):
    if i % 2 == 1:
        flag = 1
    else:
        flag = -1
    s = flag*comb_mod(N,i,MOD)*nPr(M-i,N-i,MOD)
    ans += s
    if ans > MOD:
        ans %= MOD
ans1 = 1
for i in range(N):
    ans1 *= (M-i)
    ans1 %= MOD
ans2 = (ans1*ans1)%MOD
ans3 = (ans*nPr(M,N,MOD)) %MOD
print((ans2-ans3)%MOD)


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

int main(){
  int K,S,sum=0;
  cin >> K >> S;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      int z=S-x-y;
      if(z>=0 && z<=K){
        sum += 1;
      }
    }
  }cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector> 
#include <algorithm> 
using namespace std; 
int main() 
{ 
	int n;
	cin >> n;
	vector<char> s(n);
    for(int i=0;i<n;i++){
        cin>>s.at(i);
    }
   
    vector<char>::iterator ip; 
    ip = std::unique(s.begin(), s.begin() +n); 
    s.resize(std::distance(s.begin(), ip)); 
    cout << s.size() << endl; 

    return 0; 
} 

Measured memory_bytes: 384
#include<iostream>
using namespace std;
char a[50][9];
int hantei(int x,int y,int z,int k){
    if(a[k][x] == a[k][y] && a[k][y] == a[k][z]){
        if(a[k][x] == 'o'){return 1;}
        else if(a[k][x] == 'x'){return 2;}
        else{return 0;}
    }
    else{return 0;}
}
int handan(int l){
    if(hantei(0,1,2,l) ==1 || hantei(3,4,5,l) ==1 || hantei(6,7,8,l) ==1 || hantei(0,3,6,l) ==1 || hantei(1,4,7,l) ==1 || hantei(2,5,8,l) ==1 || hantei(0,4,8,l) ==1 || hantei(2,4,6,l) ==1){
        return 1;
    }
    else if(hantei(0,1,2,l) ==2 || hantei(3,4,5,l) ==2 || hantei(6,7,8,l) ==2 || hantei(0,3,6,l) ==2 || hantei(1,4,7,l) ==2 || hantei(2,5,8,l) ==2 || hantei(0,4,8,l) ==2 || hantei(2,4,6,l) ==2){
        return 2;
    }
    else {return 0;}
}
int main(){
    int n = 0;
    while(cin >> a[n][0] >> a[n][1] >> a[n][2] >> a[n][3] >> a[n][4] >> a[n][5] >> a[n][6] >> a[n][7] >> a[n][8]){
        n ++;
    }
    for(int i = 0;i < n;i++){
        if (handan(i) == 1){
            cout << "o" <<endl;
        }
        else if(handan(i) == 2){
            cout << "x" <<endl;
        }
        else{cout << "d" << endl;}
    }
    return 0;
}


Measured memory_bytes: 3008
import java.util.*;
import java.io.*;
public class Main
{
	static LinkedHashMap<String,Integer> map = new LinkedHashMap<>();
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		String arr[]=new String[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=fs.next();
		}
		Arrays.parallelSort(arr);
//		System.out.println(Arrays.toString(arr));
		int c=0;
		int max=-inf;
		for(int i=0;i<=arr.length-2;i++)
		{
			if(arr[i].compareToIgnoreCase(arr[i+1])==0)
			{
				c++;
			}
			else
			{
				map.put(arr[i],c+1);
				max=Math.max(max,c+1);
				c=0;
			}
		}
		max=Math.max(max,c+1);
		map.put(arr[arr.length-1],c+1);
//		System.out.println(map);
		for(String key:map.keySet())
		{
			if(map.get(key)==max)
			{
				System.out.println(key);
			}
		}
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

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


int main(){
    int n, m; cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << ln;
}

Measured memory_bytes: 3632
h,w = map(int,input().split())
area = [input() for i in range(h)]

row=[False]*h
col=[False]*w

for i in range(h):
  for j in range(w):
    if area[i][j] == '#':
      row[i] = True
      col[j] = True

for i in range(h):
  if row[i]:
    for j in range(w):
      if col[j]:
        print(area[i][j], end='')

    print()

Measured memory_bytes: 4468
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	const inputLines = input.split("\n");
	const line0 = inputLines[0];
	const s = line0;
	const result = s.substr(0, 3);
	console.log(result);

	// tmp = input[1].split(" ");
	// //文字列から10進数に変換するときはparseIntを使います
	// var a = parseInt(input[0], 10);
	// var b = parseInt(tmp[0], 10);
	// var c = parseInt(tmp[1], 10);
	// var s = input[2];

	//出力
	// console.log('%d %s',a+b+c,s);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// node index.js
// 1
// 2 3
// test
// (Ctrl + D)


Measured memory_bytes: 29628
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

template<typename T = int> struct SegmentTree
{
    using u32 = unsigned int;
    u32 msb(u32 x) { u32 l=0, r=32, m=0; while (l+1<r){ m=(l+r)>>1; (x>>m?l:r)=m; } return l; }

    vector<T> data;

    // 親子関係 => 親:(p-1)/2, 左:p*2+1, 右:p*2+2
    void init(int n, T v=0) { data.assign((1 << (msb(n - 1) + 1)) * 2 - 1, v); }

    // ノード数
    inline int size() const { return (data.size() + 1) >> 1; }

    // 葉から木全体の値を更新する
    void add(int p, T x)
    {
        p += size() - 1;
        data[p] += x;

        while (p > 0) { p = (p - 1) >> 1; data[p] += x; }
    }

    // 二分木の構造を利用して区間の値を取得する
    T query(int a, int b){ return query(a, b, 0, 0, size()); }
    T query(int a, int b, int k, int l, int r)
    {
        if(r <= a || b <= l) { return 0; }
        if(a <= l && r <= b) { return data[k]; }

        return query(a, b, (k << 1) + 1, l, (l + r) >> 1)
            + query(a, b, (k << 1) + 2, (l + r) >> 1, r);
    }

};

SegmentTree<> seg;

struct Query
{
    ll ID, L, R;
};

int main()
{
    ll N, Q;
    cin >> N >> Q;

    vector<ll> C(N);
    rep (i, N) { cin >> C[i]; --C[i]; }

    vector<Query> queries(Q);

    rep (i, Q)
    {
        auto& query = queries[i];
        query.ID = i;

        cin >> query.L >> query.R;
        --query.L;
        --query.R;
    }

    sort(queries.begin(), queries.end(), [](const auto& a, const auto& b)
    {
        return a.R < b.R;
    });

    vector<ll> last(N, -1);
    vector<ll> ans(Q);

    seg.init(N);

    ll index = 0;

    for (const auto& query : queries)
    {
        while (index <= query.R)
        {
            const auto c = C[index];
            if (last[c] != -1) { seg.add(last[c], -1); }

            last[c] = index;
            seg.add(index, 1);

            ++index;
        }

        const auto res = seg.query(query.L, query.R + 1);
        ans[query.ID] = res;
    }

    rep (i, Q) { cout << ans[i] << endl; }

    return 0;
}


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

using namespace std;

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

#define INF 0x3f3f3f3f

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    vector<int> dp(n+1, INF);
    dp[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= min(i, k); j++) {
            dp[i] = min(dp[i], dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define loop(i, n) for(ll i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
#define PI 3.141592653589793238
#define bc __builtin_popcountll
#define pf push_front
#define pb push_back
#define rf pop_front
#define rb pop_back
#define fs first
#define sc second
#define mp make_pair
#define fi ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
const ll M = 1e9 + 7;
const ll INF = 1e9;
inline ll pwr(ll base, ll n, ll m) {ll ans = 1;while( n > 0 ) {if ( n & 1 ) ans = (ans * base) % m; base = (base * base) % m; n>>=1;}return ans;}
 
bool cmp( pair< long double, long double > a, pair< long double, long double > b ) {
    if (a.fs >= 0 && b.fs < 0)
        return true;
    if (a.fs < 0 && b.fs >= 0)
        return false;
    if (a.fs == 0 && b.fs == 0) {
        if (a.sc >= 0 || b.sc >= 0)
            return a.sc > b.sc;
        return b.sc > a.sc;
    }

    ll det = (a.fs * b.sc) - (b.fs * a.sc);
    if( det != 0 )
        return det < 0;

    ll d1 = (a.fs * a.fs) + (a.sc * a.sc);
    ll d2 = (b.fs * b.fs) + (b.sc * b.sc);
    return d1 > d2;
}
 
int main() {
    fi;
 
    // #ifndef ONLINE_JUDGE
    // freopen( "input.txt", "r", stdin );
    // freopen( "output.txt", "w", stdout );
    // #endif

    int n;
    cin >> n;
    long double x, y;
    vector< pair<long double, long double> > vctrs;
 
    loop(i, n) {
        cin >> x >> y;
        vctrs.pb(mp(x, y));
    }
 
    sort(vctrs.begin(), vctrs.end(), cmp);
    long double ans = 0;
 
    loop(i, n) {
        long double x1 = 0, y1 = 0;
        int cnt = 1, j = i;
 
        while( cnt <= n) {
            x1 += vctrs[j].fs;
            y1 += vctrs[j].sc;
            ans = max(ans, (x1*x1) + (y1*y1));
            j = (j+1) % n;
            cnt++;
        }
 
    }
 
    cout << setprecision(30);
    cout << fixed;
    cout << sqrtl(ans);
 
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	long long H;
	cin>>H;
	
	long long num = 1;
	
	long long ans = 0;
	
	while(true){
		ans += num;
		H /= 2;
		num *= 2;
		
		if(H==0)break;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var L = ReadLongs().ToList();

            var count = 0L;
            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    for (int k = j + 1; k < N; k++)
                    {
                        var l1 = L[i];
                        var l2 = L[j];
                        var l3 = L[k];
                        if (l1 < l2 + l3
                            && l2 < l3 + l1
                            && l3 < l1 + l2
                            && l1 != l2
                            && l2 != l3
                            && l3 != l1)
                        {
                            count++;
                        }
                    }
                }
            }

            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main() {

  int n,k ; cin >> n >> k ;
  vector<int> vec(n);
  for ( int i = 0 ; i < n ; i++ ) 
    cin >> vec.at(i) ;
  
  sort(vec.begin(),vec.end(),greater<int>());
    
  int sum = 0;
  for (int i = 0 ; i<k ; i++) 
    sum += vec.at(i) ;
	
  cout << sum ; 


}

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

int main() {
	/*int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A*B>C*D)
	{
		cout << A * B << endl;
	}
	else
	{
		cout << C * D << endl;
	}*/
	int x;
	cin >> x;

	if (x<1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[105];
int main() {
    int k;
    scanf("%d%s", &k, s);
    int n = strlen(s);
    if(n > k) {
        for(int i = 0; i < k; i++) {
            printf("%c", s[i]);
        }
        printf("...\n");
    }else {
        printf("%s\n", s);
    }
    return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define l long long int 
using namespace std;
int main()
{
	FastIO;
	int n,t;
	cin>>n>>t;
	cout<<(3*n+t)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  string s;cin>>s;
  bool fl1=false;
  bool fl2=false;
  if(s.at(2)=='0'){
    if(s.at(3)!='0') fl1=true;
  }
  if(s.at(2)=='1'){
    if(s.at(3)=='0') fl1=true;
    if(s.at(3)=='1') fl1=true;
    if(s.at(3)=='2') fl1=true;
  }
  if(s.at(0)=='0'){
    if(s.at(1)!='0') fl2=true;
  }
  if(s.at(0)=='1'){
    if(s.at(1)=='0') fl2=true;
    if(s.at(1)=='1') fl2=true;
    if(s.at(1)=='2') fl2=true;
  }
  if(fl1 && !fl2) cout<<"YYMM"<<endl;
  if(!fl1 && fl2) cout<<"MMYY"<<endl;
  if(fl1 && fl2) cout<<"AMBIGUOUS"<<endl;
  if(!fl1 && !fl2) cout<<"NA"<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> A(m);
    for(int i=0;i<m;i++)cin>>A[i];
    int l=0,r=0;
    for(int i=0;i<m;i++){
        if(A[i]<x)l++;
        else r++;
    }
    cout<<min(l,r)<<endl;
}

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

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

	int A, B;
	cin >> A >> B;
	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible";
	}
	else cout << "Impossible";
}


Measured memory_bytes: 256
n = int(input())
li = []
li2 = []
li4 = []
c = 0

for i in range(n):
    s = input()
    li.append(s)
    li3 = set(li)
    
m = int(input())
for i in range(m):
    t = input()
    li2.append(t)

for a in li3:
    c = li.count(a)
    c -= li2.count(a)
    li4.append(c)

if max(li4) < 0:
    print(0)
else:
    print(max(li4))

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main(string[] args)
    {
        //?°???????
        while (true)
        {
            char[] aryData = Console.ReadLine().ToCharArray();
                
            if (aryData[0] == '0') break;
                
            int sum = 0;

            foreach (char c in aryData)
                sum += int.Parse(c.ToString());
                
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 9180
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let makeDivList n =
  List.rev (List.filter (fun x -> n mod x = 0) (Array.to_list (Array.init n (fun i -> i+1))))
let f a b k = List.nth (makeDivList (gcd a b)) (k-1)
let () = Scanf.scanf "%d %d %d\n"
    (fun a b k -> f a b k) |> print_int

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

using namespace std;

int main(){    
    int N;
    string S;

    cin >> N;
    cin >> S;

    int sum = 1;

    if(N == 1){
        cout << sum << endl;
        exit(0);
    }

    for(int i = 1; i < N; i++){
        if(S[i-1] != S[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);


const int INF = INT_MAX;


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

    vector<int> dp(n, INF);
    dp[0] = 0;
    rep(i, n) {
        if(i + 2 < n) {
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
        }
        if(i + 1 < n) {
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int f[100010];

int main()
{
    int n,a,r=0,s=9999,b;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a);
        f[a]++;
        f[a+1]++;
        if(a!=0)
            f[a-1]++;

        r=max(r,a);

        b=min(a,s);
        s=b;
    }
    int p=0;
    if(b!=0)b--;

    for(int i=b; i<r+1; i++)
    {
        p=max(p,f[i]);
    }
    printf("%d\n",p);

    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var N int

func main() {
	fmt.Scan(&N)
	reader := bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)

	A := make([]int, N)
	ans := make([]int, 0)

	for i := 0; i < N; i++ {
		reader.Scan()
		A[i], _ = strconv.Atoi(reader.Text())
	}

	sort.Ints(A)

	for i := N - 1; 0 < i; i-- {
		if A[i] == A[i-1] {
			ans = append(ans, A[i])
			i--
		}

		if len(ans) == 2 {
			fmt.Println(ans[0] * ans[1])
			return
		}
	}
	fmt.Println(0)
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


Measured memory_bytes: 3072
// at_abc148c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {
    if (a == 0)return b;
    return gcd(b%a,a);
}
int main()
{
    ll a, b; cin >> a >> b;
    cout << a * b / gcd(a, b);
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256