akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 2e5+8;
int n;
vector<int> adj[MAX];
vector<char> color;
vector<int> parent;
int cycle_start, cycle_end;

bool dfs(int v) {
    color[v] = 1;
    for (int u : adj[v]) {
        if (color[u] == 0) {
            parent[u] = v;
            if (dfs(u))
                return true;
        } else if (color[u] == 1) {
            cycle_end = v;
            cycle_start = u;
            return true;
        }
    }
    color[v] = 2;
    return false;
}

void find_cycle(ll x) {
    color.assign(n+1, 0);
    parent.assign(n+1, -1);
    cycle_start = -1;

    for (int v = 0; v < n; v++) {
        if (color[v] == 0 && dfs(v))
            break;
    }
        vector<int> cycle;
        cycle.push_back(cycle_start);
        for (int v = cycle_end; v != cycle_start; v = parent[v])
            cycle.push_back(v);
        cycle.push_back(cycle_start);
    int curr=1;
    vector<int>cycle2;
    while(curr!=cycle_start){
            cycle2.push_back(curr);
            curr=adj[curr][0];
            if(curr==cycle_start)break;
    }
    //if(!cycle2.empty())reverse(cycle2.begin(),cycle2.end());
    reverse(cycle.begin(), cycle.end());
    if(cycle.size()>1)cycle.pop_back();
//    cout<<"c2: ";
//    for(auto x:cycle2)cout<<x<<" ";
//    cout<<endl;
//    cout<<"c1: ";
//    for(auto x:cycle)cout<<x<<" ";
//    cout<<endl;
    if(x<cycle2.size()){
            cout<<cycle2[x]<<endl;
            return;
    }
    else{
        x-=cycle2.size();
    }
    if(cycle.size()==1){cout<<cycle[0];return;}
    int sz = cycle.size();
    x%=(sz);
    cout<<cycle[x]<<endl;
}
int main (){
    ll k;
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        int v;cin>>v;
        adj[i].push_back(v);
    }
    find_cycle(k);
    return 0;
}
/*
4 1
3 2 4 1
4 2
3 2 4 1
4 3
3 2 4 1
4 4
3 2 4 1
4 5
3 2 4 1
4 6
3 2 4 1

6 1
6 5 2 5 3 2
*/


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

using namespace std;

int main(void){
	string p,tmpstr;
	int n,ret=0;
	string str;
	cin >> p;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> tmpstr;
		str = tmpstr;
		str += tmpstr;
		for(int j=0;j<str.size()/2;j++){
			bool isok = true;
			for(int k=0;k<p.size();k++){
				if(str[j+k] != p[k]){
					isok = false;
				}
			}
			if(isok){
				ret++;
				break;
			}
		}

	}
	cout << ret << endl;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

i32 n;

void dfs(string ans = "", i32 d = 0, i32 use = 0) {
    if (d == n) {
        cout << ans << endl;
        return;
    }

    for (i32 i = 0; i <= min(d, use); i++) {
        dfs(ans + (char) ('a' + i), d + 1, use + (i == use));
    }
}

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


Measured memory_bytes: 1664
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n,b;
cin>>n>>b;
if((n+b)%2==0)
    c((n+b)/2);
else
    cout<<"IMPOSSIBLE\n";
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


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

int main(){

  int N,i, red=0, blue=0;
  char s[100];


  scanf("%d",&N);

  //for (i = 0; i < N; i++)
	  scanf("%s", &s);

	  for (i = 0; i < N; i++)
	  if (s[i]=='R'){
		  red++;
	  }
	  else{
		  blue++;
	  }

	  if (red>blue){
		  printf("Yes");
	  }
	  else{
		  printf("No");
	  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    int a[15];
    int i, j;
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    long long int ans = 999999999999999;
    int bit;
    int a_temp[15];
    int can_see = 0;
    int maxh = 0;
    long long int cost;
    for(bit = 0; bit < (1 << n); ++bit){
        cost = 0;
        can_see = 0;
        for(i = 0; i < n; i++){
            a_temp[i] = a[i];
        }
        for(i = 0; i < n; i++){
            if(bit & (1 << i)){
                can_see++;
                //0番目から(i-1)番目までの建物の高さの最大値を求める
                //ただしi = 0のときは0
                maxh = 0;
                for(j = 0; j <= i - 1; j++){
                    maxh = maxh > a_temp[j] ? maxh : a_temp[j];
                }
                //i番目の高さをmaxh+1以上にする
                if(a_temp[i] < maxh + 1){
                    cost += maxh + 1 - a_temp[i];
                    a_temp[i] = maxh + 1;
                }
            }
        }
        if(can_see >= k){
            ans = ans < cost ? ans : cost;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  long long ans = 0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      ans += a[i] * a[j];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int d[10];

bool dfs(int left, int right, int i)
{
    if(i==10){
        return true;
    }
    bool res=false;
    if(d[i]>left)res=res | dfs(d[i], right, i+1);
    if(d[i]>right)res=res | dfs(left, d[i], i+1);
    return res;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++)cin>>d[j];
        if(dfs(-1, -1, 0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}



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

using namespace std;

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

	int w[n], v[n];
	for(int i=0; i<n; i++)
		scanf("%d %d", &w[i], &v[i]);

	long long dp[n][W+1];
	memset(dp, 0, sizeof(dp));

	for(int i=w[0]; i<=W; i++) {
		dp[0][i] = v[0];
	}

	for(int i=1; i<n; i++) {
		for(int rw = 0; rw <= W; rw++) {
			dp[i][rw] = dp[i-1][rw];
			if(rw >= w[i])
				dp[i][rw] = max(dp[i][rw], v[i] + dp[i-1][rw-w[i]]);
		}
	}

	// printing the table
	// for(int i=0; i<n; i++) {
	// 	for(int rw=0; rw <= W; rw++) {
	// 		printf("%lld ", dp[i][rw]);
	// 	}
	// 	printf("\n");
	// }

	printf("%lld\n", dp[n-1][W]);

	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007LL;

ll ipow(ll base, ll exp)
{
    ll result = 1LL;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

struct DisjointSet {
    vector<int> parent, rank, size;
    DisjointSet(int n) : parent(n), rank(n, 1), size(n, 1) {
        for(int i = 0; i < n; ++i) 
            parent[i] = i;
    }

    int find(int u) {
        if(u == parent[u]) return u;
        return parent[u] = find(parent[u]);
    }

    void merge(int u, int v) {
        u = find(u); v = find(v);
        if(u == v) return;
        if(rank[u] > rank[v]) swap(u, v);
        parent[u] = v;
        if(rank[u] == rank[v]) ++rank[v];
        size[v] += size[u];
    }
};

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a%b);
}
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;
int n;
vi a;
vi g;
vi rg;

int main(void) {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    cin >> n;
    a.resize(n);
    g.resize(n);
    rg.resize(n);
    rep(i,0,n) {
        cin >> a[i];
    }
    rep(i,0,n) {
        if(i == 0) {
            g[i] = a[i];
            rg[n-1-i] = a[n-1-i];
            continue;
        }
        g[i] = gcd(a[i], g[i-1]);
        rg[n-1-i] = gcd(a[n-1-i], rg[n-1-i+1]);
    }

    int ret = 0;
    rep(i,0,n) {
        if(i == 0) {
            ret = max(ret, rg[1]);
            continue;
        } 
        if(i == n-1) {
            ret = max(ret, g[n-2]);
            continue;
        }
        ret = max(ret, gcd(g[i-1],rg[i+1]));
    }
    cout << ret << endl;
    return 0;
}


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

int main()
{
	int h, w;
	std::cin >> h >> w;
	std::vector<std::string> ss(h);
	for (int i = 0; i < h; ++i) {
		std::cin >> ss[i];
	}

	const std::vector<int> dx = { 1, 0, -1,  0, 1,  1, -1, -1};
	const std::vector<int> dy = { 0, 1,  0, -1, 1, -1,  1, -1 };

	std::vector<std::vector<int> > mat(h, std::vector<int>(w, 0));
	for (int irow = 0; irow < h; ++irow) {
		for (int jcol = 0; jcol < w; ++jcol) {
			if (ss[irow][jcol] == '#') continue;
			int cnt = 0;
			for (int i = 0; i < 8; ++i) {
				const int currx = irow + dx[i];
				const int curry = jcol + dy[i];
				if (currx < 0 || currx >= h) continue;
				if (curry < 0 || curry >= w) continue;
				if (ss[currx][curry] == '#') ++cnt;
			}
			ss[irow][jcol] = char('0' + cnt);
		}
	}

	for (int i = 0; i < h; ++i) {
		std::cout << ss[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long cnt[100001];
int main(){
  long long n,k;
  cin>>n>>k;
  int a,b;
  for(int i=0;i<n;++i){
    cin>>a>>b;
    cnt[a]+=b;
  }
  long long sum=0;
  for(int i=1;sum<k;++i){
    if(sum+cnt[i]>=k){
      cout<<i<<endl;
      break;
    }
    sum+=cnt[i];
  }
  return 0;
}


Measured memory_bytes: 1024
var
    a,b,c,i,ans:longint;
    a1:array[1..100000]of longint;
begin
    read(a,b,c);
    for i:=1 to a do
    begin
        read(a1[i]);
        if(a1[i]<b)or(a1[i]>=c)then inc(ans);
    end;
    writeln(ans);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  long long k;
  cin>>k;
  long long n = 50;
  vector<long long> ans(n);
  for(long long i=0;i<n;i++){
    ans[i] = i;
  }
  long long loop = k/n;
  long long rest = k%n;
  for(long long i=0;i<n;i++){
    ans[i] += loop;
  }
  for(long long i=0;i<rest;i++){
    ans[i] += n;
    ans[i] -= rest-1;
  }
  for(long long i=rest;i<n;i++){
    ans[i] -= rest;
  }
  
  cout<<n<<endl;
  for(long long i=0;i<n;i++){
    cout<<ans[i]<<' ';
  }
  cout<<endl;
  return 0;
}


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

dic = {}
for a in A:
    for i in [-1,0,1]:
        dic[a+i] = dic.get(a+i,0) + 1

m = 0
ans = 0
for d in dic:
    if dic[d] > m:
        ans = d
        m = dic[d]
print(m)


Measured memory_bytes: 62892
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll solve(ll x){
    ll ans=0;
    for(int i=1;i<=10;i++){
        ll n=x*i;
        ans+=(x%10);
    }
    return ans;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    long double A[n];
    for(int i=0;i<n;i++)cin>>A[i];
    sort(A,A+n);
    long double x=A[0];
    for(int i=1;i<n;i++){
        x=(x+A[i])/2;
    }
    cout<<fixed<<setprecision(10)<<x;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map> 
#include <cmath> 
using namespace std;
// typedef pair<int, int> P;
typedef long long ll;

long long *L = new long long[200001];
long long *R = new long long[200001];

int main() {
    int N;
    cin >> N;
    map<long long, long long> mp; 
    for(int i=1;i<N + 1;i++){
        long long a;
        cin >> a;
        L[i] = i + a;
        R[i] = i - a;
    }
    ll cnt = 0;
    for(int i=1;i<N+1;i++){
        // auto itr = mp.find(L[i]);
        // if( itr != mp.end() ) {
        //     mp[L[i]] = itr->second + 1;
        // }else{
        //     mp[L[i]] = 1;
        // }
        mp[L[i]]++;
        // itr = mp.find(R[i]);
        // if( itr != mp.end() ) {
        //     cnt += itr->second;
        // }
        cnt += mp[R[i]];
    }
    // for(int i=1;i<N+1;i++){
    //     auto itr = mp.find(R[i]);
    //     if( itr != mp.end() ) {
    //         cnt += itr->second;
    //     }
    // }
    
    cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 29436
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
ostream& operator << (ostream& out, vector<int>& v) {
	for (auto& x: v) out << x << ' ';
	return out;
}

ostream& operator << (ostream& out, pii& v) {
	out << v.fi << ", " << v.se;
	return out;
}

istream& operator >> (istream& in, pii& a) {
	in >> a.fi >> a.se;
	return in;
}

const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin >> s;
	fr (i, sz (s) - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << ' ' << i + 2 << '\n';
			exit (0);
		}
	}
	fr (i, sz (s) - 2) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << ' ' << i + 3 << '\n';
			exit (0);
		}
	}
	cout << -1 << ' ' << -1 << '\n';






}

Measured memory_bytes: 3780
//https://atcoder.jp/contests/abc125/tasks/abc125_c
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

std::vector<int> seg;
int M=1;
int N;
int gcd(int a, int b){
  if(a==-1) return b;
  if(b==-1) return a;
  if(b>a) swap(a, b);
  int r = a%b;
  if(r==0) return b;
  while(r!=0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
void init(int N){
  while(M<N) M*=2;
  M=M*2-1;
  for(int i=0;i<M;i++) seg.push_back(-1);
}
void update(int a, int k){
  k += (M+1)/2-1;
  seg[k]=a;
  while(k>0){
    k=(k-1)/2;
    seg[k]=gcd(seg[k*2+1], seg[k*2+2]);
  }
}
int query(int a, int b, int l, int r, int k){
  //std::cout << l << r << k << '\n';
  if(r<=a||b<=l) return -1;
  if(a<=l&&r<=b) return seg[k];
  int Aq = query(a, b, l, (l+r)/2, k*2+1);
  int Bq = query(a, b, (l+r)/2, r, k*2+2);
  return gcd(Aq, Bq);
}
int main(int argc, char const *argv[]) {
  std::cin >> N;
  std::vector<int> A(N);
  init(N);
  for(int i=0;i<N;i++) {
    std::cin >> A[i];
    update(A[i], i);
  }
  int ans = 1;
  for(int i=0;i<N;i++){
    int left = query(0, i, 0, (M+1)/2, 0);
    int right = query(i+1, N, 0, (M+1)/2, 0);
    ans = max(ans, gcd(left, right));
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1784
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;



int N;
LL K;
LL A[1234];
LL R[1234];

bool ok(LL x) {
	for (int i = 0; i < N; ++i) {
		R[i] = A[i] % x;
	}
	LL wrap = 0;
	for (int i = 0; i < N; ++i) {
		wrap += R[i];
	}
	wrap /= x;
	sort(R, R + N);
    int idx = N-1;
	//for (int i = N - 1; i >= 0; --i) {
		while (wrap > 0 && idx > 0) {
			wrap--;
			R[idx] -= x;
            idx--;
		}
	//}
	LL can = 0;
	for (int i = 0; i < N; ++i) {
		can += max(0LL, R[i]);
	}
	return can <= K;
}

int main() {
	cin >> N >> K;
	LL total = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		total += A[i];
	}
	set<LL>yak;
	for (LL i = 1; i * i <= total; ++i) {
		if (total % i == 0) {
			yak.insert(i);
			yak.insert(total / i);
		}
	}
	LL ans = 1;
	for (LL y : yak) {
		if (ok(y)) {
			ans = max(ans, y);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const string YES = "Possible";
const string NO = "Impossible";
vector<vector<int>> vec{{1,0},{0,1}};

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  vector<string> a;
  int h,w;
  cin >> h >> w;
  a.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int l = 0; l < w; l++) {
      if(a[i][l] == '#')ans++;
    }
  }
  cout << (ans==(h+w-1) ? YES : NO) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, K;
  long long S;
  scanf("%d",&N);
  scanf("%d",&K);
  scanf("%lld",&S);
  if (S!=1000000000){
    for (int i=0; i<K; i++){
      std::cout << S << " ";
    }
    for (int i=0; i<N-K; i++){
      std::cout << 1000000000 << " ";
    }
  } else {
    for (int i=0; i<K; i++){
      std::cout << S << " ";
    }
    for (int i=0; i<N-K; i++){
      std::cout << 1 << " ";
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

long int n, a, b;
long int h[100000];


bool C(long int x){
    long int dif = a - b;
    long int del = x;
    for(int i = 0; i < n; i++){
        long int hp = h[i] - x * b;
        if(hp > 0){
            if(hp % dif == 0){
                del -= hp / dif;
            }else{
                del -= hp / dif + 1;
            }
        }
    }
    // cout << del << endl;
    return del >= 0;
}

int main(){
    cin >> n >> a >> b;
    rep(i, n) cin >> h[i];
    long int l = 0;
    long int r = 1000000000;
    while(l < r - 1){
        long int mid = (l + r) / 2;
        if(C(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    if(C(r)){
        cout << r << endl;
    }else{
        cout << l << endl;
    }
}

Measured memory_bytes: 1024
n,k = map(int, input().split( ))
v = list(map(int, input().split( )))
import bisect
ans = 0
for i in range(k):
    for j in range(min(n-i,k-i)+1):#+1
        u = v[:j]+v[n-i:]
        u.sort()
        ind = bisect.bisect_left(u,0)###
        t = min(ind, k-i-j)
        sm = sum(u[t:])
        if ans < sm:
            #print(i,j,t)
            ans = sm
    
print(ans)

Measured memory_bytes: 41960
import sys
from collections import Counter
N,*A = map(int, open(0).read().split())
Cnt = Counter(A)
if Cnt[1]>1:
  if N==2:
    print('Possible')
  else:   
    print('Impossible')
  sys.exit()
m = max(A)
S = set()
for i in range(m):
  S.add(max(m-1-i,i+1))
for a in A:
  if a not in S:
    print('Impossible')
    sys.exit()
for c in S:
  if Cnt[c]==0:
    print('Impossible')
    sys.exit()
n = min(A)
if m%2==1:
  if Cnt[n]!=2:
    print('Impossible')
    sys.exit()
else:
  if Cnt[n]!=1:
    print('Impossible')
    sys.exit()
print('Possible')

Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define oo 9999999987654321LL
#define INT long long
using namespace std;

int n, x, a[300001];
set<int> s;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>x;
    if( x == 1 or x == 2*n-1 )
        cout<<"No"<<endl;
    else
    {
        for(int i = 1 ; i < 2*n ; i++ ) s.insert(i);
        cout<<"Yes"<<endl;
        a[n-2] = x-1, a[n-1] = x, a[n] = x+1;
        s.erase(s.find(x-1)), s.erase(s.find(x)), s.erase(s.find(x+1));
        set<int>::iterator p = s.begin();
        for(int i = 0 ; i < 2*n-1 ; i++ )
        {
            if( n-2 <= i and i <= n ) continue;
            a[i] = *p;
            p++;
        }
        for(int i = 0 ; i < 2*n-1 ; i++ )
            cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11776
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int A, B;
    cin >> A >> B;

    cout << (A > 12 ? B : (A > 5 ? B / 2 : 0)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include<set>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
  string L;
  cin >> L;
  int N = L.size();
  ll dp1[N];
  ll dp2[N];
  dp1[0] = 1;
  dp2[0] = 2;

  REP(i,1,N){
    if(L[i]=='0'){
      dp1[i] = 3 * dp1[i-1];
      dp2[i] = dp2[i-1];
    }else{
      dp1[i] = 3 * dp1[i-1]+dp2[i-1];
      dp2[i] = 2 * dp2[i-1];
    }
    dp1[i] %= MOD;
    dp2[i] %= MOD;
  }
  ll ans = (dp1[N - 1] + dp2[N - 1]) % MOD;
  cout << ans << endl;


}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], fa[N], to[N];
int n, m;
int Find(int x){
    return fa[x] == x ? x : (fa[x] = Find(fa[x]));
}
void Merge(int x, int y){
    x = Find(x), y = Find(y);
    if(x != y) fa[x] = y;
}
bool Same(int x, int y){
    return Find(x) == Find(y);
}
int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i){
        fa[i] = i;
        scanf("%d", a+i);
        to[a[i]] = i;
    }
    for(int i = 1; i <= m; ++i){
        int x, y;
        scanf("%d%d", &x, &y);
        Merge(x, y);
    }
    int ans = 0;
    for(int i = 1;  i<= n; ++i){
        if(a[i] == i){
             ans++;
              continue;
        }
        else{
            if(Same(i, to[i])){
                ans++;
                to[a[i]] = to[i];
                swap(a[i], a[to[i]]);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n,aa[110000][10],k=0,cnt=0,a,b;
pair<int,int> p[220000];
string s,ss[220000],sf,se;
char c;
signed main(){
    cin>>s;
    if(s.size()%2==1){
        cout<<"No";
        return 0;
    }else{
        rep(i,s.size()/2){
            if(s[i*2]!='h'||s[i*2+1]!='i'){
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
}

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

int main() {
    ll n;
    std::cin >> n;
    if( (n/100)*100 <= n && n <= (n/100)*105 ){
        std::cout << 1 << std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
class point{ // as necessary
	public:
		static const int COUNTER_CLOCKWISE=1;
		static const int CLOCKWISE=-1;
		static const int ONLINE_BACK=2;
		static const int ONLINE_FRONT=-2;
		static const int ON_SEGMENT=0;
		static const double EPS=1e-10;
		double x;
		double y;
		point(double x=0,double y=0):x(x),y(y){}

		point operator+(point p){return point(x+p.x,y+p.y);}
		point operator-(point p){return point(x-p.x,y-p.y);}
		point operator*(double a){return point(x*a,y*a);}
		point operator/(double a){return point(x/a,y/a);}

		static double dot(const point &p1,const point &p2){
			return p1.x*p2.x+p1.y*p2.y;
		}

		double norm(){
			return x*x+y*y;
		}

		double abs(){
			return sqrt(norm());
		}

		static double cross(point p1,point p2){
			return p1.x*p2.y-p1.y*p2.x;
		}

		static int ccw(point p0,point p1,point p2){
			point a=p1-p0; // ??????p0p1
			point b=p2-p0; // ??????p0p2
			if(cross(a,b)>EPS) return COUNTER_CLOCKWISE; // a????????????b??????????¨?
			if(cross(a,b)<-EPS) return CLOCKWISE; // a????????????b???????¨?
			if(dot(a,b)<-EPS) return ONLINE_BACK; // p2-p0-p1???????????¢???
			if(a.norm(),b.norm()) return ONLINE_FRONT; // p0-p1-p2???????????¢???
			return ON_SEGMENT; // p0-p2-p1???????????¢???
		}
};

int main(void){
	int n;
	double x,y;
	cin>>n;
	while(n--){
		cin>>x>>y;
		point a(x,y);
		cin>>x>>y;
		point b(x,y);
		cin>>x>>y;
		point c(x,y);
		cin>>x>>y;
		point d(x,y);
		if(fabs(point::cross(b-a,d-c))<point::EPS)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 3148
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  ll r = sqrt(N);
  for (ll i = r; r > 0; --r) {
    if (N % r == 0) {
      out(r + N / r - 2);
      return 0;
    }
  }
  return 0;
}

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

int main(){
  string S , T ; 
  cin >> S >> T ; 
  string U ; 
  
  for(int i = 1 ; i <= S.size() ; i++){
    U = S.substr(S.size()-i,i) + S.substr(0,S.size() - i ) ; 
    //cout << U << endl ;
    if(U == T){
      cout << "Yes" << endl;
      return 0 ; 
    }
  }
  
  cout << "No" << endl ; 
}

Measured memory_bytes: 3600
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i32 = read();
    let k: i32 = read();
    let mut sum = 0_f64;
    for i in 1..(n + 1) {
        let mut j = 0;
        while i * 2_i32.pow(j) < k {
            j += 1;
        }
//        dbg!(i, j);
        sum += (1_f64 / 2_f64).powf(j as f64);
    }
    println!("{}", sum / n as f64)
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]

ans = -1

for x in range(1000):
    if len(str(x)) != N: 
        continue
    else:
        count = 0
        s = str(x)
        for p in P:
            if int(s[int(p[0]) - 1]) == p[1]:
                count += 1
        if count == M:
            ans = x
            break

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;
int main(){
 long long n,m;
 long long i,j,k;
 scanf("%lld%lld",&n,&m);
 long long a[m+1],b[m+1];
 long long num[n+1],ans[n+1];
 bool visited[n+1];
 queue<long long>que;
  
 vector<long long>memo[n+1];
 for(i=0;i<m;i++){
  scanf(" %lld%lld",&a[i],&b[i]);
  memo[a[i]].push_back(b[i]);
  memo[b[i]].push_back(a[i]);
 }
 
 que.push(1);
 for(i=0;i<1+n;i++){
  visited[i]=0;
  ans[i]=0;
  num[i]=100000;
 }
 num[1]=0;
 long long u,v;
 while(!que.empty()){
  u=que.front();
  que.pop();
  visited[u]=1;
  for(i=0;i<memo[u].size();i++){
   v=memo[u].at(i);
   if(num[v]>num[u]+1){
    num[v]=num[u]+1;
    if(!visited[v]){
     ans[v]=u;
     que.push(v);
    }
   }
  }
 }
 puts("Yes"); 
 for(i=2;i<n+1;i++){
  printf("%lld\n",ans[i]);
  }

return 0;}

Measured memory_bytes: 17012
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define v vector
#define len length()
#define fi first
#define se second
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
v<ll> fact;
//factorial
void factorial(ll n)
{
    fact[0] = 1;
    for (ll i = 1; i <=n; i++)
    {
        fact[i] = i * fact[i - 1];
        fact[i] %= M;
    }
}
// modular exponentiation 
ll binpow(ll val, ll deg)
{
    if (!deg)
        return 1 % M;
    if (deg & 1)
        return binpow(val, deg - 1) * val % M;
    ll res = binpow(val, deg >> 1);
    return (res * res) % M;
}
//combination
ll combination(ll n, ll i)
{
    ll res = fact[n]; 
    ll div = fact[n - i] * fact[i];
    div %= M;
    // using fermat little theorum
    div = binpow(div, M - 2); // modular inverse  
    return (res * div) % M; 
}

int main() {
	// your code goes here
	IOS;
	ll n,m,i;
	ll j,t,x,y,z,k,d;
	cin>>n>>m>>k;
	ll a[n+1],b[m+1],s1[n+1]={0},s2[m+1]={0};
	rep(i,n+1) {
	if(i>0){      
	cin>>a[i];
	s1[i]+=s1[i-1]+a[i];
	}
	//cout<<s1[i]<<" ";
	}
	//cout<<endl;
	rep(i,m+1) {
	
	if(i>0){
	cin>>b[i];
	s2[i]+=s2[i-1]+b[i];
	}
	//cout<<s2[i]<<" ";
	}
	ll maxi=0;
	ll count;
	for(i=0;i<=n;i++){
	      count=0;
	      if(s1[i]>k)
	      break;
	      ll rem=k-s1[i];
	      //cout<<i<<"\n";
	      count+=i;
	      ll min=0,max=m,mid,ans;
	      while(min<=max){
	            mid=(min+max)/2;
	            if(s2[mid]<=rem){
	                  min=mid+1;
	                  ans=mid;
	                  
	            }
	            else
	            max=mid-1;
	      }
	      //cout<<ans<<" \n";
	      count+=ans;
	      if(count>maxi)
	      maxi=count;
	}
	cout<<maxi;
	return 0;
}

Measured memory_bytes: 9908
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = 0;
    int i = 0;
    do{
      if(a > b)
        x += a--;
      else
        x += b--;
      i++;
    }while(i != 2);
      
    System.out.println(x);
  }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        
        if(s.length() <= K) {
            System.out.println(s);
        } else {
            System.out.println(s.substring(0,K) + "...");
        }
    }
}

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

int main()
{
	//ofstream fcout;
	//fcout.open("output.txt");
	
    ifstream fcin;
    fcin.open("input.txt"); 

    	int x,y;
    	cin>>x>>y;

    	if(x <= 9 && y <= 9)
    	cout<<x*y<<endl;
        else
        cout<<-1<<endl;

    fcin.close();
	//fcout.close();

	return 0;

}

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

int main(){
	char S[15],T[15],U[15];
	int A,B;
	scanf("%s %s\n",&S,&T);
	scanf("%d %d\n",&A,&B);
	scanf("%s",&U);
	if ((strcmp(U,S)==0)){
		printf("%d %d",A-1,B);
	}
	else if (strcmp(T,U)==0){
		printf("%d %d",A,B-1);
	}
	return 0;
	
}

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

int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a_tmp;
            cin >> a_tmp;
            a[i][a_tmp - 1] = 1;
        }
    }
    int ans = 0;
    rep(i, m) {
        int cnt = 0;
        rep(j, n) {
            if(a[j][i] == 1) cnt++;
        }
        if(cnt == n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[300000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    n *= 3;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);
    reverse(a, a + n);
    ll sol = 0;
    for (int i = 0; i < n; i += 2)
    {
        sol += a[i + 1];
        n--;
    }
    cout << sol;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int f(int x){
    int ret = 0;
    while(x >= 1){
        ret += x % 10;
        x /= 10;
    }
    return ret;
}
int main(void){
    int n;
    cin >> n;
    if(n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

char a[105][105];

int d[105][105];

int dx[] = {0, 1};
int dy[] = {1, 0};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < 105; i++) {
        for (int j = 0; j < 105; j++) {
            d[i][j] = numeric_limits<int>::max();
        }
    }

    deque<pair<int,int>> q;
    q.push_back({1, 1});
    d[1][1] = 0;
    while (!q.empty()) {
        int y, x;
        y = q.front().first;
        x = q.front().second;
        //auto [y, x] = q.front();
        q.pop_front();
        for (int i = 0; i < 2; i++) {
            int yy = y + dy[i];
            int xx = x + dx[i];
            if (yy < 1 || xx < 1 || yy > n || xx > m) continue;
            int dist = d[y][x] + (a[y][x] == a[yy][xx] ? 0 : 1);
            if (dist < d[yy][xx]) {
                if (a[yy][xx] == a[y][x])
                    q.push_front({yy, xx});
                else
                    q.push_back({yy, xx});
                d[yy][xx] = dist;
            }
        }
    }
    cout << d[n][m] / 2 + (a[1][1] == '#' || a[n][m] == '#') << endl;
}

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

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<int> vec1 = {x2-x1, y2-y1};
  vector<int> vec2 = {-(y2-y1), x2-x1};
  vector<int> vec3 = {-(x2-x1), -(y2-y1)};
  
  cout << x2+vec2[0] <<" "<< y2+vec2[1] <<" "<< x1+vec2[0] <<" "<< y1+vec2[1] << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = [i-1 for i in a]
ans = 0
ans += b[a[0]]
prev = a[0]
for i in range(1,n):
    ans+= b[a[i]]
    if prev == a[i]-1:
        ans += c[prev]
    prev = a[i]
print(ans)

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

using namespace std;

int N, M;
pair<int, int> arr[100005];
set<int> st;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    st.insert(-1);
    for(int i = 0; i<M; i++){
        st.insert(i);
    }
    for(int i = 1; i<=N; i++){
        cin >> arr[i].second >> arr[i].first;
    }
    sort(arr+1, arr+1+N, greater<pair<int, int>>());
    long long ans = 0;
    for(int i = 1; i<=N; i++){
        int k = M-arr[i].second;
        if(k < 0){
            continue;
        }
        int p = *(--st.upper_bound(k));
        if(p != -1){
            ans += arr[i].first;
            st.erase(p);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    int n;cin>>n;
    vector<pair<int,pii> >v(0);
    rep(i,n){
        int a,b;cin>>a>>b;
        v.pb(make_pair(a+b,make_pair(a,b)));
    }
    sort(rall(v));
    ll cntt=0,cnta=0;
    rep(i,n){
        if(i%2==0)cntt+=v[i].second.first;
        else cnta+=v[i].second.second;
    }
    cout<<cntt-cnta<<endl;
}

Measured memory_bytes: 1912
open Printf
open Scanf

let solve s t =
  let l = String.length s in
  let rec loop i =
    if i = l then "Yes"
    else if s.[i] = t.[i] then loop (i + 1)
    else "No"
  in loop 0

let () =
  scanf "%s %s " solve |> printf "%s\n"


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") puts("No");
    else puts("Yes");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
        }
}

// 二項係数計算
long long COM(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {
        int n;
        ll k;
        ll ans = 0;
        cin >> n >> k;
        if(k ==1){
                ans = (n*(n-1))%MOD;
        }
        else if(k < n){
                COMinit();
                rep(i,k+1){
                           ans = ( ans + (COM(n-1,i) * COM(n,i))%MOD)%MOD;
                }

        }else{
          COMinit();
          rep(i,n){
            ans = ( ans + (COM(n-1,i) * COM(n,i))%MOD)%MOD;
          }
        }

        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define int unsigned long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int n,k;
int a[N],f[N],inv[N];
const int mod = 1e9+7;

int bin_expo(int num, int exp)
{
	int calc = num, ans = 1;
	while(exp)
	{
		if(exp&1)
			ans = (ans*calc)%mod;
		calc = (calc*calc)%mod;
		exp>>=1;
	}
	return (ans%mod);
}

int32_t main()
{
	fast;

	cin>>n>>k;
	int x = n-k;
	a[1] = x+1;
	f[0] = 1;

	for(int i=1;i<=k;i++)
		inv[i] = bin_expo(i,mod-2);

	for(int i=2;i<=k;i++)
	{
		f[i-1] = (((f[i-2]*(k-i+1))%mod)*inv[(i-1)])%mod;
		a[i] = (((a[i-1]*(x-i+2))%mod)*inv[i])%mod;
	}

	for(int i=1;i<=k;i++)
		cout<<(f[i-1]*a[i])%mod<<endl;
	return 0;
}


Measured memory_bytes: 4352
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22484