akhauriyash/Code-Regression huggingface dataset:
def get_coin(a,b,coin=0):
  if a >= b:
    coin += a
    if a > 3:
      a-=1
  else:
    coin += b
    if b > 0:
      b-=1
  return a,b,coin

a = list(map(int,input().split()))
b,c,d = get_coin(a[0],a[1])
e,f,g = get_coin(b,c,d)
print(g)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int N, M;

#define MAX 20010
int dp[MAX];

class node{
public:
	int t, s, d;
	node(int t, int s, int d):t(t), s(s), d(d){}

	bool operator<(const node& r) const{
		return t < r.t;
	}
};

int main(void)
{
	while (cin >> N >> M, N|M) {
		vector<node> ns;
		rep(i, M) {
			int t, s, d;
			cin >> t >> s >> d;
			ns.push_back(node(t, --s, --d));
		}
		sort(ALL(ns));

		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		rep(i, ns.size())
			dp[ns[i].d] |= dp[ns[i].s];

		int ans = 0;
		rep(i, N)
			ans += dp[i];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1760
use std::io;


fn main() {
    let (a, b, c, d) = {
        let i = read::<usize>();
        (i[0], i[1], i[2], i[3])
    };
    println!("{}", b - a - (calc(b, c, d) - calc(a - 1, c, d)) + 1);
}

fn calc(n: usize, a: usize, b: usize) -> usize {
    let da: usize = n / a;
    let db: usize = n / b;
    da + db - n / lcm(a, b)
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 { a }
    else { gcd(b, a % b) }
}

fn lcm(a: usize, b: usize) -> usize {
    (a / gcd(a, b)) * b
}


#[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
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
a1 = []
b = []
for s in a:
    a1.extend(s)
b = sorted(a1)

for i in range(n):
    if a1[i] == b[n - 1]:
        print(b[n - 2])
    else:
        print(b[n - 1])

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

int main(){
    int N, ans=1;
    cin >> N;
    string S;
    cin >> S;

    for(int i=0; i<N-1; i++){
	if(S[i]!=S[i+1])
	    ans++;
    }
    cout << ans << endl;

    
}


Measured memory_bytes: 512
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let n: usize = s.parse().unwrap();

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let a: Vec<usize> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut answer = vec![0; n];
    for i in 0..n {
        // println!("a[i]: {:?}", a[i]);
        answer[a[i] - 1] = i + 1;
        // println!("answer: {}", answer[a[i] - 1]);
        // println!("{:?}", answer);
    }
    // println!("{:?}", answer);

    let str = answer.iter().map(|&x| x.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", str);
}


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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=2e5+1, M=(ll)1e9+1 ;
const int mod = 998244353 ;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// ll g[N][N],keep[N*N];
vl g[N],a(N),gc(N),dist(N,1),vis(N,0);

// ll solve(ll l,ll r){
//   if(l==r)
//     return l;
//   ll n1=solve(l,(l+r)/2);
//   ll n2=solve((l+r)/2 +1,r);
//   if(g[n1][n2]>0){
//     keep[g[n1][n2]]=true;
//     return n1;
//   }
//   else{
//     keep[g[n2][n1]]=true;
//     return n2;
//   }
  
// }
ll ma=0;
void dfs(ll x){
  vis[x]=1;
  // cout << x << " ";
  for(auto &it:g[x]){
    if(vis[it])
      continue;
    dfs(it);
    if(__gcd(a[x],gc[it])!=1){
      if(dist[x]<1+dist[it]){
        dist[x]=1+dist[it];
        gc[x]=__gcd(a[x],gc[it]);
      }
    }
  }
  // if(a[x]!=1)
    ma=max(ma,dist[x]);
  // return ma;
}
int main(){
 ios_base::sync_with_stdio(0);
  ll i,n;
  cin >>n;
  vl a(n),b(n);
  ll ma=0,mb=0;
  for(i=0;i<n;i++){
    cin >> a[i];
    ma+=a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
    mb+=b[i];
  }
  
  if(ma<mb){
    cout << -1;
    return 0;
  }
  vl dif[n];
  for(i=0;i<n;i++){
    dif[i]={a[i]-b[i],i};
  }
  sort(dif,dif+n);
  ll j=0,c=0,k=0;
  for(i=n-1;i>=0;i--){
    // c++;
    k=0;
    if(j>=i)
      break;
    while(dif[i][0]>0  && dif[j][0]<0){
        k=1;
        c++;
        if(dif[i][0]<abs(dif[j][0])){
          dif[j][0]+=dif[i][0];
          dif[i][0]=0;
          c--;
          break;
        }
        else  
          dif[i][0]+=dif[j][0];
        j++;
      // else
      //   break;
    }
    if(k)
      c++;
  }
  cout << c << endl;
    return 0;
}

Measured memory_bytes: 19968
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc047
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            List<int> list = new List<int>();
            list.Add(Convert.ToInt32(str[0]));
            list.Add(Convert.ToInt32(str[1]));
            list.Add(Convert.ToInt32(str[2]));

            int avg = (from item in list select item).Sum() / 2;

            if (avg * 2 != (from item in list select item).Sum()) {
                Console.WriteLine("No");
            }
            else if ((from item in list where item == avg select item).Count() > 0)
            {
                Console.WriteLine("Yes");
            }
            else if ((from item in list where item < avg select item).Sum() == avg)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 3160
//https://atcoder.jp/contests/dp/tasks/dp_n
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x)
#define mid (l + r) / 2
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector <lli> ar(n);
	for(int i=0; i<n; i++) cin >> ar[i];

	lli dp[n+1][n+1];
	memset(dp, 1000000, sizeof dp);

	for(int i=n-1; i>=0; i--){
		for(int j=i; j<n; j++){
			if(i == j) dp[i][j] = 0;
			lli sum = 0;
			for(int k=i; k<=j; k++) sum += ar[k];
			for(int k=i; k<=j; k++){
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum);
			}
		}
	}

	cout << dp[0][n-1];

	return 0;
}

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

int main(){
  ll x,N,ans=0;
  cin>>N;
  while(N--){
    cin>>x;
    while(!(x%2)){x/=2;ans++;}
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int c = 0, v[100000], m[100000];
	while(scanf("%d,%d", &v[c], &m[c]) != EOF){
		c++;
	}
	
	int sum = 0, ave = 0;
	for(int i = 0; i < c; ++i){
		sum += v[i] * m[i];
		ave += m[i];
	}
	cout << sum << endl;
	
	double d = (ave / (double)c) - ave / c;
	if(d >= 0.5)
		cout << ave / c + 1 << endl;
	else
		cout << ave / c << endl;
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
void dfs(long x);
vector<string> c;
int n;
int main(){
    cin>>n;
    dfs(0);
    int ans=0;
    for(int i=0;i<c.size();i++){
        bool f1=false,f2=false,f3=false;
        for(int j=0;j<c[i].size();j++){
            if(c[i][j]=='7')f1=true;
            if(c[i][j]=='5')f2=true;
            if(c[i][j]=='3')f3=true;
        }
        if(f1&&f2&&f3)ans++;
    }
    cout<<ans<<endl;
    return 0;
}
void dfs(long x){
    if(x<=n){
        c.push_back(to_string(x));
    }
    else{
        return;
    }
    dfs(x*10+3);
    dfs(x*10+5);
    dfs(x*10+7);
}


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

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

  int N; cin >> N;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int index = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == index) {
      index++;
    } else {
      ans++;
    }
  }
  if (ans == N) ans = -1;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
int in[M];
using namespace std;
typedef long long LL;
int main()
{ 
	int n, ans;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> in[i];
	sort(in, in+n);
	ans = in[n/2] - in[n/2-1];
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d\n",b+MIN(a+b+1,c));
	return 0;
}
    
    


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int i, j;
    long int n, k, a[200000];
    scanf("%ld", &n);
    scanf("%ld", &k);
    for(i=0; i<n; i++) scanf("%ld", &a[i]);
    for(i=k+1; i<=n; i++){
        if(a[i-1] > a[i-k-1]) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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

int main()
{
int x,y;
cin>>x>>y;
char c=y;
    if(x<y)
             {
                for(int i=0;i<y;i++)
                   {
                       cout<<x;
                   }
             }


     else
        {
                for(int i=0;i<x;i++)
                   {
                       cout<<y;
                   }
             }

return 0;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  ll x, k, d; cin>>x >>k >>d;
  if(x<0) x *= -1;
  if(x / d >= k) cout<< x - d * k <<endl;
  else{
    ll  a = x / d;
    k -= a;
    x -= a * d;
    if(k % 2 == 0) cout<< x <<endl;
    else cout<< d - x <<endl;
  }
}


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

int main() {
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	if (a > b) {
		ans += b;
		if (a > c) ans += a * 10 + c;
		else ans += c * 10 + a;
	}
	else {
		ans += a;
		if (b > c) ans += b * 10 + c;
		else ans += c * 10 + b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Queue;
import java.util.LinkedList;

public class Main
{
	public static void main(String[] args)
	{
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ,x =fr.nextInt()-1 ,y =fr.nextInt()-1 ,lvl[] =new int[n] ,i ,j ,k ,l ,d[] =new int[n] ;
 		ArrayList<ArrayList<Integer>> g =new ArrayList<>() ;	Queue<Integer> q =new LinkedList<>() ;
 		for (i =0 ; i<n ; ++i)	g.add(new ArrayList<>()) ;
 		for (i =0 ; i+1<n ; ++i) {
 			g.get(i).add(i+1) ;	g.get(i+1).add(i) ;
 		}
 		g.get(x).add(y) ;	g.get(y).add(x) ;
 		
 		for (l =0 ; l+1<n ; ++l) {	
 			for (i =0 ; i<n ; ++i)	lvl[i] =-1 ;
			lvl[l] =0 ;	q.add(l) ;	
			while (!q.isEmpty()) {
				i =q.poll() ;
				for (j =0 ; j<g.get(i).size() ; ++j) {
					k =g.get(i).get(j) ;	if (lvl[k]!=-1)	continue;
					lvl[k] =lvl[i]+1 ;	q.add(k) ;
				}
			}
			for (i =l+1 ; i<n ; ++i)	d[lvl[i]]++ ;
		}
		for (i =1 ; i<n ; ++i)	op.println(d[i]) ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
    int N;
    cin >> N;
    int ans = 90;

    for (int i = 1; i < N; i++) {
        int n = findSumOfDigits(i) + findSumOfDigits(N - i);
        ans = min(ans, n);
    }

    cout << ans << endl;

    return 0;
}

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

struct store {
	long long price;
	long long stock;

	bool operator< (const store& other) {
		return this->price < other.price;
	}
};

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

	vector<store> ar;
	ar.resize(n);
	long long money = 0;
	for (auto& i : ar)
	{
		cin >> i.price >> i.stock;
	}

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

	long long result = 0;
	int i = 0;
	while (m) {
		int tmp = min(m, ar[i].stock);
		m -= tmp;
		result += tmp * ar[i].price;
		i++;
	}

	cout << result;	
	

	


	return 0;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;

int main(void) {
	ll n, ans = 1;
	cin >> n;
	vint a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vint cnt(n);
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			ans *= 3 - cnt[0];
			cnt[0]++;
		}
		else {
			ans = (ans* (cnt[a[i] - 1]-cnt[a[i]]))%1000000007;
			cnt[a[i]]++;
		}

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

Measured memory_bytes: 1792
//#include <cmath>
//#include <ctime>
#include <cstdio>
//#include <cstdlib>
//#include <cstring>

//#include <map>
//#include <set>
//#include <queue>
//#include <string>
//#include <vector>
//#include <sstream>
//#include <iostream>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int MAXN = 100005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;

inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}



int main() {
    int a,b,c;
    a=getint();b=getint();c=getint();
    c = min(c, a+b+1);
    printf("%d",b+c);
}


Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
    int sum = 0;
    char ch;
 
    while(true)
    {
        while((ch = getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum == 0)
            break;
        else{
            printf("%d\n",sum);
            sum = 0;
        }
    }
}


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

int main()
{
  int64_t N, ans = 0;
  string a, b, c;
  cin >> N >> a >> b >> c;
  for (int i = 0; i < N; i++)
  {
    if (a[i] == b[i] && b[i] == c[i])
      continue;
    if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i])
      ans++;
    else
      ans += 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())

    if N == 1 or M == 1:
        if N == 1 and M == 1:
            print(1)
            return
        print(N*M-2)
        return

    if N == 2 or M == 2:
        print(0)
        return

    print((N-2)*(M-2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def gen_d_prim(n):
    D = [0,0] + [-1] * (n-1)
    for i in range(2, n+1, 2): D[i] = 2
    for i in range(3, n+1, 2):
        if D[i] > 0: continue
        for j in range(i, n+1, i): D[j] = i
    return D

def is_pairwise(A):
    D = gen_d_prim(10**6)
    past = set()
    for a in A:
        now = set()
        while a != 1:
            # 素数 D[a]: 今回は未済 & 過去で済
            if not D[a] in now and D[a] in past: return False
            now.add(D[a])
            past.add(D[a])
            a //= D[a]
    return True

def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def solve():
    if is_pairwise(A): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


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

int main()
{
	int H, W;
	while(cin >> H >> W && H != 0 || W != 0)
	{
		for(int i = 0; i < H; ++i)
		{
			for(int j = 0; j < W; ++j)
			{
				cout << (i == 0 || i == H - 1 || j == 0 || j == W - 1 ? "#" : ".");
			}
			cout << endl;
		}
		cout << endl;
	}

    return 0;
}



Measured memory_bytes: 2988
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  vector<int> a(5);
  int x = 10;
  int ans = 0;
  rep(i, 5){
    cin >> a[i];
    int y = a[i] % 10;
    if (y != 0) x = min(x, y);
    a[i] += 9;
    a[i] = a[i] / 10 * 10;
    ans += a[i];
  }
  ans -= (10 - x);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3584
/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
using ll = long long;
#define endl '\n'
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define all(x) (x).begin(), (x).end()
/* **************************************************************************************** */

void test_case()
{
    int x;
    cin >> x;
    if(x == 0)
        cout << '1';
    else 
        cout << '0';
	return ;
}
int main()
{
	FAST_IO
    test_case();
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

ll dp[10010][105][2];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll m;
  string s;
  cin >> s >> m;
  const int n = s.size();

  dp[0][0][0] = 1;
  REP(i, n) REP(j, m) REP(k, 2) {
    int lim = k?9:s[i]-'0';
    REP(d, lim+1) {
      (dp[i+1][(j+d)%m][k || d<lim] += dp[i][j][k]) %= MOD;
    }
  }

  ll ans = 0;
  REP(i, 2) (ans += dp[n][0][i]) %= MOD;
  cout << (ans+MOD-1) % MOD << endl;

  return 0;
}


Measured memory_bytes: 16640
#include <stdio.h>
#include <string.h>
 
void mD(char C, int *D) {
  switch (C) {
    int t;
  case 'N':
    t = D[0]; D[0] = D[1]; D[1] = D[5]; D[5] = D[4]; D[4] = t;
    break;
  case 'S':
    t = D[0]; D[0] = D[4]; D[4] = D[5]; D[5] = D[1]; D[1] = t;
    break;
  case 'E':
    t = D[0]; D[0] = D[3]; D[3] = D[5]; D[5] = D[2]; D[2] = t;
    break;
  case 'W':
    t = D[0]; D[0] = D[2]; D[2] = D[5]; D[5] = D[3]; D[3] = t;
    break;
  case 'R':
    t = D[1]; D[1] = D[3]; D[3] = D[4]; D[4] = D[2]; D[2] = t;
    break;
  case 'L':
    t = D[1]; D[1] = D[2]; D[2] = D[4]; D[4] = D[3]; D[3] = t;
    break;
  }
  return;
}
 
 
int main(void) {
  int D1[6],D2[6],d,b=0;
  char C[]={' ','N','N','N','E','E','E'}; int c;
  for(d=0;d<6;d++)
    scanf("%d",&D1[d]);
  for(d=0;d<6;d++)
    scanf("%d",&D2[d]);
 
  for (c=0;c<7;c++) {
    mD(C[c], D2);
    if (D1[0]==D2[0]) {
      for(d=0;d<6;d++) {
        mD('R', D2);
        if (D1[1]==D2[1]) {
          if ((D1[2]==D2[2]) && (D1[3]==D2[3])
              && (D1[4]==D2[4]) && (D1[5]==D2[5]))
            b=1;
        }
      }
    }
  }
  if (b)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

//  bool judge = (vc == "1479");
//  if (judge) print("Yes");
//  else print("No");

  std::string s;
  std::cin >> s;

  if (s.size() == 3) std::reverse(s.begin(), s.end());
  print(s);

  return 0;
}


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

long long dp[2009][2009], inv[2009], N, A, B, C, D, ret[2009][2009], mod = 1000000007;

long long ncr(long long M,long long R) {
	return dp[M - R][R];
}

int main() {
	for (int i = 0; i < 2008; i++) {
		for (int j = 0; j < 2008; j++) {
			if (i == 0 || j == 0) dp[i][j] = 1;
			else dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}
	for (int i = 1; i <= 2008; i++) {
		for (int j = 0; j < i; j++) {
			long long T = 1LL * mod*j + 1;
			if (T%i == 0) { inv[i] = T / i; break; }
		}
	}
	cin >> N >> A >> B >> C >> D;
	ret[1][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (i < A || B < i) {
				ret[i + 1][j] += ret[i][j]; ret[i + 1][j] %= mod;
				continue;
			}
			ret[i + 1][j] += ret[i][j]; ret[i + 1][j] %= mod;
			long long F = ret[i][j], cnt = 0;
			for (int k = j + i; k <= N; k += i) {
				F *= ncr(k, i); F %= mod; cnt++; F *= inv[cnt]; F %= mod;
				if (cnt < C || D < cnt) continue;
				ret[i + 1][k] += F; ret[i + 1][k] %= mod;
			}
		}
	}
	cout << ret[N + 1][N] << endl;
	return 0;
}

Measured memory_bytes: 48512
import java.util.Arrays;
import java.util.Scanner;

//A Long Ride on a Railway
public class Main{

	int n, m, max;
	int INF = 1<<27;
	int[][] d;
	boolean[] u;
	int[] ans, trace;
	
	void debug(Object...o){
		System.err.println(Arrays.deepToString(o));
	}
	
	long f(int[] a, int n){
		long x = 0;
		for(int i=0;i<n;i++)x = x*10+(a[i]-1);
		return x;
	}
	
	void dfs(int k, int v, int dist){
		if(max==dist){
			trace[k] = v;
			long a = f(trace, k+1);
			long b = f(ans, ans.length);
			if(a<b){
				ans = new int[k+1];
				for(int i=0;i<=k;i++)ans[i]=trace[i];
//				debug(max); debug(ans);
			}
		}
		else if(max<dist){
			trace[k] = v;
			max = dist;
			ans = new int[k+1];
			for(int i=0;i<=k;i++)ans[i]=trace[i];
//			debug(max); debug(ans);
		}
		for(int i=0;i<m;i++){
			if(u[i])continue;
			if(d[i][0]!=v&&d[i][1]!=v)continue;
			trace[k] = v;
			if(d[i][0]==v){
				int t = d[i][1];
				u[i] = true;
				dfs(k+1, t, dist+d[i][2]);
				u[i] = false;
			}
			else{
				int t = d[i][0];
				u[i] = true;
				dfs(k+1, t, dist+d[i][2]);
				u[i] = false;
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			m = sc.nextInt();
			if((n|m)==0)break;
			d = new int[m][3];		
			for(int i=0;i<m;i++)for(int j=0;j<3;j++)d[i][j]=sc.nextInt();
			trace = new int[m];
			u = new boolean[m];
			max = 0;
			for(int i=0;i<m;i++){
				u[i] = true;
				trace[0] = d[i][0];
				dfs(1, d[i][1], d[i][2]);
				trace[0] = d[i][1];
				dfs(1, d[i][0], d[i][2]);
				u[i] = false;
			}
			System.out.println(max);
			for(int i=0;i<ans.length;i++)System.out.print(ans[i]+(i==ans.length-1?"\n":" "));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s;
    cin >> s;
    int x = 0;
    rep(i,s.size()){
        x += s[i] - '0';
    }
    if(x % 9 == 0)yn;
    return 0;
}




Measured memory_bytes: 3696
#include<iostream>
using namespace std;
int main()
{
	int h=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]=='C')
    	{
    		h=1;
    	}
    	if(h==1&&s[i]=='F')
    	{
    		cout<<"Yes"<<endl;
    		return 0;
    	}
    }
    cout<<"No"<<endl;
    return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 202
using namespace std;
int n;
int a[N];
int main()
{
//	freopen("test_.inp","r",stdin);
//	freopen("test_.out","w",stdout);
	ios::sync_with_stdio(0);
	cin>>n;
	n*=2;
	for (int i=1; i <= n; i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	int res=0;
	for (int i=1; i <= n; i+=2)
		res+=a[i];
	cout<<res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
#define pb(x) push_back(x)
#define fi first
#define se second
#define mp(x,y) make_pair(x,y);

/*struct comp
{
    bool operator()()
    {
        
    }
};*/

int32_t main() {
    int t=1;
    //cin>>t;
    while(t--)
    {
     int X;
     cin>>X;
        map<int,int> M;
        
        for(int i=0;i*i*i*i*i<10000000000000000;i++)
        {
             M[i*i*i*i*i]=i;
             M[(-1LL)*i*i*i*i*i]=(-i);
                
        }
        
        for(int i=0;true;i++)
        {
            if(M.find(X+i*i*i*i*i)!=M.end())
            {
                cout<<M[X+i*i*i*i*i]<<" "<<i;
                return 0;
            }
            if(M.find(X+(-1LL)*i*i*i*i*i)!=M.end())
            {
                cout<<M[X+(-1LL)*i*i*i*i*i]<<" "<<-i;
                return 0;
            }
        }
        

        
    }
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int res=0;
    for(int i=1;;i++)
    {
        res+=i;
        if(res>a && res-a==(res+i+1)-b)
        {
            cout<<res-a<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/
ll dp[100005][2];
ll A[100005];
ll n;
ll solve(ll i,bool f){
    if(i == n){
        return 0;
    }
    if(dp[i][f] != -1)
        return dp[i][f];
    ll d = __gcd( A[i], solve(i+1,f) );
    if(f){
        ll d2 = solve(i+1,false);
        d = max(d,d2);
    }
    return dp[i][f] = d;
}
int main(){
    //freopen(".txt", "w", stdout
    //IO;

    cin>>n;
    ll d2 = 0;
    for(int i = 0; i < n; i++){
        cin>>A[i];
        if(i+1 != n)
            d2 = __gcd(d2,A[i]);
    }
    memset(dp,-1,sizeof dp);
    cout<<max(d2, solve(0,true));
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
int main(void){
  int m,f,r;
  while(scanf("%d %d %d",&m,&f,&r),m+f+r!=-3){
    if(m==-1||f==-1)
      printf("F\n");
    else if(m+f>=80)
      printf("A\n");
    else if(m+f>=65)
      printf("B\n");
    else if(m+f>=50)
      printf("C\n");
    else if(m+f>=30){
      if(r>=50)
	printf("C\n");
      else
	printf("D\n");
    }
    else
      printf("F\n");
  }
  return 0;
}



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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, wcnt = 0, cnt = 0;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < n; ++i){
		if (s[i] == 'W') ++wcnt;
	}
	for (int i = 0; i < wcnt; ++i){
		if (s[n-1-i] != 'W') ++cnt;
	}	
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

typedef long long ll;
using namespace std;
const int mod = 1000000007;


int N, K;
ll R, S, P;
string T;
vector< vector<char> > hand(100001);

ll point(char a);
bool judge(int r, int c);

int main() {

    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    for (int i = 0; i < T.size(); i++)
        hand[i % K].push_back(T[i]);

    /*
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < hand[i].size(); j++) {
            cout << hand[i][j] << ' ' ;
        }
        cout << '\n';
    }
    */

    ll ans = 0;
    for (int i = 0; i < K; i++) {
        ll tmp1 = 0;
        for (int j = 0; j < hand[i].size(); j++) {
            if (judge(i, j))
                tmp1 += point(hand[i][j]);
     //   cout << tmp1 << ' ' << tmp2 << '\n';
        }
        ans += tmp1;
    }

    cout << ans << '\n';

}

bool judge(int r, int c) {

    bool can = true;
    if (c != 0) {
        if (hand[r][c-1] == hand[r][c]) {
            can = false;
            hand[r][c] = 'z';
        }
    }
    return can;
}


ll point(char a) {
    if (a == 'r') return P;
    else if (a == 's') return R;
    else if (a == 'p') return S;
    return 0;
}


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



int main(){
  int N;
  cin>>N;
  
  map<string, int> dic;
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if(dic.count(s)) dic.at(s)+=1;
    else dic[s] = 1;
  }
  
  int M;
  cin>>M;
  for(int i=0;i<M;i++){
    string s;
    cin>>s;
    if(dic.count(s)) dic.at(s)-=1;
    else dic[s] = -1;
  }
  int ans = 0;
    for(auto& x: dic) {
        ans = max(ans, x.second);
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[][] num = new int[3][3];
        boolean[][] flag = new boolean[3][3];
        int flag2 = 0;

        for(int i = 0;i<3;i++){
            for(int j = 0;j<3;j++){
                num[i][j] = sc.nextInt();
                flag[i][j] = true;
            }
        }

        int cnt = sc.nextInt();
        int n = 0;

        while(cnt>n){
            int ans = sc.nextInt();
            for(int i = 0; i<3;i++){
                for(int j = 0;j<3;j++){
                    if(num[i][j]==ans){
                        flag[i][j]=false;
                    } 
                }
            }
            n++;
        }   


        if(flag[0][0]==flag[0][1] && flag[0][1]==flag[0][2] && flag[0][2]==false){
            flag2 = 1;
        }
        if(flag[1][0]==flag[1][1] && flag[1][1]==flag[1][2]&& flag[1][2]==false){
            flag2 = 1;
        }
        if(flag[2][0]==flag[2][1] && flag[2][1]==flag[2][2]&& flag[2][2]==false){
            flag2 = 1;
        }
        if(flag[0][0]==flag[1][0] && flag[1][0]==flag[2][0]&& flag[2][0]==false){
            flag2 = 1;
        }
        if(flag[0][1]==flag[1][1] && flag[1][1]==flag[2][1]&& flag[2][1]==false){
            flag2 = 1;
        }
        if(flag[0][2]==flag[1][2] && flag[1][2]==flag[2][2]&& flag[2][2]==false){
            flag2 = 1;
        }
        if(flag[0][0]==flag[1][1] && flag[1][1]==flag[2][2]&& flag[2][2]==false){
            flag2 = 1;
        }
        if(flag[0][2]==flag[1][1] && flag[1][1]==flag[2][0]&& flag[2][0]==false){
            flag2 = 1;
        }

        if(flag2 == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int sum[]=new int[2];
		for(int i=0;i<4;i++){
			sum[0]+=sc.nextInt();
		}
		for(int i=0;i<4;i++){
			sum[1]+=sc.nextInt();
		}
		if(sum[1]<=sum[0]){
			System.out.println(sum[0]);
		}
		else{
			System.out.println(sum[1]);
		}
	}
}

Measured memory_bytes: 12000
from collections import deque

S = list(input())
q = deque(S)
cnt_rev = 0
Q = int(input())
for _ in range(Q):
    T, *R = input().split()
    if T == "1":
        cnt_rev += 1
    else:
        F, c = R
        if cnt_rev % 2 == 0:
            if F == "1":
                q.appendleft(c)
            else:
                q.append(c)
        else:
            if F == "1":
                q.append(c)
            else:
                q.appendleft(c)

ans = list(q)
if cnt_rev % 2 == 1:
    ans.reverse()
print(*ans, sep="")


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

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++)
		cin >> h.at(i);
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		bool canW = true;
		for (int j = 0; j < i; j++)
		{
			if (h.at(i) < h.at(j))
			{
				canW = false;
				break;
			}
		}
		if (canW)
			ans++;
	}
	cout << ans << endl;
}

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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  
 if(op == '+'){
  cout<<A + B<<endl;
  }
  
 if(op == '-'){
  cout<<A - B<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n;
	int a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 == 0 || a % 5 == 0) {
				continue;
			}
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}






Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		long x = sc.nextLong();
		for (int i = 0; i < 10; i++) {
			x = r * x - d;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 23892
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n;
LL cnt[200005];
vector< pair<LL, pLL> > ed;

int main()
{
	FIO;
	cin >> n;
	LL ans = 0;
	rep(i,1,n) ans += i*(n-i+1);
	rep(i,1,n-1) {
		LL u,v;
		cin >> u >> v;
		if(u > v) swap(u, v);
		LL mn = min(u, n-v+1);
		LL mx = max(u, n-v+1)-1;
		ans -= ((mn*(mn+1)));
		ans -= mn * (mx-mn);
	} 
	cout << ans << endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#define INF 10000000000000
#define MAX 100000
#define MAX_N 200
typedef long long ll;
using namespace std;
vector<vector<ll>> dp(MAX_N,vector<ll>(MAX+1,INF));
int main(){
  ll n,w,tw,tv;
  cin >> n >> w;
  for(int i=0;i<MAX_N;i++){
    dp[i][0]=0;
  }
  for(int i=1;i<=n;i++){
    cin >>tw>>tv;
    for(int j=0;j<=MAX;j++){
      dp[i][j]=dp[i-1][j];
      if(j-tv>=0&&dp[i-1][j-tv]!=INF){
        dp[i][j]=min(dp[i][j],dp[i-1][j-tv]+tw);
      }
    }
  }
  for(int i=MAX;i>=0;i--){
    if(dp[n][i]!=INF&&dp[n][i]<=w){
      cout << i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 157824
#include <stdio.h>

int main(void){
    int i,j;
    char str[20];

    for(i=0;i<20;i++) scanf("%c",&str[i]);
    
    for(j=19;j>=0;j--){
        if(str[j]!=EOF) printf("%c",str[j]); 
    } 
    printf("\n");
    return 0;
}


Measured memory_bytes: 2032
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int h[100005];
int dp[100005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>h[i];
	memset(dp,0x3f3f3f,sizeof(dp));
	dp[2]=abs(h[2]-h[1]);
	dp[1]=0;
	for(int i=3;i<=n;i++){
		int d=0;
		for(int j=0;j<k&&(i-j-1)>0;j++){
			dp[i]=min(dp[i-j-1]+abs(h[i]-h[i-j-1]),dp[i]);
		}
	}	
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4368
# coding: utf-8

n = input()
a = map(int, raw_input().split())
rate = [0] * 9

for i in xrange(n):
    if a[i] <= 399:
        rate[0] = 1
    elif a[i] <= 799:
        rate[1] = 1
    elif a[i] <= 1199:
        rate[2] = 1
    elif a[i] <= 1599:
        rate[3] = 1
    elif a[i] <= 1999:
        rate[4] = 1
    elif a[i] <= 2399:
        rate[5] = 1
    elif a[i] <= 2799:
        rate[6] = 1
    elif a[i] <= 3199:
        rate[7] = 1
    else:
        rate[8] += 1

if 1 in rate[:8]:
    print sum(rate[:8]), sum(rate)
else:
    print 1, sum(rate)


Measured memory_bytes: 2692
S=input()
T=input()

ans_list=[]
for i in range(len(S)-len(T)+1):
    X=S[i:i+len(T)]
    isOK=True
    for j in range(len(T)):
        if X[j]=="?" or X[j]==T[j]:
            pass
        else:
            isOK=False
            break
    
    if isOK:
        ans=S[:i]+T+S[i+len(T):]
        
        ans=ans.replace('?','a')
        ans_list.append(ans)

if len(ans_list)<1:
    print("UNRESTORABLE")
else:
    ans_list.sort()
    print(ans_list[0])


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

int main()
{
    int n = 0,ans = 0,j = 0;
    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        int digit = 0;
        j = i;
        while (j != 0)
        {
            j /= 10;
            digit++;
        }
        if (digit % 2 == 1)
        {
            ans++;
        } 
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3636
a = int(input())

dif = a
half = int(a / 2)
for i in range(1,half+1):
	if i <= a / i:
		if a % i == 0:
			div1 = int(i)
			div2 = int(a / i)
			continue
	else:
		break
print(div1 + div2 -2)


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

template <class T>
using V = vector<T>;

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

V<int> par;

void init(int n){
    for(int i=0; i<n; i++) par.at(i) = i;
}

int root(int x){
    if(par.at(x) == x){
        return x;
    }else{
        return par.at(x) = root(par[x]);
    }
}

bool same(int x, int y){
    return root(x) == root(y);
}

void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x == y) return;
    par.at(x) = y;
}

int main(){
    int N, M;
    cin >> N >> M;
    V<int> A(M), B(M);
    rep(i, M){
        cin >> A.at(i) >> B.at(i);
        A.at(i)--; B.at(i)--;
    }

    par.resize(N);
    init(N);
    rep(i, M) unite(A.at(i), B.at(i));

    V<int> cnt(N, 0);
    rep(i, N) cnt.at(root(i))++;

    int max = 0;
    rep(i, N){
        if(cnt.at(i) > max) max = cnt.at(i);
    }
    cout << max << endl;
}

Measured memory_bytes: 9424
//##MohK
//13/2/2020.... 7,40
#include <bits/stdc++.h>
using namespace std ;
using ll = long long ;
using ld = long double;
int main(){
    ll a;
    cin>>a;
    ll c=a/100;
    if(a%100>00&&a%100<=12&&c>00&&c<=12){
        cout<<"AMBIGUOUS"<<endl;
    }
    else if(a%100>00&&a%100<=12&&(c==0||c>12)){
        cout<<"YYMM"<<endl;
    }
     else if((a%100==00||a%100>12)&&(c>00&&c<=12)){
        cout<<"MMYY"<<endl;
    }
    else cout<<"NA"<<endl;

 return 0 ;
}




Measured memory_bytes: 256
x = int(input())

if x < 600:
  print (8)
elif x < 800:
  print (7)
elif x < 1000:
  print (6)
elif x < 1200:
  print (5)
elif x < 1400:
  print (4)
elif x < 1600:
  print (3)
elif x < 1800:
  print (2)
else:
  print (1)

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

int main() {
    long long n,a,b,x;
    cin >> n;
    float rn = sqrt(n);
    int ans = 10;
    for (int i=1; i<=rn; i++) {
        a = i;
        if (n % a == 0) {
            b = n / a;
            x = max(a, b);
            int dig = 0;
            while (x > 0) {
                x = x / 10;
                dig++;
            }
            ans = min(ans, dig);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a[101][101],b[101],c[101];
    int i,j;
    int n,m;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++) {
        for (j=0;j<m;j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    for (i=0;i<n;i++) {
        c[i]=0;
        for(j=0;j<m;j++){
            c[i]=a[i][j]*b[j]+c[i];
        }
    }
    for (i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    return 0;
}


Measured memory_bytes: 2080