akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef unsigned long long ll;
const int maxn = 100005;

int f[maxn][3];
bool in[maxn][3];
vector<int>e[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
  }
  memset(f,-1,sizeof(f));
  int s,t;
  cin>>s>>t;
  f[s][0] = 0;
  queue<int>qx,qy;
  in[s][0]=1;
  qx.push(s);
  qy.push(0);
  while(!qx.empty()){
    int x = qx.front();
    qx.pop();
    int y = qy.front();
    qy.pop();
    in[x][y]=0;
    for(int i=0;i<e[x].size();i++){
      int nx = e[x][i];
      int ny = (y+1)%3;
      int val = f[x][y] + (y==2?1:0);
      if(f[nx][ny]==-1||f[nx][ny]>val){
        f[nx][ny]=val;
        if(!in[nx][ny]){
          qx.push(nx);
          qy.push(ny);
          in[nx][ny]=1;
        }
      }
    }
  }
  cout<<f[t][0]<<endl;
  return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(int argc, char** argv) {
	pair<double, double> P1, P2;
	cin >> P1.first >> P1.second 
		>> P2.first >> P2.second;
	cout << fixed << setprecision(6)
		<< (double)sqrt(pow(P1.second-P2.second, 2.0)+pow(P1.first-P2.first, 2.0)) << endl;
	return 0;
}

Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var a, z int
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			a = i
			break
		}
	}
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'Z' {
			z = i
			break
		}
	}
	fmt.Println(z - a + 1)
}


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

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

using namespace std;

typedef long long ll;

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

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

  ll ans = 0;
  ll sum = 0;
  rep(i, n) {
    a[i] += sum;
    if (a[i] % b[i]) {
      ll v = (a[i] / b[i] + 1) * b[i] - a[i];
      ans += v;
      sum += v;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python

N, M = map(int, input().split())
As = []
Bs = []

ret = 'No'
for n in range(N):
    As.append(input())
for m in range(M):
    Bs.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        same = True
        for k in range(M):
            if As[i+k][j:j+M] != Bs[k]:
                same = False
                break
        if same:
            ret = 'Yes'
print(ret)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int x, y;
    cin >> x >> y;
    int X, Y;

    if (x == 2){
        X = 3;
    }
    else if (x == 4 || x == 6 || x == 9 || x == 11){
        X = 2;
    }
    else {
        X = 1;
    }

    if (y == 2){
        Y = 3;
    }
    else if (y == 4 || y == 6 || y == 9 || y == 11){
        Y = 2;
    }
    else {
        Y = 1;
    }

    if (X == Y){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
X = int(input())

if X >= 1800:
    print(1)
elif X >= 1600:
    print(2)
elif X >= 1400:
    print(3)
elif X >= 1200:
    print(4)
elif X >= 1000:
    print(5)
elif X >= 800:
    print(6)
elif X >= 600:
    print(7)
elif X >= 400:
    print(8)
    


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int s = *max_element(A.begin(), A.end());
  
  vector<int> ans(N, s);
  bool flag = true;
  
  for (int i = 0; i < N; i++) {
    int tmp;
    if (A.at(i) == s && flag) {
      A.at(i) = 0;
      ans.at(i) = *max_element(A.begin(), A.end());
      tmp = A.at(i);
      flag = false;
    } else if (A.at(i) == s && !flag) {
      A.at(i) = tmp; 
    }
  }
  
  for (int i = 0; i < N; i++) cout << ans.at(i) << endl;
  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

int main() {
    int n;
    cin >> n;
    int a[100];
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a + n);
    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int howMany(int i, int k) {
    int ans=1;
    while(i < k) {
        i *= 2;
        ans *= 2;
    }
    return ans;
}

int main()
{
    int n, k;
    double ans=0;

    scanf("%d%d", &n ,&k);

    for (int i = 1; n >= i; i++) {
        ans += 1.0 / ((double)n*howMany(i, k));
    }

    printf("%.9f\n", ans);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  string S;
  cin >> N >> S;
  int ans=1;
  rep(i,N-1) if(S[i]!=S[i+1]) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>

using ll = long long;
const ll K = 1000000000000000000;

int main(){
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        if(a[i] == 0){
            std::cout <<  0 << std::endl;
            return 0;
        }
    }

    ll sum = 1;
    for(int i = 0; i < n; i++){
        ll tmp = K / sum;
        if(a[i] > tmp){
            std::cout << -1 << std::endl;
            return 0;
        }
        sum *= a[i];
    }
    std::cout << sum << std::endl;
    return 0;
}


Measured memory_bytes: 4052
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1 << 30)

int H, A[MAX + 1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if (l <= H && A[l] > A[i])
        largest = l;
    else
        largest = i;
    if (r <= H && A[r] > A[largest])
        largest = r;

    if (largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if (H < 1)
        return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key)
{
    if (key < A[i])
        return;
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i])
    {
        swap(A[i], A[i / 2]);
        i = i / 2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main()
{
    int key;
    char com[10];

    while (1)
    {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n')
            break;
        if (com[0] == 'i')
        {
            scanf("%d", &key);
            insert(key);
        }
        else
        {
            printf("%d\n", extract());
        }
    }

    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846


int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int> > pairs(n);
    int a,b;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        pair<int,int> mypair;
        mypair.first = a;
        mypair.second = b;
        pairs[i] = mypair;
    }

    double temp;
    double sum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i+1; j < n; j++)
        {
            temp = (double)sqrt((double)pow(pairs[i].first-pairs[j].first,2)+(double)pow(pairs[i].second-pairs[j].second,2));
            sum += (double)((facctorialMethod(n)*(n-1))/((n*(n-1))/2)*temp);
        }
        
    }
    cout << setprecision(13)<< sum/facctorialMethod(n) << endl;
    
}


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

bool isPrime(unsigned int n) {
  unsigned int count=0;
  unsigned int max;
  count = 0;
  max = n;

  for(int i=2; i<max; i++) {
    if(n%i==0) return false;
    max = n/i;
  }
  return true;
}

int main() {
  unsigned int input;
  unsigned int count;
  unsigned int cum[500000]; // for odd numbers greater than or equal to 1

  count = 1; // For 2
  cum[0] = 0; // For 1
  cum[1] = 2; // For 3
  for(int i= 2; i<500000; i++) {
    if(isPrime(2*i+1)) {
      cum[i] = cum[i-1]+1;
      count++;
    } else {
      cum[i]=cum[i-1];
    }
  }

  while(cin >> input) {
    count = 0;
    if(input==2)
      cout << "1" << endl;
    else
      cout << cum[(int)(input-0.5)/2] << endl;
  }

  return 0;
}

Measured memory_bytes: 3104
#b
n,k=map(int,input().split())
h=list(map(int,input().split()))

N=100010
INF=float('INF')
dp=[INF]*N
dp[0]=0

for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])

Measured memory_bytes: 55392
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind tree(n);
    int a,b;
    vector<int> fri(n,0); 
    rep(i,m) {
        cin >> a >> b;
        tree.unite(a-1,b-1);
        ++fri[a-1];
        ++fri[b-1];
    }
    vector<vector<int>> bl(n);
    rep(i,k) {
        cin >> a >> b;
        bl[a-1].push_back(b-1);
        bl[b-1].push_back(a-1);
        // rep(j,n) cout << bl[j] << endl;
    }
    vector<int> ren(n);
    rep(j,n) ++ren[tree.root(j)];
    
    rep(i,n) {
        int ans=ren[tree.root(i)]-1-fri[i];
        rep(j,bl[i].size()) {
            if (tree.root(i)==tree.root(bl[i][j])) ans--;
        }
        cout << ans;
        if (i<n-1) cout << ' ';
        else cout << endl;
    }
}

Measured memory_bytes: 7552
n = int(input())
a = list(map(int, input().split()))

dicplus = {}
dicmins = {}
for i in range(n):
	b = i + a[i]
	c = i - a[i]
	if b not in dicplus:
		dicplus[b] = 1
	else:
		dicplus[b] += 1
	if c not in dicmins:
		dicmins[c] = 1
	else:
		dicmins[c] += 1

ans = 0
for i in dicplus:
	if i in dicmins:
		ans += dicplus[i] * dicmins[i]
print (ans)

Measured memory_bytes: 56760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int a;
string s;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>a>>s;
	if(a>=3200)cout<<s<<endl;
	else cout<<"red\n";
	
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
#define INF INT_MAX/2

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

struct Edge {
  int cost;
  int to;
};

int n;
vv<Edge> g;
vector<int> d;

void dijkstra(int s) {
  d.assign(n, INF);
  priority_queue<vi, vector<vi>, greater<vi> > q;
  d[s] = 0;
  q.push({0, s}); // candidate of min-cost, edge number

  while (!q.empty()) {
    auto p = q.top(); // delete from queue
    q.pop();
    int v = p[1];
    if (d[v] < p[0]) {
      continue;
    }
    for (auto e : g[v]) {
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        q.push({d[e.to], e.to});
      }
    }
  }
}

int main() {
  int ne, s;
  scanf("%d %d %d", &n, &ne, &s);
  g.resize(n);
  rep (i, ne) {
    int a, b, d;
    scanf("%d %d %d", &a, &b, &d);
    Edge e;
    e.cost = d;
    e.to = b;
    g[a].pb(e);
  }
  dijkstra(s);
  rep (i, n) {
    if (d[i] == INF) {
      printf("INF\n");
    } else {
      printf("%d\n", d[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 17008
#include <stdio.h>
#include <math.h>


main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%c",j==0||j==w-1||i==0||i==h-1?'#':'.');
		}
		printf("\n");
	}
	printf("\n");
}
}




Measured memory_bytes: 2036
#include <cstdio>
using ll = long long;
constexpr ll off = 1ll << 58;
int n, dp[2][3], nxt[2][3];
ll x[100005], y[100005];
inline bool solve(ll sum, int rem)
{
	bool res = false;
	for (int i = 0; i < n; i++)
	{
		if (y[i] >= sum)
			continue;
		ll lim = sum - y[i];
		for (int j = 0; j < 3; j++)
			dp[0][j] = dp[1][j] = 0;
		dp[0][0] = 1;
		for (int j = 60; j >= 0; j--)
		{
			for (int k = 0; k < 3; k++)
				nxt[0][k] = nxt[1][k] = 0;
			for (int a = 0; a < 2; a++)
			{
				int mx = x[i] >> j & 1;
				if (!a && !(lim >> j & 1))
					mx = 0;
				for (int b = 0; b < 3; b++)
				{
					if (!dp[a][b])
						continue;
					for (int t = 0; t <= mx; t++)
					{
						int k = (b + t * ((j & 1) + 1)) % 3;
						nxt[a || t != (lim >> j & 1)][k] ^= 1;
					}
				}
			}
			for (int k = 0; k < 3; k++)
			{
				dp[0][k] = nxt[0][k];
				dp[1][k] = nxt[1][k];
			}
		}
		res ^= dp[1][(rem - y[i] % 3 + 3) % 3];
	}
	return res;
}
inline bool calc(ll pos)
{
	bool res = false;
	for (int i = 0; i < n; i++)
	{
		ll cur = pos - y[i];
		if (cur >= 0 && cur <= x[i] && (x[i] & cur) == cur)
			res ^= 1;
	}
	return res;
}
int main()
{
	// freopen("C.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld%lld", x + i, y + i);
		x[i] += off;
		y[i] += off;
	}
	int rem = 0;
	while (!solve(1ll << 60, rem))
		rem++;
	ll pos = 0;
	for (int i = 60; i >= 0; i--)
	{
		if (solve(pos, rem) == solve(pos + (1ll << i), rem))
			pos += 1ll << i;
	}
	ll l = pos, r = pos;
	for (int i = 60; i >= 0; i--)
	{
		if (calc(l - (1ll << i)))
			l -= 1ll << i;
		if (calc(r + (1ll << i)))
			r += 1ll << i;
	}
	printf("%lld %lld\n", r - l - off, l - off);
	return 0;
}


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

int main(){
  int D;
  cin>>D;
  int C[26];
  map<int,int>mp;
  for(int i=0;i<26;i++){
    cin>>C[i];
    if(C[i]<10){
      mp[i]++;
    }   
  }
  int S[365][26];
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      cin>>S[i][j];
    }
  }
  
  int flag=1;
  int temp=0;
  int now=0;
  int maxans=0;
  while(temp<365){
    maxans=0;
    now=0;
    
    if(temp>200 && temp<228){
      if(mp[temp%26]==1){
        cout<<temp%26+1<<endl;
        temp++;
        continue;
      }
    }
    
    
    for(int i=0;i<26;i++){
      if(S[temp][i]>maxans){
        now=i;
        maxans=S[temp][i];
      }
    }    
    
    if(mp[temp%26]==0){
      cout<<temp%26+1<<endl;
      temp++;
      continue;
    }

    cout<<now+1<<endl;
    temp++;
  }
  return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  string s;
  cin>>s;
  if(s[0]=='S')cout<<"Cloudy";
  if(s[0]=='C')cout<<"Rainy";
  if(s[0]=='R')cout<<"Sunny";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long int n,i,k,a[200010],ans;
  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<long long int>());
  for(i=k;i<n;i++){
    ans=ans+a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456];
int par[213456];//親
int depth[213456];//木の深さ
//n要素で初期化
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		depth[i] = 0;
	}
}
//木の根を求める
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}
//xとyの属する集合を併合
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) { return; }
	if (depth[x] < depth[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (depth[x] == depth[y])depth[x]++;
	}
}
//xとyが同じ集合に属するか否か
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int n, m, a, b, c, ans = 0; cin >> n >> m;
	init(n + 1);
	for (int h = 0; h < n; h++) {
		cin >> a; test[a] = h + 1;
	}
	for (int h = 0; h < m; h++) {
		cin >> b >> c; unite(b, c);
	}
	for (int h = 1; h <= n; h++) {
		if (same(h, test[h])) { ans++; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
def linear_search(target_array, value)
  target_array.each do |arr_value|
    return 1 if arr_value == value
  end
  0
end

n = gets.to_i
s = gets.chomp.split ' '
q = gets.to_i
t = gets.chomp.split ' '
count = 0
t.each do |value|
  count += linear_search s, value
end

puts count


Measured memory_bytes: 7080
#include <stdio.h>
void solve(void)
{
	unsigned long long a, b, x, p, q;
	scanf("%llu %llu %llu", &a, &b, &x);
	printf("%llu\n", (b+x)/x - (a+x-1)/x);
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
char a[101][11];
int b[101];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
	cin >> a[i];
for (int i = 0; i < n - 1; i++)
	for (int j = i + 1; j < n; j++)
	{
		if (strcmp(a[i], a[j]) == 0)
		{
			cout << "No";
			goto here;
		}
	}
for (int i = 0; i < n; i++)
{
	b[i] = strlen(a[i]) - 1;
}
for (int i = 0; i < n - 1; i++)
{
	if (a[i][b[i]] != a[i + 1][0])
	{
		cout << "No";
		goto here;
	}
}
cout << "Yes";
here:
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int temp = 0;
  int ans = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'T' || s.at(i) == 'G') {
      temp += 1;
      if(temp > ans) {
        ans = temp;
      }
    } else {
      temp = 0;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m;cin >> n >> m;
  vector<string> a(n); cin >> a;
  vector<string> b(m); cin >> b;
  bool f = false;
  for(int i = 0; i < n-m+1 && !f; ++i){
    for(int j = 0; j < n-m+1 && !f; ++j){
      f = true;
      for(int k = 0; k < m && f; ++k){
	for(int l = 0; l < m && f; ++l){
	  f &= a[i+k][j+l] == b[k][l];
	}
      }
      if(f)break;
    }
  }
  cout << (f?"Yes":"No") << endl;
}



Measured memory_bytes: 3580
h, w = map(int, input().split())
ls_s = [[_ for _ in input()] for _ in range(h)]

ls_ans = [[0 for _ in range(w+2)] for _ in range(h+2)]


for i in range(h):
    for j in range(w):
        if ls_s[i][j] == "#":
            ls_ans[i][j] += 1
            ls_ans[i][j+1] += 1
            ls_ans[i][j+2] += 1
            ls_ans[i+1][j] += 1
            ls_ans[i+1][j+2] += 1
            ls_ans[i+2][j] += 1
            ls_ans[i+2][j+1] += 1
            ls_ans[i+2][j+2] += 1

for i in range(h):
    for j in range(w):
        if ls_s[i][j] == "#":
            ls_ans[i+1][j+1] = "#"
            
del(ls_ans[0])
del(ls_ans[h])

for k in range(h):
    ls_ans[k] = ls_ans[k][1:w+1]
    
for a in ls_ans:
    print(*a, sep="")

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	ll a,b,c,d,t;
	cin>>a>>b>>c>>d>>t;
	if(b > d && (ll)ceill(llabs(c-a) / ld(b-d)) <= t) cout<<"YES\n";
	else cout<<"NO\n";
	
}


Measured memory_bytes: 3680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int{
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil{
		panic(e)
	}
	return i
}

func main(){
	sc.Split(bufio.ScanWords)
	a, b := nextInt(), nextInt()

	count, min:=1, 0
	for count<b{
		count--
		count += a
		min++
	} 
	fmt.Println(min)

	return
}

Measured memory_bytes: 1772
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vint A;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		A.pb(a);
	}
	int ans=0;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(i!=j)
				ans=max(ans,abs(A[i]-A[j]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
  int bingo[3][3] = {{0,0,0},{0,0,0},{0,0,0}};
  int i,j = 0;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
    	scanf("%d", &a[i][j]);
    }
  }
  int n = 0;
  scanf("%d", &n);
  int k;
  int count = 0;
  int g = 0;
  for(g=0;g<n;g++){
    scanf("%d", &k);
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(k == a[i][j]){
          bingo[i][j] = 1;
        }
      }
    }
  }
  if ((bingo[0][0] + bingo[0][1] + bingo[0][2] == 3) ||
(bingo[1][0] + bingo[1][1] + bingo[1][2] == 3) ||
(bingo[2][0] + bingo[2][1] + bingo[2][2] == 3) ||
(bingo[0][0] + bingo[1][0] + bingo[2][0] == 3) ||
(bingo[0][1] + bingo[1][1] + bingo[2][1] == 3) ||
(bingo[0][2] + bingo[1][2] + bingo[2][2] == 3) ||
(bingo[0][0] + bingo[1][1] + bingo[2][2] == 3) ||
(bingo[0][2] + bingo[1][1] + bingo[2][0] == 3)){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 128
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


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


if __name__ == '__main__':
    b, c = map(int, input().split())
    a =abs(b% c)
    
    if abs(a-c) < a:
        print(abs(a-c))
    else:
        print(a)


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

int main() {

  int n, x;

    cin >> n >> x;
  while (0 != n || 0 != x) {
        int cnt = 0;
  for (int i = 1; n >= i; i++) {
    for (int j = i + 1; n >= j; j++) {
      for (int k = j + 1; n >= k; k++) {
          if (x == i + j + k) {
            cnt++;
          }
      }
    }
  }
    cout << cnt << endl;
    cin >> n >> x;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int i,n=0;
  string s;
  cin >> s;
  for (i=0;i<4;i++){
    if (s.at(i)=='+') n++;
    else n--;
  }
  cout << n << endl;
  return 0;
}

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

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

using ll = long long;

using namespace std;

int main(){

  int x,a,b;
  cin >> x >> a >> b;
  if( (a-x)*(a-x) < (b-x)*(b-x)){
    cout << "A" << endl;
  }else{
    cout << "B" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x,l,r;
    string s;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> re;
    vector<ll> de;

    cin >> a >> b >> k;

    ll co = 0;

    per1(i, min(a,b)){
        if(a%i==0 && b%i==0){
            co++;
            if(co == k){
                ans = i;
                break;
            }
        }

    }

    
    std::cout << ans << endl; 

    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append((b-1,c))
    G[b-1].append((a-1,c))
q,k=map(int,input().split())
k=k-1
stack=[k]
dis=[-1]*n
dis[k]=0
ls=1
while ls>0:
    now=stack.pop()
    ls-=1
    d=dis[now]
    for i in G[now]:
        if dis[i[0]]==-1:
            dis[i[0]]=d+i[1]
            stack.append(i[0])
            ls+=1
for i in range(q):
    x,y=map(int,input().split())
    x=x-1
    y=y-1
    print(dis[x]+dis[y])




Measured memory_bytes: 79776
spot=int(input())
avg_pre,object_pre =  (int(x) for x in input().split())   
temp_list = list(input().split())

ans_list=[]
for i in temp_list:
	ans_list.append(abs(avg_pre-0.006*int(i)-object_pre))

print(ans_list.index(min(ans_list))+1)

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

int main(){
   int n;
   cin >>n;
   auto a = priority_queue<int>();
   for (int i = 0; i < n; i++)
   {
       /* code */
       int temp;
       cin >> temp;
       a.push(-temp);
   }

   while (a.size()>1)
   {
       auto i = a.top();
       if(i==1)break;
       a.pop();
       int num = a.top() % i;
       a.pop();
       if(num==0){
       		a.push(i);
       }else{
       		if(num==i)
              a.push(i);
         	else{
            	a.push(i);
              	a.push(num);
            }
       }
   }

   cout << -a.top();
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    cin.tie(0);
    int n;
    cin >> n;

    int64_t t = 0, a = 0;

    for (int i = 0; i < n; i++) {
        int tt, aa;
        cin >> tt >> aa;

        if (t == 0) {
            t = tt;
            a = aa;
            continue;
        }

        // (t + x) * aa = (a + y) * tt;

        // t * aa + x *aa = a * tt + y * tt;

        // x*aa = a*tt + y*tt - t*aa

        // x = (a*tt - t*aa + y*tt)/aa

        for (int64_t y = 0;; y++) {
            // int64_t ddd = (a * tt - t * aa + y * tt);
            if ((a + y) % aa == 0) {
                // (a * tt - t * aa + y * tt) / aa
                // (a * tt + y * tt) / aa

                int64_t x = (a + y) / aa * tt - t;

                if (x < 0) {
                    int64_t inc = (-x + tt - 1) / tt;
                    x += inc * tt;
                    y += inc * aa;
                }

                t += x;
                a += y;

                break;
            }
        }

        // cerr << t << ", " << a << endl;
    }

    cout << t + a << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int,int> m;
    int sum=0;
    rep(i,1,n+1){
        int x;
        cin >> x;
        sum+=x;
        m[x]++;
        //cout << x << " " << m[x] << "\n";
    }
    int q;
    cin >> q;
    while(q--){
        int b,c;
        cin >> b >> c;
        int x=m[b];
        m[b]=0;
        m[c]+=x;
        //cout << x << "\n";
        sum=sum+(c-b)*x;
        cout << sum << "\n";
    }
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int k;
    cin >> k;
    ll sum = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int t = 1; t <= k; ++t) {
                sum += __gcd(__gcd(i, j), t);
            }
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long blue = sc.nextLong();
		long red = sc.nextLong();
		
		long s = n / (blue + red);
		long k = n - s * (blue + red);
		
		if(k >= blue) {
			System.out.println(blue * (s + 1));
		}else {
			System.out.println(blue * s + k);
		}
	}
	
}


Measured memory_bytes: 22100
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(m) inp(n)
	fo(i,n)
	{
		inp(a)
		m-=a;
	}
	if(m<0)
		m=-1;
	cout<<m<<'\n';
	printclock;
}

Measured memory_bytes: 3792
#include <stdio.h>
#include<limits.h>

int main(void) {

        int N;
      scanf("%d",&N);
    
  
      long long int G = 1;
      
        for(int i=1;i<=N;i++){
        G *=10;
          if(G>1000000007){
            G %=1000000007;
          }
      }
        
     long  long int P = 1;
      for (int j=1;j<=N;j++){
        P *=8;
          if(P>1000000007){
            P %=1000000007;
              
        }
          
      }
      
     
    
    long long int D =1;
    for (int l=1;l<=N;l++){
        D *=9;
         if (D>1000000007){
            D %=1000000007;
        }
    
    }
    
    
    
    
      
    long long int answer;
    answer = G-2*D+P;
    if(answer<0){
        answer +=1000000007;
    }
    if(answer<0){
        answer +=1000000007;
    }
      printf("%lld",answer);
    
  

    

    return 0;
}

Measured memory_bytes: 2112
#include<iostream>
#include<cstdio> 
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
typedef long long ll;
const ll mod=1e9+7;
const ll INF=0x3f3f3f3f;
const ll maxn=1e6+5;
const double pi = acos(-1.0);
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	cout<<6-n-m<<endl;
}

Measured memory_bytes: 256
N, M = (int(d) for d in input().split())

C = [set() for i in range(N+1)]
for i in range(M):
    A, B = (int(d) for d in input().split())
    C[A].update([B])
    C[B].update([A])

# BFS
seen = set()
G = []

for i in range(1, N+1):
    if i in seen:
        continue

    # create new group
    G.append(set())

    # create queue
    Q = [i]
    G[-1].update(Q)
    seen.update(Q)

    while len(Q) > 0:
        # queue is not empty

        I = Q.pop(0)
        J = C[I].difference(seen)
        Q += list(J)
        G[-1].update(J)

        seen.update(J)

print(max([len(g) for g in G]))



Measured memory_bytes: 116772
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(void)
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1, 0);
    vector<ll> a_sum(n+1, 0);
    vector<ll> b(m+1, 0);
    vector<ll> b_sum(m+1, 0);
    
    for (int i=1;i<=n;i++){
    	cin >> a[i];
	a_sum[i] = a_sum[i-1] + a[i];
    }
    for (int i=1;i<=m;i++){
    	cin >> b[i];
	b_sum[i] = b_sum[i-1] + b[i];
    }

    ll max_c = 0;
    ll i, j;
    j = m;
    for (i=0;i<=n && a_sum[i]<=k;i++){
	while(a_sum[i]+b_sum[j]>k){
	    j--;
	}
	if(i+j > max_c)
	    max_c = i+j;
    }

    cout << max_c << endl;
    return 0;
}


Measured memory_bytes: 9568
import java.util.Arrays;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//Network Mess
public class Main{

	class R{
		int id, con;
		int[] dist;
		Set<Integer> adj;
		public R(int id) {
			con = 0;
			this.id = id;
			dist = new int[n];
			Arrays.fill(dist, -1);
			adj = new HashSet<Integer>();
		}
		void add(int k){
//			System.out.println("Tar:"+k+" Here:"+id);
			R v = new R(ID);
			sw[ID] = v;
			adj.add(ID);
			v.adj.add(id);
			for(int i=0;i<n;i++){
				if(dist[i]==-1)continue;
				v.dist[i] = dist[i]+1;
			}
			ID++;
			if(a[0][k]-1==v.dist[0]){
//				System.out.println("Assign Start : "+id);
				v.con++;
				v.assign(k, 1);
			}
			else v.add(k);
		}
		void assign(int k, int d){
			if(dist[k]!=-1)return;
//			System.out.println("Let assign: "+id);
			dist[k] = d;
			for(int i:adj)sw[i].assign(k, d+1);
		}
		public String toString() {
			String res = "ID: " + id;
			for(int i=0;i<n;i++)res+=" "+dist[i];
			res += " ADJ:";
			for(int i:adj)res+=" "+i;
			return res;
		}
	}
	
	int n, ID;
	R[] sw;
	int[][] a;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			a = new int[n][n];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j]=sc.nextInt();
			sw = new R[1500];
			ID = 0;
			sw[0] = new R(ID++);
			sw[0].con++;
			sw[0].assign(0, 1);
			for(int k=1;k<n;k++){
//				System.out.println("SIZE:"+ID);
//				for(int i=0;i<ID;i++)System.out.println(sw[i]);
				boolean s = true;
				for(int i=0;i<ID;i++){
					boolean f = true;
					for(int j=0;j<k;j++){
						if(sw[i].dist[j]!=a[j][k]-1){
							f = false; break;
						}
					}
					if(f){
//						System.out.println("AAA:"+i+" Decide:"+k);
						s = false; sw[i].con++; sw[i].assign(k, 1); break;
					}
				}
				if(!s)continue;
//				System.out.println("K:"+k);
				for(int i=0;i<ID;i++){
					boolean f = true;
					int dif = a[0][k]-sw[i].dist[0];
					for(int j=1;j<k;j++){
						if(dif!=a[j][k]-sw[i].dist[j])f = false;
					}
					if(f){
//						System.out.println("Attach:"+i+" Dif:"+dif + " Decide:"+k);
						sw[i].add(k);
						break;
					}
				}
				
			}
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			for(int i=0;i<ID;i++)q.add(sw[i].adj.size()+sw[i].con);
			System.out.print(q.poll());
			while(!q.isEmpty())System.out.print(" "+q.poll());
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
    string S; cin >> S;
    int s = S.size();
    int s1 = 0;
    int s0 = 0;
    rep(i, s){
        if(i % 2 == 0){
            if(S[i] == '0'){
                s1++;
            } else {
                s0++;
            }
        } else {
            if(S[i] == '0'){
                s0++;
            } else {
                s1++;
            }
        }
    }

    int ans = min(s0, s1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#include<math.h>
typedef struct{
    double x;
    double y;
}point;


void koh(int d,point p1,point p2){
    if(d==0) return;
    point s,u,t;
    s.x=(2*p1.x+p2.x)/3;
    s.y=(2*p1.y+p2.y)/3;
    t.x=(p1.x+p2.x*2)/3;
    t.y=(p1.y+p2.y*2)/3;
    u.x=(t.x-s.x)/2-(t.y-s.y)*sqrt(3)/2+s.x;
    u.y=(t.x-s.x)*sqrt(3)/2+(t.y-s.y)/2+s.y;
    
    koh(d-1,p1,s);
    printf("%f %f\n",s.x,s.y);
    koh(d-1,s,u);
    printf("%f %f\n",u.x,u.y);
    koh(d-1,u,t);
    printf("%f %f\n",t.x,t.y);
    koh(d-1,t,p2);
}

int main(){
    int n;
    scanf("%d",&n);
    point p1={0,0};
    point p2={100,0};
    
    printf("%f %f\n",p1.x,p1.y);
    koh(n,p1,p2);
    printf("%f %f\n",p2.x,p2.y);
    
    
    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  long double tot = 0;
  do {
    for (int i = 0; i + 1 < n; i++) {
      long long dx = x[p[i]] - x[p[i + 1]];
      long long dy = y[p[i]] - y[p[i + 1]];
      tot += sqrt(dx * dx + dy * dy);
    }
  } while (next_permutation(p.begin(), p.end()));
  cerr << tot << endl;
  long long k = 1;
  for (int i = 1; i <= n; i++) k *= i;
  cout << setprecision(20) << fixed << tot / k << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);

    int answer = 0;
    int position = 1;
    for (int i = 0; i < n; i++)
    {
        if (position == 2)
        {
            break;
        }
        else
        {
            answer++;
            position = a.at(position - 1);
        }
    }
    if (position == 2)
    {
        cout << answer << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a[5][5]={},n,b,f=0,x[5][5]={},cnt=0;
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      cin >> a[i][j];
    }
  }
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> b;
    for(int j=0; j<3; j++) {
      for(int k=0; k<3; k++) {
        if(a[j][k]==b) {
          x[j][k]=1;
        }
      }
    }
  }
  for(int i=0; i<3; i++) {
    cnt=0;
    for(int j=0; j<3; j++) {
      if(x[i][j]==1) {
        cnt++;
      }
    }
    if(cnt==3) {
      f=1;
    }
  }
  for(int i=0; i<3; i++) {
    cnt=0;
    for(int j=0; j<3; j++) {
      if(x[j][i]==1) {
        cnt++;
      }
    }
    if(cnt==3) {
      f=1;
    }
  }
  if((x[0][0]&&x[1][1]&&x[2][2])||(x[0][2]&&x[1][1]&&x[2][0])) {
    f=1;
  }
  if(f) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256