akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll roundup(ll a, ll b){
  return (a+b-1)/b;
}

int main(){
  ll n;
  cin >> n;
  ll t,a;
  cin >> t >> a;
  REP(i,n-1){
    ll t1, a1;
    cin >> t1 >> a1;
    ll r = max(roundup(t,t1),roundup(a,a1));
    t = r*t1, a = r*a1;
  }
  cout << t+a << endl;
  return 0;
}


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

#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

class DisjointSet{
    public:
        vector<int> rank, p, num;

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

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
            num[x] = 1;
        }//グループを作る

        bool same(int x, int y){
            return findSet(x) == findSet(y); //x,yが同じグループに属しているか判定
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
            
        }//xとyの属するsetを結合する

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
                num[x] += num[y];
                num[y] = 0;
            }else{
                p[x] = y;
                if( rank[x] == rank[y]){
                    rank[y]++;
                }
                num[y] += num[x];
                num[x] = 0;
            }
        }//rankが大きい方の下にrankが小さいものをくっつける

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }//再帰的にxの親を見つけている

        int size(int x){
            return num[findSet(x)];
        }// xの属する集合の大きさを返す
};
//DisjointSet ds = DisjointSet(V);//初期化の方法

int main(){
    int N, M; cin >> N >> M;
    DisjointSet ds = DisjointSet(N + M);
    for(int i = 0; i < N; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int l; cin >> l; l--;
            ds.unite(i + M, l);
        }
    }
    bool flag = 1;
    for(int i = 1; i < N; i++){
        if(!ds.same(M, M + i)){
            flag = 0;
            break;
        }
    }
    if(flag) puts("YES");
    else puts("NO");

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n, m;
	cin >> n >> m;
	int x[m], y[m], Cmp[n + 1], ans = 1;
	for (int i = 0; i <= n; i++) {
		Cmp[i] = 1;
	}
	bool flag[n + 1] = {};
	flag[1] = true;
	for (int i = 0; i < m; i++) {
		cin >> x[i] >> y[i];
		// cout << "Before:" << endl << "i: " << i << " Cmp[x[i]]: " << Cmp[x[i]] << " Cmp[y[i]]: " << Cmp[y[i]] << " flag[x[i]]: " << flag[x[i]] << " flag[y[i]]: " << flag[y[i]] << " ans: " << ans << endl;
		if (Cmp[x[i]]) {
			if (flag[x[i]]) {
				if (!flag[y[i]]) {
					flag[y[i]] = true;
					ans++;
				}
				if (Cmp[x[i]] == 1) {
					ans--;
					flag[x[i]] = false;
				}
			}
			Cmp[x[i]]--;
			Cmp[y[i]]++;
		}
		// cout << "After:" << endl << "i: " << i << " Cmp[x[i]]: " << Cmp[x[i]] << " Cmp[y[i]]: " << Cmp[y[i]] << " flag[x[i]]: " << flag[x[i]] << " flag[y[i]]: " << flag[y[i]] << " ans: " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

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

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    System.out.println(b % a == 0 ? a + b : b - a);
  }
}

Measured memory_bytes: 21588
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    int n;
    cin>>n;
    string out1=".,!? ";
    string out2="abc";
    string out3="def";
    string out4="ghi";
    string out5="jkl";
    string out6="mno";
    string out7="pqrs";
    string out8="tuv";
    string out9="wxyz";
    for(int s=0;s<n;s++){
        string in;
        cin>>in;
        int cnt=0;
        for(int i=0;i<in.length();i++){
            switch (in[i]-'0') {
                case 0:
                    switch (in[i-1]-'0') {
                        case 1:
                            cout<<out1[(cnt-1)%5];
                            break;
                        case 2:
                            cout<<out2[(cnt-1)%3];
                            break;
                        case 3:
                            cout<<out3[(cnt-1)%3];
                            break;
                        case 4:
                            cout<<out4[(cnt-1)%3];
                            break;
                        case 5:
                            cout<<out5[(cnt-1)%3];
                            break;
                        case 6:
                            cout<<out6[(cnt-1)%3];
                            break;
                        case 7:
                            cout<<out7[(cnt-1)%4];
                            break;
                        case 8:
                            cout<<out8[(cnt-1)%3];
                            break;
                        case 9:
                            cout<<out9[(cnt-1)%4];
                            break;
                        case 0:
                            break;
                    }
                    cnt=0;
                    break;
                default:
                    cnt++;
                    break;
            }
        }
        if(in=="0")cout<<"";
        else cout<<endl;
    }
    return 0;
}

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

int main() {
    ll x;
    cin >> x;
    int n500 = 0, n5 = 0;
    if (x == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (x - 500 >= 0) {
        x -= 500;
        n500++;
    }
    while (x - 5 >= 0) {
        x -= 5;
        n5++;
    }
    cout << n500 * 1000 + n5 * 5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=(int)(3e5)+5;
int a[maxn],vi[maxn];

struct node {
	int x,v;
} p[maxn];

inline bool operator < (node a,node b) {
	return a.v!=b.v?a.v<b.v:a.x<b.x;
}

int main() {
	int n;
	read(n);
	REP(i,1,n) {
		read(p[i].v);p[i].x=i;
	} sort(p+1,p+n+1);
	int now=1;
	REP(i,1,n) {
		int c=p[i].x;
		REP(j,1,p[i].x-1) {
			while(now<p[i].v && vi[now]) now++;
			if(now>=p[i].v || vi[now]) {
				printf("No\n");return 0;
			} a[now]=c;vi[now]=1;now++;
		} a[p[i].v]=c;vi[p[i].v]=1;
	}
	now=n*n;
	PER(i,n,1) {
		int c=p[i].x;
		REP(j,1,n-p[i].x) {
			while(now>p[i].v && vi[now]) now--;
			if(now<=p[i].v || vi[now]) {
				printf("No\n");return 0;
			} a[now]=c;vi[now]=1;now--;
		}
	}
	printf("Yes\n");
	REP(i,1,n*n) printf("%d ",a[i]);putchar('\n');
	return 0;
}

Measured memory_bytes: 3072
use std::io;


fn main() {
    let n = read_one::<String>().chars().collect::<Vec<char>>();
    let mut cnt = 0;
    for c in n {
        if c == '2' { cnt += 1; }
    }
    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

const int MAX_N=1e6,MAX_A=1e5;

typedef long long ll;

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

int N;
int a[MAX_N];

ll sum[MAX_N+1];

int main(){
	do{
		scanf("%d",&N);
		if (N){
			REP(i,N){
				scanf("%d",&a[i]);
			}
			ll ma=-MAX_A;
			sum[0]=0;
			REP(i,N){
				sum[i+1]=sum[i]+a[i];
			}
			REP(i,N){
				FOR(j,i,N){
					ma=max(ma,sum[j+1]-sum[i]);
				}
			}
			printf("%lld\n",ma);
		}
	}while(N);
	return 0;
}

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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  
  ll res=0,sum=0;
  int r=0;
  rep(l, n) {
    while (r<n&&(sum^a[r])==(sum+a[r])) {
      sum+=a[r];
      ++r;
    }
    res+=r-l;
    if (r==l) r++;
    else sum-=a[l];
  }
  cout<<res<<endl;
}

Measured memory_bytes: 1024
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e9 + 5, NMAX = 1e6 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

signed main() {
    fast_work
    string s, t;
    cin >> s >> t;

    int answer = t.size();

    for(int i = 0; i +t.size() - 1 < s.size(); ++i) {
        int ans = 0;
        for(int j = 0; j < t.size(); ++j) if(s[i + j] != t[j]) ++ans;

        answer = min(ans, answer);
    }

    cout << answer;
}


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

int main(){
  
  int n;
  int sum1=0;
  int sum2=0;
  int a,b;
  cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v.at(i);
    sum1+=v.at(i);
  }
  rep(i,n){
    b=sum1-sum2;
    sum1-=v.at(i);
    sum2+=v.at(i);
    
    if(sum2>=sum1){
      a=sum2-sum1;
      break;
    }
  }
  cout<<min(a,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
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(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      if (res.size() == 0 || res.back() != f[x])
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};
int n;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main() {
  cin >> n;
  vi A(n);
  rep(i,n) cin >> A[i];
  Sieve sieve(1e6+1);
  bool pairwise = true;
  vector<bool> fac(1e6+10);
  [&]{
    rep(i,n) {
      vi list = sieve.factorList(A[i]);
      for (ll num: list) {
        if (fac[num]) {
          pairwise = false;
          return;
        }
        fac[num] = true;
      }
    } 
  }();
  if (pairwise) {
    puts("pairwise coprime");
    return 0;
  }
  ll now = A[0];
  rep2(i,1,n) {
    now = gcd(now, A[i]);
  }
  if (now == 1) {
    puts("setwise coprime");
    return 0;
  }
  puts("not coprime");
  return 0;
}

Measured memory_bytes: 11712
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    unordered_map<char,long long> D;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M'||s[0]=='A'||s[0]=='R'||s[0]=='C'||s[0]=='H'){
            D[s[0]]++;
        }
    }
    long long a=D['M'],b=D['A'],c=D['R'],d=D['C'],e=D['H'];
    long long res = 0;
    res += a*b*c;
    res += a*b*d;
    res += a*b*e;
    res += a*c*d;
    res += a*c*e;
    res += a*d*e;
    res += b*c*d;
    res += b*c*e;
    res += b*d*e;
    res += c*d*e;
    cout<<res<<endl;
}

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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;

    for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
        // (0,0)からの移動距離
        int step = h + w;
        // step が奇数であれば "." を出力
        if (step - (step / 2) * 2 == 1)
          cout << ".";
        else
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



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

int main(){
	int n;
	while( cin >> n, n ){
		int a[101], key;
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i];
		}
		cin >> key;
		
		int low = 0, high = n-1, mid, cnt = 0;
		while( low <= high ){
			cnt++;
			mid = (low + high) / 2;
			
			if( a[mid] == key ){
				break;
			}else if( a[mid] < key ){
				if( low == mid+1 ) break;
				low = mid+1;
			}else{
				if( high == mid-1 ) break;
				high = mid-1;
			}
		}
		cout << cnt << endl;
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define FOR(i,a,b) for (int i=a;i<b;i++)
#define fi first
#define se second
#define pb push_back

int n;
pii points[1005];
int arr[1005];

vector<LL> powers;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    FOR(i,1,n+1) cin >> points[i].fi >> points[i].se;
    FOR(i,1,n+1){
        arr[i] = ((((points[i].fi + points[i].se)%2)+4)%2);
    }
    FOR(i,2,n+1){
//cout << arr[i] << ":";
        if (arr[i] != arr[i-1]){
            puts("-1");
            return 0;
        }
    }
    if (arr[1] == 0) powers.pb(1);
    for (LL k = 1; k <= 2e9; k<<=1) powers.pb(k);
    reverse(powers.begin(), powers.end());

    cout << powers.size() << '\n';
    for (int i = 0; i < powers.size(); i++){
	cout << powers[i] << (i == powers.size() - 1 ? '\n' : ' ');
    }
    for (int i = 1; i <= n; i++){
	for (int j = 0; j < powers.size(); j++){
	    if (abs(points[i].fi) >= abs(points[i].se)){
		if (points[i].fi < 0){
		    cout << 'L';
		    points[i].fi += powers[j];
		} else {
		    cout << 'R';
		    points[i].fi -= powers[j];
		}
	    } else {
		if (points[i].se < 0){
		    cout << 'D';
		    points[i].se += powers[j];
		} else {
		    cout << 'U';
		    points[i].se -= powers[j];
		}
	    }
	}
	cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


n, k = nm()
k -= 1
S = list(input())
S[k] = S[k].lower()
print(''.join(S))

Measured memory_bytes: 9124
n, m = map(int, input().split())

s = [0] * n
s[0] = 1
b = [1] * n
for i in range(m):
    x, y = map(int, input().split())
    if s[x-1]:
        s[y-1] = 1
    if b[x-1] == 1:
        s[x-1] = 0
    b[x-1] -= 1
    b[y-1] += 1

ans = 0
for i in range(n):
    if s[i] and b[i]:
        ans += 1

print(ans)


Measured memory_bytes: 4596
// 164 B

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl; 
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c=1;cin>>a>>b;
  c=b;
  rep(i,a-1){
    c*=b-1;
  }
  cout<<c;
}



Measured memory_bytes: 26988
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;

  if (B%A == 0)
  {
    cout << A + B << endl;
  }
  else
  {
    cout << B - A << endl;
  }
}

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

signed main(){
  int K;
  cin>>K;
  int ans=(K/2)*((K+1)/2);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<char>() );
	if(s<t)cout<<"Yes"<<endl;
	if(s>=t)cout<<"No"<<endl;

	return 0;
}


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

int main(void){
   int N;
   cin>>N;
   int ans=N%10;
   if(ans==2||ans==4||ans==5||ans==7||ans==9){
      cout<<"hon"<<endl;
   }else if(ans==0||ans==1||ans==6||ans==8){
      cout<<"pon"<<endl;
   }else{
      cout<<"bon"<<endl;
   }
   return 0;
}



Measured memory_bytes: 3636
from itertools import combinations


def main():
    while True:
        n, x = map(int, input().split())
        if (n, x) == (0, 0):
            break

        ans = 0
        for nums in combinations(range(1, n + 1), 3):
            if x == sum(nums):
                ans += 1

        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 5636
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    N=2**n
    K=[None]*m
    for i in range(m):
        a,b=map(int,input().split())
        key=0
        for c in map(lambda x:int(x)-1,input().split()):
            key+=(1<<c)
        K[i]=(key,a)

    dp=[INF]*N
    dp[0]=0
    for key,cost in K:
        ndp=dp[:]
        for S in range(N):
            ndp[S|key]=min(ndp[S|key],dp[S]+cost)
        dp=ndp

    print(dp[-1] if(dp[-1]!=INF) else -1)
resolve()

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

typedef pair<int, int> P;
ll modnum = 1e9+7;


const int MAX_V = 50;
const int MAX_S = MAX_V*50+5;
const ll INF = 1e18;

struct Edge {
    int to,a,b;
    Edge(int to, int a, int b): to(to), a(a), b(b) {}
};

struct Data {
    int v,s;
    ll x;
    Data(int v, int s, ll x): v(v),s(s),x(x) {}
    bool operator<(const Data& a) const {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];
ll dp[MAX_V][MAX_S+5];

int main() {
    int n,m,s; cin >> n >> m >> s;
    rep(i, m) {
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        --u; --v;
        g[u].emplace_back(v,a,b);
        g[v].emplace_back(u,a,b);
    }
    vector<int> c(n), d(n);
    rep(i, n) cin >> c[i] >> d[i];
    rep(i, n) rep(j, MAX_S+5) dp[i][j] = INF;

    // ダイクストラ
    priority_queue<Data> que;

    // queに突っ込む関数
    auto push = [&](int v, int s, ll x) {
        // 所持金がマイナスになる移動は不可なのでNG
        if(s < 0) return;
        // 更新先が今の移動時間より小さかったら、やる意味ないので終わり
        if(dp[v][s] <= x) return;
        dp[v][s] = x;
        que.emplace(v,s,x);
    };


    // 所持金が不要にあれば、捨てる
    s = min(s, MAX_S);
    // 開始地点を突っ込む
    push(0, s,0);

    // ダイクストラを回していく
    while(!que.empty()) {
        // 一番小さい時間のを取り出す
        Data da = que.top(); que.pop();
        int v = da.v;
        int s = da.s;
        ll x = da.x;

        // dp[v][s] = 10 となるようなのがqueにpushされた後, これが取り出される前に
        // dp[v][s] = 5 となるようなのがqueにpushされることはありえる
        // この場合、dp[v][s] = 5を取り出して、処理した後にdp[v][s] = 10というのを取り出すということが発生して、計算量が増えるので
        // 以下で、queに突っ込まれた後に、最小値が更新されてたら抜けるというのをいれている.
        // queは常に最小時間を先に取り出すし、dpテーブルも常に最新の最小時間情報が保存されているので、一致しない = 最小時間ではない
        if (dp[v][s] != x) continue;

        // 今の地点で、銀貨を1枚金貨に交換する
        int ns = min(s + c[v], MAX_S);
        push(v, ns, x + d[v]);
        
        // 隣接する頂点に交通量を払って移動する
        for(Edge e : g[v]) {
            push(e.to, s-e.a, x+e.b);
        }
    }

    for(int i=1; i < n; i++) {
        ll ans = INF;
        rep(j, MAX_S+5) {
            ans = min(ans, dp[i][j]);
        }
        cout << ans << endl;
    }



    return 0;
}

Measured memory_bytes: 6064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    int a,b,t;
    cin>>n>>a>>m>>b>>t;

    // if(a == b and n != m)
    // {
    //     cout<<"NO";
    //     return;
    // }


    
   
    if(a*t>=abs(n-m)+b*t)
    {
        cout<<"YES";
    }
    else cout<<"NO";

    


}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 3644
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b,n,dp[17][17],x,y;
bool c[17][17];
int main()
{
while(1){
	scanf("%d %d",&a,&b);
	if(a==0&&b==0) return 0;
	for(int i=1;i<=a;i++){
		fill(c[i],c[i]+b+1,0);
		fill(dp[i],dp[i]+b+1,0);
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		c[x][y]=1;
	}
	dp[1][1]=1;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			if(c[i][j]) continue;
			if(i-1>0) dp[i][j]+=dp[i-1][j];
			if(j-1>0) dp[i][j]+=dp[i][j-1];
		}
	}
	printf("%d\n",dp[a][b]);
}
}

Measured memory_bytes: 1028
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void)
{
  int n,k; cin>>n>>k;
  vector<int> p(n);
  int r=0;
  
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  
  sort(p.begin(),p.end());
  
  for(int i=0;i<k;i++){
    r+=p[i];
  }
  
  cout<<r<<endl;
  
  return 0;
}

Measured memory_bytes: 3632
import fractions
import collections
   
A,B = map(int,input().split())
gcd = fractions.gcd(A,B)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = prime_factorize(gcd)
d = set(c)
print(len(d)+1)


Measured memory_bytes: 5048
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int gcd(int x, int y) {
    if(x % y == 0) {
        return y;
    } else {
        return gcd(y, x % y);
    }
}

int main() {
    int x, y, res;
    cin >> x >> y;
    if(x >= y) {
        cout << gcd(x, y) << endl;
    } else {
        cout << gcd(y, x) << endl;
    }
}



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

int main() {
	vector<vector<long long> > a, b;
	long long temp;
	int l,m,n;
	cin >> n >> m >> l;
	a.resize(n);
	b.resize(m);
	for(int i=0; i<n; ++i) {
		a[i].reserve(m);
		for(int j=0; j<m; ++j) {
			cin >> temp;
			a[i].push_back(temp);
		}
	}
	for(int i=0; i<m; ++i) {
		b[i].reserve(l);
		for(int j=0; j<l; ++j) {
			cin >> temp;
			b[i].push_back(temp);
		}
	}
	for(int i=0; i<n; ++i) {
		for(int j=0; j<l; ++j) {
			temp=0;
			for(int k=0; k<m; ++k) {
				temp+=a[i][k]*b[k][j];
			}
			cout << temp;
			if(j!=l-1) {
				cout << " ";
			} else {
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3148
from bisect import bisect


n, m, k = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(1, n + 1):
    A[i] += A[i - 1]
for j in range(1, m):
    B[j] += B[j - 1]

ans = 0
for i in range(n + 1):
    if A[i] <= k:
        x = k - A[i]
        j = bisect(B, x)
        ans = max(ans, i + j)

print(ans)


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

int main() {
    int n;
    int a[101];
    float r = 0.0;

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        r += 1.0 / a[i];
    }

    cout << (1.0 / r) << endl;

    return 0;
}

Measured memory_bytes: 256
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i+=2)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n;
		cin >> n;
		vector<pll> e(100005);
		vector<pll> o(100005);
		vll vec2(n);
		in(vec2);

		forn(i, 0, n) {
			e[vec2[i]].f++;
			e[vec2[i]].s = vec2[i];

		}
		forn(i, 1, n) {
			o[vec2[i]].f++;
			o[vec2[i]].s = vec2[i];

		}

		sortr(e);
		sortr(o);

		if (e[0].s != o[0].s)
			cout << abs(e[0].f - n / 2) + abs(o[0].f - n / 2) << endl;
		else
			cout << min((abs(e[1].f - n / 2) + abs(o[0].f - n / 2)), (abs(o[1].f - n / 2) + abs(e[0].f - n / 2))) << endl;



	}
	CLOCK
	return 0;
}



Measured memory_bytes: 7144
#include <iostream>

using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  int ans = 0;
  for(int i=0;i<3;i++){
  if(a.at(i)!=b.at(2-i)) ans=1;
  }
  if(ans) cout << "NO";
  else cout << "YES";
}


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x, a[105];
#define gc ch = getchar()
inline int re(){
	char ch = getchar(); int x = 0, f = 1;
	for (; !isdigit(ch); gc) if (ch == '-') f = -1;
	for (; isdigit(ch); gc) x=  x * 10 + ch - '0';
	return x * f;  
}
#undef gc
int main(){
	n = re(); x = re();
	for (int i = 1; i <= n; i++) a[i] = re();
	sort(a + 1, a + 1 + n);
	int cnt = 0;
	for (int i = 1; i <= n; i++){
		if (x >= a[i]){
			x -= a[i]; cnt++;
			if (cnt == n && x > 0) cnt--;
		}	
		else break;
	}
	printf("%d\n", cnt);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const int m = *std::max_element(a.begin(), a.end()) + 1;

	vector<int> last(m);
	for(int i = n - 1; i >= 0; --i){ last[a[i]] = i; }

	vector<int> next(n);
	for(int i = n - 1; i >= 0; --i){
		next[i] = last[a[i]];
		last[a[i]] = i;
	}

	vector<int> heads;
	heads.push_back(0);
	do {
		int cur = heads.back();
		while(true){
			if(next[cur] == n - 1){
				if(next[cur] == cur){ heads.push_back(n); }
				heads.push_back(0);
				break;
			}else if(next[cur] <= cur){
				heads.push_back(next[cur] + 1);
				break;
			}else{
				cur = next[cur] + 1;
			}
		}
	} while(heads.back() != 0);
	heads.pop_back();

	vector<int> b;
	for(int i = heads[(k - 1) % heads.size()]; i < n; ++i){
		if(next[i] > i){
			i = next[i];
		}else{
			b.push_back(a[i]);
		}
	}
	for(const auto x : b){
		cout << x << " ";
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 5620
#include <string.h>
#include <set>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace std;
typedef long long ll;
set<int> st;
int x[105];
int main()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 1; i <= n; i++)
    {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < v.size(); i++)
    {
        for (int j = i + 1; j < v.size(); j++)
        {
            if (v[j] == v[i])
                continue;
            for (int k = j + 1; k < v.size(); k++)
            {
                if (v[k] == v[j] || v[k] == v[i])
                    continue;
                if (v[i] + v[j] > v[k])
                {
                    ans++;
//                    cout << v[i] << " " << v[j] << " " << v[k] << endl;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3168
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  int a, b;
  std::cin >> a >> b;
  for (int i = 13; i < 1300; i++) {
    if ((static_cast<int>(i * 0.08) == a) && (static_cast<int>(i * 0.1) == b)) {
      std::printf("%d\n", i);
      return 0;
    }
  }
  std::puts("-1");
  return 0;
}


Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let points = 
    [|1..n|] |> Array.map (
        fun _ -> 
            let xyh = stdin.ReadLine().Split() |> Array.map int
            let (x, y, h) = (xyh.[0], xyh.[1], xyh.[2])
            (x, y, h)
    )

for i in [|0..100|] do
    for j in [|0..100|] do
        let ch = points |> Array.map (fun (x, y, h) -> h + (i - x |> abs) + (j - y |> abs)) |> Array.min
        if points |> Array.forall (fun (x, y, h) -> (ch - (i - x |> abs) - (j - y |> abs) |> max 0) = h) then
            printf "%d %d %d" i j ch


Measured memory_bytes: 18380
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  char A,B;cin>>A>>B;
  
  if(A==B){
    cout<<'H'<<endl;
  }
  else{
    cout<<'D'<<endl;
  }
}

Measured memory_bytes: 3512
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		while(n != 0) { 
			int[] num = new int[n];
			double average = 0;
			double dispersion = 0;
			double A;
			for (int i = 0; i < n; i++) {
				num[i] = scan.nextInt();
				average += num[i];
			}
			average = average / n;
			for (int i = 0; i < n; i++) {
				dispersion += Math.pow((num[i] - average), 2);
			}
			A = Math.sqrt(dispersion / n);
			System.out.println(A);
			n = scan.nextInt();
		}
	}

}

Measured memory_bytes: 31556
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.8.2)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

d, t, s = map(int, input().split())
print('Yes' if d / t <= s else 'No')


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  ll n=s.size();
  
  vll a(26,-1);
  rep(i,n){
    if(a[s[i]-'a']==-1){
      a[s[i]-'a']=t[i]-'a';
    }else{
      if(a[s[i]-'a']!=(t[i]-'a')){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  a=vll(26,-1);
  rep(i,n){
    if(a[t[i]-'a']==-1){
      a[t[i]-'a']=s[i]-'a';
    }else{
      if(a[t[i]-'a']!=(s[i]-'a')){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //配列(vector)vの重複要素を削除

void dfs(string s, int end, int num){
    if(s.size()==end){
        cout << s << endl;
        return;
    }

    for(char i='a'; i<='a'+num; i++){
        if(i<'a'+num) dfs(s+i, end, num);
        else dfs(s+i, end, num+1);
    }
}

void solve(){
    int N;
    cin >> N;
    dfs("a", N, 1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  int a,b,c,tem;
  cin>>a>>b>>c;
  tem=b/a;
  if(tem>c)cout<<c<<endl;
  else cout<<tem<<endl;
}
void solveH()
{
  int a,b,c,tem,i;
  cin>>a>>b>>c;
  tem=min(a,b);
  vector<int>vec;
  for(i=1;i<=tem;i++)
  {
    if(a%i==0&&b%i==0)
    {
      vec.push_back(i);
    }
  }
  cout<<vec[vec.size()-c]<<endl;
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
// solveE();
 //solveF();
// solveG();
solveH();
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int n,cnt=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int j=1;j<n;j++){
        if(a[j-1]==a[j]){
            a[j]=-1;
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    vector<ll> g(n+1, 0);
    ll MAX = 0;
    ll ans = 1;
    for(ll i = 0; i < n; i++){
        ll a;
        cin >> a;
        g[a]++;
        MAX = max(MAX, a);
        if(i==0 && a!=0) ans = 0;
    }
    ll INF = 998244353;
    for(ll i = 1; i <= MAX; i++){
        for(ll j = 0; j < g[i]; j++)
            ans=(ans*g[i-1])%INF;
    }
    if(g[0]>1) ans = 0;
    cout << ans << endl;
   /* for(ll i = 0; i <= MAX; i++){
        if(g[i]==0)
        cout << i << " " << g[i] << endl;
    }*/
    return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;;
	cin >>n;
	VI a0(n), a1(n);
	rep(i, n) cin >>a0[i];
	rep(i, n) cin >>a1[i];
	
	int ans =0;
	rep(i, n){
		int sm =0;
		rep(j, i+1) sm += a0[j];
		rep2(j,i, n) sm += a1[j];
		ans = max(ans, sm);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int max_element(int* a, int n)
{
    int i, res=a[0];
    for(i=1;i<n;++i) if (res<a[i]) res=a[i];
    return res;
}

int max(int x, int y) { return x>y?x:y; }

int main(void)
{
    int n, w;
    while (scanf("%d%d", &n, &w), n) {
        int i, m=0, x, h[101]={0};
        double res;
        for(i=0;i<n;++i) {
            int t;
            scanf("%d", &t);
            h[t/w]++;
            m=max(m, t/w);
        }
        x=max_element(h, m+1);
        res=0.01;
        for(i=0;i<m;++i) res+=(1.*h[i]/x)*(m-i)/m;
        printf("%.8f\n", res);
    }
    return 0;
}

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

#define maxn
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int main() {
    //freopen("getdiff.inp", "r", stdin);
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    int n, k, t=-1;
    bool ok = false;
    scanf("%d%d", &n, &k);
    FOR(i, 1, n) {
        int x; scanf("%d", &x);
        t = t==-1 ? x : __gcd(x, t);
        ok = ok || x>=k;
    }
    printf("%s", k%t==0 && ok ? "POSSIBLE" : "IMPOSSIBLE");
}



Measured memory_bytes: 256
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
count = 0
s = list()
s.append(0)
for i in range(N):
  s.append(a[i] + s[i])
for j in  Counter(s).values():
  count += (j * (j-1))/2
print(int(count))

Measured memory_bytes: 41696