akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];

int cnt = 0;
    for(int i=0;i<n;i++)
    {cin>>arr[i];
    if(arr[i]%2!=i%2 && arr[i]%2==1)
    cnt++;}

    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);


//入力変数
String[] S=new String[9];
String A=sc.next();
String B=sc.next();
String C=sc.next();


//入力値変換


//出力変数
String ans=A.substring(0,1)+B.substring(1,2)+C.substring(2,3);

//計算


//出力
System.out.println(ans);

}}

Measured memory_bytes: 21332
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s;cin>>s;
    bool ans = true;
    if(s[0] != 'A')ans = false;
    int e = 0;
    for(int i = 1; i<s.size(); ++i){
        if(2<=i && i<=s.size()-2 && s[i] == 'C')e++;
        else if(isupper(s[i]))ans = false;
    }
    if(e != 1)ans = false;
    cout<<((ans)?"AC":"WA")<<endl; return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n = 0, r = 0;
    std::cin >> n >> r;
    int nr = 0;
    if (n >= 10) 
    {
        nr = r;
    }
   else 
    {
        nr = r + 100 * (10 - n);
    }
    std::cout << nr;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define mkp make_pair
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n; n++;
	string s; cin>>s;
	s='.'+s+'#';
	int a=0,b=0;
	if(s[0]=='#') a++;
	for(int i=n-1;i>=1;i--) if(s[i]=='.') b++;
	int mn=200010;
	For(i,1,n)
	{
		mn=min(mn,a+b);
		if(s[i]=='#') a++;
		else b--;
	}
	cout<<mn<<"\n";
	return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 788
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args){
        final Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] p=new int[n+1];
        int[][] m=new int[n+1][n+1];

for(int i = 1; i <= n; i++)
    {
        p[i - 1] = sc.nextInt();
        p[i] = sc.nextInt();
    }

for(int i = 1; i <= n; i++) m[i][i] = 0;

for(int j = 2; j <= n; j++)
    {
        for(int i = 1; i <= n - j + 1; i++)
            {
                int k = i + j - 1;
                m[i][k] = 200000;
                for(int l = i; l <= k - 1; l++)
                    {
                        m[i][k] = ((m[i][k] < m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k]) ? m[i][k] : (m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k]));
                    }
            }
    }
System.out.println(m[1][n]);
}
}

Measured memory_bytes: 26312
#include <stdio.h>
#include <stdbool.h>

int main(int argc, char const *argv[])
{
	int i, j, n;
	char mark;
	char marks[4] = {'S', 'H', 'C', 'D'};
	int num;
	bool cards[4][13]={false};	//最初はすべてのカードがfalse

	scanf("%d ", &n);	//入力数を読み取る
	for (i=0;i<n;i++){	//入力数の分だけ
		scanf("%c %d ", &mark, &num); //柄　数字　を読み取る
		for (j=0;j<4;j++) {		//柄の判定
			if(mark==marks[j]) {	//柄がある
				cards[j][num-1]=true;	//そのときの柄と数字を持つカードはtrueとなる
				break;
			}
		}

	}
	for(i=0;i<4;i++) {			//出力は柄の降べき
		for(j=0;j<13;j++) {		
			if(!cards[i][j]) {	//cards[][]がfalse
				printf("%c %d\n", marks[i], j+1);	//cards[][]の内容を表示
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[100001];
int main(){
    ll n,x;
    cin>>n>>x;
    ll ans=0;
    rep(i,n) cin>>a[i];
    rep(i,n-1){
        ans+=max(a[i]+a[i+1]-x,0ll);
        if(a[i]+a[i+1]>x)a[i+1]=max(x-a[i],0ll);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int t;
	cin >> t;
	string s1;
	cin >> s1;
	char ch = s1[0];
	int js = 1;
	for(int i=1;i<s1.size();i++){
		if(ch != s1[i]){
			js++;
			ch = s1[i];
		}
	}
	cout << js << endl;
	return 0;
}

Measured memory_bytes: 512
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

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

	vector<double> v(n);

	for(int i=0; i<n; i++){
		cin>>v[i];
	}

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

	double ans = v[0];
	for(int i=1; i<n; i++){
		double vi = v[i];
		ans = (ans + vi)/2.;
	}

	cout<< ans <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 200000;
bool flag = false;
int n,m; 
bool vis[maxn];
int main()
{
	cin >> n >> m;
	vector<int> E[maxn+5];
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin >> u >> v;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for(int i=0;i<E[1].size();i++)
		vis[E[1][i]] = true;
	for(int i=0;i<E[n].size();i++)
		if(vis[E[n][i]]) flag = true;
	if(flag) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
}

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

int main() {
    string str;
    char op[3];
    cin >> str;
    int ans;
    for (int i = 0; i < (1 << 3); ++i) {
        ans = str[0] - '0';
        for (int j = 0; j < 3; ++j) {
            if (i & (1 << j)) {
                op[j] = '+';
                ans += str[j + 1] - '0';
            }
            else {
                op[j] = '-';
                ans -= str[j + 1] - '0';
            }
        }
        if (ans == 7) {
            cout << str[0] << op[0] << str[1] << op[1] << str[2] << op[2] << str[3] << "=7" << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

m = 0
for i in range(n):
    a_i = a[i] - 1
    m += b[a_i]
    if i > 0:
        if a[i] == a[i-1]+1:
            m += c[a[i-1] - 1]

print(m)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[100005]={1,2,3,4,5,6,7,8,9};
ll p[100005];
int main()
{
    int n;
    cin>>n;
    if(n<=9)printf("%lld\n",s[n-1]);
    else
    {
        n-=9;
        int cnt=9;
        int tot=0;
        while(1)
        {
            for(int i=0;i<cnt;i++)
            {
                ll l=s[i]%10;
                if(l-1>=0)
                {
                    n--;
                    if(n==0){printf("%lld\n",s[i]*10+l-1);return 0;}
                    p[tot++]=s[i]*10+l-1;
                }
                if(l>=0)
                {
                    n--;
                    p[tot++]=s[i]*10+l;
                    if(n==0){printf("%lld\n",s[i]*10+l);return 0;}
                }
                if(l+1<=9)
                {
                    n--;
                    p[tot++]=s[i]*10+l+1;
                    if(n==0){printf("%lld\n",s[i]*10+l+1);return 0; }
                }
            }
            cnt=0;
            for(int j=0;j<tot;j++)
                s[cnt++]=p[j];
            tot=0;
        }
    }
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 2e5 + 7;

vector<int> G[N];

int main() {
  _upgrade;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  queue<int> Q({1});
  vector<bool> vis(n + 1, false);
  vis[1] = true;
  vector<int> sign(n + 1);
  int nb_vis = 0;
  while (!Q.empty()) {
    int v = Q.front();
    nb_vis++;
    Q.pop();
    for (auto &u : G[v]) {
      if (!vis[u]) {
        sign[u] = v;
        Q.push(u);
        vis[u] = true;
      }
    }
  }

  if (nb_vis != n) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
    for (int i = 2; i <= n; i++) {
      cout << sign[i] << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 12540
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=4e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
char s[N];
int main()
{
    int n;read(n);
    scanf("%s",s+1);
    if(n&1) return puts("No"),0;
    bool flag=1;
    int l=1,r=n/2+1;
    while(r<=n)
    {
        if(s[l]==s[r]) l++,r++;
        else 
        {
            flag=0;
            break;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){ 
	string S; 
	cin >> S; 
	int count = 0; 
	for(int i = 0; i < S.size(); i++){
		if(S.at(i) == 'g'){count ++;}
	}
    int saishou = (S.size() + 1)/2 ; 
	cout << count - saishou << endl; 
}

Measured memory_bytes: 512
#include<stdio.h>
#include <stdlib.h>
int main()
{
	int i, x = 7, K;
	scanf("%d", &K);
	if (K % 2 == 0 || K % 5 == 0) {
		printf("-1");
		exit(0);
	}
	for (i = 0; i <= K - 1; i++) {
		if (x % K == 0) {
			printf("%d", i+1);
			exit(0);
		}
		x = (x * 10 + 7) % K;
	}
	printf("-1");
}

Measured memory_bytes: 1696
import sys
N = int(input())
HN = list(map(int,input().split()))
HN.reverse()
if N == 1:
  print("Yes")
  sys.exit()
  
for n in range(N-1):
  left = HN[n]
  right = HN[n+1]
  if left-right >= 0:
    continue
  elif left-right == -1:
    HN[n+1] -= 1
  else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 15020
m,d=map(int,input().split())
ans=0
for month in range(1,m+1):
    for day in range(1,d+1):
        day=str(day)
        if len(day)!=2:
            continue
        if int(day[0])*int(day[1])!=month:
            continue
        if int(day[0])<2 or int(day[1])<2:
            continue
        #print(month,day)
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
#define sq(x) x*x
#define fr(i,m,n) for(i=m;i<n;i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int,int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(),v.end()
int ara[102];
int main()
{
    int i,j,k,a,b,c,x,y,z,n,m,t;
    string s,u,v;
    cin>>x>>n;

    fr(i,0,n){
        cin>>z;
        ara[z]=1;
    }y=0;int mn=10000009;
    fr(i,0,105){
        if(ara[i]==0 && abs(x-i)<mn){ mn=abs(x-i); y=i;}
    }
        cout<<y<<endl;
}



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

using ll = long long;
#define rep(n, i) for(int i = 0; i < n; ++i)

void solve(void) {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(n, i) {
    cin >> a[i];
    a[i]--;
  }

  set<ll> reached;
  vector<ll> path;
  ll pos = 0;

  while(reached.count(pos) == 0) {
    path.emplace_back(pos);
    reached.insert(pos);
    pos = a[pos];
  }

  ll s = find(path.begin(), path.end(), pos) - path.begin();
  ll r = (int)path.size() - s;

  if (k < s) {
    cout << path[k] + 1 << endl;
    return;
  } else {
    cout << path[((k-s) % r + s)] + 1 << endl;
    return;
  }
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 15492
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

int main(){
	fastio;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust\n";
	else cout<<"win\n";
	
}

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

using namespace std;

#define fr(i,s,e) for(i=s;i<e;i++)

int main() {
   int a,b,x;
   cin>>a>>b>>x;
   if(x<a||x>(a+b))
    cout<<"NO";
   else
    cout<<"YES";

return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		CountingRoads solver = new CountingRoads();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class CountingRoads {
		private int n;
		private int m;

		private int a[];
		private int b[];

		Map<Integer,Integer> map = new HashMap<Integer,Integer>();

		private Scanner scanner;
		private int output[];

		public CountingRoads() {
			scanner = new Scanner(System.in);

		}
		public void readInput() {
			n = scanner.nextInt();
			m = scanner.nextInt();

			for(int i=0; i<n; i++) {
				map.put(i, 0);
			}
		}

		public void solve() {
			int buf;
			for(int i=0; i<m; i++) {
				for(int j=0; j<2; j++) {
					buf = scanner.nextInt();
					map.compute(buf-1, (key,value) -> value+1);
				}
			}
		}
		public void writeOutput() {
			for(Integer key : map.keySet()) {
				System.out.println(map.get(key));
			}
		}
	}
}


Measured memory_bytes: 26580
from itertools import product


def f(comb, ans, scores):
    score = 0
    problems = 0
    for i, bi in enumerate(comb):
        if bi == 1:
            score += scores[i][1] + scores[i][0] * 100 * (i + 1)
            problems += scores[i][0]

    if score >= g:
        return min(ans, problems)

    else:
        for j in reversed(range(d)):
            if comb[j] == 0:
                for _ in range(1, scores[j][0]):
                    problems += 1
                    score += (j + 1) * 100
                    if score >= g:
                        ans = min(ans, problems)
                        return ans

        return ans


d, g = map(int, input().split())

scores = []
for _ in range(d):
    pc = list(map(int, input().split()))
    scores.append(pc)

ans = float("inf")
for comb in product((0, 1), repeat=d):
    ans = f(comb, ans, scores)

print(ans)


Measured memory_bytes: 3188
#include<iostream>
 
int get_x(int A, int B, int T){
  
  int i = 0;
  while(1){
    if(i*A<=T+0.5 && T+0.5<(i+1)*A) return i;
  	i++;
  }
}
 
int main(){
  
  int A,B,T;
  
  std::cin >> A;
  std::cin >> B;
  std::cin >> T;
  
  int x = get_x(A,B,T);
  
  std::cout << x*B << std::endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

void add(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

const int MX = 1007;

string s[MX];
int f[MX][MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (s[i][j] == '#') {
                continue;
            }
            if (i == n - 1 && j == m - 1) {
                f[i][j] = 1;
            } else {
                f[i][j] = f[i + 1][j];
                add(f[i][j], f[i][j + 1]);
            }
        }
    }

    cout << f[0][0] << "\n";
    return 0;
}



Measured memory_bytes: 5248
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long long t;
  cin >> t;
  if (t < 4) {
    cout << t << endl;
    return 0;
  }
  vector<long long> steps;
  vector<long long> stops;
  long long j = 1;
  long long now = 0;
  long long time = 1;
  while (true) {
    now += j;
    steps.push_back(j);
    stops.push_back(now);
    if (now * 2 + j * 3 - 1 > t) break;
    j *= 3;
    ++time;
  }
  long long rest = t - now;
  for (long long i = steps.size() - 1; i >= 0;) {
    if (rest == 0) break;
    if (rest - (stops[i] - 1) < 0) {
      --i;
    }
    rest -= steps[i];
    ++time;
  }
  cout << time << endl;

  return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=100005,M=N<<1;

int v[M],nxt[M];
int head[N],sg[N],n;

il void addedge(int p,int x,int y){
	v[p]=y,nxt[p]=head[x],head[x]=p;
}

il void dfs(int u,int p){
	sg[u]=0;
	for(int e=head[u];e;e=nxt[e]){
		if(v[e]==p) continue;
		dfs(v[e],u);
		sg[u]^=(sg[v[e]]+1);
	}
}

int main(){
	scanf("%d",&n);
	rep(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(lch(i),x,y);
		addedge(rch(i),y,x);
	}
	dfs(1,0);
	puts(sg[1]?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 4864
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m;
int p[1001];
int pp[1500000];
int main() {
    while (scanf("%d%d",&n,&m)) {
        if (!n&&!m) break;
        memset(p, 0, sizeof(p));
        for (int i=0; i<n; i++) scanf("%d",&p[i]);
        sort(p, p+(++n));
        for (int c=0; c<=n; c++) {
            for (int d=0; d<=n; d++) {
                pp[c*n+d]=p[c]+p[d];
            }
        }
        sort(pp, pp+n*n);
        int res=0;
        for (int i=0; i<n*n; i++) {
            int temp = upper_bound(pp,pp+n*n,m-pp[i])-pp-1;
            if (pp[temp]+pp[i]<=m) res = max(res, pp[temp]+pp[i]);
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 4676
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
int main () { 
	long long x,y;
	cin >> x;
	y= 0;
	for(int i = 1;i <= x; ++i){
		y = y+i;
		if(y >= x){
			cout << i << endl;
				break;
		}
	}	
} 			



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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    rep(i, 5) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int iinf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, c;
int b[300000];
struct A {
	int s, t, c;
};
bool operator<(A a, A b) { 
	if (a.c != b.c) return a.c < b.c;
	return a.s < b.s;
}
A a[100000];
signed main() {
	cin >> n >> c;
	int ma = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i].s >> a[i].t >> a[i].c;
		a[i].s *= 2; a[i].t *= 2;
		ma = max(ma, a[i].t);
	}
	sort(a, a + n);
	for (int i = 0; i < n; ) {
		int j = i;
		while (j < n - 1 && a[j].t == a[j + 1].s&&a[j].c == a[j + 1].c) {
			j++;
		}
		b[a[i].s - 1]++;
		b[a[j].t]--;
		i = j + 1;
	}
	int sum = 0;
	for (int i = 1; i <= ma + 100; i++) {
		b[i] += b[i - 1];
		sum = max(sum, b[i]);
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 2176
#include <iostream>
#include <cassert>
#include <vector>

using llong = long long;
static const long long INF = 1LL << 60;

template <class T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}

int main()
{
  // Input
  int numItem;
  int weightCapacity;
  std::cin >> numItem >> weightCapacity;
  assert(1 <= numItem and numItem <= 100);
  assert(1 <= weightCapacity and weightCapacity <= 1.0e+5);
  std::vector<int> weight(1 + numItem);
  std::vector<llong> value(1 + numItem);
  for (int i = 1; i <= numItem; ++i) {
    std::cin >> weight[i] >> value[i];
    assert(1 <= weight[i] and weight[i] <= weightCapacity);
    assert(1 <= value[i] and value[i] <= 1.0e+9);
  }

  // Init
  std::vector<std::vector<llong>> dp(1 + numItem);
  for (int i = 0; i <= numItem; ++i) {
    dp[i].assign(1 + weightCapacity, -INF);
  }
  dp[0][0] = 0;

  // DP main
  for (int i = 0; i < numItem; ++i) {
    for (int w = 0; w <= weightCapacity; ++w) {
      if (dp[i][w] == -INF)
        continue;
      chmax(dp[i + 1][w], dp[i][w]);
      if (w + weight[i + 1] > weightCapacity)
        continue;
      chmax(dp[i + 1][w + weight[i + 1]], dp[i][w] + value[i + 1]);
    }
  }

  // Output
  llong result = -INF;
  for (int w = 0; w <= weightCapacity; ++w)
    chmax(result, dp[numItem][w]);
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 5;
int n, k;
ll h[maxn];
int main() {
	scanf("%d%d", &n, &k);
	ll ans = 0;
	for(int i = 1; i <= n; ++i) {
		scanf("%lld", &h[i]);
	}
	sort(h + 1, h + n + 1);
	for(int i = 1; i <= n - k; ++i) {
		ans += h[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	string s;
	cin >> s;

	if (s=="Sunny") {
		cout << "Cloudy";
	} else if (s=="Cloudy") {
		cout << "Rainy";
	} else {
		cout << "Sunny";
	}

	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#define REP(i, m, n) for(long long i = m; i < n; ++i)
#define CO(n) cout << n << endl
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >>  N;
    int a[100010];
    REP(i, 0, N) cin >> a[i+1];
    set<int> s;
    int i=1;
    int cnt = 0;
    while (1){
        if (s.end() != s.find(i)){
            CO(-1);
            return 0;
        }
        s.insert(i);
        i = a[i];
        cnt += 1;
        if (i==2){
            CO(cnt);
            return 0;
        }
    }
}

Measured memory_bytes: 5376
import math

a,b,c = map(int,input().split())

c = math.radians(c)

sinc = math.sin(c)
cosc = math.cos(c)

S = (a*b*sinc)/2
L = a + b + math.sqrt(a**2+b**2 -2*a*b*cosc)
h = b*sinc

print(S,L,h,sep="\n")


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

int main(){
  int N;
  cin >> N;
  
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }
  std::sort(v.begin(), v.end(), std::greater<int>());
  double c = v[N-1];
  for(int i = N - 2; i >= 0; i--){
    c = (v[i] + c)/2;
  }
  cout <<std::fixed << c << endl;
}  

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;

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

    bool ok = true;
    rep(i, n){
        if(a[i] != b[i]){
            ok = false;
        }
    }

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

    int ans = 0;
    rep(i, n) ans += a[i];

    int mini = INF;
    rep(i, n){
        if(a[i] > b[i]){
            mini = min(b[i], mini);
        }
    }

    if(mini == INF){
        mini = 0;
    }

    cout << ans - mini << endl;

    return 0;
}


Measured memory_bytes: 760
import math
import sys
sys.setrecursionlimit(10**6)

n = int(input())
mincost = [None]*n

def cost(n,h):
  if (mincost[n-1] is not None):
    return mincost[n-1]
  elif (n == 1):
    mincost[n-1] = 0
  elif (n == 2):
    mincost[n-1] =  abs(h[1] - h[0])
  else:
    mincost[n-1] = min(cost(n-1,h) + abs(h[n-1]-h[n-2]), cost(n-2,h) + abs(h[n-1]-h[n-3]))
  return mincost[n-1]

h = [None]*n

h = list(map(int, input().split()))

print(cost(n,h))


Measured memory_bytes: 101116
my $n=<STDIN>;
my $word = <STDIN>;chomp $word;
my @word = split(//,$word);
my @b =splice(@word,0,int($n/2));
$word = join(',',@word);
my $b=join(',',@b);
if ($b eq $word and int($n/2) ==$n/2){print "Yes\n";}else{print "No\n";}

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

using namespace std;
const int N=1e5+50;
vector<int>vt[N];
priority_queue<int>que;

int main()
{
	int n,m,a,b;cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		vt[a].push_back(b);
	}
	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=0;j<vt[i].size();j++)que.push(vt[i][j]);
		if(!que.empty()){
			ans+=que.top();
			que.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5632
import sys
from collections import defaultdict
range = xrange
input = raw_input

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

n = inp[ii]; ii += 1
m = inp[ii]; ii += 1
k = inp[ii]; ii += 1

R = inp[ii + 0: ii + 3 * k: 3]
C = inp[ii + 1: ii + 3 * k: 3]
V = inp[ii + 2: ii + 3 * k: 3]

items = [defaultdict(list) for _ in range(n)]
for i in range(k):
    r = R[i] - 1
    c = C[i] - 1
    v = V[i]
    items[r][c].append(v)

DP0 = [0] * m
DP1 = [0] * m
DP2 = [0] * m
DP3 = [0] * m

for r in range(n):
    for c in range(m):
        if c:
            DP0[c] = max(DP0[c], DP0[c - 1])
            DP1[c] = max(DP1[c], DP1[c - 1])
            DP2[c] = max(DP2[c], DP2[c - 1])
            DP3[c] = max(DP3[c], DP3[c - 1])
        if c in items[r]:
            for v in items[r][c]:
                DP3[c] = max(DP3[c], DP2[c] + v)
                DP2[c] = max(DP2[c], DP1[c] + v)
                DP1[c] = max(DP1[c], DP0[c] + v)
    for c in range(m):
        DP0[c] = max(DP0[c], DP1[c], DP2[c], DP3[c])
print DP0[-1] 


Measured memory_bytes: 149884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String line = sc.nextLine();
        
        int r = Integer.parseInt(line);

        double result = Math.pow(r, 2) / 1;
        System.out.println(((int)result));

        sc.close();
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    vector<pair<int, long long>> ops;
    ops.emplace_back(2, a);
    ops.emplace_back(3, b);
    ops.emplace_back(5, c);
    const long long inf = (long long) 4e18;
    map<long long, long long> mp;
    mp[0] = 0;
    mp[1] = d;
    function<long long(long long)> Dfs = [&](long long x) {
      if (mp.find(x) != mp.end()) {
        return mp[x];
      }
      long long ret = inf;
      if ((long double) d * (long double) x < ret) {
        ret = d * x;
      }
      for (auto& p : ops) {
        int num = p.first;
        long long cost = p.second;                      
        ret = min(ret, Dfs(x / num) + cost + d * (x % num));
        if (x % num != 0) {
          ret = min(ret, Dfs(x / num + 1) + cost + d * (num - x % num));
        }
      }
      return mp[x] = ret;
    };
    cout << Dfs(n) << '\n';
  }
  return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll N, A;
	cin >> N;
	ll P = 1;
	bool f = false;
	for (ll i = 1; i <= N; i++) {
		cin >> A;
		if (A == 0) {
			cout << 0 << endl;
			return(0);
		}
		if (log10((double)A) + log10((double)P) > 18.0) {
			f = true;
		}
		P *= A;
	}
	if (f == true || P > 1000000000000000000) {
		cout << -1 << endl;
	}
	else {
		cout << P << endl;
	}
	return(0);
}


Measured memory_bytes: 3976
#include <bits/stdc++.h> //g++-9で実行（gcc version 9.3.0），g++だとデフォルトのclang

using namespace std;

//#define int long long                         //intでオーバフローした時の切り替え用
#define OUT(x) std::cout << x << std::endl
#define DEBUG(x) cerr << #x << ": " << x << endl //エラー出力として変数名と変数の中身表示
#define DEBUG_VEC(v)                   \
    cerr << #v << ":";                 \
    for (int i = 0; i < v.size(); i++) \
        cerr << " " << v[i];           \
    cerr << endl;
#define DEBUG_MAT(v)                          \
    cerr << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cerr << v[i][j] << " ";           \
        }                                     \
        cerr << endl;                         \
    }
#define Sp(p) cout << setprecision(25) << fixed << p << endl; //小数点以下を25桁で表示
#define all(obj) (obj).begin(), (obj).end()
#define pb push_back

//usingエイリアス（別名という意味，型定義のこと）
using ll = long long;
//template <class T> using Vec = std::vector<T>;//エイリアステンプレート

const ll MOD = (ll)1e9 + 7;
//const ll MOD = 998244353;あ
const ll INF = (ll)1e18 + 1;
const double EPS = 1e-9;
const long double pi = 3.1415926535897932384626433832795028841971L;

//マクロでintをlong longと定義したときはsinged
int main()
{
    cin.tie(0);                  //cinとcoutの同期を切る（高速化)
    ios::sync_with_stdio(false); //iostreamとstdioの同期を切る（高速化)

    ll n,a;
    cin >> n ;
    a = n+ pow(n,2)+pow(n,3);
    OUT(a);
    return 0;
}


Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;
int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};

signed main(){

    int h, w; cin >> h >> w;    
    vector<vector<int> > g(h + 2, vector<int> (w + 2, false));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char in; cin >> in;
            if(in == '#') g[i][j] = true;
        }
    }

    bool flag = true;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(g[i][j]){
                bool ok = false;
                for(int h = 0; h < 4; h++){
                    int ni = i + di[h];
                    int nj = j + dj[h];
                    if(g[ni][nj]) ok = true;
                }

                if(!ok) flag = false;
            }
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll d;
    cin >> d;
    if(d == 25)cout << "Christmas";
    else if(d == 24)cout << "Christmas Eve";
    else if(d == 23)cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val (T, X) = listOfDouble()
    println(T / X)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    int i, j, k, n, m, t, x1, y1, x2, y2, s=0, c=0, l;
    string a;
    cin >> a;
    l=a.size();
    for(i=0; i<l; i++)
    {
        if(a[i]=='?')
            a[i]='D';
    }
    cout << a << endl;
}


Measured memory_bytes: 3724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String list[] = N.split("");
        for(int i = 0; i < list.length; i++){
            if(list[i].equals("7")){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35568
def ordinary_number(N: int, p: list)->int:
    return sum(
        (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1])
        for i in range(1, N-1))


if __name__ == "__main__":
    N = int(input())
    P = [int(s) for s in input().split()]

    ans = ordinary_number(N, P)
    print(ans)


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

#define N 2*100000+2
#define pb push_back
vector<int> ron[N];
vector<int> rai[N];
map<pair<int,int>,int >mes;
int p1[N],p2[N],t=0;
bool vis[N];


void dfs1(int i){
    p1[i]=t;
    vis[i]=true;
    for(int j=0;j<ron[i].size();j++){
        if(vis[ron[i][j]]==false) {
            dfs1(ron[i][j]);
        }
    }

}


void dfs2(int i){
    p2[i]=t;
    vis[i]=true;
    mes[{p1[i],p2[i]}]++;
    for(int j=0;j<rai[i].size();j++){
        if(vis[rai[i][j]]==false){
            dfs2(rai[i][j]);
        }
    }
}

int main()
{
   // freopen("data","r",stdin);
    int n,k,l;
    cin>>n>>k>>l;
    for(int i=0;i<k;i++){
        int s,e;
        cin>>s>>e;
        ron[s].pb(e);
        ron[e].pb(s);
    }
    for(int i=0;i<l;i++){
        int s,e;
        cin>>s>>e;
        rai[s].pb(e);
        rai[e].pb(s);
    }
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            t++,dfs1(i);
        }
    }
    memset(vis,0,sizeof(vis));
    t=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            t++,dfs2(i);
        }
    }

    for(int i=1;i<=n;i++){
        cout<<mes[{p1[i],p2[i]}]<<" ";
    }
    return 0;
}


Measured memory_bytes: 28160
n=parse(Int,readline())
pn=readline()
pn1=split(pn)
X=Any[]
for i=1:n
    X= push!(X , parse(Int,pn1[i]))
end
Y=Any[]
for i=1:n
    Y= push!(Y , i)
end
for i=1:n
    if X[i]!=i
        a=X[i]
        X[i],X[a]=X[a],X[i]
        break
    end
end
k=0
for i=1:n
    if X[i]!=Y[i]
        k=k+1
    else
    end
end

if k==0
    print("YES")
else
    print("NO")
end

Measured memory_bytes: 110628
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
int main(){
    int n,k;cin>>n>>k;
    int cnt=0;
    for(int i=0;i<n;i++){
       int a;cin>>a;
       if(a>=k)cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//char型のポインタ(=配列と意味は同じ)をString型と定義([0]から数える)
typedef char* String;

//与えられた文字列を比較し、結果によって決められたint型変数を返す関数
//p<qなら-1,p>qなら+1,p==qなら0
int string_compare(const void* a,const void* b){
    String p = *(String*) a;
    String q = *(String*) b;
    int i=0;
    while(i<10){
        if(p[i]<q[i]) return -1;
        else if(p[i]>q[i]) return 1;
        else{i++;}
    }
    return 0;
}

//文字列中の文字を辞書順にソートする
void string_lexical_order(String s){
    //挿入法でのソートを行う
    int i,j;
    for(i=0;i<10;i++){
        char c=s[i]; //これからこの文字(s[i])の挿入場所を探す
        for(j=i-1;j>=0&&s[j]>c;j--){ //探す範囲はs[i-1]~s[0]
            s[j+1]=s[j]; //ここじゃないなと思ったら、後ろにずらしていく
        }
        if(j!=i-1){
            s[j+1]=c; //挿入場所に入れる
        }
    }
    return;
}

int main(void){
    int N;
    scanf("%d",&N);

    //S[0]~S[N-1]に文字列(ソートずみ)を格納する
    String* S;
    NEW(S,N);
    for(int i=0;i<N;i++){
        NEW(S[i],11);
        scanf("%s",S[i]);
        string_lexical_order(S[i]);
    }

    qsort(S,N,sizeof(S[0]),string_compare);

    long ans=0;
    long count=1;
    for(int i=1;i<N;i++){
        //ポインタSに+iする=S[i]
        //ポインタにして渡さなきゃいけないことに注意
        if(string_compare(S+(i-1),S+i)==0){
            count++;
        }
        else{
            ans+=count*(count-1)/2;
            count=1;
        }
    }
    ans+=count*(count-1)/2;

    printf("%ld\n",ans);

    return 0;
}


//b11だけWAになる、他はAC

Measured memory_bytes: 4860
n, m, l = [int(i) for i in input().split()]
 
A = []
B = []
C = []
for ni in range(n):
    A.append([int(i) for i in input().split()])
 
for mi in range(m):
    B.append([int(i) for i in input().split()])
 
for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
 
for ni in range(n):
    print(" ".join([str(s) for s in C[ni]]))

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n;  cin >> n;
  string s;
  cin >> s;
  ll ans = 1;
  vector<int> num(27);
  rep(i,0,n){
    num[s[i]-'a']++;
  }
  rep(i,0,26){
    ans *= num[i] + 1;
    ans %= mod;
  }
  cout << ans-1 << endl;
  return 0;
}


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

std::vector<long long> common_divisors(long long a, long long b) {
	if (a > b) std::swap(a, b);
	std::vector<long long> ret(0), st(0);
	for (int i = 1; i <= a / i; i++) {
		if (a % i == 0) {
			if (b % i == 0) ret.push_back(i);
			if (b % (a / i) == 0 && i < a / i) st.push_back(a / i);
		}
	}
	while (st.size()) {ret.push_back(st.back()); st.pop_back();}
	return ret;
}

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

int main() {
	long long a, b;
	std::cin >> a >> b;
	std::vector<long long> v = common_divisors(a, b);
	long long ans = 1;
	for (auto i : v) {
		if (is_prime(i)) ans++;
	}
	std::cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e18+7;

int main() {
    ios::sync_with_stdio(false);   
    string s;
    cin >> s;
    Int n = (Int)s.size();
    Int cnt1 = 0;
    for (Int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (s[i] == '1') cnt1++;
        }
        else {
            if (s[i] == '0') cnt1++;
        }
    }
    Int cnt2 = 0;
    for (Int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (s[i] == '0') cnt2++;
        }
        else {
            if (s[i] == '1') cnt2++;
        }
    }
    dump(min(cnt1, cnt2));
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
int a[100],b[100],i=0;
do{
scanf("%d %d",&a[i],&b[i]);
i++;
}while(a[i-1]!=0&&b[i-1]!=0);
for(int x=0;x<i-1;x++){
for(int y=0;y<a[x];y++){
if(y%2==0){
for(int z=0;z<b[x];z++){
if(z%2==0)printf("#");
else printf(".");
}
}
if(y%2==1){
for(int z=0;z<b[x];z++){
if(z%2==0)printf(".");
else printf("#");
}
}
printf("\n");
}
printf("\n");
}
}

Measured memory_bytes: 1000