akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readIntegerList()
    val kArray = Array(m) { readIntegerList() }
    val pList = readIntegerList()

    var ans = 0
    for (state in 0 until (1 shl n)) {
        if (isAllOn(state, n, m, kArray, pList)) {
            ans++
        }
    }

    println(ans)
}

fun isAllOn(state: Int, n: Int, m: Int, kArray: Array<List<Int>>, pList: List<Int>): Boolean {
    for (i in 0 until m) {
        var onCount = 0
        for (j in 1..kArray[i][0]) {
            if (state and (1 shl (kArray[i][j] - 1)) != 0) {
                onCount++

            }
        }

        if (onCount % 2 != pList[i]){
            return false
        }
    }
    return true
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 38000
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
char c[310][310];
int ans[310][310],tag;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				ans[i][j]=++tag;
			}
		}
	}
	for(int i=1;i<=n;i++){
		int lst=0;
		for(int j=1;j<=m;j++){
			if(c[i][j]=='.')
				continue;
			for(int k=lst+1;k<=j;k++){
				ans[i][k]=ans[i][j];
			}
			lst=j;
		}
		for(int j=1;j<=m;j++)
			if(ans[i][j]==0)
				ans[i][j]=ans[i][j-1];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(ans[i][j]==0)
				ans[i][j]=ans[i-1][j];
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)
			if(ans[i][j]==0)
				ans[i][j]=ans[i+1][j];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			cout<<ans[i][j]<<' ';
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
const int MOD = 1e9 + 7;
const int INF = 2e9;
#define pb push_back
#define mp make_pair
#define mt make_tuple
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; }

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

Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

from math import pi
def Main():
    r = I()
    print(2*pi*r)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9360
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
	int a[51];
	memset(a, 0, sizeof(a));
	int x, b;
	cin >> x >> b;
	for (int i = 0; i < b; i++) {
		int c, d;
		cin >> c >> d;
		a[c]++;
		a[d]++;
	}
	for (int i = 1; i <= x; i++) {
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n, a, b[55];
long long ans;
bool dp[55][55];
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		dp[i][a] = true;
	}
	rep(i,n) scanf("%d", b+i);
	for(int i = 51; i > 0; i--){
		bool need = false;
		rep(j,n){
			bool dp2[55] ={};
			rep(k,51) dp2[k] = dp[j][k];
			for(int k = i-1; k > 0; k--) for(int l = 50; l >= k; l--) dp2[l%k] |= dp2[l];
			if(!dp2[b[j]]) need = true;
		}
		if(need){
			if(i == 51) return 0*puts("-1");
			rep(j,n) for(int k = 50; k >= i; k--) dp[j][k%i] |= dp[j][k];
			ans += 1LL<<i;
		}
	}
	printf("%lld\n", ans);
}

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

using namespace std;

int dp[21][11][156];

int main()
{
  int n, k, s;

  while (1) {
    cin >> n >> k >> s;
    if (n == 0 && k == 0 && s == 0) break;
    memset(**dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= k; j++) {
        for (int l = 0; l <= s; l++) {
          dp[i + 1][j][l] += dp[i][j][l];
          if (l >= i + 1 && j != 0) {
            dp[i + 1][j][l] += dp[i][j - 1][l - (i + 1)];
          }
        }
      }
    }
    cout << dp[n][k][s] << endl;
  }
}

  



Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program{
    static void Main(string[] args)
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine());
            if (n == 0) return;
            Dictionary<DateTime, int> time = new Dictionary<DateTime, int>();
            for(int i = 0;i < n; i++)
            {
                var token = Console.ReadLine().Split(' ');
                var dateTime = DateTime.Parse(token[0]);
                if (!time.ContainsKey(dateTime))
                {
                    time.Add(dateTime, 0);
                }
                time[dateTime]++;
                dateTime = DateTime.Parse(token[1]);
                if (!time.ContainsKey(dateTime))
                {
                    time.Add(dateTime, 0);
                }
                time[dateTime]--;
            }
            var array = time.OrderBy(p => p.Key).ToArray();
            int current = 0;
            int all = 0;
            for(int i = 0;i < array.Length; i++)
            {
                current += array[i].Value;
                all = Math.Max(all, current);
            }
            Console.WriteLine(all);
        }
    }
}



Measured memory_bytes: 37104
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int main () {
    string s;
    cin >> s;
    for (int i = 0 ; i < 3 ; ++ i)
        cout << s[i];
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3620
fun main(args: Array<String>) {
    agc025a()
}

fun agc025a() {
    val n = readLine()!!.toInt()

    var answer = Int.MAX_VALUE
    for (a in 1 until n) {
        val b = n - a
        answer = Math.min(
            answer,
            (a.toString().map { it.toString().toInt() }.sum() + b.toString().map { it.toString().toInt() }.sum())
        )
    }

    println(answer)
}


Measured memory_bytes: 51352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace mondai0000
{
    class Program
    {
        static void Main(string[] args)
        {
            for( int i = 1; i <= 9; i++ ) {
                for( int j = 1; j <= 9; j++ ) {
                    Console.WriteLine( "{0}x{1}={2}", i, j, i * j );
                }
            }
        }
    }
}

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

using namespace std;

int main() {
	int N, K,d,A;
	cin >> N >> K;
	vector<int> sunukekunn(N);
	for (int i = 0; i < K; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> A;
			sunukekunn.at(A-1)++;
		}
	}
	int count;
	for (int i = 0; i < N; i++) {
		if (sunukekunn.at(i) == 0) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3632
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 ;

int n ;
string s ;
bool dp [ N ] , mark [ N ] ; 
vector < string > vc = { "dream" , "dreamer" , "erase" , "eraser" } ; 

bool make ( int p ) {
	if ( p < -1 )
		return 0 ; 
	if ( p == -1 )
		return 1 ;
	if ( mark [ p ] )
		return dp [ p ] ;
	mark [ p ] = 1 ; 
	if ( s [ p ] == 'm' ) {
		string cur = "" ;
		for ( int i = max ( 0LL , p - 4 ) ; i <= p ; i++ )
			cur += s [ i ] ;
		if ( cur == "dream" ) 
			dp [ p ] |= make ( p - 5 ) ;  
	}
	if ( s [ p ] == 'r' ) {
		string cur0 = "" , cur1 = "" ;
		for ( int i = max ( 0LL , p - 6 ) ; i <= p ; i++ )
			cur0 += s [ i ] ;
		if ( cur0 == "dreamer" ) 
			dp [ p ] |= make ( p - 7 ) ;
		for ( int i = max ( 0LL , p - 5 ) ; i <= p ; i++ )
			cur1 += s [ i ] ;
		if ( cur1 == "eraser" ) 
			dp [ p ] |= make ( p - 6 ) ; 
	}
	if ( s [ p ] == 'e' ) {
		string cur = "" ;
		for ( int i = max ( 0LL , p - 4 ) ; i <= p ; i++ )
			cur += s [ i ] ;
		if ( cur == "erase" )  
			dp [ p ] |= make ( p - 5 ) ; 
	}
	return dp [ p ] ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s ;
	n = ( int ) s . size ( ) ;
	cout << ( make ( n - 1 ) ? "YES" : "NO" )  << '\n' ; 
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  bool flg = true;
  while(true)
  {
    if (flg)
    {
      if (a + 1 != b) a++;
      else a--;
      flg = false;
    }
    else
    {
      if (b - 1 != a) b--;
      else b++;
      flg = true;
    }
    if (a < 1)
    {
      cout << "Borys" << endl;
      return 0;
    }
    else if (b > n)
    {
      cout << "Alice" << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

int n, m, E, S, T, R;
vector<pair<int, int> > g[128];
vector<int> cs;
int dist[1<<8][128][128];

void bfs(int b, int s, int *dist) {
    rep (i, n) dist[i] = -1;
    queue<int> q;
    dist[s] = 0;
    q.push(s);
    while (!q.empty()) {
        int at = q.front();
        q.pop();
        rep (i, g[at].size()) {
            int t = g[at][i].first;
            if (dist[t] == -1) {
                int c = g[at][i].second;
                if (c == 0 || (b & (1<<(c-1)))) {
                    dist[t] = dist[at] + 1;
                    q.push(t);
                }
            }
        }
    }
}

struct ST {
    int b, c, r;
    ST() {}
    ST(int b, int c, int r) : b(b), c(c), r(r) {}
};
bool operator<(const ST& l, const ST& r) {
    if (l.b != r.b) return l.b < r.b;
    if (l.c != r.c) return l.c < r.c;
    return l.r < r.r;
}

int dp[1<<8][10][128];
priority_queue<pair<int, ST> > q;

int of(int c) {
    if (c == 0) return S;
    if (c == 1) return T;
    return cs[c-2];
}

void move(int d, int b, int c, int r, int t) {
    int z = dist[b][of(c)][of(t)];
    if (z == -1) return;
    if (r + z > R) return;
    if (c >= 2) b |= (1<<(c-2));
    q.push(mp(-d-z, ST(b, t, r+z)));
}

int solve() {
    rep (b, 1<<8) rep (i, 10) rep (j, 128) dp[b][i][j] = 1e100;
    q.push(mp(0, ST(0, 0, 0)));
    while (!q.empty()) {
        pair<int, ST> vv = q.top();
        q.pop();
        int d = -vv.first;
        int b = vv.second.b;
        int c = vv.second.c;
        int r = vv.second.r;
        if (c == 1) return d;
        if (dp[b][c][r] <= d) continue;
        dp[b][c][r] = d;
        // 1
        q.push(mp(-d-1, ST(b, 0, 0)));
        // 2
        move(d, b, c, r, 1);
        rep (i, cs.size()) move(d, b, c, r, i+2);
    }
    return -1;
}

int main() {
    scanf("%d%d%d%d%d%d", &n, &m, &E, &S, &T, &R);
    rep (i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(mp(b, 0));
        g[b].push_back(mp(a, 0));
    }
    rep (i, E) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        int k = find(cs.begin(), cs.end(), c) - cs.begin();
        if (k == (int)cs.size()) cs.push_back(c);
        g[a].push_back(mp(b, k+1));
        g[b].push_back(mp(a, k+1));
    }
    rep (b, 1<<cs.size()) rep (i, n) bfs(b, i, dist[b][i]);
    /*
    rep (b, 1<<cs.size()) {
        printf("ev %d\n", b);
        rep (i, n) {
            rep (j, n) printf("%d ", dist[b][i][j]);
            printf("\n");
        }
    }
    */
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 18608
#include <stdio.h>
int n,M[100][100],C[100],d[100],f[100],t;
void visit(int );
void dfs();
int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}
void dfs(){
  int i;
  for(i=0;i<n;i++)C[i]=0;
  t=0;
  for(i=0;i<n;i++)if(C[i]==0)visit(i);
  for(i=0;i<n;i++)printf("%d %d %d\n",i+1,d[i],f[i]);
}
void visit(int k){
  int i;
  C[k]=1;
  d[k]=++t;
  for(i=0;i<n;i++){
    if(M[k][i]==0)continue;
    if(C[i]==0)visit(i);
  }
  C[k]=2;
  f[k]=++t;
}


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

int V,E,R,S[500010],T[500010],D[500010]; //問題で与えられる入力
int C[100000]; //各頂点までの最短距離の上限
//無限を表す定数を全頂点をたどる最大超に設定
const int Inf = 10000*100000+100;

int main(){
  for (int i = 0; i < 100000; i++){
   C[i] = Inf;
   }
  cin >> V >> E >> R;
  C[R] = 0;
  for (int i=0; i<E; i++){
    cin >> S[i] >> T[i] >> D[i]; //各辺を入力
	//Cを初期化:C[R]を0に、他をInfに
	}
	for (int t=0; t<V; ++t) { //V回繰り返す
	  bool update = false;
	  for (int i = 0; i<E; ++i) {
	    int s = S[i], t = T[i], d = D[i]; //i番目の辺のs,t,dに対して
		if (C[s] < Inf && C[t] > C[s] + d) { //辺s,tで緩和できるなら
		  C[t] = C[s] + d;//C[t]を更新
		  update = true; //更新が起こったことを記録
		  }
		 }
		if (!update) break; //辺を一巡して更新がなければ打ち切ってよい
		}
	   for (int j=0; j < V; j++){
	    if (C[j] < Inf){
	    cout << C[j] << endl;
		}
		else {
		cout << "INF" << endl;
		}
	  }
	}

Measured memory_bytes: 7376
import fractions

n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

aset = set(a)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

if n == 1:
    print(1)

elif 1 < n:
    g = lcm(a[0], a[1])

    if n != 2:
        for val in aset:
            g = lcm(g, val)

    ans = 0
    for val in a:
        ans += g//val

    print(ans % mod)

Measured memory_bytes: 6580
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int K;
	scanf("%d", &K);
	string S;
	cin >> S;
	if (S.length() <= K) {
		cout << S << "\n";
	} else {
		cout << S.substr(0, K) << "..." << "\n";
	}

	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int t,a,b,c,d,k;
int calc(int x)
{
	return (a-(b-x+k-1)/k)/k;
}
int main()
{
	int i;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		k=(max(a,b)+min(a,b))/(min(a,b)+1);
		if(k==1)
		{
			for(i=c;i<=d;i++)
			{
				putchar('A'+((i&1)^(a>=b)));
			}
			puts("");
			continue;
		}
		int l=0,r=b+1,mid,ans=0;
		while(l<r)
		{
			mid=(l+r)/2;
			if(mid<=calc(mid))
			{
				l=mid+1;
				ans=mid;
			}
			else r=mid;
		}
		int lim=ans+a-(b-ans+k-1)/k+1;
		for(i=c;i<=d;i++)
		{
			if(i<=lim)
			{
				putchar('A'+(i%(k+1)==0));
			}
			else
			{
				putchar('A'+((a+b-i)%(k+1)!=k));
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
const int N = 205;
using namespace std;

vector <int> mv;
int n, a[N];

void change(int k){
    mv.push_back(k);
    for (int i = k; i < n; i++) swap(a[i], a[i-k]);
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++){
        for (int j = 1; j < n; j++){
            change(1);
            if (a[0] < a[n-1]) change(n-1);
        }
        change(1);
    }
    cout << (int)mv.size() << "\n";
    for (auto x : mv) cout << x << "\n";
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
constexpr int time_limit = 1900;
chrono::system_clock::time_point start, current;
int c[26];
int64_t s[366][26];


int64_t eval(const vector<int> &state, int d){
    int last[26] = {0};
    int64_t csum = 0;
    for(int i=0;i<26;++i) csum += c[i];
    int64_t decl = -csum;
    int64_t score = 0;

    for(int i=1;i<=d;++i){
        score += s[i][state[i]];
        decl += (i - last[state[i]])*c[state[i]];
        last[state[i]] = i;
        score += decl;
        decl -= csum;
    }
    return score;
}

struct simulated_annealing{
    random_device dev;
    mt19937_64 rng;
    uniform_real_distribution<double> dist;
    uniform_int_distribution<int> typ;
    int D;

    simulated_annealing(int d): dist{0.0, 1.0}, typ{0, 25}, D(d){
        rng.seed(dev());
    }

    vector<int> loop(){
        vector<int> state, best_state;
        state.resize(D+1); best_state.resize(D+1);
        for(int i=1;i<=D;++i) state[i] = best_state[i] = typ(rng);
        int64_t curr_score = eval(state, D), best_score = curr_score;

        for(int iter=1;;++iter){
            current = chrono::system_clock::now();
            if(chrono::duration_cast<chrono::milliseconds>(current-start).count() >= time_limit) break;
            auto next_state = neighbor(state);
            int64_t next_score = eval(next_state, D);

            if(next_score >= curr_score || dist(rng) <= probability(curr_score, next_score, temperature(iter))){
                curr_score = next_score;
                state = next_state;
                if(best_score < curr_score){
                    best_score = curr_score;
                    best_state = state;
                }
            }
        }
        return best_state;
    }
    vector<int> neighbor(const vector<int> &curr){
        vector<int> ret{curr};
        int x = rand() % D + 1;
        ret[x] = typ(rng);
        return ret;
    }
    double probability(double score1, double score2, double t){
        if(score1 <= score2) return 1.0;
        else return exp((score2 - score1) / t);
    }
    double temperature(int step){
        return pow(0.99, step);
    }
};

int main(){
    start = chrono::system_clock::now();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);

    int d;
    cin >> d;
    for(int i=0;i<26;++i) cin >>c[i];
    for(int i=1;i<=d;++i){
        for(int j=0;j<26;++j) cin >> s[i][j];
    }
    simulated_annealing sa(d);
    auto ans = sa.loop();

    for(int i=1;i<=d;++i) cout << ans[i] + 1 << endl;
    cerr << eval(ans, d) << endl;

    return 0;
}

Measured memory_bytes: 4244
#include <iostream>
using namespace std;
int main(){
	string S, T;
	cin >> S >> T;
	
	int len = S.length();
	int Tindex;
	
	int i, index;
	bool flag = false;
	for(i = 0; i < len; i++){
		if(flag == 1)
			break;
		if(T[i] == S[0]){
			for(index = 1; index < len; index++){
				if(i + index >= len)
					Tindex = i + index - len;
				else
					Tindex = i + index;
				if(T[Tindex] != S[index])
					break;
			}
			if(index == len)
				flag = 1;
		}
	}
	
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
} 

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long b = 26;
		List<long> L = new List<long>();
		L.Add(0);
		L.Add(b);
		while(true){
			if(L[L.Count - 1] >= N) break;
			b *= 26;
			L.Add(L[L.Count - 1] + b);
		}
		
		int Len = L.Count - 1;
		long h = N - L[L.Count - 2] - 1;
//Console.WriteLine("Len:{0}, h:{1}",Len, h);
		List<char> ans = new List<char>();
		for(int i=0;i<Len;i++){
			ans.Add((char)('a' + (h % 26)));
			h /= 26;
		}
		ans.Reverse();
		Console.WriteLine(new String(ans.ToArray()));
	}
	long N;
	public Sol(){
		N = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 17784
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int H, W;
vector<string> A;

int main(){

	//int H, W;
	cin >> H >> W;
	//vector<string> A(H), NEXT(H);
	A = vector<string>(H);
	int white = 0;
	queue<pint> Q;
	for(int i = 0; i < H; i ++){
		cin >> A[i];
		for(int j = 0; j < W; j ++){
			if(A[i][j] == '.')white ++;
			else{
				Q.push(mp(i, j));
			}
		}
	}
	//white = H * W;
	int qsize;
	int ans = 0;
	//cout << "white" << white << endl;
	while(white > 0){
		ans ++;
		qsize = Q.size();
		//cout << "qsize = " << qsize << endl;
		for(int i = 0; i < qsize; i ++){
			pint P = Q.front();
			//white --;
			//cout << P.first << SPACE << P.second << endl;
			Q.pop();
			if(P.first + 1 < H && A[P.first + 1][P.second] == '.'){
				Q.push(mp(P.first + 1, P.second));
				A[P.first + 1][P.second] = '#';
				white --;
			}
			if(0 <=P.first - 1 && A[P.first - 1][P.second] == '.'){
				Q.push(mp(P.first - 1, P.second));
				A[P.first - 1][P.second] = '#';
				white --;
			}
			if(P.second + 1 < W && A[P.first][P.second + 1] == '.'){
				Q.push(mp(P.first, P.second + 1));
				A[P.first][P.second + 1] = '#';
				white --;
			}
			if(0 <= P.second - 1 && A[P.first][P.second - 1] == '.'){
				Q.push(mp(P.first, P.second - 1));
				A[P.first][P.second - 1] = '#';
				white --;
			}
		}
		//cout << "white = " << white << endl;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9488
import java.util.Scanner;

public class Main {

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

	    int result = execute(sc.nextInt());
        System.out.println(result);
    }

    public static int execute(int amount){
        int count500 = amount / 500;
        amount = amount % 500;
        int happy500 = count500 * 1000;
        int count5 = amount / 5;
        int happy5 = count5 * 5;
        return happy500 + happy5;
    }

}


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

int main(){
    int n, Qtime, sumTime = 0;
    struct Q{
        string name;
        int time;
    };

    Q tmp;
    queue<Q> que;

    cin >> n >> Qtime;
    
    for(int i = 0; i < n; i++){
        cin >> tmp.name >> tmp.time;
        que.push(tmp);
    }

    while(!que.empty()){
        tmp = que.front();
        que.pop();
        if(tmp.time - Qtime > 0){
            tmp.time -= Qtime;
            sumTime += Qtime;
            que.push(tmp);
        }else{
            cout << tmp.name << " ";
            cout << tmp.time + sumTime << endl;
            sumTime += tmp.time;
        }
    }
}


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

typedef signed long long ll;
typedef vector <int> vi; 
const int MX = 1e6 + 5;
int dis[MX];
vi G[MX];
ll h[MX];

int main() {
	int n, k;
	ll ans = 0;
	scanf("%d %d", &n, &k);

	for(int i = 0; i < n; scanf("%lld", &h[i]), i++);
	sort(h, h + n);
    int lim = min(n, k);
    n -= k;
    for(int i = 0; i < n; ans += h[i], i++);
    printf("%lld\n", ans);
	
    return 0;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
#define sort_(a) sort(a.begin(), a.end())
#define sum(a) accumulate(a.begin(), a.end(), 0)
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen(".testcase", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  map<string, int> S{};
  string s;
  rep(i, N) {
    cin >> s;
    sort_(s);
    S[s] += 1;
  }

  ll ans = 0;
  ll n = 0;
  for (auto s : S) {
    n = s.second;
    ans += (n * (n - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
// Author: pankaj_m05 
// Problem: A 
//Created: 17.05.2020 17:34:03

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

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

const int mod = 1e9 + 7;

int main(void) { 
	fast
	int n; cin >> n;
	int ones = n % 10;
	if(ones == 0 || ones == 1 || ones == 6 || ones == 8)
		cout << "pon" << '\n';

	if(ones == 2 || ones == 4 || ones == 5 || ones == 7 || ones == 9)
		cout << "hon" << '\n';
	
	if(ones == 3)
		cout << "bon" << '\n';
	return 0;
}                                          

Measured memory_bytes: 3616
ps = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
N = int(input())
if N == 1:
  print(0)
  quit()
l = [0 for _ in range(98)]
def fac(n):
  for k in ps:
   if n == 1:
     break
   if n % k == 0:
    l[k] += 1
    fac(n // k)
    break

for i in range(2,N+1):
  fac(i)

p = [k for k in l if k > 1]

ans = 0

def num(n):
  r = 0
  for k in p:
    if k >= n:
      r += 1
  return(r)

if p[0] >= 74:
  ans += 1

#5*15

ans += (num(14) * (num(14) - 1))
ans += (num(14) * (num(4) - num(14)))

#3 * 25
ans += (num(24) * (num(24) - 1))
ans += (num(24) * (num(2) - num(24)))

#3 * 5 * 5
ans += (num(4) * (num(4) - 1) * (num(4) - 2) // 2)
ans += (num(4) * (num(4) - 1) //2) * (num(2) - num(4))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;
 
int n, a, b;

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
  return 0;
}




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

int main() {
  int64_t a, b, k;
  std::cin >> a >> b >> k;

  std::set<int64_t> ans;

  for (int64_t i = 0; i < k; i++) {
    if (a + i <= b) {
      ans.insert(a + i);
    }
  }

  for (int64_t i = 0; i < k; i++) {
    if (a <= b - i) {
      ans.insert(b - i);
    }
  }

  for (const auto i : ans) {
    std::cout << i << std::endl;
  }
  return 0;
}

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

using namespace std;

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

	int type1 = a + b;
	int type2 = a + c;
	int type3 = b + c;

	cout << min({ type1,type2,type3 }) << endl;
}






Measured memory_bytes: 3604
def main():
    a,b = map(str,input().split())
    #print(a,b)
    A = str(a*int(b))
    B = str(b*int(a))
    #print(A)
    if A<B:
        print(A)
    else:
        print(B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
	int n,t;
	cin >> n >> t;
	vector<vector<int>> dp(n+1,vector<int>(t+1));
	vector<vector<int>> dp1(n+2,vector<int>(t+1));
	
	vector<P> ab(n);
	for(int i = 0;i<n;i++)
	{
		cin >> ab[i].first >> ab[i].second;
	}

	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<=t;j++)
		{
			if(j-ab[i].first>=0)dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i].first]+ab[i].second);
			else dp[i+1][j] = dp[i][j];
		}
	}
	for(int i = n+1;i>1;i--)
	{
		for(int j = 0;j<=t;j++)
		{
			if(j-ab[i-2].first>=0)dp1[i-1][j] = max(dp1[i][j],dp1[i][j-ab[i-2].first]+ab[i-2].second);
			else dp1[i-1][j] = dp1[i][j];

		}
	}
	
	
	int ans = 0;
	for(int i = 1;i<=n;i++)
	{
		for(int j = 0;j<t;j++)ans = max(ans,dp[i-1][j]+dp1[i+1][t-1-j]+ab[i-1].second);
	}



	cout << ans << endl;
	
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, d; cin >> n >> d;
  d = 1 + d * 2;
  cout << (n + d - 1) / d << '\n';
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n; scanf("%d",&n);
   int cnt=0;
   rep(i,0,n){
      int tmp; scanf("%d",&tmp);
      if(tmp&1)cnt++;
   } printf(cnt&1?"NO":"YES");
   return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Debug.Trace

main :: IO ()
main = do
  [sa, sb, sc] <- replicateM 3 getLine
  putStrLn [play (sa, sb, sc) 'a']

play :: (String, String, String) -> Char -> Char
play (sa, sb, sc) now
  | now == 'a' && null sa = 'A'
  | now == 'b' && null sb = 'B'
  | now == 'c' && null sc = 'C'
  | otherwise =
      case now of
        'a' -> let (p:sa') = sa in play (sa', sb, sc) p
        'b' -> let (p:sb') = sb in play (sa, sb', sc) p
        'c' -> let (p:sc') = sc in play (sa, sb, sc') p


Measured memory_bytes: 508
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

bool kaki[200][200];
int N, W, H, S, T;

int cal(int x, int y)
{
  int ans = 0;
  for(int i = 0; i < S; i++)
  {
    for(int j = 0; j < T; j++)
    {
      ans += kaki[i + x][j + y];
    }
  }
  return ans;
}

int main()
{
loop:
  memset(kaki, 0, sizeof kaki);
  cin >> N;
  if(!N)
    return 0;
  cin >> W >> H;
  for(int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    a--; b--;
    kaki[a][b] = 1;
  }
  cin >> S >> T;
  int ans = 0;
  for(int x = 0; x <= W - S; x++)
   for(int y = 0; y <= H - T; y++)
     ans = max(ans, cal(x, y));
  cout << ans << endl;
  goto loop;
}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const long long mod = 1e9+7;
long long dp[2100][2100];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, M;
    cin >> N >> M;

    vector<long long> S(N), T(M);
    for (int i=0; i<N; ++i) cin >> S[i];
    for (int i=0; i<M; ++i) cin >> T[i];

    // init
    for (int i=0; i<=N; ++i) dp[i][0] = 1;
    for (int i=0; i<=M; ++i) dp[0][i] = 1;

    for (int i=1; i<=N; ++i) {
        for (int j=1; j<=M; ++j) {
            if (S[i-1] == T[j-1]) {
                if (i>0) dp[i][j] += dp[i-1][j];
                dp[i][j] %= mod;
                if (j>0) dp[i][j] += dp[i][j-1];
                dp[i][j] %= mod;
            } else {
                if (i>0) dp[i][j] += dp[i-1][j];
                dp[i][j] %= mod;
                if (j>0) dp[i][j] += dp[i][j-1];
                dp[i][j] %= mod;
                if (i>0 && j>0) dp[i][j] += mod - dp[i-1][j-1];
                dp[i][j] %= mod;
            }
            dp[i][j] %= mod;
        }
    }

    cout << (dp[N][M] % mod) << endl;

    return 0;
}


Measured memory_bytes: 33152
<?php
$n = intval(fgets(STDIN));
$odd = 0;
$even = 0;
for($i=0;$i<$n;$i++){
    if(intval(fgets(STDIN)) % 2){
        $odd++;
    }else{
        $even++;
    }
}
echo $odd ? "first" : "second";


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

int main() {
    int a_1, b_1, a_2, b_2, a_3, b_3;
    vector<int> way(6);
    int path_list[4];
    for (int i ; i<4;i++){
        path_list[i] = 0;
    }



    cin >> way[0] >> way[1];
    cin >> way[2] >> way[3];
    cin >> way[4] >> way[5];

    for (int path: way){
        path_list[path-1] += 1;
    }
    bool no_flag = false;
    for (int path: path_list){
        if(path>2){
            no_flag = true;
            break;
        }

    }

    if (no_flag==false ){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }



}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int par[100000];
int fri[100010] = { 0 };
int blo[100010] = { 0 };
int gro[100010] = { 0 };
int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
int main() {
	int n, q, p, a, b;
	int x, y;
	cin >> n >> q >> p;
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
	for (int j = 0; j < q; j++) {
		cin >> a >> b;
		x = root(a - 1);
		y = root(b - 1);
		if (x != y) {
			par[x] = y;
		}
		fri[a - 1]++;
		fri[b - 1]++;
	}
	for (int k = 0; k < p; k++) {
		cin >> a >> b;
		if (root(a - 1) == root(b - 1)) {
			blo[a - 1]++;
			blo[b - 1]++;
		}
	}
	for (int k = 0; k < n; k++) {
		gro[root(k)]++;
	}
	for (int l = 0; l < n; l++) {
		cout << gro[root(l)] - fri[l] - blo[l] - 1;
		if (l != n - 1) {
			cout << " ";
		}
	}
	cout << endl;
	return 0;
}
	

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

vector<bool> prime(100001000);
void eratos ( int n){
	prime[2] = true; prime[0] = prime[1] = false;
	for(int i = 3; i <= n; i += 2) prime[i] = true, prime[i+1] = false;
	int limit = (int)sqrt((double)n) + 1;
	for(int i = 3; i <= limit; i += 2){
		if(!prime[i]) continue;
		for(int j = i * i, k = i * 2; j <= n; j += k) prime[j] = false;
	}
}
int main(){
	eratos(100000009);
	int n, ans=0;
	cin >>n;
	rep(i,n){
		int a; cin >>a;
		if(prime[a]) ans++;
	}
	cout << ans <<"\n";
	return 0;
}




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

int main() {
  int X;
  cin >> X;
  if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int P, Q, A, N;

int dfs(int p, int q, int n, int tmp){
  if(P * q == p * Q)return 1;
  if(P * q < p * Q)return 0;
  if(N == n) return 0;
  
  int ret = 0;
  
  for(int i = tmp;q * i <= A; i++){
    ret+=dfs(p*i+q, q*i, n + 1, i);
  }

  return ret;
}

int main() {
  while(cin >> P >> Q >> A >> N,
        !(P * Q * A * N == 0)){
    cout << dfs (0, 1, 0, 1) << endl;
  }
  return 0;
}

    

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

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

  rep(i, k) {
    if (b <= a) {
      b *= 2;
    } else if (c <= b) {
      c *= 2;
    }
  }

  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>

int main(void){
    int x,y;
    int i;
    while(1){
        scanf("%d %d",&x,&y);
        if( x == 0 && y == 0){
            return 0;
        }
        else if( x > y ){
            int temp = x;
            x = y;
            y = temp;
        }
        printf("%d %d\n",x,y);
    }
}


Measured memory_bytes: 2704
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	string a;
	cin >> a;
	int kol = 0;
	for (int i = 0; i < a.size(); i ++) {
		int t = sz (a) - i - 1;
		if (a[i] != a[t]) {
			a[i] = a[t];
			kol ++;
		}
	}
	cout << kol;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

template<class T, class S>
inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






int main(){
    int A, B, C, D; std::cin >> A >> B >> C >> D;
    while(1){
        C -= B;
        if(C <= 0){
            std::cout << "Yes" << std::endl;
            return 0;
        }
        A -= D;
        if(A <= 0){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
 
    int N;
    cin>>N;
    vector<long long int> sum(N+1);
    for(int i=0;i<N;i++){
        long long int a;cin>>a;
        sum[i+1]=sum[i]+a;
    }
    long long int ans;
    for(int i=0;i<N-1;i++){
        if(i==0) ans=abs(sum[N]-2*sum[i+1]);
        else ans=min(ans,abs(sum[N]-2*sum[i+1]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.Arrays;

import java.util.Scanner;

public class Main{
	static int[] parent;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int[] n = new int[b];
		int[] m = new int[b];
		parent = new int[a];
		for (int i = 0; i < m.length; i++) { //Setting up the two arrays start and finish
			n[i] = scan.nextInt();
			m[i] = scan.nextInt();
		}
		
		for(int i = 0; i < parent.length; i ++) {
			parent[i]= i;
		}
		
		for (int i = 0; i < b; i++) {
		union(n[i], m[i]);
		}
		
		int q = scan.nextInt();
		for(int i = 0; i < q; i ++) {
			int s = scan.nextInt();
			int t = scan.nextInt();
			
			if(find(s) == find(t)) //runs for each one of the pairs inputed
				System.out.println("yes");
			else
				System.out.println("no");

		}
		
	}
	
	public static void union(int x,int y) {
		int r1 = find(x);
		int r2 = find(y);
		if(r1 != r2)
			parent[r2] = r1;
		
	}
	public static int find(int x) {
		int curr = x;
		if(parent[curr] == curr) return curr;
		parent[curr] = find(parent[curr]);
		return parent[curr];
	}


}



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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int num[5];
  rep(i, 3) cin >> num[i];
  sort(num, num + 3, greater<>());

  int k;
  cin >> k;
  rep(i, k) num[0] *= 2;

  cout << num[0] + num[1] + num[2] << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdint.h>
int main(void)
{
    int is_good[100001];
    for (int64_t i = 0; i < 100001; i++)
    {
        is_good[i] = 1;
    }
    int64_t N, M;
    scanf("%lli %lli", &N, &M);
    int64_t height[100000];
    for (int64_t i = 1; i <= N; i++)
    {
        scanf("%lli", &height[i]);
    }
    for (int64_t i = 1; i <= M; i++)
    {
        int64_t A, B;
        scanf("%lli %lli", &A, &B);
        if (height[A] >= height[B])
        {
            is_good[B] = 0;
        }
        if (height[A] <= height[B])
        {
            is_good[A] = 0;
        }
    }
    int64_t sum = 0;
    for (int64_t i = 1; i <= N; i++)
    {
        if (is_good[i])
        {
            sum++;
        }
    }
    printf("%lli\n", sum);
    return 0;
}

Measured memory_bytes: 2904