akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 4e6 + 5;
const int M = 4e6 + 5;
int arr[N] = {};
int lr[M] = {};
int n, q;
struct tree {
    int sum[M << 2] = {}, left[M << 2] = {}, right[M << 2] = {};
    int ver[N] = {};
    int top = 0;
    void modify(int l, int r, int &now, int pre, int idx) {
        now = ++top;
        sum[now] = sum[pre] + 1;
        if (l == idx && r == idx) return;
        int mid = (l + r) >> 1;
        left[now] = left[pre], right[now] = right[pre];
        if (idx <= mid) modify(l, mid, left[now], left[pre], idx);
        else modify(mid + 1, r, right[now], right[pre], idx);
    }
    int query(int ql, int qr, int l, int r, int now) {
        if (ql == l && qr == r) return sum[now];
        int mid = (l + r) >> 1;
        if(qr <= mid) return query(ql, qr, l, mid, left[now]);
        else if (mid + 1 <= ql) return query(ql, qr, mid + 1, r, right[now]);
        else return query(ql, mid, l, mid, left[now]) + query(mid + 1, qr, mid + 1, r, right[now]);
    }
} tr;
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    for (int i = 1; i <= n; i++) {
        tr.modify(0, n, tr.ver[i], tr.ver[i - 1], lr[arr[i]]);
        lr[arr[i]] = i;
    }
    int l, r;
    while (q--) {
        cin >> l >> r;
        cout << tr.query(0, l - 1, 0, n, tr.ver[r]) - tr.query(0, l - 1, 0, n, tr.ver[l - 1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 127068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  if(b =='A'){
    cout <<'T'<< endl;
  }
   else if(b =='T'){
    cout <<'A'<< endl;
  }
     else if(b =='C'){
    cout <<'G'<< endl;
  }
     else if(b =='G'){
    cout <<'C'<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>
#include <map>

int main()
{
    int k{};
    std::cin >> k;
    int result{};
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                result += std::gcd(a, std::gcd(b, c));
            }
        }
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

const int nmax = 40, abmax = 10, inf = INT_MAX;
int dp[nmax + 1][nmax * abmax + 1][nmax * abmax + 1];

int main()
{
  int n, ma, mb;
  cin >> n >> ma >> mb;
  
  vector<int> mal(n), mbl(n), cl(n);
  for (int i = 0; i < n; i++) {
    cin >> mal[i] >> mbl[i] >> cl[i];
  }
  
  
  for (int i = 0; i <= nmax; i++) {
    for (int j = 0; j <= nmax * abmax; j++) {
      for (int k = 0; k <= nmax * abmax; k++) {
        dp[i][j][k] = inf;
      }
    }
  }
  
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= nmax * abmax; j++) {
      for (int k = 0; k <= nmax * abmax; k++) {
        if (dp[i][j][k] == inf) {
          continue;
        }
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
        dp[i + 1][j + mal[i]][k + mbl[i]] = min(dp[i + 1][j + mal[i]][k + mbl[i]], dp[i][j][k] + cl[i]);
      }
    }
  }
  
  int res = inf;
  for (int i = 1; i < nmax; i++) {
    int a = i * ma, b = i * mb;
    if (a > nmax * abmax || b > nmax * abmax) {
      continue;
    }
    res = min(res, dp[n][a][b]);
  }
  if (res == inf) {
    cout << -1 << endl;
  } else {
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 25984
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let S: Vec<char> = read_line().chars().collect();
    let K: usize = read_line().parse().unwrap();
    for i in 0..K {
        if S[i] != '1' {
            println!("{}", S[i]);
            return;
        }
    }
    println!("1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 2510
int OFF;

int ans[MAXN][MAXN];
int N,M,D,p;
queue<pair<pi, int>> Q;
vector<pair<pi,int>> V;
char mk[5] = {'A', 'R','Y','G','B'};

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N>>M>>D;

	if (D%2 == 1){
		p = (D+1)/2;
		Q.push(mp(mp(p+D,1+D), 1));
		Q.push(mp(mp(1+D,p+1+D), 2));
		Q.push(mp(mp(p+1+D,D+1+D), 3));
		Q.push(mp(mp(D+1+D,p+D), 4));
		int dx[] = {D+1,-D+1,-(D+1),-(-D+1)};
		int dy[] = {D-1,D+1,-(D-1), -(D+1)};
		while (SZ(Q)){
			pi cur = Q.front().f;
			int in = Q.front().s;
			ans[cur.f][cur.s] = in;
			V.pb(Q.front());
			Q.pop();
			// cout<<cur.f<<' '<<cur.s<<' '<<in<<'\n';
			for (int i=0;i<4;++i){
				int cx = cur.f + dx[i];
				int cy = cur.s + dy[i];
				if (cx <= 0 || cy <= 0 || cx > N+2*D || cy > M+2*D)continue;
				if (ans[cx][cy])continue;
				ans[cx][cy] = in;
				Q.push(mp(mp(cx,cy), in));
			}
		}

		for (auto i : V){
			pi t = i.f;
			int in = i.s;
			for (int j=1-p;j<=p-1;++j){
				for (int k=1-p+abs(j); k<= p-1-abs(j);++k){
					int cx = t.f + j;
					int cy = t.s + k;
					if (cx <= D || cy <= D || cx > N+D || cy > M+D)continue;
					ans[cx][cy] = in;
				}
			}
		}
		for (int i=1;i<=N;++i){
			for (int j=1;j<=M;++j)cout<<mk[ans[i+D][j+D]];
			cout<<'\n';
		}
		
	}else {

		p = D/2;
		Q.push(mp(mp(D,D), 1));
		Q.push(mp(mp(D+p,D-p), 2));
		Q.push(mp(mp(D+p,D+p), 3));
		Q.push(mp(mp(D,2*D), 4));
		int dx[] = {0,0,D, -D};
		int dy[] = {2*D,-2*D,-D, D};

		while (SZ(Q)){
			pi cur = Q.front().f;
			int in = Q.front().s;
			ans[cur.f][cur.s] = in;
			V.pb(Q.front());
			Q.pop();
			// cout<<cur.f<<' '<<cur.s<<' '<<in<<'\n';
			for (int i=0;i<4;++i){
				int cx = cur.f + dx[i];
				int cy = cur.s + dy[i];
				if (cx < 0 || cy < 0 || cx >= N+2*D || cy >= M+2*D)continue;
				if (ans[cx][cy])continue;
				ans[cx][cy] = in;
				Q.push(mp(mp(cx,cy), in));
			}
		}
		for (auto i : V){
			pi t = i.f;
			int in = i.s;
			for (int j=1-p;j<=p-1;++j){
				for (int k=1-p+abs(j); k<= p-abs(j);++k){
					// cout<<j<<' '<<k<<'\n';
					int cx = t.f + j;
					int cy = t.s + k;
					if (cx < D || cy < D || cx >= N+D || cy >= M+D)continue;
					ans[cx][cy] = in;
				}
			}
			// break;
		}
		for (int i=0;i<N;++i){
			for (int j=0;j<M;++j)cout<<mk[ans[i+D][j+D]];
			cout<<'\n';
		}
	}
}


Measured memory_bytes: 14848
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
inline char tc() {
    static char fl[100], *A = fl, *B = fl;
    return A == B && (B = (A = fl) + fread(fl, 1, 100, stdin), A == B) ? EOF
                                                                       : *A++;
}
inline int intread() {
    int a = 0;
    static char c;
    c = tc();
    while (c & 16) a = a * 10 + c - 48, c = tc();
    return a;
}
inline ll llread() {
    ll a = 0;
    static char c;
    c = tc();
    while (c & 16) a = a * 10 + c - 48, c = tc();
    return a;
}

static const int buf_size = 4096;
static int write_pos      = 0;
static char write_buf[buf_size];

inline void writeChar(ll x) {
    if (write_pos == buf_size)
        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;
    write_buf[write_pos++] = x;
}
inline void write(ll x, char end) {
    char s[24];
    int n = 0;
    while (x || !n) s[n++] = '0' + x % 10, x /= 10;
    while (n--) writeChar(s[n]);
    if (end) writeChar(end);
}
struct Flusher {
    ~Flusher() {
        if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;
    }
} flusher;

int X, Y, Z, K;
ll A[1001], B[1001], C[1001], ABC[3000];
int main() {
    X = intread(), Y = intread(), Z = intread(), K = intread();
    rep(i, X) A[i] = llread();
    rep(i, Y) B[i] = llread();
    rep(i, Z) C[i] = llread();
    sort(A, A + X, greater<ll>());
    sort(B, B + Y, greater<ll>());
    sort(C, C + Z, greater<ll>());
    A[X] = -1e17, B[Y] = -1e17, C[Z] = -1e17;
    priority_queue<pair<ll, ll>> pq;
    pq.push(make_pair(A[0] + B[0] + C[0], 0));
    set<int> s;
    s.insert(0);
    ll cnt = 0, h;
    while (cnt < K) {
        auto v = pq.top();
        pq.pop();
        ABC[cnt++] = v.first;
        rep(i, 3) {
            h = v.second;
            if (i == 0) h += (1 << 20);
            if (i == 1) h += (1 << 10);
            if (i == 2) h++;
            if (s.find(h) == s.end()) {
                s.insert(h);
                pq.push(make_pair(
                    A[(h >> 20)] + B[((h >> 10) & 1023)] + C[(h & 1023)], h));
            }
        }
    }
    rep(i, K) { write(ABC[i], '\n'); }
    return 0;
}

Measured memory_bytes: 768
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
a.sort()
for num in a:
    if x >= num:
        ans += 1
        x -= num
    else:
        break
else:
    if x == 0:
        print(ans)
    else:
        print(ans - 1)
    exit()
print(ans)

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<i32> L(N);
    for (i32 i = 0; i < N; i++) cin >> L[i];
    sort(ALL(L));
    i64 sum = 0;
    for (i32 i = 0; i < N - 1; i++) {
        for (i32 j = i + 1; j < N; j++) {
            auto it = lower_bound(ALL(L), L[i] + L[j]);
            i32 dist = distance(L.begin(), it);
            sum += max(dist - (j + 1), 0);
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n;
   cin>>n;
   vector<int> f(n+1);
   rep(i,1,n+1){
	   rep(j,i,n+1){
			f[j]++;
			j+=i-1;
	   }
   }
   //print(f);
   int ans=0;
   rep(i,1,n+1){
	   ans+=i*f[i];
	  // cout<<i*f[i]<<"\n";
   }
   cout<<ans<<"\n";
   return 0;
}

Measured memory_bytes: 81288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif
  
  int n, r; cin >> n >> r;
  if (n < 10) r += 100 * (10 - n);
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    string u;
    char c;
    for(int i=0;i<s.size();i++){
        c=s[0];
        u=s.substr(1,s.size()-1);
        u=u+c;
        s=u;
        if(t==u){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input().rstrip())
Xs = [int(x) for x in map(int, input().rstrip().split())]
import sys
sum_val = sys.maxsize
for i in range(min(Xs), max(Xs)+1):
    tmp_sum_val = 0
    for j in Xs:
        tmp_sum_val += (j - i)**2
    if sum_val > tmp_sum_val:
        sum_val = tmp_sum_val
print(sum_val)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		String x = "";
		while (true) {
			a = sc.nextInt();
			x = sc.next();
			b = sc.nextInt();
			if (x.equals("?"))
				break;
			if (x.equals("+"))
				System.out.println(a + b);
			if (x.equals("-"))
				System.out.println(a - b);
			if (x.equals("*"))
				System.out.println(a * b);
			if (x.equals("/"))
				System.out.println(a / b);
		}
	}
}


Measured memory_bytes: 26180
#include<stdio.h>

#define MAX 10000
#define NIL -1
struct Node {int p,l,r;};
struct Node T[MAX];
int n;
void preParse(int u){
	if (u==NIL){
		return;
	}
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}
void inParse(int u){
	if (u==NIL){
		return;
	}
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}
void postParse(int u){
	if (u==NIL){
		return;
	}
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}
int main(void){
	int i,v,l,r,root;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p=NIL;
	}
	for(i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL){
			T[l].p=v;
		}
		if(r!=NIL){
			T[r].p=v;
		}
	}
	for(i=0;i<n;i++){
		if(T[i].p==NIL){
			root=i;
		}
	}
	printf("Preorder\n");
	preParse(root);
	printf("\nInorder\n");
	inParse(root);
	printf("\nPostorder\n");
	postParse(root);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> W(N);
  int total = 0;
  for(int i=0;i<N;i++){
    cin>>W.at(i);
    total += W.at(i);
  }

  vector<int> Sub(N-1);
  int tmp = 0;
  for(int i=0;i<N-1;i++){
    tmp += W.at(i);
    Sub.at(i) = abs(total-2*tmp);
  }

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

  cout<<Sub.at(0)<<endl;
}


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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    string s; cin>>s;
    cout<<(s=="ABC"?"ARC":"ABC");
	return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;

    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

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

        if(S>W){
            System.out.println("safe");
        } else{
            System.out.println("unsafe");
        }

        sc.close();
    }
}

Measured memory_bytes: 35760
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
	string s1, s2;

	cin >> s1 >> s2;

	if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        cout << 'x';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <bits/stdc++.h>
#include <string.h>

using namespace std;

string s;

int main () {
    cin >> s;
    for ( int i = 0; i < s.size(); i++) {
        if ( s[i] == '7' ) {
            cout <<"Yes" << endl; return 0;
        }
    }
    cout <<"No";
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++)
  {
    for (int j = 0; j <= b; j++)
    {
      for (int k = 0; k <= c; k++)
      {
        int sum = 500 * i + 100 * j + 50 * k;
        if (sum == x)
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

int main() {
    //cout.precision(10);
    int a, b, x;
    cin >> x >> a >> b;
if(b<=a)cout << "delicious" << endl;
else if(b <= x + a) cout << "safe" << endl;
else cout << "dangerous" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n,m,k;
   cin>>n>>m>>k;
   ll i,j;
   i=0,j=0;
   ll res=0;
   ll a[n],b[m];
   for(i=0;i<n;i++)cin>>a[i];
   for(i=0;i<m;i++)cin>>b[i];

   ll pre1[n],pre2[m];
   pre1[0]=a[0];
   pre2[0]=b[0];
   ll maxi=0;
   for(i=1;i<n;i++)
   {
       pre1[i]=pre1[i-1]+a[i];
   }
   for(i=1;i<m;i++)
   {
       pre2[i]=pre2[i-1]+b[i];
   }

   for(i=0;i<n;i++)
   {
       ll no = k-pre1[i];
       if(no<0)
       {
           continue;
       }
       ll ind = upper_bound(pre2,pre2+m,no)-pre2;
       
       if(ind==0)
       {
           maxi=max(maxi,i+1);
       }
       else{
           ind--;
           if(pre1[i]+(pre2[ind])<=k){
        //    cout<<i<<" "<<ind<<"\n";
           ll tans = i+1+ind+1;
        //    cout<<tans<<" "<<i<<"\n";
           maxi=max(maxi,tans);
           }
       }

   }
   for(i=0;i<m;i++)
   {
       ll no = k-pre2[i];
       if(no<0)
       {
           continue;
       }
       ll ind =upper_bound(pre1,pre1+n,no)-pre1;
       if(ind==0)
       {
           maxi=max(maxi,i+1);
       }
       else{
           ind--;
           if(pre2[i]+pre1[ind]<=k)
           {
                    ll tans = i+1+ind+1;
        //    cout<<tans<<" "<<i<<"\n";
           maxi=max(maxi,tans);
           }
       }
   }
   cout<<maxi<<"\n";
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;



int main()
{
    ll a,b,c,e;
    cin>>a>>b>>c>>e;

    cout<<max(max(min(a,b)*min(c,e),max(a,b)*max(c,e)),max(min(a,b)*max(c,e),max(a,b)*min(c,e)));
return 0;
}

Measured memory_bytes: 3632
def judge(s):
    if int(s[0]) == 0:
        if int(s[1]) > 0:
            return 1
        else:
            return 0
    elif int(s[0]) == 1:
        if int(s[1]) <=2:
            return 1
        else:
            return 0
    else:
        return 0

S = input()
tmp = list(S)
first = ''.join([tmp[0],tmp[1]])
second = ''.join([tmp[2],tmp[3]])

flag1 = -1
flag2 = -1

#YYMMがあるか判定　下2桁が01~12であればよい
flag1 = judge(second)

#MMYYがあるか判定
flag2 = judge(first)

#結果発表
if flag1 ==1 and flag2 == 1:
    print("AMBIGUOUS")
elif flag1 == 1 and flag2 == 0:
    print("YYMM")
elif flag1 == 0 and flag2 == 1:
    print("MMYY")
else:
    print("NA")

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

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

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

using ll = long long;

int d[101][101];
int a[1001], b[1001], c[1001];

int main() {
  int n, m; cin >> n >> m;
  REP(i,n) REP(j,n) d[i][j] = INF;
  REP(i,m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  REP(i,n) d[i][i] = 0;
  REP(k,n) REP(i,n) REP(j,n) chmin(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  REP(i,m) {
    bool f = false;
    REP(j,n) if (d[j][a[i]] + c[i] == d[j][b[i]]) f = true;
    if (!f) ans++;
  }
  cout << ans << endl;
  return 0;
}


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


#define long long long int

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pi;


int main() {
    std::ios_base::sync_with_stdio(false);

    int n;
    vector<vector<int>> v(3, vector<int>(3));
    vector<vector<int>> p(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> v[i][j];
        }
    }
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int key;
        cin >> key;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (v[j][k] == key) {
                    p[j][k] = 1;
                }
            }
        }
    }
    int res = max(0, p[0][0] + p[0][1] + p[0][2]);
    res = max(res, p[1][0] + p[1][1] + p[1][2]);
    res = max(res, p[2][0] + p[2][1] + p[2][2]);
    res = max(res, p[0][0] + p[1][1] + p[2][2]);
    res = max(res, p[0][1] + p[1][1] + p[2][1]);
    res = max(res, p[0][2] + p[1][2] + p[2][2]);
    res = max(res, p[0][0] + p[1][0] + p[2][0]);
    res = max(res, p[0][2] + p[1][1] + p[2][0]);
    cout << (res == 3 ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2) 
#include<bits/stdc++.h>
#define rg register
#define il inline
#define int long long
using namespace std;
typedef long long ll;
const int mod=1e9+7,O=200010;
il int gi(){
	rg int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return fl*o;
}
int h,w,a,b,fac[O],inv[O],ans;
il ll C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
signed main(){
	fac[0]=inv[0]=inv[1]=fac[1]=1;
	for(int i=2;i<O;++i)fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<O;++i)inv[i]=1ll*inv[i-1]*inv[i]%mod;
	scanf("%lld%lld%lld%lld",&h,&w,&a,&b);
	for(int i=1;i<=h-a;++i)
		(ans+=C(i+b-2,i-1)*C(h-i+w-b-1,h-i)%mod)%=mod;
	printf("%lld\n",ans);
	return 0;
}
//(1,1)->(i,b)*(i,b)->(n,m)


Measured memory_bytes: 3328
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
                                                                                                                                     template<typename integer>
integer __lcm(integer a, integer b) {
  return (a * b) / __gcd(a, b);                                                                                                      }

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

  rep (i, n+1) {
    for (int j=0; n>=i+j; j++) {
      if (10000*i + 5000*j + 1000*(n-i-j) == y) {
        cout << i << " " << j << " " << n-i-j << endl;
        return 0;                                                                                                                          }
    }
  }

  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<=b && b<=c)
	{
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<=c && c<=b)
	{
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a && a<=c)
	{
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c && c<=a)
	{
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a && a<=b)
	{
		printf("%d %d %d\n",c,a,b);
	}
	else
	{
		printf("%d %d %d\n",c,b,a);
	}
	
	return 0;
}


Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    for(int i=1;i<10;++i) {
        if((n/i)<10 && n%i==0) {
        cout << "Yes" << endl;
        return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+5;

int n,m,u,v,a[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	while (m--){
		cin >> u >> v;
		if (u>v){
			swap(u,v);
		}
		a[u]++;
		a[v]--;
	}
	int ok=1;
	for (int i=1;i<=n;i++){
		a[i]=a[i-1]+a[i];
		ok&=!(a[i]&1);
	}
	cout << (ok?"YES":"NO") << "\n";
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+7;
const ll mod = 1e9+7;
const int sz = 62;
#define afdafafafdafaf y1;
int n,m;
char ch[maxn];
int ar[maxn], site[maxn];

int mxl[2][maxn], mxr[2][maxn];
set<int>::iterator it;
int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", ar+i);
        site[ar[i]] = i;
    }
    vector<int> v;
    for(int i=1;i<=n;i++){
        while(v.size() > 0 && v.back() < ar[i]){
            mxr[0][site[v.back()]] = i;
            v.pop_back();
        }
        v.push_back(ar[i]);
    }
    v.resize(0);
    for(int i=n;i>=1;i--){
        while(v.size() > 0 && v.back() < ar[i]){
            mxl[0][site[v.back()]] = i;
            v.pop_back();
        }
        v.push_back(ar[i]);
    }
    set<int> s;
    for(int i=1;i<=n;i++){
        for(it = s.begin(); it != s.end(); ){
            int x = *it;
            if(x<ar[i]){
                if(mxr[0][site[x]] == i){
                    it++;
                }
                else{
                    assert(mxr[1][site[x]] == 0);
                    mxr[1][site[x]] = i;
                    s.erase(it++);
                }
            }
            else{
                break;
            }
        }
        s.insert(ar[i]);
    }
    s.clear();
    for(int i=n;i>=1;i--){
        for(it = s.begin(); it != s.end(); ){
            int x = *it;
            if(x<ar[i]){
                if(mxl[0][site[x]] == i){
                    it++;
                }
                else{
                    assert(mxl[1][site[x]] == 0);
                    mxl[1][site[x]] = i;
                    s.erase(it++);
                }
            }
            else{
                break;
            }
        }
        s.insert(ar[i]);
    }
    
    for(int i=1;i<=n;i++){
        if(mxr[0][i]==0){
            assert(mxr[1][i]==0);
        }
        if(mxl[0][i]==0){
            assert(mxl[1][i]==0);
        }
    }
    for(int i=1;i<=n;i++){
        if(mxr[0][i]==0)mxr[0][i] = n+1;
        if(mxr[1][i]==0)mxr[1][i] = n+1;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans += ar[i] * 1LL * 
            ((mxl[0][i] - mxl[1][i]) * 1LL * (mxr[0][i] - i) + 
             (mxr[1][i] - mxr[0][i]) * 1LL *(i - mxl[0][i]));
    }
    printf("%lld\n", ans);



    return 0;
}


Measured memory_bytes: 7544
n = int(input())
aiList = [int(input()) for i in range(n)]
count = 0
now = 1
while True:
    count += 1
    if count >= n:
        count = -1
        break
    nextNum = aiList[now - 1]
    if nextNum == 2:
        break
    now = nextNum
print(count)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 1023
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

vll ps;

ll p5(ll x){
    ll r = 1LL;
    for(int i = 1; i <= 5; ++i){
        r = r * x;
    }
    return r;
}

int main(){
    ios_base::sync_with_stdio(0);
    ll x;
    ll n;
    for(ll i = 1;i < 1000000LL ; ++i){
        if(p5(i) <= 1000000000LL){
            ps.pb(i);
        }
        else {
            break;
        }
    }
    cin >> n;
    for(ll x : ps){
        if((p5(x) + 1LL) == n) {
            cout << x << ' ' << "-1\n";
            return 0;
        }
    }
    x = 5500;
    for(ll i = -x; i <= x; ++i){
        for(ll j = -x; j <= x; ++j){
            if(p5(i) - p5(j) == n){
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3648
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) arr[i] = scan.nextInt();
        Arrays.sort(arr);
        
        System.out.println(arr[n-1] - arr[0]);
    }
}



Measured memory_bytes: 23124
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};

const int MAXN = (int)1e5+9;

const int N = 100000;

ll f(ll n)
{
	if(n%4==0)
		return n;
	else if(n%4==1)
		return 1;
	else if(n%4==2)
		return n+1;
	else
		return 0;
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */
    
    ll a,b, i,j,k,l,m,n,p,q,r,tc,t;
    
    cin>>a>>b;
    
    ll ans = f(a-1) ^ f(b);
    
    cout<<ans<<endl;

//	main();
    return 0;
}

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

"""ナイーブ
count = 0
for i in range(n-1):
    for j in range(i, n):
        if i != j and abs(i-j) == a[i] + a[j]:
            count += 1
print(count)
"""
# idxとa[idx]で別々にループ回すからO(n**2)になってしまう
# 前処理としてidxとa[idx]の二つの情報をまとめた何かがつくれれば、、ってとこまでは気付けた
from collections import Counter
a_plus = [0]*n
a_minus = [0]*n
for i in range(n):
    a_plus[i] = i + a[i]
    a_minus[i] = i - a[i]
c1 = Counter(a_plus)
c2 = Counter(a_minus)
#print(c1)
#print(c2)
ans = 0
for key in c1.keys():
    if key in c2.keys():
        ans += c1[key]*c2[key]
print(ans)


Measured memory_bytes: 127300
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#include <sstream>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    cout << min(a,b) + min(c,d) << endl;
    
    return 0;
}



Measured memory_bytes: 768
i = 0
a = Array.new
a[i], a[i+1] = gets.split.map(&:to_i)
while a[i] != 0 || a[i+1] != 0
	i += 2
a[i], a[i+1] = gets.split.map(&:to_i)
end
i = 0
while a[i] != 0 || a[i+1] != 0
	if a[i] < a[i+1] then
		puts "#{a[i]} #{a[i+1]}"
	else
		puts "#{a[i+1]} #{a[i]}"
	end
	i += 2
end

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

#define fir first
#define sec second

typedef pair <int, int> P;
vector <P> v(1028);

int dp[1028][2048];

int main(void)
{
	int cnt = 1;
	while (1){
		int w, n;
		cin >> w; if (w == 0) break;
		cin >> n;
		char a;
		for (int i = 0; i < n; i++){
			scanf("%d,%d", &v[i].fir, &v[i].sec);
		}
		for (int i = 0; i < n; i++){
			for (int j = 0; j <= w; j++){
				if (j < v[i].sec) dp[i+1][j] = dp[i][j];
				else dp[i+1][j] = max(dp[i][j], dp[i][j-v[i].sec]+v[i].fir);
			}
		}
		int res1 = 0, res2 = 0;
		for (int i = 1; i <= w; i++){
			if (res1 < dp[n][i]){
				res1 = dp[n][i];
				res2 = i;
			}
		}
		cout << "Case " << cnt << ":" << endl << res1 << endl << res2 << endl;
		cnt++;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
    long k,n;
    cin >> k >> n;
    long a[n];
    long s[n];
    rep(i,n){
        scanf("%ld",&a[i]);
    }
    s[n-1]=k-a[n-1]+a[0];
    for(int (i)=0;(i)<(n-1);(i)++){
        s[i]=a[i+1]-a[i];
        // cout << i<<":"<<s[i] << endl;
    }
    // cout << s[n];
    long max=0;
    for(int (i)=0;(i)<(n);(i)++){
        if(max<s[i]){
            max=s[i];
            // cout << max<<endl;
        }
    }
    // cout << k << endl;
    // cout << max << endl;
    cout << k-max;
    return 0;
}


Measured memory_bytes: 3328
import math
n = input()
 
p1_x = float(0)
p1_y = float(0)
p2_x = float(100)
p2_y = float(0)
 

def kock(i, n, x1, y1, x2, y2):
    a = [0,0,0,0,0]
    b = [0,0,0,0,0]
    if i < n:
        a[0] = x1
        b[0] = y1
        a[1] = (2*x1+x2)/3.0
        b[1] = (2*y1+y2)/3.0
        a[2] = (x1+2*x2)/3.0
        b[2] = (y1+2*y2)/3.0
        a[3] = (a[2] - a[1])*math.cos(math.pi/3) - (b[2] - b[1])*math.sin(math.pi/3) + a[1]
        b[3] = (b[2] - b[1])*math.cos(math.pi/3) + (a[2] - a[1])*math.sin(math.pi/3) + b[1]
        a[4] = x2
        b[4] = y2
        kock(i+1, n, a[0], b[0], a[1], b[1])
        print a[1], b[1]
        kock(i+1, n, a[1], b[1], a[3], b[3])
        print a[3], b[3]
        kock(i+1, n, a[3], b[3], a[2], b[2])
        print a[2], b[2]
        kock(i+1, n, a[2], b[2], a[4], b[4])

print p1_x, p1_y
kock(0, n, p1_x, p1_y, p2_x, p2_y)
print p2_x, p2_y

Measured memory_bytes: 6668
#import math

def gcd(m,n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!= 0:
            z = x%y
            x = y
            y =z
        else:
            return z


A, B, K = map(int, input().split())

Max = int(gcd(A, B) )


list = [0] * 1000

j =0

if A == 1 or B == 1:
    print("1")
    quit()

for i in range(Max):

    if i == 0:
        continue
    if Max % i == 0:
        list[j] = i
        j += 1

if K == 1:
    print(Max)
    exit()

print(list[j - K+1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

using ll = long long;

int main() {
    // freopen("g.txt", 'r', stdin);
    // fastio;

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

    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; i ++) {
        scanf("%d", &arr[i].first);
        arr[i].second = i+1;
    }

    sort(begin(arr), end(arr));

    for (auto e : arr)
        printf("%d ", e.second);
    puts("");

    return 0;
}



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

int main(){
  int W , H;
  while(1){
    cin >>W>>H;
    if(H == 0 && W ==0)break;
    else
  for (int j = 0; j < W ;j++){
    for (int i = 0; i < H ;i++){
      cout << "#";}
    cout << endl;}
  cout << endl;}
  return 0;
}


Measured memory_bytes: 3088
k()=readline()|>chomp
s()=[parse(Int,x)for x=k()|>split]
n,q=s()
t=k()
a=zeros(Int,n)
c=0
for j=2:n
if t[j-1:j]=="AC"
c+=1
end
a[j]=c
end
for i=1:q
l,r=s()
println(a[r]-a[l])
end

Measured memory_bytes: 156416
n = int(input())
a_list = list(map(int,input().split()))
dum_list = [0]*n
ans_list = []
for i in range(n-1,-1,-1):
    total = 0
    for j in range(i,n,i+1):
        #print(j)
        total += dum_list[j]
    if total%2 != a_list[i]:
        dum_list[i] = 1
        ans_list.append(i+1)
if sum(dum_list) == 0:
    print(0)
else:
    #print(ans_list)
    ans_list.sort()
    print(sum(dum_list))
    print(" ".join(map(str,ans_list)))


Measured memory_bytes: 81000
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]  
    n, q = [int(x) for x in input().split()]  
    g = defaultdict(list)
    cnt = [0] * (n+1)

    for _ in range(n-1):
        a, b = [int(x) for x in input().split()]  
        g[a].append(b)
        g[b].append(a)

    for _ in range(q):
        v, x = [int(x) for x in input().split()]
        cnt[v] += x
    
    q = deque([(1, 0)])
    w = set([1])
    while q:
        v, val = q.popleft()
        cnt[v] += val
        for to in g[v]:
            if to not in w:
                q.append((to, cnt[v]))
                w.add(to)

    print(*cnt[1:])


    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
a b a
d c d
a b a
"""


Measured memory_bytes: 82324
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(string s) {
	int len = s.length();
	int k1 = 0, k2 = 0;
	stack<char> last;
	bool f = true;
	FORE(c, s) {
		if (c == '(') {
			last.push(c);
			k1++;
		} else if(c == '[') {
			last.push(c);
			k2++;
		}else if (c == ')') {
			if (last.empty() || (!last.empty() && last.top() != '(') || k1 <= 0) f = false;
			if (!last.empty()) last.pop();
			k1--;
		} else if(c == ']') {
			if (last.empty() || (!last.empty() && last.top() != '[') || k2 <= 0) f = false;
			if (!last.empty()) last.pop();
			k2--;
		}
	}
	if (k1 || k2 || !f || !last.empty()) {
		cout << "no" << endl;
	} else {
		cout << "yes" << endl;
	}
}

int main(void) {
	string s;
	while (getline(cin, s)) {
		if (s == ".") break;
		solve(s);
	}
}

Measured memory_bytes: 3220
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL N, K, fact, ans;
std::vector<LL>a;
std::vector<std::vector<std::vector<LL>>>memo(112, std::vector<std::vector<LL>>(112, std::vector<LL>(300, -1)));

LL dp(LL i, LL j, LL k)
{
	if (k == K && j == 0) return 1;
	if (j <= 0 || i == N) return 0;
	if (memo[i][j][k] != -1) return memo[i][j][k];
	LL dp1 = dp(i + 1, j - 1, k^a[i]);
	LL dp2 = dp(i + 1, j, k);
	return memo[i][j][k] = (dp1 + dp2) % mod;
}

int main()
{
	in >> N >> K;
	a.resize(N);
	rep(i, N) in >> a[i];
	fact = 1;
	for (LL i = 1; i <= N; ++i)
	{
		fact *= i;
		fact %= mod;
		ans += (dp(0, i, 0)*fact) % mod;
		ans %= mod;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 30464
/**
 *    author:  tourist
 *    created: 20.11.2019 08:37:52       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int k1 = 0, k2 = 0, k4 = 0;
  for (int x : a) if (x % 4 == 0) ++k4; else if (x % 2 == 0) ++k2; else ++k1;
  if (k2 == 0 && k4 >= k1 - 1 || k4 >= k1) cout << "Yes"; else cout << "No";
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

const int MAX = 5000;
const int MOD = 1000000007;

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(){
  COMinit();
  int s;
  cin>>s;

  int l=1,ans=0;
  while(s>=l*3){
    ll r=s-l*3;
    ans=(ans+COM(r+l-1,r))%MOD;
    l++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3708