akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int SZ = 200000;
class UF {
public:
	int P[SZ + 1], saidai;
	UF() : P(), saidai() {
		saidai = -1;
		rep1(i, SZ) P[i] = -1;
	}
	int find(int A) {
		if (P[A] < 0) return A;
		return P[A] = find(P[A]);
	}
	bool unite(int A, int B) {
		int a = find(A);
		int b = find(B);
		if (a == b) return false;
		if (P[a] > P[b]) swap(a, b);
		P[a] += P[b];
		if (P[a] < saidai) saidai = P[a];
		P[b] = a;
		return true;
	}
} uf;

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

	int N = getint(), M = getint();

	rep(i, M) {
		uf.unite(getint(), getint());
	}

	printf("%d\n", -uf.saidai);


	Would you please return 0;
}

Measured memory_bytes: 2516
int main(void)
{
    int a,b,k;
    
    scanf("%d%d%d",&a,&b,&k);
    int m=a,n=b-k+1;
    while((m<a+k)&&(m<=b)){
        printf("%d\n",m);
        m++;
    }
    if(m>n) n=m;
    while(n<=b){
        printf("%d\n",n);
        n++;
    }
    return 0;
}

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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	long long ans = 1;
	int n = in();

	for (int i = 1; i <= n; ++i) {
		ans *= i;
		ans %= mod;
	}

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef pair<int,int> pii;
typedef vector<int> vi;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
  int n;
  bool b=false;
  while(cin>> n,n){
    int ans=0;
    b=false;
    for(int i=0;i<n;i++){
      int a;
      cin>> a;
      if(a>0) ans++;
      if(a>1) b=true;
    }
    if(ans && b) cout<< ans+1<< endl;
    else cout<<"NA"<< endl;
  }
}

Measured memory_bytes: 1160
fun main() {
    val input1 = rint()
    val set = hashSetOf<String>()
    for (i in 0 until input1) {
        set += readLine()!!
    }
    println(set.toSet().size)
}

inline fun rsp() = readLine()!!.split(" ")

inline fun rspint() = rsp().map(String::toInt)

inline fun rint() = readLine()!!.toInt()

Measured memory_bytes: 77180
object Main extends App {
    val in = io.Source.stdin.getLines
    for (x <- in; r@Array(m, nmin, nmax) = x.split(" ").map(_.toInt) if r.exists(_ != 0)) {
        val ps = in.take(m).map(_.toInt)
        println(ps.zipWithIndex.foldLeft((0, 0, 0)){
            case ((gap, p0, res), (p1, i)) if (nmin - 1 to nmax).contains(i) =>
                if (p0 - p1 >= gap) (p0 - p1, p1, i) else (gap, p1, res)
            case y => y._1
        }._3)
    }
}

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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t;
const int mxN=100, mxK=1e5;
int n,k;
vi nums(mxN);
vector<int>dp(mxK+1);

void test_case(){
    cin>>n>>k;
    fo(i,n)cin>>nums[i];
    Fo(i,1,k+1){
        fo(j,n){
            if(i-nums[j]<0)continue;
            if(!dp[i-nums[j]]){
                dp[i]=1;
                break;
            }
        }
    }
    cout<<(dp[k]?"First":"Second")<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }
    
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	vector<pair<str, pair<int, int>>> towns(n);
	rep(i, n)
	{
		str s;
		int point;
		cin >> s >> point;
		point = point * (-1);
		towns[i] = make_pair(s, make_pair(point, i + 1));
	}
	sort(all(towns));
	rep(i, n)
	{
		cout << towns[i].second.second << endl;
	}

	return 0;
}

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

int main(){
    int K;
    cin >> K;
    long team_member[K];
    for(int i = 0; i < K; i++){
        cin >> team_member[i];
    }
    long back_member_min = 2;
    long back_member_max = 2;
    for(int i = K - 1; i >= 0; i--){
        back_member_min = team_member[i] * ((back_member_min - 1) / team_member[i] + 1);
        back_member_max = team_member[i] * (back_member_max / team_member[i] + 1) - 1;
        if(back_member_min > back_member_max){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << back_member_min << " " << back_member_max << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  string ans="Balanced";
  if(a+b>c+d) ans="Left";
  else if(a+b<c+d) ans="Right";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>
#include <cstring>

using namespace std;

int main(){

    int a;
  	cin >> a;
    cout << a/100  + (a/10)%10 + a%10;

    return 0;
}

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

int n, k, c[1005], ans;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c, c+n);
    for (int i = 0; i < k; i++){
        ans += c[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3640
n = int(input())
L = [[[0]*10 for i in range(3)] for j in range(4)]
cnt = 0
while cnt < n:
    b, f, r, v = map(int, input().split())
    L[b-1][f-1][r-1] += v
    cnt += 1
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' {}'.format(L[i][j][k]), end='')
        print('')
    if i != 3:
        print('#'*20)


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

int main() {

  string S;
  int count = 0;

  cin >> S ;

  for (int i = 0;i<3;i++){
    if(S.at(i) == 'R'){
      count++;
    }
  }

  if(S.at(1) == 'S' && count == 2){
    count = 1;
  }

  cout << count << endl;

 return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector <int> b(n - 1);
  for (int i = 0; i < n - 1; i++) cin >> b[i];
  vector <int> a(n);

  a[n - 1] = b[n - 2];
  for (int i = n - 2; i > 0; i--) {
    a[i] = min(b[i - 1], b[i]); 
  } 
  a[0] = b[0];

  int sum = accumulate(a.begin(), a.end(), 0);
  cout << sum << endl;
  return 0;  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
struct data_p{int hed,clr;ll siz;}pot[200005];
struct data_l{int to,nxt;}lin[400005];
struct data_q{ll now,ans;}qst[200005];
ll n;
int top=0;
void add_l(int a,int b){lin[++top].to=b;lin[top].nxt=pot[a].hed;pot[a].hed=top;}
void get_siz(int a,int fa)
{
	pot[a].siz=1;int b;
	for(int i=pot[a].hed;i;i=lin[i].nxt)
	{
		b=lin[i].to;
		if(b==fa)continue;
		get_siz(b,a);
		pot[a].siz+=pot[b].siz;
	}
}
void dp(int a,int fa)
{
	ll tmp=qst[pot[a].clr].now,potl=n-pot[a].siz+1-qst[pot[a].clr].now;int b;
	qst[pot[a].clr].ans+=potl;
	for(int i=pot[a].hed;i;i=lin[i].nxt)
	{
		b=lin[i].to;
		if(b==fa)continue;
		qst[pot[a].clr].now=n-pot[b].siz;
		dp(b,a);
		qst[pot[a].clr].ans+=potl*pot[b].siz;
		potl+=pot[b].siz;
	}
	qst[pot[a].clr].now=tmp+pot[a].siz;
}
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&pot[i].clr);
	for(int i=1;i<n;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		add_l(a,b);add_l(b,a);
	}
	get_siz(1,1);
	dp(1,1);
	for(int i=1;i<=n;i++)
	{
		printf("%lld\n",qst[i].ans);
	}
	return 0;
}

Measured memory_bytes: 31876
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second 
using namespace std;
typedef pair<int,int> PII; 
typedef long long ll;
const int N = 30;
int c[N],c2[N];
int main(){
	for(int i =0;i<N;i++) c[i] = 1000;
	int n;
	scanf("%d",&n);
	for(int i =0;i<n;i++){
		string s;
		cin>>s;
		memset(c2,0,sizeof(c2));
		for(int i =0;i<s.size();i++) c2[s[i]-'a']++;
		for(int i =0;i<N;i++) c[i]=min(c[i],c2[i]);
	}
	for(int i =0;i<26;i++) for(int j =0;j<c[i];j++) putchar('a'+i);
	puts("");
	return 0;
}

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

const double PI=3.1415926535897932;

int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double ans=a*a+b*b-2*a*b*cos(PI*(60*h-11*m)/360);
  ans=sqrt(ans);
  printf("%.10f\n",ans);
}


Measured memory_bytes: 4188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N, T; cin >> N >> T;
    Int res = LLONG_MAX;

    Int c, t;
    rep(i, 0, N) {
        cin >> c >> t;
        if (t <= T) res = min(res, c);
    }

    if (res == LLONG_MAX) cout << "TLE" << endl;
    else cout << res << endl;
}


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

int main() {
    int n;
    cin >> n;
    int res = 0;
    while (true){
	if (n == 1) break;
	n /= 2;
	res++;	
    }
    int k = 1;
    for (int i = 0; i < res; ++i) {
	k *= 2;
    }
    cout << k << endl;
}


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

const int N = 100005;
const int MOD = 1000000007;

int power(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1) {
    if (y & 1) ret = 1LL * ret * x % MOD;
    x = 1LL * x * x % MOD;
  }

  return ret;
}

int g[N];

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

  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    g[i] += i;
    for (int j = i*2; j <= k; j += i) {
      g[j] -= g[i];
    }

    ans = (ans + 1LL * power(k/i, n) * g[i]) % MOD;
  }

  printf("%d\n", ans);
  return 0;
}


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

int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 2756
#include "iostream"
#include "cmath"
#include "iomanip"
#include "string"
using namespace std;

int main()
{
	string str;
	getline(cin,str);
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] >= 'a'&&str[i] <= 'z')
		{
			str[i] += 'A' - 'a';
		}
		else if (str[i] >= 'A'&&str[i] <= 'Z')
		{
			str[i] -= 'A' - 'a';
		}
	}
	cout << str << endl;
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
using ll = long long;
#define pb push_back
#define INF 100100100
//const int INF = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

int main()
{
  int N;
  cin >> N;
  vector<ll> a;
  rep(i,N) {
    ll tmp;
    cin >> tmp;
    a.pb(tmp);
  }
  vector<ll> b;
  b = a;
  sort(ALL(a));
  int naka_l = N/2 - 1;
  int naka_r = N/2 ;
  ll l_v = a[naka_l];
  ll r_v = a[naka_r];
  rep(i,N) {
    if (b[i] <= l_v) {
      cout << r_v << endl;
    } else if (b[i] >= r_v) {
      cout << l_v << endl;
    }
  }

}

Measured memory_bytes: 5488
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long int s ;
    cin >> s ;
    int count = 1 ;

    while(1){
       if(s == 1 || s == 2 || s==4){
           cout << count + 3 << endl;
           break ;
       }
       if(s % 2 == 0 ){
           s = s / 2 ;
       }else{
           s = 3 * s + 1 ;
       }

       count++ ; 
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    val a = readLine()!!.split(' ').map { it.toInt() }

    var m: MutableMap<Int, Int> = mutableMapOf()

    for (t in a) {
        m[t] = m.getOrDefault(t, 0) + 1
    }

    if (m.containsKey(1)) {
        if (m[1] == 1) {
            println(1)
        } else {
            println(0)
        }
        return
    }

    var ans = n

    for (t in a) {
        if (m[t]!! >= 2) {
            ans--
            continue
        }

        for (i in 2..t) {
            if (i * i > t)
                break

            if (t % i == 0) {
                if (m.containsKey(i) || m.containsKey(t / i)) {
                    ans--
                    break
                }
            }
        }
    }

    println(ans)

}

Measured memory_bytes: 84940
import java.util.Scanner;
class Main
{
  public static long knapsack(int[] wt, long[] val, int n, int w, long[][] dp)
  {
    for(int i = 1; i <= n; i++)
    {
      for(int j = 1; j <= w; j++)
      {
        if(wt[i - 1] <= j)
        {
          dp[i][j] = Math.max((val[i - 1] + dp[i - 1][j - wt[i - 1]]), dp[i - 1][j]);
        }
        else
                                                      {
                                                        dp[i][j] = dp[i - 1][j];
                                                      }
                                                        
                                                      
      }
    }
                                                      return dp[n][w];
  }
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int w = scan.nextInt();
    int wt[] = new int[n];
    long val[] = new long[n];
    for(int i = 0; i < n; i++)
    {
      wt[i] = scan.nextInt();
      val[i] = scan.nextLong();
    }
    long[][] dp = new long[n + 1][w + 1];
    long maxProfit = knapsack(wt, val, n, w, dp);
    System.out.println(maxProfit);
  }
}


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

long long arr[10000001];
long long a,b,c,d,e;

int main() {
	cin>>a>>b>>c;
	for(long long i=0;i<c;i++) {
		cin>>d;
		arr[d]++;
	}
	for(long long i=1;i<=a;i++) {
		e=b-c+arr[i];
		if(e>0) cout<<"Yes";
		else cout<<"No";;
		cout<<"\n";
	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
ll g1(ll n, int p) {
	if (n == 0) return 0; //階乗の場合
	return n/p + g1(n/p,p);
}
ll g2(ll n, int p){
	ll res = 0;
	if ( n % 2 == 1) {
		return g1(n,p) - g2(n-1,p);
	}
	res = g1(n/2,p);
	if(p == 2) res += n/2;
	return res;
}

int main()
{
	ll n;
	cin >> n;
	ll ans = min(g2(n,2), g2(n,5));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  string s;
  cin>>s;
  int c[3]={};
  int n=s.size();
  for(int i=0;i<n;i++) c[s[i]-'a']++;
  //cout<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
  sort(c,c+3);
  cout<<(abs(c[0]-c[2])<=1?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c));
    vector<vector<int>> g(n,vector<int>(n));
    vector<map<int,int>> vg(3);
    REP(i,c) REP(j,c) cin >> d[i][j];
    REP(i,n) REP(j,n) {
        cin >> g[i][j];
        g[i][j]--;
        vg[(i+j) % 3][g[i][j]]++;
    }

    int ans = 1e9;
    REP(i,c) {
        REP(j,c) {
            if (i == j) continue;
            REP(k,c) {
                int tmp = 0;
                if (i == k || j == k) continue;
                for(auto m:vg[0]) {
                    tmp += d[m.first][i] * m.second;
                }
                for(auto m:vg[1]) {
                    tmp += d[m.first][j] * m.second;
                }
                for(auto m:vg[2]) {
                    tmp += d[m.first][k] * m.second;
                }
                ans = min(ans,tmp);
            }
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int x=a.size();
	int y=b.size();
	int maxn=0;
	for(int i=0;i<=x-y;i++)
	{
		int num=0;
		for(int j=0;j<y;j++)
		{
			if(a[i+j]==b[j])num++;
		}
		maxn=max(maxn,num);
	}
	cout<<y-maxn;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
long long n, ans, cnt, mi=1, a[1005], s[2], x[505], y[505], z;
int main() {
	int i, j;
	cin>>n;
	for(i=1; i<=n; i++) {
		cin>>a[i];
		s[i%2] += max(a[i], 0LL);
		if(a[i]>a[mi]) mi=i;
	}
	for(i=s[1]>s[0]; i<=n; i+=2) if(a[i]>0) {
		x[++z] = i;
		if(z>1) cnt += y[z-1] = (x[z] - x[z-1]) / 2;
	}
	if(z) {
		ans = max(s[0], s[1]);
		cnt += x[1]-1 + n-x[z];
	} else {
		ans = a[mi];
		cnt = n-1;
		x[++z] = mi;
	}
	cout<<ans<<endl<<cnt<<endl;
	for(i=n; i>x[z]; i--) cout<<i<<endl;
	for(i=1; i<x[1]; i++) cout<<1<<endl;
	for(i=1; i<z; i++) for(j=y[i]; j; j--) cout<<j+1<<endl;
	return 0;
}


Measured memory_bytes: 256
N,X=map(int,input().split())
x=input().split()
x_s=[int(a) for a in x]

x_s.append(X)

list_s=sorted(x_s)

numbers=[]

for n in range(1,N+1):
    number=list_s[n]-list_s[n-1]
    numbers.append(number)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

number=numbers[0]
for n in range(len(numbers)):
    number=gcd(number,numbers[n])

print(number)


Measured memory_bytes: 92496
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 3e5 + 5; 
using namespace std;

int n, m, t[N], mx;
struct node
{
	int l, r;
	bool operator < (const node &p) const
		{
			return r - l < p.r - p.l; 
		}
} p[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int lowbit(int x) { return x & (-x); }

void modify(int x, int y)
{
	for(int i = x; i <= mx; i += lowbit(i)) t[i] += y; 
}

void add(int x, int y) { modify(x, 1), modify(y + 1, -1); }

int query(int x)
{
	int res = 0;
	for(int i = x; i >= 1; i -= lowbit(i)) res += t[i];
	return res; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++)
		p[i].l = read <int> () + 1, p[i].r = read <int> () + 1, mx = max(mx, p[i].r); 
	sort(p + 1, p + n + 1); 
	for(int pos = 1, res, i = 1; i <= m; i++)
	{
		while(pos <= n && p[pos].r - p[pos].l < i - 1) add(p[pos].l, p[pos].r), pos++; 
		res = 0; 
		for(int j = 0; j * i < mx; j++) res += query(j * i + 1); 
		printf("%d\n", res + n - pos + 1); 
	}
	return 0; 
}


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

const int N = 1e5;
int niz[N + 10];
int binNiz[N + 10];
int odnos[N + 10];
set<int> Set;
vector<int> brojevi;
ll n;
int seg[15*N + 10];

void update(int t, int start, int end, int ind, int x)
{
    if(start == end)
    {
        seg[t] += x;
        return;
    }

    int mid = (start + end) / 2;
    if(start <= ind && ind <= mid) update(2*t, start, mid, ind, x);
    else update(2*t+1, mid+1, end, ind, x);

    seg[t] = seg[2*t] + seg[2*t+1];
    return;
}

int query(int t, int start, int end, int l, int r)
{
    if(end < l || start > r) return 0;

    if(start >= l && end <= r) return seg[t];

    int mid = (start + end) / 2;
    int x1 = query(2*t, start, mid, l, r);
    int x2 = query(2*t+1, mid+1, end, l, r);
    return (x1 + x2);
}


ll calc(int ind)
{
    int x = brojevi[ind];
    //memset(binNiz, 0, sizeof(binNiz));
    //memset(odnos, 0, sizeof(odnos));
    memset(seg, 0, sizeof(seg));

    for(int i = 1; i <= n; i++)
    {
        if(niz[i] >= x) binNiz[i] = 1;
        else binNiz[i] = 0;
    }
    ll belo = 0;
    ll crno = 0;
    //cout << x << "\n";
    for(int i = 1; i <= n; i++)
    {
        if(binNiz[i] == 1) crno++;
        else belo++;
        odnos[i] = crno - belo;
        //cout << odnos[i] << " ";
        odnos[i] += N;
    }
    ll res = 0;
    update(1, 0, 2*N, N, 1);
    for(int i = 1; i <= n; i++)
    {
        int vr = odnos[i];
        res += query(1, 0, 2*N, 0, vr);
        update(1, 0, 2*N, vr, 1);
    }
    return res; //+ crno;

}

int binarna(int l, int r)
{
    if(l == r) return l;
    int p = (l + r + 1) / 2;
    ll res = calc(p);
    ll uk = n*(n+1)/2;
    if(res >= (uk+1)/2) return binarna(p, r);
    return binarna(l, p - 1);
}

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

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> niz[i];
        Set.insert(niz[i]);
    }
    for(set<int>::iterator it = Set.begin(); it != Set.end(); it++)
        brojevi.pb(*it);

    /*for(int i = 0; i < brojevi.size(); i++)
    {
        cout << brojevi[i] << " " << calc(i) << "\n";
    }*/
    //cout << calc(0);
    cout << brojevi[binarna(0, brojevi.size()-1)];


    return 0;
}

/*
4
4 3 1 3
*/


Measured memory_bytes: 12540
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, C;
    cin >> N >> C;
    vint s(N), t(N), c(N);
    rep(i, N) cin >> s[i] >> t[i] >> c[i];
    unordered_map<int, set<int>> ch_s_map;
    unordered_map<int, set<int>> ch_t_map;
    
    rep(i, N) {
        ch_s_map[c[i]].insert(s[i]);
        ch_t_map[c[i]].insert(t[i]);
    }

    int ans = 0;
    REP(x, 1, 100001) {
        int cost = 0;
        REP(ch, 1, C + 1) {
            auto s_upper = ch_s_map[ch].upper_bound(x);
            auto t_lower = ch_t_map[ch].lower_bound(x);
            if (s_upper == ch_s_map[ch].end() && t_lower == ch_t_map[ch].end()) continue;
            else if (s_upper == ch_s_map[ch].end() && t_lower != ch_t_map[ch].end()) cost++;
            else if (*s_upper >= *t_lower) cost++;
        }
        ans = max(cost, ans);

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

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

int main() {
	char n[10];
	scanf("%s", n);
	
	if (n[0] == n[1] && n[1] == n[2]) printf("Yes");
	else if (n[1] == n[2] && n[2] == n[3]) printf("Yes");
	else printf("No");
	
	return 0;
}

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

const int N = 100005;
int n, m, deg[N], tot = 1, nxt[4 * N], fst[N], to[4 * N], f[4 * N], cur[N], dis[N], S, T;

void addedge(int u, int v, int w) {
	nxt[++tot] = fst[u]; fst[u] = tot; to[tot] = v; f[tot] = w;
	nxt[++tot] = fst[v]; fst[v] = tot; to[tot] = u; f[tot] = 0;
}
bool bfs() {
	static int q[N];
	int st = 0, ed = 0;
	for (int i = 1; i <= n; ++i)
		dis[i] = -1, cur[i] = fst[i];
	q[ed++] = S;
	dis[S] = 0;
	while (st < ed) {
		int u = q[st++];
		for (int i = fst[u]; i; i = nxt[i])
			if (dis[to[i]] == -1 && f[i] > 0) {
				dis[to[i]] = dis[u] + 1;
				if (to[i] == T) return true;
				q[ed++] = to[i];
			}
	}
	return false;
}
int dfs(int u, int fl) {
	if (u == T || !fl) return fl;
	int used = 0;
	for (int &i = cur[u]; i; i = nxt[i])
		if (dis[to[i]] == dis[u] + 1) {
			int t = dfs(to[i], min(fl - used, f[i]));
			f[i] -= t, f[i ^ 1] += t, used += t;
			if (used == fl) break;
		}
	return used;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, u, v; i <= m; ++i) {
		scanf("%d%d", &u, &v);
		addedge(u, v, 1);
		addedge(v, u, 1);
		++deg[u], ++deg[v];
	}
	int c = 0;
	for (int i = 1; i <= n; ++i)
		if (deg[i] % 2) return puts("No"), 0;
	for (int i = 1; i <= n; ++i) {
		if (deg[i] >= 6) return puts("Yes"), 0;
		if (deg[i] == 4) ++c;
	}
	if (c >= 3) return puts("Yes"), 0;
	if (c <= 1) return puts("No"), 0;
	for (int i = 1; i <= n; ++i)
		if (deg[i] == 4) {
			if (!S) S = i;
			else T = i;
		}
	int res = 0;
	while (bfs()) res += dfs(S, 1 << 30);
	if (res == 2) puts("Yes");
	else puts("No");
	return 0;
}


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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	int a[n], b[n-1];
	for (int i = 0; i < n - 1; ++i) cin >> b[i];
	for (int i = n - 2; i >= 0; --i) {
		a[i] = b[i];
		if (i == n - 2) a[i + 1] = b[i];
		else a[i + 1] = min(a[i+1], b[i]);
	}
	int res = 0;
	for (int i = 0; i < n; ++i) {
		res += a[i];
	} 
	cout << res;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(void){
  ios_base::sync_with_stdio(0);
  int n, m;
  int coin[20];
  cin >> n >> m;
  rep(i, m) cin >> coin[i];

  int dp[50001];
  rep(i, 50001) dp[i] = INF;

  dp[0] = 0;

  rep(i, m){
    REP(j, coin[i], n+1) dp[j] = min(dp[j], dp[j-coin[i]] + 1);
  }

  cout << dp[n] << endl;
  return 0; 
}

Measured memory_bytes: 1388
//
//AtCoder Grand Contest 013
//A
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

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

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int flag=0;
    int ans=1;
    int bef_a = a[0];
    FOR(i, 1, n-1){
        if (bef_a < a[i]){
            if (flag==-1) {
                ans++;
                flag=0;
            }else flag=1;
        }else if (bef_a > a[i]){
            if (flag==1) {
                ans++;
                flag=0;
            }else flag=-1;
        }
        bef_a=a[i];
    }
    cout << ans << endl;
    return 0;
}


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

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

	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a') a++;
		if (s[i] == 'b') b++;
		if (s[i] == 'c') c++;
	}

	if (a == 1 && b == 1 && c == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int P[200001];
ll kotae = 0;
int N;
int to[400001], ne[400001], he[200001];
int dfs(int v, int prev) {
	int kazu = 1;
	for (int u = he[v]; u; u = ne[u]) {
		if (to[u] != prev) kazu += dfs(to[u], v);
	}
	kotae += P[N - kazu] + P[kazu];
	return kazu;
}

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


	N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	P[0] = 1;
	rep1(i, N) P[i] = P[i - 1] * 2 % mod;

	dfs(1, 0);
	kotae = ((ll(P[N - 1]) * N + P[N] - 1 + N - kotae) % mod + mod) % mod;
	kotae = kotae * modpow(P[N], mod - 2) % mod;

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 7936
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j +(i+1) < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        ball[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Measured memory_bytes: 14132
n, m = map(int, input().split())
MOD = 1000000007

fact=[0,1]
fact_inv=[0]*(n+1)
for i in range(2,n+1):
  fact.append(fact[-1]*i % MOD)

fact_inv[n] = pow(fact[n],MOD-2,MOD)
for i in range(n-1,-1,-1):
  fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def comb(n,r):
  return fact[n]*fact_inv[r]*fact_inv[n-r]%MOD

def sigmaComb(dis):
  ans=0
  if dis == 1 or dis == 0:
    return 1
  end=dis//2+1
  for i in range(end):
    t=comb(dis-i,i)
    #print(dis-i,i,t)
    ans+=t
  return ans

hole=[0]
ans=1
for i in range(m):
  t = int(input())
  availLeft=hole[-1]
  availRight=t-1
  dis=availRight-availLeft
  if dis <0:
    ans=0
    break

  ans=ans*sigmaComb(dis)%MOD
  #print("dis=",dis,t,ans)
  hole.append(t+1)
else:
  availLeft=hole[-1]
  availRight=n
  dis=availRight-availLeft
  #print("dis=",dis,hole[-1],ans)
  ans=ans*sigmaComb(dis)%MOD

print(ans%MOD)

Measured memory_bytes: 12972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >>n;
  double a[n];
  for(int i=0;i<n;i++)cin >>a[i];
  double ans=0.0,temp=0.0;
  for(int i=0;i<n;i++)temp+=1.0/a[i];
  printf("%f",1.0/temp);
}

Measured memory_bytes: 256
N, M = [int(nm) for nm in input().split()]
if M != 0:
  a = int(input())

C = [1, 0] # [-2段目, -1段目]
C += [0]*(N+10) # C = [-2段目, -1段目, 0段目, 1段目, 2段目, ...]
for n in range(0, N+1):
  if M == 0:
    C[n+2] = (C[n] + C[n+1]) % 1000000007
  else: # M > 0:
    if n != a:
      C[n+2] = (C[n] + C[n+1]) % 1000000007
    else: # n == a:
      C[n+2] = 0
      M -= 1
      if M > 0:
        a = int(input())

ans = C[N+2]  % 1000000007
print(ans)

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int x;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> x;
	int ans = 0;
	REP(i, 1, x + 1){
		if ((i*360)%x == 0){
			ans = (i*360)/x;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define INF 1000000000
#define sz(v) (int)v.size()
#define mp(a,b) make_pair(a,b)

typedef long long ll;
typedef vector<long> vl;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void solve() {
    ll n,a,b;
    cin >> n >> a >> b;

    ll res = 0;
    if ((b-a) % 2 == 0) {
        res = (b-a)/2;
    } else {
        res = min(b-1, n-a);
        res = min(res, (b-a-1)/2 + a);
        res = min(res, (b-a-1)/2 + n-b+1);
    }
    cout << res << endl;
}


int main() {
    solve();
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス //
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

// End of Template //

int main() {

    int N;
    cin >> N;
    
    if (N % 108 == 13 || N % 108 == 26 || N % 108 == 40 || N % 108 == 53 || N % 108 == 67 || N % 108 == 80 || N % 108 == 94 || N % 108 == 107) cou(":(");
    else cou(ceil(N / 1.08));
}

Measured memory_bytes: 256
N, C = map(int, input().split())
D =[]
for _ in range(C):
    D.append(list(map(int, input().split())))
c = []
for _ in range(N):
    c.append(list(map(int, input().split())))
#print(c)

diago = [[0]*(C + 1) for _ in range(3)]
for i in range(N):
    for j in range(N):
        diago[(i + j) % 3][c[i][j]] += 1
#print(diago)

diff = [[0]*(C+1) for _ in range(3)]

for i, naname in enumerate(diago):
    for color in range(1, C+1):
        for j, cell in enumerate(naname):
            diff[i][color] += D[j-1][color-1] * cell
#print(diff)

candicate = []
for i in range(1, C+1):
    for j in range(1, C+1):
        for k in range(1, C+1):
            if i != j and j != k and k != i:
                candicate.append(diff[0][i]+diff[1][j]+diff[2][k])
print(min(candicate))



Measured memory_bytes: 44892
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> a, b;
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        int tmp;
        if(n%2==0){
            tmp=n+1;
            for(int i=2; i<n; ++i){
                a.push_back(1);
                b.push_back(i);
            }
            for(int i=2; i<=n; ++i){
                for(int j=i+1; j<=n; ++j){
                    if(j==tmp-i)
                        continue;
                    a.push_back(i);
                    b.push_back(j);
                }
            }
            cout<<a.size()<<endl;
            for(int i=0; i<a.size(); ++i){
                cout<<a[i]<<" "<<b[i]<<endl;
            }
        }
        else{
            tmp=n;
            for(int i=1; i<=n; ++i){
                for(int j=i+1; j<=n; ++j){
                    if(j==tmp-i)
                        continue;
                    a.push_back(i);
                    b.push_back(j);
                }
            }
            cout<<a.size()<<endl;
            for(int i=0; i<a.size(); ++i){
                cout<<a[i]<<" "<<b[i]<<endl;
            }
        }
    }
  return 0;
}




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

using namespace std;

int main(){
	int a, b, c, ans = 0;
	scanf("%d %d %d", &a, &b, &c);
	for(int i = a; i <= b; i++){
		if(!(c % i)){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1188
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string S;
	cin >> S;

	if (S[0] == S[1] && S[1] == S[2])
	{
		cout << "No" << '\n';
	}
	else
	{
		cout << "Yes" << '\n';
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
 ll N;
  in(N);
  vl A(N);
  rep(i,N)in(A[i]);
  int ans =0;
  rep(i,N){
   while(A[i]%2==0){
    ans++;
     A[i] /= 2;
   }
  }
  out(ans);
}	


Measured memory_bytes: 384
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, T;
    cin >> N >> T;

    int ans = INF;
    REP(i, N) {
        int c, t;
        cin >> c >> t;
        if (t > T) continue;
        ans = min(ans, c);
    }
    if (ans == INF) {
        cout << "TLE" << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string.h>
#include<math.h>

int main(){
	double a,b,c,d,e,f,y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
		y=(d*c-f*a)/(d*b-e*a);
		
		printf("%.3lf %.3lf\n",(c-b*y)/a+0.00001,y+0.00001); 
	}
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    for (int i  =1; i <=9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    for(int i = 0; i < 9; ++i){
        if(i*100+i*10+i < N && N <= (i+1)*100+(i+1)*10+(i+1)){
            cout << (i+1)*100+(i+1)*10+(i+1) << endl;
            return 0;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int N;
list<int> B;
vi ret;

int main(int argc, char** argv) {
  cin >> N;
  B.resize(N);

  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    B.push_back(x);
  }

  int n = N;
  while (n>=1) {
    bool ok = false;
    auto ri = B.rbegin();
    int i=n;
    while (i>=1) {
//cout << "ri " << *ri << ", i " << i << endl;
      if (*ri == i) {
//cout << "erase " << i << endl;
        ret.emplace_back(*ri);
        B.erase(next(ri).base());
	ok = true;
	break;
      }
      ri++;
      i--;
    }

    if (!ok) {
      cout << -1 << endl;
      return 0;
    }

    n--;
  }

  reverse(begin(ret), end(ret));
  for (int x : ret) {
     cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <stack>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;

int main() {
	uint64_t N, K;
	cin >> N >> K;
	uint64_t c1, c2;
	for (uint64_t i = 0; i < N; i++)
	{
		uint64_t a;
		cin >> a;
		if (a == 1) {
			c1 = i;
			c2 = N - i - 1;
			if (c1 > c2) {
				auto c = c1;
				c1 = c2;
				c2 = c;
			}
		}
	}
	uint64_t ans = 0;
	ans += c1 / (K - 1);
	if (c1 % (K - 1) != 0) {
		c2 -= (K - (c1 % (K - 1)) - 1);
		++ans;
	}
	ans += c2 / (K - 1);
	if (c2 % (K - 1) != 0)++ans;

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
l = {}
for _ in range(N):
  s = input()
  l.setdefault(s, 0)
  l[s] += 1
l = sorted([(v, k) for k, v in l.items()])
c = l[-1][0]
r = []
for i in range(-1, -len(l)-1, -1):
  if l[i][0] < c:
    break
  r.append(l[i][1])
for x in reversed(r):
  print(x)

Measured memory_bytes: 115236