akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<cstdio>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
int isp[N];
vector<int>prime;
void getprime(int n)
{
	for(int i=2;i<n;i++){
		if(isp[i]==-1)continue;
		for(int j=2*i;j<n;j+=i){
			isp[j]=-1;
		}
		prime.push_back(i);
	}
}
int vis[N];
void solve(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n){
		cin>>a[i];
		vis[a[i]]++;
	}
	int gc=a[0];
	for(int i=1;i<n;i++)gc=gcd(gc,a[i]);
	bool f=false;
	for(int i:prime){
		int cnt=0;
		cnt+=vis[i];
		for(int j=2*i;j<N;j+=i)cnt+=vis[j];
		if(cnt>1){f=true;break;}
	}
	if(!f)cout<<"pairwise coprime";
	else if(gc==1)cout<<"setwise coprime";
	else cout<<"not coprime";
}
int main()
{
	getprime(N);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
   int n; cin >> n;
   int a[n]; rep(i,n) cin >> a[i]; 
   bool positive = false,negative = false;
   rep(i,n){
       if(a[i] > 0) positive = true;
       if(a[i] <= 0) negative = true;
   }
   ll ans = 0;
   sort(a,a+n);
   ll x = a[0], y = a[n-1];
   queue<int> n_que;
   queue<int> p_que;
   for(int i = 1; i < n-1; i++){
       if(a[i] <= 0) n_que.push(a[i]);
       else p_que.push(a[i]);
   }
   if(positive && negative){
       rep(i,n) ans += abs(a[i]);
       cout << ans << endl;
       while(!p_que.empty()){
           int k = p_que.front(); p_que.pop();
           cout << x << ' ' << k << endl;
           x -= k;
       }
       cout << y << ' ' << x << endl;
       y -= x;
       while(!n_que.empty()){
           int k = n_que.front(); n_que.pop();
           cout << y << ' ' << k << endl;
           y -= k;
       }
   }else if(positive){
       rep(i,n) ans += a[i];
       cout << ans - 2 * a[0] << endl;
       while(!p_que.empty()){
           int k = p_que.front(); p_que.pop();
           cout << x << ' ' << k << endl;
           x -= k;
       }
       cout << y << ' ' << x << endl;
   }else{
       rep(i,n) ans += abs(a[i]);
       cout << ans + 2 * a[n-1] << endl;
       while(!n_que.empty()){
           int k = n_que.front(); n_que.pop();
           cout << y << ' ' << k << endl;
           y -= k;
       }
       cout << y << ' ' << x << endl; 
   }  
}

Measured memory_bytes: 2688
m = 0
f = 0
r = 0

while(True):
    I = input().split()
    m = int(I[0])
    f = int(I[1])
    r = int(I[2])
    if m == -1 and f == -1 and r == -1:
        break
    score = m + f
    if m == -1 or f == -1:
        print('F')
        continue
    if score >= 80:
        print('A')
    if 65 <= score and score < 80:
        print('B')
    if 50 <= score and score < 65:
        print('C')
    if 30 <= score and score < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    if score < 30:
        print('F')

Measured memory_bytes: 7720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
        }
        A[0] = A[N] - K;

        int aaa = Integer.MIN_VALUE;

        for (int i = 1; i <= N; i++) {
            aaa = Math.max(A[i] - A[i - 1], aaa);
        }

        System.out.println(K - aaa);

    }

}


Measured memory_bytes: 82132
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 5e4+5,INF = 0x3f3f3f3f; int n,ecnt = 1,head[N],s,t,p[4],dx[4] = {1,1,-1,-1},dy[4] = {1,-1,1,-1},pre[N],flow[N]; LL dis[N]; bool vis[N]; queue<int> q;
	struct Edge {int v,w,f,nxt;} e[N]; il void add(int u,int v,int f,int w) {e[++ecnt] = (Edge){v,w,f,head[u]}; head[u] = ecnt; e[++ecnt] = (Edge){u,-w,0,head[v]}; head[v] = ecnt;}
	il bool spfa(int s,int t) {
		memset(dis,flow[s] = INF,sizeof(dis)); dis[s] = pre[t] = 0; q.push(s);
		while (!q.empty()) {
			int u = q.front(); q.pop(); vis[u] = 0; grep(i,u) if (e[i].f && dis[v] > dis[u]+e[i].w) {
				pre[v] = i; dis[v] = dis[u]+e[i].w; flow[v] = min(flow[u],e[i].f); if (!vis[v]) {q.push(v); vis[v] = 1;}
			}
		}
		return pre[t];
	}
	il LL mcmf(int s,int t) {LL res = 0; while (spfa(s,t)) {res += 1LL*dis[t]*flow[t]; int x = t; while (x) {e[pre[x]].f -= flow[t]; e[pre[x]^1].f += flow[t]; x = e[pre[x]^1].v;}} return res;}
	void main() {
		n = read(); s = n*2+1; t = s+1; rep(i,0,3) p[i] = t+i+1;
		rep(i,1,n) {int x = read(),y = read(),k = read(); add(s,i,k,0); rep(j,0,3) add(i,p[j],INF,dx[j]*x+dy[j]*y);}
		rep(i,n+1,n*2) {int x = read(),y = read(),k = read(); add(i,t,k,0); rep(j,0,3) add(p[j],i,INF,-dx[j]*x-dy[j]*y);}
		printf("%lld\n",-mcmf(s,t));
	}
}
int main() {
	qiqi::main(); return 0;
}

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

int main() {
  string n;
  cin >>n;
  if(n=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
}


Measured memory_bytes: 3496
require 'pp'

a = Array.new(9)
a[0], a[1], a[2] = gets.split.map(&:to_i)
a[3], a[4], a[5] = gets.split.map(&:to_i)
a[6], a[7], a[8] = gets.split.map(&:to_i)
n = gets.to_i
b = Array.new(n)
n.times do |i|
    b[i] = gets.to_i
end

x = Array.new(9, 0)
b.each do |i|
    t = a.find_index(i)
    if t
        x[a.find_index(i)] = 1
    end
end

#pp x

if (x[0] == 1 && x[1] == 1 && x[2] == 1) ||
    (x[3] == 1 && x[4] == 1 && x[5] == 1) ||
    (x[6] == 1 && x[7] == 1 && x[8] == 1) ||
    (x[0] == 1 && x[3] == 1 && x[6] == 1) ||
    (x[1] == 1 && x[4] == 1 && x[7] == 1) ||
    (x[2] == 1 && x[5] == 1 && x[8] == 1) ||
    (x[0] == 1 && x[4] == 1 && x[8] == 1) ||
    (x[2] == 1 && x[4] == 1 && x[6] == 1)
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

	if (C <= A + B)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int n,k;
int f[101000];
int h[101000];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=k+1;i<=k+n;i++){
		scanf("%d",&h[i]);
		f[i]=2e9;
	}
	f[k+1]=0;
	for(int i=k+2;i<=k+n;i++)
		for(int j=1;j<=k;j++)
			if(i-j>=k+1)f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
	printf("%d",f[k+n]);
	return 0;
}

Measured memory_bytes: 1024
d,g=map(int,input().split())
pc={_:(list(map(int,input().split()))) for _ in range(d)}
bin_lst=[]
d2=2**d
for x in range(d2):
    buf=bin(x)[2:]
    len_buf=len(buf)
    if len_buf<d:
        buf='0'*(d-len_buf)+buf
    bin_lst.append(buf)
lst_cnt=[]
buf_lst=[]
for x in bin_lst:
    cnt=0
    buf_int=0
    len_x=len(x)
    for y in range(d):
        if x[y]=="1":
            buf_lst=pc[y]
            buf_int+=(y+1)*100*buf_lst[0]+buf_lst[1]
            cnt+=buf_lst[0]
    if buf_int<g:
        buf_index=x.rfind("0")
        buf_lst=pc[buf_index]
        i=buf_lst[0]
        for z in range(1,i):
            if buf_int+(buf_index+1)*100*z>=g:
                buf_int+=(buf_index+1)*100*z
                cnt+=z
                break
    if buf_int>=g:
        lst_cnt.append(cnt)
print(min(lst_cnt))

Measured memory_bytes: 3064
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

r,g,b = sarr()
flag = int(r+g+b)%4 == 0
ans = "YES" if flag else "NO"
print(ans)


Measured memory_bytes: 14980
let _ =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let s = Scanf.scanf "%s\n" (fun s -> s) in
  let r, b = ref 0, ref 0 in
  for i = 0 to (n-1) do
    let c = String.get s i in
    if c = 'R' then r := !r + 1;
    if c = 'B' then b := !b + 1;
  done;
  (if !r > !b then "Yes" else "No") |> print_string

Measured memory_bytes: 384
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int dp[55][55][3333];

main(){
	int n,a;cin>>n>>a;int x[n];rep(i,n)cin>>x[i];
	dp[0][0][0]=1;
	rep(i,n)rep(j,n)rep(k,2500){
		dp[i+1][j][k]+=dp[i][j][k];
		dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[n][i][i*a];
	}
	dans;
}





Measured memory_bytes: 72448
$prime = {}
$p = {}
def p(i)
  unless $p[i]
    if i == 0
      $p[i] = 2
    elsif i == 1
      $p[i] = 3
    else
      j = p(i-1) + 2
      loop do
        break if is_prime(j)
        j += 2
      end
      $p[i] = j
    end
  end
  return $p[i]
end

def sum_p(n)
  sum = 0
  n.times{|i|
    sum += p(i)
  }
  return sum
end

def is_prime(n)
  unless $prime[n]
    if n < 2
      $prime[n] = false
    elsif n < 4
      $prime[n] = true
    elsif n % 2 == 0
      $prime[n] = false
    else
      i = 3
      flag = true
      while i <= Math.sqrt(n)
        if n % i == 0 then
          flag = false
          break
        end
        i += 2
      end
      $prime[n] = flag
    end
  end
  return $prime[n]
end

while n = gets.to_i
  break if n == 0
  puts sum_p(n)
end

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

int main(){
	int n,t;
	while(cin >> n){
		int ret=0,now=0;
		vector<int> dt(n);
		for(int i=0;i<n;i++)
			cin >> dt[i];
				
		sort(dt.begin(),dt.end());
		for(int i=0;i<n;i++){
			now+=dt[i];
			ret+=now;
		}
		cout << ret << endl;
	}	
}

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

using namespace std;

int main() {
	string S;
	long long int N;
	cin >> S >> N;
	for( size_t i = 0; i < S.length(); i++ ) {
		if( 'z' + 1 - S[i] <= N&&S[i] != 'a' ) {
			N -= 'z' + 1 - S[i];
			S[i] = 'a';
		}
	}
	S[S.length() - 1] = (S[S.length() - 1] - 'a' + N) % 26 + 'a';
	cout << S << endl;
}


Measured memory_bytes: 512
#include<stack>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char list[255];
int main()
{
	list['A'] = 'T';
	list['T'] = 'A';
	list['C'] = 'G';
	list['G'] = 'C';
	char c;
	cin >> c;
	cout << list[c] << endl;
  	return 0;
	
}

Measured memory_bytes: 256
S = input()
count = 0
if S[0] == 'R':
    count += 1
for i in range(1, len(S)):
    if S[i] == 'R':
        if i == 2 and count == 0:
            count += 1
        if S[i-1] == 'R':
            count += 1
if S == "SRS":
    count = 1
print(count)

Measured memory_bytes: 61776
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    temp = []
    for j in range(a):
        x, y = map(int, input().split())
        temp.append((x, y))
    xy.append(temp)

ans = 0
for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break

    else:
        ans = max(ans, sum(ts))

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int n; cin >> n;
	vector<ll> a(n);
	vector<ll> odd(n+1), even(n+1);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
		odd[i + 1] = odd[i];
		even[i + 1] = even[i];
		if (i % 2 == 0) {
			even[i + 1] += a[i];
		}
		else {
			odd[i + 1] += a[i];
		}
	}
	sum /= 2;
	rep(i, n) {
		if (i > 0)cout << " ";
		if ((i + 1) % 2 == 0) {
			ll ans = even[n]-even[i+1]+odd[i];
			ans = sum - ans;
			cout << 2*ans;
		}
		else {
			ll ans = odd[n] - odd[i + 1] + even[i];
			ans = sum - ans;
			cout << 2*ans;
		}
	}
	cout << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a[100], i, N, exc, d, j, minj;

  scanf("%d", &N);

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

// Selection Sort(A,N)
  exc = 0;
  for (i = 0; i <= N - 1; i++ ){
    minj = i;
    for (j = i; j <= N - 1; j++){
      if (a[j] < a[minj]){
        minj = j;
      }
    }
    if(i != minj){
      exc++;
    }
    d = a[i];
    a[i] = a[minj];
    a[minj] = d;
  }

  for(i = 0; i <= N - 2; i++){
    printf("%d ", a[i]);
  }

  printf("%d\n%d\n",a[N-1], exc);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> A(N+1), B(N+1), C(N);
	int ans = 0;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) cin >> B[i];
	for (int i = 1; i <= N-1; i++) cin >> C[i];

	for (int i = 1; i <= N; i++) {
		ans += B[i];
		if (i != N && A[i + 1] - A[i] == 1) ans += C[A[i]];
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;

int main() {
	int n,q;
	std::vector<int> s, t;
	std::cin >> n;
	int a;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		s.emplace_back(a);
	}
	std::cin >> q;
	for (int i = 0; i < q; i++) {
		std::cin >> a;
		t.emplace_back(a);
	}
	int ans = 0;
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (s[j] == t[i]) {
				ans++;
				break;
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 3208
#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;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 1e5 + 10;

int n, m;
vector<PII> fwd[N], bwd[N];
LL x[N];
LL maxc, minc;

void die() {
    cout << "No\n";
    exit(0);
}

void dfs(int u) {
    minc = min(minc, x[u]);
    maxc = max(maxc, x[u]);
    for (PII p : fwd[u]) {
        int v = p.first;
        int d = p.second;
        if (x[v] == LINF) {
            x[v] = x[u] + d;
            dfs(v);
        } else {
            if (x[v] != x[u] + d) {
                die();
            }
        }
    }
    for (PII p : bwd[u]) {
        int v = p.first;
        int d = p.second;
        if (x[v] == LINF) {
            x[v] = x[u] - d;
            dfs(v);
        } else {
            if (x[v] != x[u] - d) {
                die();
            }
        }
    }
}

int main() {
    cin >> n >> m;
    REP(rep, m) {
        int l, r, d;
        cin >> l >> r >> d;
        fwd[l].emplace_back(r, d);
        bwd[r].emplace_back(l, d);
    }
    memset(x, LINF, sizeof x);
    for (int i = 1; i <= n; i++) {
        if (x[i] == LINF) {
            minc = LINF, maxc = -1;
            x[i] = 0;
            dfs(i);
            if (maxc - minc > (int)1e9) {
                die();
            }
        }
    }
    cout << "Yes\n";
}






























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

int main(void) {
	int N;
	long long D;
	scanf("%d %lld", &N, &D);
	long long X, Y;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		scanf("%lld %lld", &X, &Y);
		if (X*X + Y*Y <= D*D) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;

const int mn=2e5+5;
const int mod=998244353;

int n;
char s[mn];
int cal;
ll d[mn][3][3][2];// pos cnt this eq

void spj(){
	bool eq=1;
	for(int i=1;i<n;i++) if(s[i]!=s[i+1]){eq=0;break;}
    if (eq){puts("1");exit(0);}
    if (n==2){
		puts("2");
		exit(0);
    }
    if (n==3){
		int cnt=0;
		if (s[1]==s[3]) cnt++;
		if (s[2]==s[3]) cnt++;
		if (s[1]==s[2]) cnt++;
		if (cnt==0) puts("3");
		else if (s[1]==s[3]&&s[1]!=s[2]&&s[2]!=s[3]) puts("7");
		else puts("6");
		exit(0);
    }

}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=1;
	for(int i=1;i<=n;i++){
		cal=(cal+s[i]-'a')%3;
		if (s[i]==s[i+1]) flag=0;
	}
	spj();
	d[1][0][0][0]=1;
	for(int k=1;k<=n;k++){//position
		for(int i=0;i<=2;i++){//state
			for(int j=0;j<=2;j++){//previous letter
				if(k==1&&j!=0) continue;
				for(int l=0;l<=2;l++){//nxt letter
					if (j==l&&k!=1){
						d[k+1][(i+l)%3][l][1]+=d[k][i][j][0]+d[k][i][j][1];
						d[k+1][(i+l)%3][l][1]%=mod;
					}
					else{
						d[k+1][(i+l)%3][l][1]+=d[k][i][j][1];
						d[k+1][(i+l)%3][l][1]%=mod;
						d[k+1][(i+l)%3][l][0]+=d[k][i][j][0];
						d[k+1][(i+l)%3][l][0]%=mod;
					}
				}
			}
		}
	}
	printf("%lld\n",(flag+d[n+1][cal][0][1]+d[n+1][cal][1][1]+d[n+1][cal][2][1])%mod);

	return 0;
}


Measured memory_bytes: 28544
table = {
	'AC' : 0,
	'WA' : 0,
	'TLE' : 0,
	'RE' : 0,
}

n = int(input())

for i in range(n):
	verdict = input().strip()
	table[verdict]+=1

for v in table:
	print('{0} x {1}'.format(v, table[v]))

Measured memory_bytes: 9208
#include<stdio.h>
int main(void)
{
	int a,b,c,k,max;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	if (a<=b) max=b; else max=a;
	if (max<=c) max=c;
	int anc;
	anc=a+b+c-max;
	for(int i=0;i<k;i++){
		max=max*2;
	}
	anc=anc+max;
	printf("%d",anc);
	return 0;
}

Measured memory_bytes: 128
// C++ program to find median of a matrix 
// sorted row wise 
#include<bits/stdc++.h> 
using namespace std; 

#define ll long long

int main() 
{ 
	ll n,k,r;
  
    cin>>n>>k>>r;
  
    ll min1 = n*k;
    ll min2 = min(min1,r);
  
    cout<<min2<<endl;
} 


Measured memory_bytes: 256
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(setq *n* (read))
(setq *ps* (mapcar #'parse-integer (split " " (read-line))))

(defun increasingp (l)
  (let ((delta (if
                (or
                  (< (car l) (cadr l) (caddr l))
                  (> (car l) (cadr l) (caddr l))
                ) 1 0)
        ))
       
    (if (equal (cadddr l) nil)
        delta
        (+ delta (increasingp (cdr l)))
  )))

(print (increasingp *ps*))

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

using namespace std;

#define MAX_H 15
#define MAX_W 15
#define MAX_O 55
#define INF (1<<29)

struct State{
    int cost,x,y,o;
    State(){}
    State(int cost,int x,int y,int o) :
        cost(cost),x(x),y(y),o(o) {}

    bool operator < (const State &s)const{
        if(cost != s.cost){
            return cost > s.cost;
        }else{
            return o < s.o;
        }
    }
};

int main(){
    int W,H,f,m,o;
    while(cin >> W >> H, W){
        cin >> f >> m >> o;
        vector<vector<int> > G(H+1,vector<int>(W,0));
        for(int i = 1 ; i <= H ; i++){
            for(int j = 0 ; j < W ; j++){
                cin >> G[i][j];
            }
        }

        const int dx[] = {-1,0,1}, dy[] = {0,1,0};
        bool reachable = 0;
        
        priority_queue<State> Q;
        Q.push(State(0,0,0,o));
        
        int d[MAX_H][MAX_W][MAX_O];
        for(int i = 0 ; i < MAX_H ; i++){
            for(int j = 0 ; j < MAX_W ; j++){
                for(int k = 0 ; k < MAX_O ; k++){
                    d[i][j][k] = INF;
                }
            }
        }
        d[0][0][o] = 0;
        
        while(!Q.empty()){
            State s = Q.top(); Q.pop();
            int x = s.x,y = s.y; o = s.o;
            if(o == 0) continue;
            if(y == H){
                if(s.cost <= f){
                    reachable = 1;
                    cout << s.cost << endl;
                }
                break;
            }
            if(o == 1) continue;
            for(int i = 0 ; i < 3 ; i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx < 0 || nx >= W) continue;
                if(G[ny][nx] < 0){
                    if(d[y][x][o] - G[ny][nx] < d[ny][nx][o-1]){
                        d[ny][nx][o-1] = d[y][x][o] - G[ny][nx];
                        Q.push(State(d[ny][nx][o-1],nx,ny,o-1));
                    }
                }else if(G[ny][nx] > 0){
                    int no = min(o+G[ny][nx]-1,m);
                    if(d[y][x][o] < d[ny][nx][no]){
                        d[ny][nx][no] = d[y][x][o];
                        Q.push(State(d[ny][nx][no],nx,ny,no));
                    }
                }else{
                    if(d[y][x][o] < d[ny][nx][o]){
                        d[ny][nx][o] = d[y][x][o];
                        Q.push(State(d[ny][nx][o],nx,ny,o));
                    }
                }
            }
        }
        if(!reachable){
            cout << "NA" << endl;
        }
    }
    return 0;
}

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

const int inf = 1e8;
int n,k,a[8888],dp[8888];

int main(){
  scanf("%d%d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);

  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=a[i]-i+1;j++)dp[j] = inf;
    int arg = 0;
    for(int j=i;j<a[i]-1;j++){
      if(a[i]<a[j]){
	int tmp = lower_bound(dp,dp+arg+1,a[j]) - dp;
	dp[tmp++] = a[j];
	if(arg<tmp)arg = tmp;
      }
    }
    ans = max(ans, ++arg);
  }
  printf("%d\n",min(ans+k,n/2));
}

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

using namespace std;

vector<int> Ws[100001], Hs[100001];
int par[40000];

int find(int x)
{
    return (par[x] >= 0 ? par[x] = find(par[x]) : x);
}

void merge(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (-par[x] < -par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
}

int main()
{
    int n, w, h;
    int cw = 0, ch = 0;
    
    scanf("%d %d %d", &n, &w, &h);
    
    for (int i = 0; i < n; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        
        if (a == 1 || a == w) cw = 1;
        if (b == 1 || b == h) ch = 1;
        
        Ws[a].push_back(i);
        Hs[b].push_back(i);
    }
    
    memset(par, -1, sizeof(par));
    for (int i = 1; i <= w; i++){
        for (int j = 1; j < Ws[i].size(); j++){
            merge(Ws[i][j - 1], Ws[i][j]);
        }
    }
    for (int i = 1; i <= h; i++){
        for (int j = 1; j < Hs[i].size(); j++){
            merge(Hs[i][j - 1], Hs[i][j]);
        }
    }
    
    set<int> s;
    for (int i = 0; i < n; i++) s.insert(find(i));
    
    printf("%d\n", s.size() == 1 ? n - 1 : (n - 1 + s.size() - (cw | ch)));
    
    return (0);
}

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


int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  bool has_odd = false;
  for(int i = 0;i < n;i++){
    cin >> in[i];
    if (in[i]%2 != 0)has_odd= true;
  }
  if (has_odd)cout <<"first" << endl;
  else cout <<"second" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main(){
	int n,m;
	char t;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
{
	for(int j=1;j<=m;j++)
{
	cin>>t;
	if(t=='#')
	a[i][j]=1;
	else a[i][j]=0; 
}	
}	
	for(int i=1;i<=n;i++)	
{
	for(int j=1;j<=m;j++)
{
	if(a[i][j]==1) 
    printf("#");
	else 
{
	 printf("%d",a[i+1][j+1]+
	 a[i+1][j-1]+
	 a[i+1][j]+
	 a[i][j+1]+
	 a[i][j-1]+
	 a[i-1][j+1]+
	 a[i-1][j]+
	 a[i-1][j-1]);
}
}	
    printf("\n");
}   
    return 0;
}

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

int main(void){
	int N,M,x,cnt=0;
	cin>>N>>M;
	map<int,bool> a;
	rep(i,M){
		cin>>x;
		a[x]=true;
	}
	queue<int> qu;
	rep(i,N)qu.push(i);
	while(qu.size()>1){
		int l=qu.front(); qu.pop();
		int r=qu.front(); qu.pop();
		if(!a[l] && !a[r])cnt++;

		if(!a[r])qu.push(r);
		else qu.push(l);
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include<vector>
#include<stdio.h>
#include<iostream>
using namespace std;

vector<pair<int,int>> g[100001];
int diks[100001];
bool is_checked[100001];
bool is_reached[100001];

bool is_root(int a){
    if(is_checked[a]) {
        return true;
    } else is_checked[a] = true;
    
    for(int i = 0; i < g[a].size(); i++){
        if(is_reached[ g[a][i].first ]){
            if(diks[ g[a][i].first ] != diks[a] + g[a][i].second){
                return false;
            }
        }
        diks[ g[a][i].first ] = diks[a] + g[a][i].second;
        is_reached[ g[a][i].first ] = true;
        if(!is_root(g[a][i].first)) return false;
    }
    return true;
}

int main(){
    int N, M; cin >> N >> M;
    for(int i = 0; i < M; i++){
        int L, R, D; cin >> L >> R >> D;
        g[L-1].push_back(pair<int,int>(R-1, D));
        g[R-1].push_back(pair<int,int>(L-1, -D));
    }
    for(int i = 0; i < N; i++){
        is_checked[i] = false;
        is_reached[i] = false;
    }
    
    // for(int i = 0; i < N; i++){
    //     for(int j = 0; j < g[i].size(); j++){
    //         cout << g[i][j].first;
    //     } cout << endl;
    // }
    for(int i = 0; i < N; i++){
        diks[i] = 0;
        if(!is_root(i)) {
            cout << "No";
            return 0;
        }
    } cout << "Yes";
    
    return 0;
}



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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

bool isPrimeNum(const unsigned n) {
    if (n <= 1) return false;
    for (unsigned i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    /* code */
    unsigned X;
    cin >> X;
    while (true) {
        if (isPrimeNum(X)) {
            cout << X << endl;
            return 0;
        }
        X++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char b[1];
  
  	scanf("%s",b);
  	if(b[0]=='A') 
      printf("T\n");
  	else if(b[0]=='T')
      printf("A\n");
  	else if(b[0]=='C')
      printf("G\n");
  	else if(b[0]=='G') 
      printf("C\n");
  
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define INF 1000000000
#define f first
#define s second
using namespace std;
typedef pair <int,pair <int,int> > P;
typedef long long ll;
int n,d,tree[4][(1<<19)];
P star[200001];
 
void update(int i,int flg,int x){
  i = i+(1<<18)-1;
  tree[flg][i] = x;
  while(i) {
    i = (i-1)/2;
    tree[flg][i] = max(tree[flg][i*2+1],tree[flg][i*2+2]);
  }
}
 
int find(int a,int b,int ima,int L,int R,int flg){
  if(R<=a || b<=L) return -INF;
  if(a<=L && R<=b) return tree[flg][ima];
  int M = (L+R)/2;
  return max(find(a,b,ima*2+1,L,M,flg),find(a,b,ima*2+2,M,R,flg));
}
 
int main() {
  cin >> n >> d;
 
  for(int i=0;i<n;i++)cin >> star[i].s.f >> star[i].s.s >> star[i].f;
  sort(star,star+n);  
   
  for(int i=0;i<4;i++) 
    for(int j=0;j<(1<<19);j++) tree[i][j] = -INF;
   
  for(int i=0;i<n;i++) {
    update(i,0,star[i].s.f); // max(x);
    update(i,1,star[i].s.s); // max(y);
    update(i,2,-star[i].s.f); // min(x);
    update(i,3,-star[i].s.s); // min(y);
  }
 
  long long S=0;
  int ima=0;
  for(int i=0;i<n;i++){
    while(ima!=n && star[ima].f-star[i].f <=d) ima++;
    ll maxx = find(i,ima,0,0,(1<<18),0);
    ll maxy = find(i,ima,0,0,(1<<18),1);
    ll minx = find(i,ima,0,0,(1<<18),2);
    ll miny = find(i,ima,0,0,(1<<18),3);
    S = max(S,((maxx+minx)*(maxy+miny)));
  }
  cout << S<<endl;
  return 0;
}

Measured memory_bytes: 11700
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long mod=1e9+7;

int main() {
  int A, B, X;
  cin >> X >> A >> B;
  if(B-A <= 0){
    cout << "delicious" << endl;
  }else if(B-A <= X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    char C;
    cin >> C;
    C++;
    cout << C << endl;
}



Measured memory_bytes: 256
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int d, n;
  scanf("%d%d", &d, &n);
  if (d == 0)
  {
    printf("%d\n", n == 100 ? 101 : n);
  }
  else if (d == 1)
  {
    printf("%d\n", n == 100 ? 10100 : n * 100);
  }
  else
  {
    printf("%d\n", n == 100 ? 1010000 : n * 100 * 100);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

const long long MAX_P = 200001;

// 入力はすべて正とする
// 素数判定O(√n)
bool is_prime(long long n) {
	for (long long i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return n != 1; // 1の場合は例外
}
// 約数の列挙O(√n)
vector<long long> divisor(long long n) {
	vector<long long> res;
	for (long long i = 1; i * i <= n; i++) {
  	if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) res.push_back(n / i);
		}
	}
	return res;
}
// 素因数分解O(√n)
map<long long, long long> prime_factor(long long n) {
	map<long long, long long> res;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

long long mod_inverse(long long a, long long m) {
	long long x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}

long long fact[MAX_P+1];
// n! mod pのテーブルを作る O(p)
void mod_fact(long long n, long long m) {
	fact[0] = 1;
	for (long long i = 1; i <= n; i++) fact[i] = fact[i-1]*i%m;
}

// n!=a p^e としたときのa mod pを求める。O(log_p n)
long long mod_fact(long long n, long long p, long long& e) {
	e = 0;
	if (n == 0) return 1;
	// pの倍数の部分を計算
	long long res = mod_fact(n / p, p, e);
	e += n / p;
	// (p-1)!≡-1なので(p-1)!^(n/p)はn/pの偶奇だけで計算できる
	if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
	return res * fact[n % p] % p;
}

// nCk mod pを求める。O(log_p n)
long long mod_comb(long long n, long long k, long long p) {
	if (n < 0 || k < 0 || n < k) return 0;
	long long e1, e2, e3;
	long long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
	//if (a1 * mod_inverse(a2 * a3 % p, p) % p == 0) printf("%lld, %lld, %lld,%lld, %lld, %lld\n",n, p, e1,a1, a2, a3);
	if (e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p, p) % p;
}



void solve(long long N, long long K){
	mod_fact(MAX_P,mod);
	repn(i, K) {
		cout << mod_comb(N-K+1,i,mod)*mod_comb(K-1,i-1,mod)%mod << endl;
	}
}

int main(){	
	long long K;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&K);
	solve(N, K);
	return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    // input
    string S; cin >> S;
    string T; cin >> T;

    // compute
    vector<char> s(S.size());
    vector<char> t(T.size());
    for (int i = 0; i < S.size(); i++){
        s[i] = S.at(i);
    }
    for (int i = 0; i < T.size(); i++){
        t[i] = T.at(i);
    }
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());

    // output
    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n, sum;

int digit_sum(int n) {
    int ret = 0;
    while(n) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}
signed main() {
    cin >> n;
    int s = digit_sum(n);
    string ans =  (n % s == 0)? "Yes":"No";
    cout << ans << endl;
}

Measured memory_bytes: 256
def number_of_divisors(m)
	count = 1
	for i in 2..m/2
		if m%i == 0
			count += 1
		end
	end	
	if (m > 1)
		count += 1
	end
	return count
end

n = gets.chop.to_i

total_count = 0

for j in 1..n
	if j%2 == 1 && number_of_divisors(j) == 8
		total_count += 1
	end
end

puts total_count.to_s

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back
#define mp         make_pair

#define TRUE true
#define LIAR false

const int N = 600;

typedef pair<int,int> pii;

class Edge{
public:
  int t;
  bool isyes;
};

vector<Edge> edge[N];
bool vis[N];

void dfs(int now,bool istrue,int &cnt,vector<int> &trueset,int work){
  if (istrue){
    if (work == 0);
    if (work == 1)cnt++;
    if (work == 2)trueset.pb(now);
  }
  vis[now]=true;
  rep(i,edge[now].size()){
    int next=edge[now][i].t;
    if (vis[next])continue;
    if (edge[now][i].isyes)dfs(next,istrue,cnt,trueset,work);
    else dfs(next,!istrue,cnt,trueset,work);
  }
}


int table[1000][1000];
bool path[1000][1000];//used true(first) or liar(second)
vector<int> dp(vector<pii> &in,int numT){
  vector<int> used;
  int n =in.size();
  rep(i,n){
    rep(j,numT+1){
      table[i][j]=0;
      path[i][j]=false;
    }
  }


  table[0][in[0].first]++;
  path[0][in[0].first]=true;
  
  table[0][in[0].second]++;
  path[0][in[0].second]=false;
  
  REP(i,1,n){
    rep(j,numT+1){
      if (j-in[i].first>=0 &&table[i-1][j-in[i].first]){
	table[i][j]+=table[i-1][j-in[i].first];
	path[i][j]=true;
      }
      if (j-in[i].second>=0&&table[i-1][j-in[i].second]){
	table[i][j]+=table[i-1][j-in[i].second];
	path[i][j]=false;
      }
    }
  }
  

  if (table[n-1][numT] != 1){
    used.clear();
    return used;
  }

  int i=n-1,j=numT;
  while(i >=0){
    if (path[i][j] == true)j=j-in[i].first,used.pb(1);
    else j=j-in[i].second,used.pb(0);
    i--;
  }
  
  reverse(ALL(used));
  return used;
}

void solve(int n,int numT){
  rep(i,n)vis[i]=false;
  int cnt=0;
  vector<int> dummy;
  vector<int> root;
  vector<pii> data;
  
  rep(i,n){
    if (vis[i])continue;
    root.pb(i);
    dfs(i,TRUE,cnt,dummy,0);
  }
  
  rep(i,root.size()){
    pii ins;
    int tmp=0;
    //root[i]=true
    rep(j,n)vis[j]=false;
    tmp=0;
    dfs(root[i],TRUE,tmp,dummy,1);
    ins.first=tmp;
    //root[i]=liar
    rep(j,n)vis[j]=false;
    tmp=0;
    dfs(root[i],LIAR,tmp,dummy,1);
    ins.second=tmp;
    data.pb(ins);
  }
  
  vector<int> rootset=  dp(data,numT);

  if (rootset.size() == 0){
    cout <<"no"<<endl;
    return;
  }
  
  rep(i,n)vis[i]=false;
  
  vector<int>trueset;
  rep(i,rootset.size()){
    dfs(root[i],rootset[i]==1,cnt,trueset,2);
  }

  sort(ALL(trueset));
  rep(i,trueset.size()){
    cout << trueset[i]+1 << endl;
  }
  cout <<"end"<<endl;
  return;
}


main(){
  int m,p1,p2;
  while(cin>>m>>p1>>p2 ){
    if (m == 0 && p1 == 0 && p2 == 0)break;
    int n=p1+p2;
    rep(i,n)edge[i].clear();
    
    rep(i,m){
      int f,t;
      string q;
      bool isyes;
      cin>>f>>t>>q;
      f--;t--;
      if (q =="yes")isyes=true;
      else isyes=false;
      edge[f].pb((Edge){t,isyes});
      edge[t].pb((Edge){f,isyes});
    }

    solve(n,p1);
  }
  return false;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  vector<P> s(k);
  rep(i, k) {
    cin >> s[i].first >> s[i].second;
    ++s[i].second;
  }
  vector<mint> dp(n+1, 0);
  dp[1] = 1;
  dp[2] = -1;
  for(int i = 1; i < n; ++i) {
    mint x = dp[i];
    rep(j, k) {
      if(i+s[j].first <= n) dp[i+s[j].first] += x;
      if(i+s[j].second <= n) dp[i+s[j].second] -= x;
    }
    dp[i+1] += dp[i];
  }
  cout << dp[n].x << endl;
}

Measured memory_bytes: 4824