akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	static private List<Character> list = Arrays.asList('A', 'C', 'G', 'T');

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			int current = 0;
			int max = 0;
			for (char a : s.toCharArray()) {
				if (list.contains(a)) {
					current++;
				} else {
					if (current > max) {
						max = current;
					}
					current = 0;
				}
			}
			if (current > max) {
				max = current;
			}
			System.out.println(max);
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <unordered_map>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
#define Range(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;


int main() {
	char str [100001];
	scanf("%s", str);
	int k;
	scanf("%d", &k);
	int len = strlen(str);
	REP(i, len) {
		if ((str[i] != 'a') && ((str[i] + k) > 'z')) {
			k -= ('z' + 1) - str[i];
			str[i] = 'a';
		}
	}
	k %= 26;
	str[len - 1] += k;
	if (str[len - 1] > 'z')
		str[len - 1] -= 26;
	printf("%s\n",str);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a,b,k;
vector<int>vec;
int main()
{
	cin>>a>>b>>k;
	for(int i=1;i<=100;i++)
	{
		if((a%i==0)&&(b%i==0))
			vec.push_back(i);
	}
	sort(vec.begin(),vec.end(),greater<int>());
	cout<<vec[k-1]<<endl;
	return 0;
}

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

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

    for (int i = k; i < n; i++){
        if (a[i - k] < a[i]) puts("Yes");
        else
            puts("No");
    }
}


Measured memory_bytes: 4832
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main()
{
	int n, k;
	string str;
	char input[100001];
	int i;
	int sol = 0;
	int cand = 0;
	int ptr = 1, ptr2;
	queue<int> state;
	bool phase = false;

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

	scanf("%s", input);

	str = input;

	if (n == 1)
	{
		printf("0\n");

		return 0;
	}

	for (i = 0; i < n - 1; i++)
	{
		sol += (str[i] == str[i + 1]);
	}
	
	for (i = 1; i < n; i++)
	{
		cand += str[i] != str[i + 1];
	}

	if (cand % 2)
	{
		if (k >= cand / 2 + 1)
		{
			sol = n - 1;
		}

		else
		{
			sol += k * 2;
		}
	}

	else
	{
		if (k >= cand / 2)
		{
			sol = n - 1;
		}

		else
		{
			sol += k * 2;
		}
	}

	printf("%d\n", sol);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
int main ()
{
  string S;
  int K;
  cin>>K;
  cin>>S;
  if(S.size()<=K)
  {
    cout<<S<<endl;
    return 0;
  }
  else
  {
    for(int i=0;i<K;i++)
    {
      cout<<S[i];
    }
  }
  cout<<"..."<<endl;
  return 0;
}

Measured memory_bytes: 3564
//ABC069-C

#include <iostream>

using namespace std;

int main(){
	int N;
	cin >> N;
	int a[N];
	int c4 = 0;
	int c1 = 0;
	int c2=0;
	for(int i=0;i<N;i++){
		cin >> a[i];
		if(a[i]%4==0){
			c4++;
		} else if(a[i]%2==1) c1++;
		else if(a[i]%2==0) c2++;
	}
	if(c1==0 && c2>1) cout <<"Yes\n";
	else if(c1==0 && c4>=1) cout <<"Yes\n";
	else if(c1==1 && c4>=1) cout <<"Yes\n";
	else if(c1>1 && c2==0 && c4>=c1-1) cout <<"Yes\n";
	else if(c1>1 && c2>=1 && c4>=c1) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
int main() {
    ull n, k, temp;
    vector<ull>a;
    cin>>n>>k;
    for (ull i = 0; i < n; i++)
    {  cin>>temp;	a.push_back(temp);	}
    for (ull i = k, j = 0; i < n; i++, j++)
      if (a[i] > a[j])
        cout<<"Yes"<<endl;
  	  else
        cout<<"No"<<endl;
  	a.clear();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define dbg(x) TRACE(cerr << #x" = " << x << endl)
#define dbgall(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

//=========================

void run_test() {
	ll n; cin >> n;
    string ans;
    while(n > 0) {
        n--;
        int k = n % 26;
        ans = char('a' + k) + ans;
        n /= 26;
    }
    cout << ans << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int _t = 1, __t; cin >> __t; while(_t <= __t) { cout << "Case #" << _t++ << ": "; run_test(); }
	// int _t; cin >> _t; while(_t--) run_test();
	run_test();
	return 0;	
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int bit[MAX];
 
void Add(int i,int x){
  while(i){
    bit[i]+=x;
    i-=(i&-i);
  }
}
 
int Get(int i){
  int res=0;
  while(i<MAX){
    res+=bit[i];
    i+=(i&-i);
  }
  return res;
}
 
int n,q;
 
int main(){
  scanf("%d %d",&n,&q);
  while(q--){
    int type;
    scanf("%d",&type);
    if(type==0){
      int l,r,x;
      scanf("%d %d %d",&l,&r,&x);
      Add(r,x);
      Add(l-1,-x);
    }else{
      int target;
      scanf("%d",&target);
      printf("%d\n",Get(target));
    }
  }
  return 0;
}

Measured memory_bytes: 3528
#include <stdio.h>
#include <vector>
#include <list>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


using std::string;
using std::vector;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// logic
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static unsigned long count = 0;
void merge(vector<int>& list, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1);
    vector<int> R(n2 + 1);
    for(int i = 0; i < n1; i++){
        L[i] = list[left + i];
    }
    for(int i = 0; i < n2; i++){
        R[i] = list[mid + i];
    }
    L[n1] = std::numeric_limits<int>::max();
    R[n2] = std::numeric_limits<int>::max();

    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){

        if(L[i] <= R[j]){
            list[k] = L[i];
            i++;
        }else{
            count += n1 - i;
            list[k] = R[j];
            j++;
        }
    }
}

void mergeSort(vector<int>& list, int left, int right){
    // printf("left:%d right:%d\n", left, right);
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(list, left, mid);
        mergeSort(list, mid, right);
        merge(list, left, mid, right);
    }
}

void solve() {
    int n;
    scanf("%d", &n);

    vector<int> list(n);
    for(int i = 0; i < n; i++){
        int v;
        scanf("%d", &v);
        list[i] = v;
    }
    mergeSort(list, 0, n );
    printf("%zu\n", count);
    // printList(list);
}


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


Measured memory_bytes: 4396
#include <stdio.h>

int main(){
  int N,i,j,v,k;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  for(i=1;i<N;i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(k=0;k<N;k++){
    if(k>0)printf(" ");
    printf("%d",A[k]);
  }
     printf("\n");
  }

  return 0;
}






Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int maxn = 3e5 + 10;
int x, y, r[maxn], c[maxn];
vector<int>  rr, cc;
set<pair<int,int> >st;
int main()
{
    int h, w, m;
    cin >> h >> w >> m;
    int mr = 0, mc = 0;///行最大，列最大值
    for (int i = 0; i < m; i++)
    {
        cin>>x>>y;
        st.insert(make_pair(x,y));
        r[x]++;
        c[y]++;
        if(mr<r[x])
        {
            mr=r[x];///更新行最大值
            rr.clear();
            rr.pb(x);///看有幾行最大的值
        }
        else if(mr==r[x])
        {
            rr.pb(x);///如果相等放進來
        }
        if(mc<c[y])
        {
            mc=c[y];
            cc.clear();
            cc.pb(y);
        }
        else if(mc==c[y])
        {
            cc.pb(y);
        }
    }
    for(int i:rr)///便利的是存進來的是行值最大的行坐標
        for(int j:cc)///列值最大的列坐標
        {
            if(st.count(make_pair(i,j)))///如果這個點有東西的話
                continue;
            else
            {
                cout<<mr+mc;///弱國這個點沒東西
                return 0;
            }
        }
    cout << mr+mc-1;///如果都是在一點用東西，那就要減去在重曡的一個
    return 0;
}


Measured memory_bytes: 21856
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int a, b, c;
    cin>>a>>b>>c;
    int temp[3] = {a, b, c};
    int dp[n+2][3];
    string s;
    cin>>s;
    vector<char> div[k+2];
    for(int i= 0;i<n;i++){
    	div[i%k].pb(s[i]);
    }    
    map<char, int> key;
    key['r'] = 2;
    key['p'] = 1;
    key['s'] = 0;
    int ans = 0;
    for(int i= 0;i<k;i++){
    	dp[0][0] = dp[0][1] = dp[0][2] = 0;
    	for(int j =1;j<=div[i].size();j++){
    		dp[j][key[div[i][j-1]]] = temp[key[div[i][j-1]]] + max(dp[j-1][(key[div[i][j-1]] +1)%3], dp[j-1][(key[div[i][j-1]] +2)%3]);
    		dp[j][(key[div[i][j-1]] +1)%3] = max(dp[j-1][(key[div[i][j-1]] +2)%3], dp[j-1][(key[div[i][j-1]] +3)%3]);
    		dp[j][(key[div[i][j-1]] +2)%3] = max(dp[j-1][(key[div[i][j-1]] +3)%3], dp[j-1][(key[div[i][j-1]] +4)%3]);
    	}
    	ans += max({dp[div[i].size()][0], dp[div[i].size()][1], dp[div[i].size()][2]});
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5200
import java.util.Scanner;

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

    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    trace(A, N);

    insertionSort(A, N);
  }

  private static void insertionSort(int[] A, int N) {
    for (int i = 1; i < N; i++) {
      int v = A[i];
      int j = i - 1;
      while (j >= 0 && A[j] > v) {
        A[j + 1] = A[j];
        j--;
      }
      A[j + 1] = v;
      trace(A, N);
    }
  }

  private static void trace(int[] A, int N) {
    for (int i = 0; i < N; i++) {
      if (i > 0) {
        System.out.print(" ");
      }
      System.out.print(A[i]);
    }
    System.out.print("\n");
  }
}



Measured memory_bytes: 33920
N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])

Measured memory_bytes: 3064
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
BA = [[] for i in range(N)]
for i in range(N):
    A,B = LI()
    BA[i] = [B,A]


BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A[i]>= 0:
        pass
    else:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 47280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATherefore solver = new ATherefore();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATherefore {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            switch (n % 10) {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    out.println("hon");
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    out.println("pon");
                    break;
                default:
                    out.println("bon");
                    break;
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 25552
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(max(a,b)>8)printf(":(\n");
	else printf("Yay!\n");	
	return 0;
}

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    LL K;
    cin >> K;
    if(K % 7 == 0) {
        K /= 7;
    }
    K *= 9;
    LL powten = 1;
    for(int n = 1; n <= K; ++n) {
        powten = (powten * 10) % K;
        if(powten == 1) {
            cout << n << "\n";
            return 0;
        }
    }
    cout << "-1\n";
    
    
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,m;
    cin>>n>>m;
    ll ans=0;
    if(n>m){
        swap(n,m);
    }

    if(n==1&&m==2)ans=3;
    if(n==1&&m==3)ans=2;
    if(n==2&&m==3)ans=1;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
//Ruthless Coding 
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (c - (d - b)) << ' ' << d + (c - a) << ' ' << a - (d - b) << ' ' << b + (c - a);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MOD 1000000007
#define ll long long
#define maxn 100000
inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = 1LL * rez * a % MOD;
        a = 1LL * a * a % MOD;
        n /= 2;
    }
    return rez;
}
int f[maxn + 1];

int main() {
    int n, a;
    ll rez = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        f[a]++;

    }
    if (n % 2 == 0) {
        for (int i = 1; i < n; i += 2)
            if (f[i] != 2)
                rez = 0;
    } else {
        for(int i = 2; i < n; i += 2)
            if (f[i] != 2)
                rez = 0;
        if (f[0] != 1)
            rez = 0;
    }
    if (rez == 0)
        printf("%lld", rez);
    else {
        rez = 1LL * lgput(2, n / 2) % MOD;
        printf("%lld", rez);
    }

    return 0;
}


Measured memory_bytes: 512
n = gets.to_i
ar = gets.chomp.split.map(&:to_i)
ans = 0
i = 0
(n - 2).times{
  i += 1
  tmp = [ar[i-1],ar[i],ar[i+1]].sort
  if (tmp[1] == ar[i])
    ans += 1
  end
}
puts ans

Measured memory_bytes: 3836
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;

int main()
{
    int N, A;
    std::cin >> N >> A;

    std::vector<int> X;
    for (size_t i = 0; i < N; ++i) {
        int t;
        std::cin >> t;
        X.push_back(t - A);
    }

    boost::multi_array<int64_t, 2> memo(boost::extents[N+1][(N*50+1)*2]);

    std::fill(memo.data(), memo.data() + memo.num_elements(), INT64_MIN);

    auto f = [&memo, &X, N](auto F, size_t i, int sum) -> size_t  {
        if (memo[i][sum + N*50+1] != INT64_MIN) {
            return memo[i][sum + N*50+1];
        }
        if (i == N) {
            return 0;
        }
        size_t ret = 0;
        if (sum + X[i] == 0) {
            ret++;
        }

        return memo[i][sum + N*50+1] = ret + F(F, i+1, sum+X[i]) + F(F, i+1, sum);
    };

    auto count = f(f, 0, 0);

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 2304
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [e for e in lines[0].split(' ')]

    return (n, )


def solve(n):

    result = 'No'
    if '7' in n:
        result = 'Yes'

    
    return  result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62012
<?php
fscanf(STDIN, "%d%d", $N, $Q);
for($i = 0; $i < $N; $i++){
    fscanf(STDIN, "%d%d%d", $s, $t, $x);
    $s-=$x;
    $t-=$x;
    $S[]=$s;
    $T[]=$t;
    $X[]=$x;
}
for($i = 0; $i < $Q; $i++){
    fscanf(STDIN, "%d", $D[]);
}
$R = array_fill(0, $Q, -1);
$N = array_fill(0, $Q, -1);
 
array_multisort($X,SORT_ASC,$S,$T);
foreach($X as $i => $x){
    $f = bsl($D, $S[$i]-0.5);
    $t = bsl($D, $T[$i]-0.5);
//    echo "$S[$i] → $T[$i] $f → $t ($x)\n";
    for($i = MAX($f+1,0); $i <= $t; $i++){
        if($N[$i] != -1){
            $i = $N[$i];
        }
        if($R[$i] == -1){
            $R[$i] = $x;
            $N[$i] = $t;
        }
    }
}
echo implode("\n", $R);
 
 
function bsl($nums, $target) {
    $size = count($nums);
    $min = 0; 
    $max = $size - 1;
    while(true){
        $center = floor(($min + $max) / 2);
        $centerValue = $nums[$center];
        if($target == $centerValue){
            return $center;
        }elseif($target > $centerValue){
            $min = $center + 1;
        }else{
            $max = $center;
        }
        if($min == $max){
            $center = floor(($min + $max) / 2);
            $centerValue = $nums[$center];
            if($centerValue == $target){
                return $center;
            }elseif($centerValue < $target){
                return $center;
            }else{
                return $center-1;
            }
        }
    }
}

Measured memory_bytes: 89696
#include "bits/stdc++.h"
#define ld long double
#define pi 3.14159265358979323846
#define int long long
#define mii map<int,int>
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

signed main() {
  int n;
  cin>>n;
  vector<int>vec(n);
  int a=0;
  int b=0;
  for(int i=0;i<n;i++) cin>>vec.at(i);
  sort(vec);
  for(int i=n-1;i>0;i--) {
    if(vec.at(i)==vec.at(i-1)) {
      if(a) {
        b=vec.at(i);
        break;
      }
      else {
        a=vec.at(i);
      }
      i--;
    }
  }
  cout<<a*b<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	int e,o;
	cin >> e >> o;
	int a = (e * (e - 1)) / 2;
	int b = (o * (o - 1)) / 2;
	cout << a + b;
	return (0);
}


Measured memory_bytes: 3632
N, M = map(int, input().split())
A_B = [list(map(int, input().split())) for _ in range(N)]

A_B.sort()
count = 0
money = 0
i = 0
while count != M:
    money += A_B[i][0] * min(M-count, A_B[i][1])
    count += min(M-count, A_B[i][1])
    i += 1
print(money)

Measured memory_bytes: 27328
n = int(input())
ans, q = 0, ["3", "5", "7"]

while q:
    p = q.pop()
    for s in ["3", "5", "7"]:
        t = p + s
        if int(t) <= n:
            q.append(str(t))
            if len(list(set(list(str(t))))) == 3:
                ans += 1

print(ans)

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll a, b;
  cin >> a >> b;
  ll sum = a + b;
  if (sum & 1) cout << "IMPOSSIBLE\n";
  else cout << sum / 2 << endl;
  return (0);
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
b=sum(a)
flg=True
for i in range(m):
    if a[i]<b/(4*m):
        flg=False
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9084
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, M int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &M)

	edges := make(map[int][]int)
	redges := make(map[int][]int)
	inCnt := make(map[int]int)
	for i := 0; i < N-1+M; i++ {
		var from, to int
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &from, &to)
		edges[from] = append(edges[from], to)
		redges[to] = append(redges[to], from)
		inCnt[to]++
	}

	root := -1
	for i := 1; i <= N; i++ {
		if inCnt[i] == 0 {
			root = i
			break
		}
	}

	tpsorted := make([]int, 0)
	workList := make([]int, 0)
	left, right := 0, 0
	workList = append(workList, root)
	right++
	for left < right {
		// remove node
		node := workList[left]
		left++
		// add node
		tpsorted = append(tpsorted, node)
		for _, to := range edges[node] {
			inCnt[to]--
			if inCnt[to] == 0 {
				workList = append(workList, to)
				right++
			}
		}
	}

	node2order := make(map[int]int)
	for i, node := range tpsorted {
		node2order[node] = i
	}

	var buffer bytes.Buffer
	for i := 1; i <= N; i++ {
		if i == root {
			buffer.WriteString("0\n")
		} else if len(redges[i]) == 1 {
			buffer.WriteString(strconv.Itoa(redges[i][0]))
			buffer.WriteString("\n")
		} else {
			tmpOrder := -1
			tmpNode := -1
			for _, from := range redges[i] {
				order := node2order[from]
				if order > tmpOrder {
					tmpOrder = order
					tmpNode = from
				}
			}
			buffer.WriteString(strconv.Itoa(tmpNode))
			buffer.WriteString("\n")
		}
	}
	fmt.Println(buffer.String())
}


Measured memory_bytes: 39936
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(register int i = x; i <= y; i ++)
#define rrep(i, x, y) for(register int i = x; i >= y; i --)
#define eps 1e-8
#define lb(x) x & -x
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 19;
const int L = 65600;
const int mod = 1e9 + 7;
int n, m, a[N], f[N][L];
ll js[L], inv[L];
int cnt[L];
 
ll dec(ll x,ll y)
{
	return x < y ? x - y + mod : x - y;
}
ll add(ll x,ll y)
{
	return x + y >= mod ? x + y - mod : x + y;
}
 
int main()
{
	n = read();
	m = read();
	rep(i, 1, m) a[i] = read();
	js[0] = inv[0] = inv[1] = 1;
	rep(i, 1, 1 << n) js[i] = js[i - 1] * i % mod;
	rep(i, 2, 1 << n) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	rep(i, 2, 1 << n) inv[i] = inv[i] * inv[i-1] % mod;
	f[m + 1][0] = 1;
	sort(a + 1, a + 1 + m);
	rrep(i, m, 1)
	{
		rep(j, 0, (1 << n) - 1)
			if (f[i + 1][j])
			{
				rep(x, 0, n - 1)
				if (((1 << x) & j) == 0 && (j + (1 << x) <= (1 << n) - a[i] + 1))
					f[i][j | (1 << x)] = add(f[i][j | (1 << x)], 1ll * f[i + 1][j] * (1 << x) % mod * js[(1 << n) - a[i] - j] % mod * inv[(1 << n) - a[i] - j - ((1 << x) - 1)] % mod);
				f[i][j] = add(f[i][j], f[i + 1][j]);
			}
	}
	rep(i, 1, (1 << n) - 1) cnt[i] = cnt[i - (i & -i)] + 1;
	ll ans=0;
	rep(i, 0, (1 << n) - 1)
	{
		ll v = f[1][i];
		v = v * js[(1 << n) - i - 1] % mod;
		if (cnt[i] % 2 == 0) ans = add(ans, v);
		else ans = dec(ans, v);
	}
	ans = ans * (1 << n) % mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6144
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort()
    ans = 0
    for i in range(n-2):
        a = l[i]  # 最小の辺の長さ
        for j in range(i + 1, n-1):
            b = l[j]  # 真ん中の辺の長さ
            ans += bisect_left(l, a+b) - j - 1
    print(ans)

if __name__ == '__main__':
    main()

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

die = True
for i in range(N-1):
    if A[i] < A[i+1]:
        die = False
        break
if die:
    print(1000)
    exit()

ud = [(0, A[0])]
for i in range(N-1):
    if A[i] < A[i+1]:
        ud.append((1, A[i+1]))
    elif A[i] > A[i+1]:
        ud.append((-1, A[i+1]))

hold = 0
hand = 1000
for i in range(len(ud)-1):
    if ud[i][0] == 0 and ud[i+1][0] == 1:
        buy = hand // ud[i][1]
        hold += buy
        hand -= buy * ud[i][1]
    if ud[i][0] == 0 and ud[i+1][0] == -1:
        pass
    if ud[i][0] == -1 and ud[i+1][0] == 1:
        buy = hand // ud[i][1]
        hold += buy
        hand -= buy * ud[i][1]
    if ud[i][0] == -1 and ud[i+1][0] == -1:
        pass
    if ud[i][0] == 1 and ud[i+1][0] == 1:
        pass
    if ud[i][0] == 1 and ud[i+1][0] == -1:
        hand += hold * ud[i][1]
        hold = 0
if hold:
    hand += hold * ud[-1][1]
    hold = 0
print(hand)

Measured memory_bytes: 9320
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, mm, tmp1, tmp2;
	cin >> nn >> mm;
	bool memo1[nn], memo2[nn];
	for(int64 ii = 0;ii < nn;ii++)
	{
		memo1[ii] = false;
		memo2[ii] = false;
	}
	for(int64 ii = 0;ii < mm;ii++)
	{
		cin >> tmp1 >> tmp2;
		tmp1--;
		tmp2--;
		if(tmp1 == 0)
		{
			memo1[tmp2] = true;
		}
		if(tmp2 == nn - 1)
		{
			memo2[tmp1] = true;
		}
	}
	for(int64 ii = 1;ii < nn - 1;ii++)
	{
		if(memo1[ii] && memo2[ii])
		{
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,a;
	cin>>x>>y;
	for(a=x;a>=0;a--){
		if(4*a+2*(x-a)==y){
			cout<<"Yes";
			return 0;
		}
		else continue;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
const int N=1e5+7;
int ans[N];
int score;

void solve(){
    int n,k,q;cin>>n>>k>>q;
    rep(i,q){
        int tmp;cin>>tmp;
        ans[tmp]++;
    }
    rep1(i,n){
        if(q-ans[i]>=k) cout<<"No\n";
        else cout<<"Yes\n";
    }
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 1024
n,p=map(int,input().split())
if n==1:
    print(p)
    exit()
a=1
for i in range(2,int(p**0.5)+2):
  if p%i==0:
    c=0
    while p%i==0:
      p//=i
      c+=1
    a*=max(i**(c//n),1)
  if p==1:
    break
print(a)


Measured memory_bytes: 40044
#include <iostream>
using namespace std;
int main(void){
    int S;
    int h;
    int m;
    int s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600)/ 60;
    s = (S % 3600) % 60;
    cout << h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x,k,d;
  cin>>x>>k>>d;
  x = abs(x);
  ll q = x / d;
  if (k <= q) {
    x -= k * d;
    cout << x << endl;
    return 0;
  }
  k -= q;
  x -= q * d;
  k %= 2;
  if (k) {
    x -= d;
    x = abs(x);
  }
  cout<<x<<endl;
  return 0;
}


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

int main(){
    int n[3],count=0; cin>>n[0]>>n[1]>>n[2];
    sort(n,n+3);
    int d1=n[2]-n[0];
    int d2=n[2]-n[1];
    if((d2-d1)%2==0){
        count=d1+(d2-d1)/2;
    }
    if((d2-d1)%2!=0){
        if(n[2]%2==n[0]%2){
            count=d1+1+(d2-d1+1)/2;
        }
        else{
            count=d1+1+(d2-d1)/2;
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int gcd(int a,int b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int main(){
	int q;
	cin>>q;
	while(q--){
		int n;
		cin>>n;
		vvi in(n);
		vi tmp;
		rep(i,n){
			string s;
			cin>>s;
			int N=s.size();
			tmp=vi(N/2);
			int gc=N/2;
			rep(j,N/2){
				tmp[j]=(s[2*j]-'0')*16+(s[2*j+1]-'0');
				if(j&&tmp[j])gc=gcd(gc,j);
			}
			for(int j=0;j<N/2;j+=gc)in[i].pb(tmp[j]);
		}
		int lc=1;
		rep(i,n){
			lc=lcm(lc,in[i].size());
			if(lc>1024)break;
		}
		if(lc>1024)cout<<"Too complex."<<endl;
		else{
			vi out(lc);
			rep(i,n){
				int t=lc/in[i].size();
				for(int j=0;j<lc;j+=t)out[j]|=in[i][j/t];
			}
			rep(i,lc)printf("%02X",out[i]);
			cout<<endl;
		}
	}
}

Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
ll n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=0;;i++)
        if((1ll<<i)>m/n) {printf("%d\n",i);break;}
    return 0;
}


Measured memory_bytes: 256
function main(input) {
   input = input.trim();
  const a = input.split(" ").map(Number);

  console.log(a[0] % 2 ==1 ?Math.floor(a[0]/2+1)/a[0] : 0.5);
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a, b;cin>>a>>b;
	b.pop_back();
	cout<<(a==b?"Yes":"No")<<endl;
	return 0;
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
void visit(const vector<vi> &g, int v, vector< vector<int> >& scc,
    stack<int> &S, vector<bool> &inS,
    vector<int> &low, vector<int> &num, int& time) {
  low[v] = num[v] = ++time;
  S.push(v); inS[v] = true;
  for(int e : g[v]) {
    int w = e;
    if (num[w] == 0) {
      visit(g, w, scc, S, inS, low, num, time);
      low[v] = min(low[v], low[w]);
    } else if (inS[w])
      low[v] = min(low[v], num[w]);
  }
  if (low[v] == num[v]) {
    scc.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      scc.back().push_back(w);
      if (v == w) break;
    }
  }
}
vector<vi> stronglyConnectedComponents(const vector<vi>& g) {
  const int n = g.size();
  vector<int> num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
	vector<vi> scc;
  int time = 0;
  rep(u, n) if (num[u] == 0)
    visit(g, u, scc, S, inS, low, num, time);
	return scc;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	vector<vi> e;
	vi in, out;
	{
		int n, m; cin >> n >> m;
		vector<vi> g(n);
		rep(i, m){
			int a, b; cin >> a >> b;
			g[a].pb(b);
		}
		vector<vi> scc = stronglyConnectedComponents(g);
		e.resize(scc.size());
		in.resize(scc.size());
		out.resize(scc.size());
		vi to(n);
		rep(i, scc.size()) for(int j : scc[i]) to[j] = i;
		rep(i, n) for(int j : g[i]){
			int a = to[i], b = to[j];
			if(a == b) continue;
			e[a].pb(b);
			out[a]++;
			in[b]++;
		}
	}
	if(e.size() == 1){
		cout << 0 << endl;
		return 0;
	}
	int x = 0, y = 0;
	rep(i, in.size()){
		if(in[i] == 0) x++;
		if(out[i] == 0) y++;
	}
	cout << max(x, y) << endl;
	
	return 0;
}


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

int main(){
    int n; cin>>n;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin>>s[i];
    int m; cin>>m;
    vector<string> t(m);
    for(int i=0; i<m; i++) cin>>t[i];
    int ans = 0;
    for(int i=0; i<n; i++) {
        int res = 0;
        for(int j=0; j<n; j++) {
            if(s[i] == s[j]) res++;
        }
        for(int j=0; j<m; j++)  {
            if(s[i] == t[j]) res--;
        }
        ans = max(res,ans);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

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

    std::vector<int> vec(n);
    for(int i = 0; i < n; ++i){
        std::cin >> vec.at(i);
    }

    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    
    std::cout << vec.size() << std::endl;

    return 0;
}


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


int main(){
  int n;
  char s[10010];
  scanf("%d %s",&n,s);
  
  int len = strlen(s);
  for(int i=0;i<len;i++){
    int x = s[i] - 'A';
    x = (x+n)%26;
    putchar('A'+x);
  }
    putchar('\n');
}

Measured memory_bytes: 128
#include<stdio.h>
int n,m;
char t[11][11];
char s[11][11];
bool process(){
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			t[i][j] = '.';
	int x = 0, y = 0;
	while(1){
		t[x][y] = '#';
		if(x==n-1 && y == m-1)break;
		if(x<n-1 && s[x+1][y] == '#')
			x++;
		else
		if(y<m-1 && s[x][y+1] == '#')
			y++;
		else
			return false;
	}
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			if(s[i][j]!=t[i][j])
				return false;
	return true;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0; i<n; i++)
		scanf("%s",s[i]);
	puts(process()?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin>>n;
    long long ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=(long long)(1e9+7);
    }
    cout<<ans<<endl;
}


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

int num(int n){
  if(n==2){
    return 1;
  }
  else if(n==4||n==6||n==9||n==11){
    return 2;
  }
  else{
    return 3;
  }
}
   
  
int main(){
  int a,b;
  cin >> a >> b;
  if(num(a)==num(b)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    for a in A[::2]:
        if a % 2 == 1:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61772
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
  #ifdef LOCAL
      input_from_file;
      output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    vector< pii > vec;
    int a;
    for(int i=1;i<=n;i++)
    {
      cin>>a;
      vec.pb(mp(a,i));
    }
    sort(vec.begin(),vec.end());
    for(auto it : vec)
    {
      cout<<it.se<<" ";
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()
#define mod 1e9+7

using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using P = pair<int,int>;

main()
{
        double n; cin>>n;
        cout<<(long)ceil(n/2)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int n;

scanf("%d",&n);
int x;
for(int i=0;i<n;i++)
{scanf("%d",&x);
int c=0;int d=10;int w=0,y=0;int max=0;
while(x/10!=0){
for(int j=0;j<6;j++)
{
w=x/d;y=x%d;d*=10;
if(j==0)max=w*y;
else if(w*y>max)max=w*y;}
x=max;c++;d=10;}
printf("%d\n",c);
}
return 0;
}

Measured memory_bytes: 1028