akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    


int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n >> m;
  VI a(m);
  rep(i,m) {cin >> a[i]; sum += a[i]; }
  if(n >= sum)
    cout << n-sum << endl;
  else
    cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin>>n>>k;
    if((n+1)/2 >= k) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a, int b)
{
  if(a<b) swap(a,b);
  while(b>0)
  {
    int temp=b;
    b=a%b;
    a=temp;
  }
  return a;
}
int LCM(int a, int b)
{
  return (a/gcd(a,b))*b;
}
int main()
{
  int n; cin>>n;
  int ans; cin>>ans;
  for(int i=0;i<n-1;i++)
  {
    int in; cin>>in;
    ans=LCM(ans,in);
  }
  cout<<ans<<"\n";
}



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

int main() {
	int a[5][2];
	while(cin >> a[0][0] >> a[0][1], a[0][0] || a[0][1]) {
		for(int i = 1; i < 5; i++) {
			cin >> a[i][0] >> a[i][1];
		}
		int indx, mx = 0;
		for(int i = 0; i < 5; i++) {
			if(mx < a[i][0] + a[i][1]) {
				mx = a[i][0] + a[i][1];
				indx = i;
			}
		}
		cout << (char)('A' + indx) << " " << mx << endl;
	}
}

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

#define all(a) (a).begin(), (a).end()
#define int unsigned long long

typedef pair<long long,long long> PII;
typedef long long ll;

signed main(){
	int n,m;
	cin>>n>>m;
	vector<PII> pai(n);
	for (int i = 0; i < n; ++i){
		cin>>pai[i].first>>pai[i].second;
	}

	sort(all(pai));

	if(n==1){
		cout<<(unsigned long)(m)*(unsigned long)(pai[0].first)<<endl;
		return 0;
	}

	unsigned long ans=0,buy=0;
	for (int i = 0; i < n; ++i){
		while(pai[i].second){
			ans+=pai[i].first;
			pai[i].second--;
			buy++;
			if(buy==m){
				cout<<ans<<endl;
				return 0;
			}
		}
	}

}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			int n = scanner.next().length();
			int m = k + n;
			// 階乗を保存する配列
			long[] factorial = new long[m + 1];
			factorial[0] = 1;
			IntStream.rangeClosed(1, m).forEach(i -> factorial[i] = factorial[i - 1] * i % MOD);
			// 階乗^-1を保存する配列
			long[] revFactorial = new long[m + 1];
			revFactorial[m] = modPow(factorial[m], MOD - 2);
			IntStream.rangeClosed(1, m).map(i -> m - i)
					.forEach(i -> revFactorial[i] = revFactorial[i + 1] * (i + 1) % MOD);
			long answer = 0L;
			for (int i = n; i <= m; i++) {
				// i-1 C n-1
				long result = factorial[i - 1] * revFactorial[n - 1] % MOD * revFactorial[i - n] % MOD;
				// 25^(k-(m-i)) x 26^(m-i)
				result = result * modPow(25, k - (m - i)) % MOD * modPow(26, m - i) % MOD;
				answer = (answer + result) % MOD;
			}
			System.out.println(answer);
		}
	}

	/**
	 * n^m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long modPow(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 73388
//abc075_c.cpp
//Sat May 26 12:02:16 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

bool visit[51];
bool graph[51][51];
int n,m;

void dfs(int v){
	visit[v] = true;
	for (int i=1;i<n+1;i++){
		if (visit[i]){
			continue;
		}else if (graph[v][i] == false){
			continue;
		}
		dfs(i);
	}
}


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

	for (int i=1;i<n+1;i++){
		for (int j=1;j<n+1;j++){
			graph[i][j] = false;
		}
	}

	int a[51],b[51];
	for (int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}

	int bridge = 0;

	for (int i=0;i<m;i++){
		graph[a[i]][b[i]] = false;
		graph[b[i]][a[i]] = false;

		for (int j=1;j<n+1;j++){
			visit[j] = false;
		}

		dfs(1);

		int bridgeflag = 0;

		for (int j=1;j<n+1;j++){
			if (visit[j] == false){
				bridgeflag = 1;
			}
		}

		if (bridgeflag == 1){
			bridge++;
		}

		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}

	cout << bridge << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(b, n*a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
int D;
int c[27], s[400][27];
int L[27];
int last[27];
long long ANS = 0;
long long ans = 0;
int main(){
    scanf("%d",&D);
    for (int i = 1; i <= 26; i++) scanf("%d",&c[i]);
    for (int i = 1; i <= D; i++){
        for (int j = 1; j <= 26; j++) scanf("%d",&s[i][j]);
    }
    for (int i = 1; i <= D; i++){
        int b1 = -1;
        long long ok = 0;
        for (int t = 1; t <= 26; t++){
            for (int x = 1; x <= 26; x++){
                for (int y = 1; y <= 26; y++){
                    ans = ANS;
                    for (int j = 1; j <= 26; j++){
                        last[j] = L[j];
                    }

                        ans += s[i][t];
                        last[t] = i;
                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i-last[j]);
                        }

                    if (i != D){
                        ans += s[i+1][x];
                        last[x] = i+1;
                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i-last[j]);
                        }
                    }

                    if (i < D-1){
                        ans += s[i+2][y];
                        last[y] = i+2;
                        for (int j = 1; j <= 26; j++){
                            ans -= c[j]*(i-last[j]);
                        }
                    }

                    if (b1 == -1 || ans > ok){
                        b1 = t;
                        ok = ans;
                    }
                }
            }
            //printf("for %d: %lld\n",t,ans);
        }
        ANS += s[i][b1];
        L[b1] = i;
        for (int j = 1; j <= 26; j++){
            ANS -= c[j]*(i-L[j]);
        }
        printf("%d\n",b1);
        //printf("score %lld\n",ANS);
    }
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// Union-Find; 素集合データ構造
class UnionFind {
public:
    vector<long long> parent;
    long long n;
    UnionFind(long long x) :parent(x, -1), n(x){}
    bool unite(long long x, long long y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y]; parent[y] = x;
        return true; }
    bool same(long long x, long long y){ return find(x) == find(y); }
    long long find(long long x){ return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    long long size(long long x){ return -parent[find(x)]; }
};

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vi a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind uf(n);
    vi ans(m);

    ll sz1 = 0, sz2 = 0;
    for(ll i=m-1; i>=0; i--){
        if(i == m-1) ans[i] = n*(n-1)/2;
        else ans[i] = ans[i+1]-sz1*sz2;
        if(uf.same(a[i], b[i])){
            sz1 = sz2 = 0;
        }
        else{
            sz1 = uf.size(a[i]);
            sz2 = uf.size(b[i]);
        }
        uf.unite(a[i], b[i]);
    }

    for(auto p: ans) cout << p << endl;
}

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

#define int long long
signed main(){
    int n,k;
    cin >>n>>k;
    int p[n];
    for(int i=0;i<n;i++)cin>> p[i];
    sort(p,p+n);
    int ans=-p[0]+p[k-1];
    for(int i=1;i<=n-k;i++ ){
        if(ans>-p[i]+p[k-1+i])ans=-p[i]+p[k-1+i];
    }
    cout << ans;
    return 0;

  
    
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  vector<pair<intll,intll>> data(n);
  
  rep(i,n){
    int a,b ;
    cin >> a >> b ;
    data.at(i) = make_pair(b,a);
  }
  
  sort(all(data));
  intll  time = 0; 
  string ans = "Yes";
  
  rep(i,n){
    int x , y ;
    tie(x,y) =  data.at(i);
    time += y ;
    if(time > x ){
      ans ="No";
      break;
    }
  }
  
  cout <<ans ;
 


}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int h,w,m; cin>>h>>w>>m;
    vector<int> p(h,0), q(w,0);
    set<P> st;
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        st.insert({a,b});
        p[a]++; q[b]++;
    }
    vector<int> candih, candiw;
    int maxh=0, maxw=0;
    rep(i,h-1){
        if(p[maxh]<p[i+1]){
            maxh=i+1;
        }
    }
    rep(i,w-1){
        if(q[maxw]<q[i+1]){
            maxw=i+1;
        }
    }
    rep(i,h){
        if(p[maxh]==p[i]){
            candih.push_back(i);
        }
    }
    rep(i,w){
        if(q[maxw]==q[i]){
            candiw.push_back(i);
        }
    }
    int ans=p[maxh]+q[maxw];
    bool ok=false;
    for(auto & v: candih){
        for(auto &vv: candiw){
            if(st.find({v,vv})==st.end()){
                //cout<<v<<vv<<endl;
                ok=true;
            }
            if(ok) break;
        }
        if(ok) break;
    }
    if(!ok) ans--;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 23848
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1007, maxm = 2007;
const int inf = 1e9 + 7;
int cnt = 1;
int head[maxn], vis[maxn], dfn[maxn], vis2[maxn];
//head[x]:点x连接的最后一条边号
//vis[x]:标记每次dfs访问过的点，以免重复搜索耗时
//dfn[x]:x的时间戳
//vis[x]2:dfs中标记访问过的次数，找环
int b[maxn];
struct edge
{
int u, v, next;
}e[maxm];
void addedge(int u, int v)//前向星
{
e[cnt].u = u;
e[cnt].v = v;
e[cnt].next = head[u];
head[u] = cnt;
cnt++;
}
vector<int> v;
int ans = inf;
void dfs(int x, int num)
{
vis[x] = 1;//标记x访问过
dfn[x] = num;
for (int i = head[x]; i ; i = e[i].next)//遍历x点连接的所有边
{
int y = e[i].v;
if (vis2[y] == 1)//y第二次被访问，说明形成环
{
if (dfn[x] - dfn[y] + 1 < ans)//ans记录最小环的大小
{
ans = dfn[x] - dfn[y] + 1;
int sz = v.size();
for (int i = 1; i <= ans; i++)
b[i] = v[sz - i];//b[i]存最小环的点
}
}
if (vis[y] == 0)//y没有访问过
{
vis2[y] = 1;
v.push_back(y);
dfs(y, num + 1);
}
}
v.pop_back();
vis2[x] = 0;
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++)
{
int x, y;
scanf("%d%d", &x, &y);
addedge(x, y);
}
for (int i = 1; i <= n; i++)
{
if (vis[i] == 0)
{
v.clear();
v.push_back(i);
vis2[i] = 1;
dfs(i, 1);
}
}
if (ans == inf)
printf("-1\n");
else
{
printf("%d\n", ans);
for (int i = ans; i >= 1; i--)
printf("%d\n", b[i]);
}
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll N,K,A[200000],B[200000];
int main(){
	cin >> N >> K;

	REP(i,N) {
		cin >> A[i] >> B[i];
	}

	ll ans = 0;
	while(true) {
		ll n = 0;
		while((1 << n) <= K)n++;

		ll sum = 0;
		REP(i,N) {
			if((A[i] | K) == K) {
				sum += B[i];
			}
		}
		ans = max(ans,sum);
		sum = 0;
		REP(i,N) {
			if(A[i] < (1 << (n - 1))) {
				sum += B[i];
			}
		}
		ans = max(ans,sum);
		K = K - (1 << (n - 1));
		if(K <= 0)
			break;
		//cout << K << "  " ;

		REP(i,N){
			A[i] = (A[i] & (0xffffffff - (1 << (n - 1))));
			//cout << A[i] << " ";
		}
		//cout << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import scala.io.StdIn._

object Main extends App {

  val Array(n,k) = readLine().split(" ").map(_.toInt)
  val A = readLine().split(" ").map(_.toLong)

  def solve() = {
    (k until n).map { i =>
      if(A(i-k) < A(i)) "Yes" else "No"
    }.mkString("\n")
  }


  println(solve())

}



Measured memory_bytes: 86664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e3+7;
int main() {

      //  freopen("../in.txt","r",stdin);
      //  freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        string s;
        string str[] = {"Sunny", "Cloudy", "Rainy"};
        cin>>s;
        if(s==str[0])   cout<<str[1]<<endl;
        if(s==str[1])   cout<<str[2]<<endl;
        if(s==str[2])   cout<<str[0]<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,n;
    char x[5];
    scanf("%d",&n);
    for(i=2;i<=n;i+=1){
        sprintf(x,"%d",i);
        if(i%3==0){
        printf(" ");
            if(i==n){
                printf("%d\n",i);
            }
            else{
                printf("%d",i);
            }
        }
        else if(x[0]=='3' || x[1]=='3' || x[2]=='3' || x[3]=='3' || x[4]=='3'){
        printf(" ");
            if(i==n){
                printf("%d\n",i);
            }
            else{
                printf("%d",i);
            }
        }
        else if(i==n){
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 612
using System;
using System.Linq;
class hello
{
    public static void Main()
    {
        int[] HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = HW[0], w = HW[1];
        char[,] mat = new char[h, w];
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine();
            for (int j = 0; j < w; j++)
            {
                mat[i, j] = s[j];
            }
        }

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (mat[i, j] == '#')
                {
                    Console.Write("#");
                    continue;
                }
                int counter = 0;
                for (int k = -1; k <= 1; k++)
                {
                    for (int l = -1; l <= 1; l++)
                    {
                        if (k == 0 && l ==0) continue;
                        if (i + k < 0 || i + k >= h || j + l < 0 || j + l >= w) continue;
                        if (mat[i + k, j + l] == '#')
                        {
                            counter++;
                        }
                    }
                }
                Console.Write(counter);
            }
            Console.WriteLine();
        }

    }
}

Measured memory_bytes: 13268
from sys import argv

debug = "a" in argv
s = input()
NUMBER = 753
ans = int(1e10)
for x in range(len(s)-2):
    if debug:
        print(s[x:x+3])
    if abs(NUMBER - int(s[x:x+3])) < ans:
        ans = abs(NUMBER - int(s[x:x+3]))
print(ans)

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

string s;
lli k;

lli calc(string x){
	lli ret = 0;
	lli n = x.size();
	for(int i = 0, j = 0; i < n; i = j){
		while(j < n && x[i] == x[j]) j++;
		ret += (j-i)/2;
	}
	return ret;
}

int main(void){
	cin >> s >> k;
	lli n = s.size();
	if(s.find_first_not_of(s[0]) == string::npos){
		cout << n*k/2 << endl;
		return 0;
	}
	lli d1 = calc(s);
	lli d2 = calc(s+s);
	lli a = d1;
	lli d = (d2-d1);
	cout << a + (k-1)*d << endl;
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if(a==b) {
        cout << a+b;
    } else {
        if(a>b) {
            cout << a+a-1;
        } else {
            cout << b+b-1;
        }
    }
    return 0;
}


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

void DFS(int idx, vector<vector<int> >& node, vector<int>& prenum, vector<int>& lowest, vector<int>& parent, int& num){
// cout << "idx = " << idx << endl;
    prenum[idx] = num++;
    lowest[idx] = prenum[idx];
    for (int i = 0; i < node[idx].size(); i++) {
        if (node[idx][i] == parent[idx]) continue;
        int lowest_tmp;
        if (parent[node[idx][i]] == -1) {
            parent[node[idx][i]] = idx;
            DFS(node[idx][i], node, prenum, lowest, parent, num);
            lowest_tmp = lowest[node[idx][i]];
        } else {
            lowest_tmp = prenum[node[idx][i]];
        }
        lowest[idx] = min(lowest[idx], lowest_tmp);
    }
}

void AP(vector<vector<int> >& node, set<int>& ans){
    int size = node.size();
    vector<int> prenum(size, 0);
    vector<int> lowest(size, 0);
    vector<int> parent(size, -1);
    parent[0] = 0;
    int num = 1;
    DFS(0, node, prenum, lowest, parent, num);
    int n_zero = 0;
    for (int i = 1; i < size; i++) {
        if (parent[i] == 0) n_zero++;
    }
    if (n_zero >= 2) ans.insert(0);
    for (int i = 1; i < size; i++) {
        if (lowest[i] >= prenum[parent[i]] && parent[i] != 0) {
            ans.insert(parent[i]);
        }
    }
// for (int i = 0; i < size; i++) {
//     cout << i << " : " << prenum[i] << " " << lowest[i] << " " << parent[i] << endl;
// }
}

int main(){
    int V, E;
    cin >> V >> E;
    vector<vector<int> > node(V);
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        node[s].push_back(t);
        node[t].push_back(s);
    }

// for (int i = 0; i < V; i++) {
//     for (int j = 0; j < node[i].size(); j++) {
//         cout << node[i][j] << " ";
//     }
//     cout << endl;
// }

    set<int> ans;
    AP(node, ans);
    for (auto it = ans.begin(); it != ans.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}



Measured memory_bytes: 4756
from collections import Counter
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
prime = [0] * (10**6+5)
for i in range(N):
    c = Counter(prime_factorize(A[i]))
    for j in c.items():
        prime[j[0]] = max(j[1],prime[j[0]])
lcm = 1
for i in range(10**6+2):
    if prime[i] > 0:
        lcm *= pow(i,prime[i])
        lcm %= MOD

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],MOD-2,MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 83148
#include <stdio.h>
#include <string.h>
#define INF 0x3f3f3f
#define M 
int map[15][15], sum;

int min(int a, int b)
{
	return a < b ? a : b;
}
int zdl(int start)
{
	int list[13];
	bool next[13];
	memset(next, false, sizeof(next));
	for(int i=0; i<=sum; i++)
	{
		list[i] = map[start][i];
	}
	next[start] = true;
	int ans = 0, st = INF;
	for(int i=0; i<=sum; i++)
	{
		int k;
		st = INF;
		for(int j=0; j<=sum; j++)
		{
			if(!next[j])
			{
				if(st > list[j])
				{
					st = list[j];
					k = j;
				}
			}
		}
		next[k] = true;
		for(int j=0; j<=sum; j++)
		{
			if(st + map[k][j] < list[j])
			{
				list[j] = st + map[k][j];
			}
		}
	}
	for(int i=0; i<=sum; i++)
	{
		ans += list[i];
	}
	return ans;
}
int main()
{
	int n, m, a, b, s;
	while(scanf("%d", &n) != EOF && n)
	{
		sum = 0;
		for(int i=0; i<13; i++)
		{
			for(int j=0; j<13; j++)
			{
				if(i == j)
					map[i][j] = 0;
				else
					map[i][j] = INF;
			}
		}
		for(int i=0; i<n; i++)
		{
			scanf("%d%d%d", &a, &b, &s);
			if(sum < a)	sum = a;
			if(sum < b)	sum = b;
			if(map[a][b] > s)
			{
				map[a][b] = map[b][a] = s;
			}
		}
		int ans = INF, k;
		for(int i=0; i<=sum; i++)
		{
			int ww = zdl(i);
			if(ans > ww)
			{
				ans = ww;
				k = i;
			}
		}
		printf("%d %d\n", k, ans);
	}
	
	return 0;
}

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

int main( void ) {
	int N;
	int X;

	scanf("%d %d", &N, &X);

	if(N < 2 || N > 1000) {
		exit(0);
	}

	int m[N];
	int sum = 0;
	int saisyo = 1000;
	int count = N;

	for(int i = 0;i < N;i++) {
		scanf("%d", &m[i]);
		if(m[i] < 1 || m[i] > 1000) {
			exit(0);
		}
		if(saisyo > m[i]) {
			saisyo = m[i];
		}
		sum += m[i];
	}

	if(sum > X || X > 100000) {
		exit(0);
	}

	X -= sum;

	count += (X / saisyo);

	printf("%d", count);

}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().strip().split()))
Q = int(input())
B = [0]*Q
C = [0]*Q
from collections import Counter
K=Counter(A)
ans = 0

for i in range(Q):
    B[i],C[i] = map(int,input().split())


for i in K:
    ans += i * K[i]

for i in range(Q):
    ans -= B[i] * K[B[i]]
    ans += C[i] * K[B[i]]
    K[C[i]] += K[B[i]]
    K[B[i]] = 0
    print(ans)

    
    
    

Measured memory_bytes: 29764
#include <cstdio>
#include <cstring>
using namespace std;

#define N 1000100
#define K 26

char s[N];
int ch[N][K], flag[N], fa[N], pos[N], chk[N], tot;

int num[N][K];

void dfs(int x) {
	for (int i = 0; i < K; i++) if (ch[x][i]) {
		dfs(ch[x][i]);
		num[x][i] += flag[ch[x][i]];
		for (int j = 0; j < K; j++) if (j != i)
			num[x][j] += num[ch[x][i]][j];
	}
}

int main() {
	//freopen("A.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s + 1);
		int len = strlen(s + 1), p = 0;
		flag[p]++;
		for (int j = len; j >= 1; j--) {
			int c = s[j] - 'a';
			if (!ch[p][c])
				ch[p][c] = ++tot, fa[tot] = p;
			p = ch[p][c];
			flag[p]++;
		}
		pos[i] = fa[p];
		chk[i] = s[1] - 'a';
	}
	dfs(0);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += num[pos[i]][chk[i]] - 1;
	printf("%lld\n", ans);
}

Measured memory_bytes: 256548
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define N 100010
#define ll long long
using namespace std;
ll num[N],ans[N];
struct ques{
	int a,t,id;
	bool operator <(const ques b)const{return t<b.t;}
}q[N];
int main()
{
	ll x;
	int n;
	scanf("%lld%d",&x,&n);
	for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
	int m;
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&q[i].t,&q[i].a),q[i].id=i;
	sort(q+1,q+m+1);
	ll u=1,r=0,up=x,down=0,opt=-1;
	ll sum=0;
	while(u<=m)
	{
		if(num[r+1]<q[u].t && r<n)
        {
        	ll res=0;
            r++;
            res=opt*(num[r]-num[r-1]);
            down=max(0ll,min(x,down+res));
			up=max(0ll,min(x,up+res));
            sum+=res;
			opt=-opt;
        }
		else
		{
			ll cnt=q[u].t-num[r];
			ll res=max(down,min(up,q[u].a+sum));
			ans[q[u].id]=max(0ll,min(x,res+opt*cnt));
			u++;
        }
    }
	for(int i=1;i<=m;i++) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3968
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	char[] n = sc.next().toCharArray();
      	if(n[0]=='7' || n[1]=='7' || n[2]=='7') System.out.println("Yes");
      	else System.out.println("No");
      	
    }
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vi A,B,C;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int X; cin >> X;
	int cnt = 1;
	while(true){
		if(X * cnt % 360 == 0) {
			cout << cnt << endl;
			return 0;
		}
		cnt++;
	}
}

Measured memory_bytes: 3640
n=int(input())
s=list(input())
p=[0,0]
l=[s.count("E"),s.count("W")]
t=[]
for i in range(n):
    if s[i]=="E":
        t.append(l[0]+p[1]-1)
        l[0]-=1
        p[0]+=1
    else:
        t.append(l[0]+p[1])
        l[1]-=1
        p[1]+=1
print(min(t))

Measured memory_bytes: 17780
X, K, D = map(int, input().split())

if X == 0:
    if K % 2 == 0:
        print(0)
    else:
        print(abs(D))
    exit(0)
X = abs(X)
if X > 0:
    k = X - K * D
    if k >= 0:
        print(k)
    else:
        kouho1 = X % D
        kouho2 = abs(kouho1 - D)
        sho = X // D
        if (K - sho) % 2 == 0:
            print(kouho1)
        else:
            print(kouho2)
    exit(0)


Measured memory_bytes: 9168
n=(input())
lenn=len(n)
#print(len(n))
s=''
for i in range(lenn):
  if i%2==0:
    s+='0'
  else:
    s+='1'
#print(s)
cnt=0
for i in range(lenn):
  if n[i] != s[i]:
    cnt+=1
s=''
for i in range(lenn):
  if i%2==1:
    s+='0'
  else:
    s+='1'
#print(s)
cnt1=0
for i in range(lenn):
  if n[i] != s[i]:
    cnt1+=1    
print(min(cnt,cnt1))

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

typedef long long ll;

#define rep(a,b,c) for(int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(int a=b,a##end=c;a>=a##end;--a)


char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}

const int N=300,K=50;

int n,m;

char s[N];
int cnt[N];

map <int,int> M;

int main(){
	scanf("%s",s);
	rep(i,0,3) M[s[i]]++;
	int fl=0;
	if(M.size()==2){
		fl=1;
		for( map<int,int> ::iterator it=M.begin();it!=M.end();it++){
			if(it->second!=2) fl=0;
		}
	}
	puts(fl?"Yes":"No");
	;
}








Measured memory_bytes: 256
import collections

n = int(input())
v = list(map(int, input().split()))

v_odd = []
v_even = []

for i, v in enumerate(v):
    if i % 2:
        v_even.append(v)
    else:
        v_odd.append(v)

# Counterに入れて、valueの降順にソート
v_odd_c = collections.Counter(v_odd)
v_odd_c = sorted(v_odd_c.items(), key=lambda x: x[1], reverse=True)
v_even_c = collections.Counter(v_even)
v_even_c = sorted(v_even_c.items(), key=lambda x: x[1], reverse=True)

# counterに一つしかkeyがないと面倒なので0が0回出たことを明示的に示しておく
# 制約上、0はvとしてあり得ないので問題ない（必ず0は0回出る）
v_odd_c.append([0, 0])
v_even_c.append([0, 0])

# print(v_odd_c)
# print(v_even_c)

if n != 2:
    o1 = v_odd_c[0]
    o2 = v_odd_c[1]
    e1 = v_even_c[0]
    e2 = v_even_c[1]

    # 最頻値が異なる場合
    if o1[0] != e1[0]:
        ans = n - o1[1] - e1[1]
    # 最頻値が等しい場合
    elif o1[0] == e1[0]:
        # o1,e2を採用する場合
        temp1 = n - o1[1] - e2[1]
        #o2, e1を採用する場合
        temp2 = n - o2[1] - e1[1]
        ans = min(temp1, temp2)

elif n == 2:
    if v_odd_c[0][1] != v_even_c[0][1]:
        ans = 0
    else:
        ans = 1

print(ans)


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

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 count = 0;
    bool flag = false;
    for (;;) {
        for (int j = 0; j < N; j++) {
            if (a.at(j) % 2 != 0) flag = true;
            if (flag) break;
            a.at(j) /= 2;
        }
        if (flag) break;
        count++;
    }

    cout << count << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll A,B,C; cin>>A>>B>>C;
	cout<<maxx(A,B,C)*9+A+B+C;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long ans=0;
		for(long i=n;i>0;i--) {
			if(i*i <= n) {
				ans=i*i;
				break;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int f[100005];
int find(int x){
	int xx=x;
	while(f[x]!=x)x=f[x];
	while(f[xx]!=x){
		int tem=f[xx];
		f[xx]=x;
		xx=tem;
	}
	return x;
}
void join(int x,int y){
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy)f[fx]=fy;
}
int n,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<=n;i++)f[i]=i;
	int a,b;
	while(m--){
		cin>>a>>b;
		join(a,b);
	}
	int q;cin>>q;
	while(q--){
		cin>>a>>b;
		if(find(a)==find(b)){
			cout<<"yes"<<endl;
		}else cout<<"no"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 1e5 + 10;
typedef long long LL;
char s[MAXN] , t[MAXN];
LL sums[MAXN] , sumt[MAXN];
int main()
{
	scanf(" %s %s" , s , t);
	int n = strlen(s) , m = strlen(t);
	for(int i = 0 ; i < n ; ++i)
		sums[i + 1] = sums[i] + (s[i] == 'A') + 1;
	for(int i = 0 ; i < m ; ++i)
		sumt[i + 1] = sumt[i] + (t[i] == 'A') + 1;
	int q;
	scanf("%d" , &q);
	while(q--)
	{
		int a , b , c , d;
		scanf("%d%d%d%d" , &a , &b , &c , &d);
		puts((sums[b] - sums[a - 1]) % 3 == (sumt[d] - sumt[c - 1]) % 3 ? "YES" : "NO");
	}
	return 0;
}


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

int main() 
{ 
	string s;
	cin>>s;
	int l =0,r=s.size()-1;
	//bool ok = true;
	int cnt =0;
	while(l<r){
		if(s[l] != s[r]){
			cnt++;
		}
		l++;
		r--;
	}
	cout<<cnt;
	return 0; 
} 


Measured memory_bytes: 256
#ABC162C_SumOfGcdOfTuples.rb
k = gets.to_i
sum = 0
(1..k).each do |i|
  (1..k).each do |j|
    (1..k).each do |l|
      sum += i.gcd(j).gcd(l)
    end
  end
end
p sum


Measured memory_bytes: 14396
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    a = I()
    b = I()
    print(6 - a - b)
    return


# B
def B():
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    A()
    return


# Solve
if __name__ == "__main__":
    A()


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

int main(){
  long long A,B,C,K;
  long long ans;
  cin>>A>>B>>C>>K;
  if(K%2==1){
    ans=B-A;
  }
  else ans=A-B;
  if(ans>1000000000000000000){
    cout<<"Unfair"<<endl;
    return 0;
  }
  cout<<setprecision(19)<<ans<<endl;
}

  

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

template <typename T>
struct Edge { int src, dst; T cost;
    Edge(int dst, T cost) : src(-1), dst(dst), cost(cost) { }
    Edge(int src, int dst, T cost) : src(src), dst(dst), cost(cost) { }
};
template <typename T> using Edges = vector<Edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
vector<vector<T>> dijkstra(const WeightedGraph<T> &g, int s, int c) {
    const T INF = numeric_limits<T>::max();
    vector<vector<T>> dp(g.size(), vector<T>(c + 1, INF));
    using Pi = tuple<T, int, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    dp[s][c] = 0; que.emplace(dp[s][c], s, c);
    while (!que.empty()) {
        T cost; int v, cc; tie(cost, v, cc) = que.top(); que.pop();
        if (dp[v][cc] < cost) continue;
        for (auto &e: g[v]) {
            int nv = e.dst; T nc = e.cost;
            if (cc) {
                if (dp[nv][cc - 1] > dp[v][cc] + nc / 2) {
                    dp[nv][cc - 1] = dp[v][cc] + nc / 2;
                    que.emplace(dp[nv][cc - 1], nv, cc - 1);
                }
            }
            if (dp[nv][cc] <= dp[v][cc] + nc) continue;
            dp[nv][cc] = dp[v][cc] + nc;
            que.emplace(dp[nv][cc], nv, cc);
        }
    }
    return dp;
}

int main() {
    int c, n, m, s, d;
    while (cin >> c >> n >> m >> s >> d, s--, d--, n) {
        WeightedGraph<int> g(n);
        while (m--) {
            int a, b, f; cin >> a >> b >> f; a--, b--;
            /*if (a != d) */g[a].emplace_back(b, f);
            /*if (b != d) */g[b].emplace_back(a, f);
        }
        auto res = dijkstra(g, s, c)[d];
        cout << *min_element(res.begin(), res.end()) << endl;
    }
    return 0;
}


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

int main(){
	// sengen
	string s,t;
	int count = 0;
	// nyuryoku
	cin >> s >> t;
	for(int i=0;i<s.size();i++){
		if(s[i] != t[i]){
			count++;
		}
	}
	// keisan
	cout << count;
	// syutsuryoku
}

Measured memory_bytes: 3844
//FIRST THINK, THEN CODE.


#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}
 
const ll mxn=1e6+5;





int main()
{ 
IOS;

char x;cin>>x;

if(x>95)cout<<"a"<<endl;
else cout<<"A"<<endl;


 return 0;
 
 
 
}

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

const int N = 3000;

int fact[N], inv_fact[N];
int a[N], b[N], buffer[N], p;

int inverse(int a) {
  return a == 1 ? 1 : (p - p / a) * inverse(p % a) % p;
}

int C(int a, int b) {
  return fact[a] * inv_fact[b] % p * inv_fact[a - b] % p;
}

void get_coeff(int k) {
  int m = p - 1;
  int km = 1;
  for (int i = m; i >= 0; -- i) {
    buffer[i] = -(km * C(m, i)) % p;
    (km *= -k) %= p;
  }
  buffer[0] = (buffer[0] + 1) % p;

  // std::cerr << k << std::endl;
  // for (int i = 0; i <= m; ++ i) {
  //   std::cerr << buffer[i] << " ";
  // }
  // std::cerr << std::endl;
}

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

  fact[0] = 1;
  inv_fact[0] = 1;
  for (int i = 1; i < p; ++ i) {
    fact[i] = fact[i - 1] * i % p;
    inv_fact[i] = inv_fact[i - 1] * inverse(i) % p;
  }

  for (int i = 0; i < p; ++ i) {
    int x;
    scanf("%d", &x);
    if (x == 1) {
      get_coeff(i);
      for (int j = 0; j < p; ++ j) {
        (b[j] += buffer[j]) %= p;
      }
    }
  }
  for (int i = 0; i < p; ++ i) {
    if (b[i] < 0) {
      b[i] += p;
    }
    printf("%d%c", b[i], i == p - 1 ? '\n' : ' ');
  }
  return 0;
}


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

int main()
{
    int i,n,t;
    int a[101];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++){
        if(a[i]==a[i+1]){
            t=t;
        }
        else t++;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1<<30)

N = int(input())
X = input()
ones = X.count('1')

v1 = 0
v2 = 0
m1 = ones + 1
m2 = ones - 1
p1 = 1 % m1
p2 = 1

for i, v in enumerate(reversed(X)):
	if v == '1':
		v1 = (v1 + p1) % m1

		if m2 > 0:
			v2 = (v2 + p2) % m2

	p1 = p1 * 2 % m1
	if m2 > 0:
		p2 = p2 * 2 % m2

from functools import lru_cache

@lru_cache(maxsize=None)
def f(i):
	if i == 0: return 0

	return 1 + f(i % popcount(i))

def popcount(x):
      b=0
      while(x > 0):
          x &= x - 1
          b+=1
      return b


for i in range(N):
	div = ones + 1 if X[i] == '0' else ones - 1
	if div == 0:
		print(0)
	elif div == 1:
		print(1)
	else:

		if div == m1:
			x = (v1 + pow(2, N-i-1, m1)) % m1
		elif div == m2:
			x = (v2 - pow(2, N-i-1, m2)) % m2
		else:
			assert False

		#print(x, (int(X, 2) ^ (1 << (N-i-1))) % div, div)

		print(1 + f(x))


Measured memory_bytes: 78344
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card,reverse=True)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Measured memory_bytes: 3060
import java.io.*
import java.util.*

fun solve(S: String, T: String){
    println(T + S)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val S = sc.next()
    val T = sc.next()
    solve(S, T)
}



Measured memory_bytes: 31388
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)>(b))?(b):(a)

typedef long long ll;
typedef unsigned long long ull;

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

	for (size_t i = 0; i < n; i++)
	{
		int h;
		scanf("%d", &h);
		if (h >= k)
		{
			cnt++;
		}
	}

	printf("%d", cnt);
}

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int a , b;
    cin >> a >> b;
    b -= 1;
    while(b>=1){
        ans ++;
        b -= a-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;


int main()
{
	int n, k;
	cin >> n >> k;
	int ans = n - k + 1;

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
import fractions

n,x = map(int,input().split())
l = list(map(int,input().split()))

for i in range(n):
    l[i] -= x
    l[i] = abs(l[i])
#print(n,x,l)

if n == 1:
    res = l[0]
else:
    res = fractions.gcd(l[0],l[1])
    for i in range(2,n):
        res = fractions.gcd(res,l[i])
print(res)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( A + B > C + D ){
    cout << "Left" << endl;
  }
  else if ( A + B < C + D ){
    cout << "Right" << endl;
  }
  else cout << "Balanced" << endl;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define All(x) (x).begin(), (x).end()
#define mp make_pair
#define Task "abc"

typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 1e9 + 7;

ll a[maxn];
int n;
ll k;

bool ok(ll mid){
  ll cnt = 0;
  for (int i = 1; i < n; ++i){
    if (a[i] == 0){
      if (mid >= 0) cnt += n - i;
      continue;
    }
    ll d = mid / a[i];
    if (a[i] > 0){
      if (abs(mid) % a[i] != 0){
        if ( (d == 0 && mid < 0) || d < 0) --d;
      }
      int pos = upper_bound(a + i + 1, a + n + 1, d) - a;
      --pos;
      cnt += pos - i;
    } else {
      if (abs(mid) % abs(a[i]) != 0){
        if ((d == 0 && mid < 0) || d > 0) d++;
      }
      int pos = lower_bound(a + i + 1, a + n + 1, d) - a;
      cnt += n - pos + 1;
    }
  }
  return cnt >= k;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(NULL);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  ll inf = 1e18;
  ll l = -inf, r = inf;
  while (l <= r){
    ll mid = (l + r) / 2;
    if (ok(mid)) r = mid - 1;
    else l = mid + 1;
  }
  cout << r + 1;
return 0;
}




Measured memory_bytes: 1792
<?php

  
$l = trim(fgets(STDIN));
list ($a, $v) = explode(" ", $l);
$l = trim(fgets(STDIN));
list ($b, $w) = explode(" ", $l);
$t = trim(fgets(STDIN));


// $a < $b 右に移動
// $a > $b 左に移動
$d = $a < $b ? 1 : -1;
$oni = $a + $v * $t * $d;
$ko = $b + $w * $t * $d;

if (($a < $b && $oni >= $ko) ||
    ($a > $b && $oni <= $ko)) {
    echo "YES\n";
 } else {
    echo "NO\n";
 }

Measured memory_bytes: 16088
count =0
while True:
    W = input()
    if W==0: break
    work = [0]*1001
    count +=1
    N = input()
    m = 0
    n = 0
    for i in range(N):
        p,w = input()
        for w0 in range(W+1)[::-1]:
            p0 = work[w0]
            if w0>0 and p0==0: continue
            w1 = w0+w
            p1 = p0+p
            if w1<=W and work[w1]<p1:
                work[w1] = p1
                if m<p1:
                    m = p1
    n = work.index(m)
    print "Case {}:".format(count)
    print m
    print n

Measured memory_bytes: 4336
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, q, r, ret, a[10000];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a + n);
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		scanf("%d", &r);
		if(upper_bound(a, a + n, r) - lower_bound(a, a + n, r)) ret++;
	}
	printf("%d\n", ret);
	return 0;
}

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

int main()
{

    int x1, x2, x3, x4, x5;

    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);

    if (x1 == 0)
        printf("1");
    else if (x2 == 0)
        printf("2");
    else if (x3 == 0)
        printf("3");
    else if (x4 == 0)
        printf("4");
    else if (x5 == 0)
        printf("5");

    return 0;
}


Measured memory_bytes: 1592
N, M = map(int, input().split())
A = list(map(int, input().split()))

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

step = max(A)
X = step // 2
while X <= M:
    for a in A:
        if (X - a // 2) % a != 0:
            break
    else:
        cnt = X // LCM + (M - X) // LCM + 1
        print(cnt)
        exit()
    X += step
print(0)

Measured memory_bytes: 63984