akhauriyash/Code-Regression huggingface dataset:
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

ll read() {
	ll X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int main() {
	ll n=read(),m=read(),c=min(n,m/2);
	n-=c,m-=2*c;
	if (m) c+=m/4;
	printf("%lld\n",c);
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
using namespace std;
#define INF 1050000000
int main(){
  int N;
  cin>>N;
  vector<int>H(N);
  for (int i=0;i<N;++i){
    cin>>H[i];
  }
  vector<int>c(N,INF);
  c[0]=0;
  for (int i=1;i<N;++i){
    if (i==1){
      c[i]=c[i-1]+abs(H[i]-H[i-1]);
    } else{
      c[i]=min(c[i-1]+abs(H[i]-H[i-1]),
               c[i-2]+abs(H[i]-H[i-2]));
    }
  }
  cout<<c[N-1]<<endl;
}                                    
                                    


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int ob = (mod + 1) >> 1;
int a[100005];
int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		ans += a[a[i]] == i;
	}
	cout << ans;

}




Measured memory_bytes: 640
W = 5

until (n = $<.gets.to_i).zero?
  field = []
  
  n.times do
    d, p, q = $<.gets.split.map(&:to_i)
    if d == 1
      block = ((1 << p) - 1) << W + 1 - p - q
      if field.empty?
        field = [block]
      else
        i = field.size - 1
        while (field[i] & block).zero?
          i -= 1
          break if i < 0
        end
        i += 1
        field[i] ||= 0
        field[i] |= block
      end
    else
      block = 1 << W - q
      if field.empty?
        p.times {field.push(block)}
      else
        i = field.size - 1
        while (field[i] & block).zero?
          i -= 1
          break if i < 0
        end
        p.times do
          i += 1
          field[i] ||= 0
          field[i] |= block
        end
      end
    end
    
    field.delete_at(i) while (i = field.index(31))
  end
  
  puts field.map {|a| a.to_s(2)}.join.count("1") 
end


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

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

  lint A, B, N;
  cin >> A >> B >> N;

  lint mx = min(B - 1, N);
  lint ans = A * mx - (A * mx) % B;
  ans /= B;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long

int n;
pair<int,int> s[200001];
signed main(){
	cin >> n;
	for(int i = 1 ; i <= n ; i ++){
		int time,dead;
		cin >> time >> dead;
		s[i] = {dead, time};
	}
	sort(s + 1, s + n + 1);
	int cur = 0;
	for(int i = 1 ; i <= n ; i ++){
		if(cur + s[i].second > s[i].first) {
			cout << "No";
			return 0;
		}
		cur += s[i].second;
	}
	cout << "Yes";
}

Measured memory_bytes: 3328
def push(s,x):
    s.append(x)
    return(s)

def pop(s):
    ind = len(s)
    a = s[ind-1]
    del s[ind-1]
    return(s, a)



A = input().split()
n = len(A)

stack = []

for i in range(n):
    if (A[i] == '+') or (A[i] == '-') or (A[i] == '*'):
        stack, b = pop(stack)
        stack, a = pop(stack)
        if A[i] == '+':
            stack = push( stack, (int(a)+int(b)) )
        elif A[i] == '-':
            stack = push( stack, (int(a)-int(b)) )
        else:
            stack = push( stack, (int(a)*int(b)) )
    else:
        push(stack, A[i])

print(stack[0])


Measured memory_bytes: 5604
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

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

vector<int> adj[MAXN];

int n;

int dfs(int v) {
    vector<int> vv;

    for (int to : adj[v]) {
        vv.pb(dfs(to));
    }

    sort(all(vv));
    reverse(all(vv));

    int ret = adj[v].size();

    for (int i = 0; i < vv.size(); ++i) {
        ret = max(ret, vv[i] + i + 1);
    }

    return ret;
}

void solve() {
    scanf("%d", &n);

    for (int i = 2, x; i <= n; ++i) {
        scanf("%d", &x);
        adj[x].pb(i);
    }

    printf("%d\n", dfs(1));
}

int main() {
    int tt = 1;

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

    return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int min(int m,int n){
    if(m>n) return n;
    else return m;
}

int main(void){
    int n;
    char s[201000];
    scanf("%d %s",&n,s);
    int dot=0;
    for(int i=0;i<n;i++)if(s[i]=='.')dot++;
    int ans=dot;
    for(int i=0;i<n;i++){
        if(s[i]=='#') dot++;
        else dot--;
        ans=min(ans,dot);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  string S;
  cin >> S;

  int N = S.size();

  ll ans = 0;
  rep(i, 1 << N - 1) {
    vector<int> plus(N);
    rep(j, N - 1) {
      plus[j] = (i >> j) & 1; /* 1:plus, 0:None */
    }
    plus[N - 1] = 1;

    ll temp = 0;
    rep(i, N) {
      temp += S[i] - '0';
      if (plus[i] == 1) {
        ans += temp;
        temp = 0;
      } else {
        temp *= 10;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# Segment tree (Sum)
class SegmentTree():
    _data = []
    _offset = 0
    _size = 0

    def __init__(self, size):
        _size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [0 for _ in range(t * 2 - 1)]

    def update(self, index, value):
        i = self._offset + index
        self._data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            self._data[i] = self._data[i * 2 + 1] + self._data[i * 2 + 2]

    def query(self, start, stop):
        result = 0
        l = start + self._offset
        r = stop + self._offset
        while l < r:
            if l & 1 == 0:
                result = result + self._data[l]
            if r & 1 == 0:
                result = result + self._data[r - 1]
            l = l // 2
            r = (r - 1) // 2
        return result


from sys import stdin
readline = stdin.readline

N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])
st = SegmentTree(N - 1)

result = 0
for a, b in ab:
    a, b = a - 1, b - 1
    if st.query(a, b) != 0:
        continue
    result += 1
    st.update(b - 1, 1)
print(result)


Measured memory_bytes: 30564
// https://atcoder.jp/contests/agc019/tasks/agc019_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string A;
  cin >> A;

  map<char, ll> ctm;

  for (char c : A) {
    ctm[c]++;
  }

  ll dup = 0;
  for (auto p : ctm) {
    dup += p.se * (p.se - 1) / 2;
  }

  ll res = 1 + A.size() * (A.size() - 1) / 2 - dup;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  int ans = 0;
  bool ok = 0;
  for(int i = 0;i<1000;i++){
     ans += k;
     if(a<=ans&&ans<=b){ok = 1;break;}
  }
  if(ok) cout << "OK";
  else cout << "NG";
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>

using namespace std;

int n;
int number[100];
int v,j;


int main(){
	cin >> n;
	for(int x=0;x<n;x++){
		cin >> number[x];
	}

	for(int i=0;i<n-1;i++){
		printf("%d ",number[i]);
	}
	printf("%d\n",number[n-1]);

	for(int i=1;i<n;i++){
		v=number[i];
		j=i-1;
		while((j >=0) && (number[j] > v)){
			number[j+1] = number[j];
			j--;
		}
		number[j+1] = v;

		for(int y=0;y<n-1;y++){
			printf("%d ",number[y]);
		}
		printf("%d\n",number[n-1]);

	}
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll L, R;
    cin >> L >> R;
    const int p = 2019;
    ll ans;
    if (R - L + 1 >= p)
    {
        ans = 0;
    }
    else
    {
        ans = LONG_MAX;
        for (ll i = L; i <= R - 1; ++i)
        {
            for (ll j = i + 1; j <= R; ++j)
            {
                ans = min(ans, ((i % p) * (j % p)) % p);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
num_of_prefectures, cities = gets.split.map &:to_i
history = Array.new(num_of_prefectures, 0)
ans = Array.new(cities).map{Array.new(4, 0)}
cities.times do |i|
  prefecture, year = gets.split.map &:to_i
  ans[i][0] = "%06d" % prefecture
  ans[i][1] = year
  ans[i][2] = i
end
ans = ans.sort_by { |e| e[1] }
cities.times do|i|
  ans[i][3] = "%06d" % (history[ans[i][0].to_i - 1] + 1)
  history[ans[i][0].to_i - 1] += 1
end
ans = ans.sort_by { |e| e[2] }
ans.each{ |c| puts [c[0],c[3]].join}


Measured memory_bytes: 41920
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int a,b,c,x;
	cin >> a>>b>>c>>x;
	x /= 50;
	int cnt=0;

	for(int i=0;i<=a;i++) {
	for(int j=0;j<=b;j++) {
	for(int k=0;k<=c;k++) {
	if (10*i+2*j+k == x) {
	cnt++;
	}}}}

	cout << cnt << endl;
	return 0;
}


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

bool all_search(vector<int> &A, int m, int idx) {
  if (int(A.size()) == idx or m < 0)
    return m == 0;
  return all_search(A, m - A.at(idx), idx+ 1) || all_search(A, m, idx + 1);
}

int main() {
  int n;
  vector<int> A;
  int temp;
  cin >> n;
  rep(_, n){
    cin >> temp;
    A.push_back(temp);
  }
  int q;
  vector<int> M;
  cin >> q;
  rep(_, q) {
    cin >> temp;
    M.push_back(temp);
  }
  for(auto &item: M) {
    if (all_search(A, item, 0))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

  }
}



Measured memory_bytes: 3172
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {
    
    lld MAXN = (lld) 1e6+2LL;
    lld n; cin >> n;
    std::vector<lld> present(MAXN, false);
    lld ans = 1LL;
    while (true) {
        if (present[n] != false)  {
            break;
        }
        present[n] = true;
        if (n & 1) n = 3*n + 1;
        else n /= 2;
        ans++;
    }
    cout << ans;

    cout << "\n"; 

    return;
}


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

    lld T3X0 = 0, T353 = 1;

    // TESTCASES() 
        solveEachTest(T353 - T3X0);
    return 0;
}


Measured memory_bytes: 11064
package main

import (
	"fmt"
	"strings"
)

func main() {
	var d int
	fmt.Scan(&d)
	ans := []string{"Christmas"}
	for i := 0; i < 25 - d; i++ {
		ans = append(ans, "Eve")
	}
	fmt.Println(strings.Join(ans, " "))
}

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

int main()
{
    long long n,k;
    cin>>n>>k;
    vector<int> a(n);
    int i,j;
    long long ans1 = 0;
    long long ans2 = 0;
    for(i = 0; i < n; i++)
    {
        cin>>a.at(i);
    }
    for(i = 0; i < n-1; i++)
    {
        for(j = i+1; j < n; j++)
        {
            if(a.at(i) > a.at(j))ans1++;
            ans1 %= 1000000007;
        }
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            if(a.at(i) > a.at(j))ans2++;
            ans2 %= 1000000007;
        }
    }
    long long ks = (k*(k-1)/2)%1000000007;
    ans2 = (ans2 * ks)%1000000007;
    ans1 = ans1 * k%1000000007;
    cout << (ans1+ans2)%1000000007 << endl;
}

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

int main(){
    string s;
    cin>>s;
    set<char> st;
    for(int i=0;i<s.size();i++) st.insert(s[i]);
    cout<<(s.size()==st.size()?"yes":"no")<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut buf = buf.split_whitespace();
    let mut a: u32 = buf.next().unwrap().parse().unwrap();
    let mut b: u32 = buf.next().unwrap().parse().unwrap();
    let mut c: u32 = buf.next().unwrap().parse().unwrap();

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

    for _ in 0..k {
        let max = cmp::max(cmp::max(a, b), c);
        if max == a {
            a *= 2;
        } else if max == b {
            b *= 2;
        } else {
            c *= 2;
        }
    }

    println!("{}", a + b + c);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define maxn 100005
#define inf (1<<30)
#define mod 1000000007
using namespace std;
typedef long long LL;
int read()
{
	char c=getchar();int f=1,sum=0;
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int n,m,K,ans;
int nex[1<<21][25],lim[25][25];
void init()
{
	n=read()-1;m=read();K=read();
	for(int i=0;i<(1<<n);i++)
	{
		int pos=-1;
		for(int j=n-1;j>=0;j--)
		{
			if(i&(1<<j)) pos=j;
			nex[i][j]=pos;
		}
	}
	memset(lim,-1,sizeof(lim));
	for(int i=1;i<=K;i++)
	{
		int a=read(),b=read(),c=read();
		lim[a][b-1]=c;	
	}
}
int dp[2][25][(1<<21)];
int main()
{
	init();
	dp[0][n][0]=1;
	int now=1;
	for(int i=1;i<=m;i++)
	{
		for(int sta=0;sta<(1<<n);sta++) dp[now][0][sta]=dp[1-now][n][sta];
		for(int j=0;j<=n;j++)
        for(int sta=0;sta<(1<<n);sta++)
        dp[1-now][j][sta]=0;
        for(int j=0;j<n;j++)
        for(int sta=0;sta<(1<<n);sta++)
        if(dp[now][j][sta])
		{
            for(int k=0;k<=1;k++)
			{
            	if(lim[i][j]!=-1 && lim[i][j]!=k) continue;
            	int t=(bool)(sta&(1<<j));
                if(k==0 && t) continue;
                if(k==t) (dp[now][j+1][sta]+=dp[now][j][sta])%=mod;
                else
				{
                    if(nex[sta][j]==-1)
					dp[now][j+1][sta+(1<<j)]=(dp[now][j+1][sta+(1<<j)]+dp[now][j][sta])%mod;
                    else
					dp[now][j+1][sta+(1<<j)-(1<<nex[sta][j])]=(dp[now][j+1][sta+(1<<j)-(1<<nex[sta][j])]+dp[now][j][sta])%mod;
                }
            }
        }
        now=1-now;
	}
	for(int sta=0;sta<(1<<n);sta++)
	ans=(ans+dp[1-now][n][sta])%mod;
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 217472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long H = GetLong();
		long W = GetLong();
		long K = GetLong();
		var grid = new char[H, W];
		for(long i = 0; i < H; i++)
		{
			var S = GetString();
			for(long j = 0; j < W; j++)
				grid[i, j] = S[(int)j];
		}

		long ans = 0;
		for(long s = 0; s < leftShift(1, H); s++)
		{
			for(long t = 0; t < leftShift(1, W); t++)
			{
				long cnt = 0;
				for(long i = 0; i < H; i++)
				{
					if(contains(s, i))
						continue;

					for(long j = 0; j < W; j++)
					{
						if(contains(t, j))
							continue;

						if(grid[i, j] == '#')
							cnt++;
					}
				}
				if(cnt == K)
					ans++;
			}
		}
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 27500
#include<stdio.h>
 
int main(){
  int m,f,r;
   
  while(1){
    scanf("%d%d%d",&m,&f,&r);
 
    if(m==-1&&f==-1&&r==-1)
      return 0;
 
    else 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&&r>=50)
      printf("C\n");
 
    else if(m+f>=30&&r<50)
      printf("D\n");
 
    else
      printf("F\n");
  }
}

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

struct Trie {

  Trie() : nodes(1, vi(26, -1)), ends(1, 0),
	   chars(1, '$' - 'a'),
	   parents(1, -1),
	   times(1, 0),
	   counts(1, vi(26, 0)){
  }

  void add(const string &S) {
    i64 cur = 0;
    for(auto c: S) {
      i64 &next = nodes[cur][c - 'a'];
      if(next == -1) {
	next = sz(nodes);
	
	nodes.pb(vi(26, -1));
	ends.pb(0);
	chars.pb(c - 'a');
	
	parents.pb(cur);
	times.pb(1);

	counts.pb(vi(26, 0));
      }
      else {
	times[next]++;
      }
      cur = next;
    }
    ends[cur] = 1;

    vi flags(26, 0);
    i64 i;
    while(cur != -1) {
      REP(0, 26, i) {
	counts[cur][i] += flags[i];
      }
      if(cur != 0) {
	flags[chars[cur]] = 1;
      }
      cur = parents[cur];
    }
  }

  i64 solve() {
    i64 N = sz(nodes), i;

    /*
    // dump trie
    REP(0, N, i) {      
      cerr << "trie edge " << parents[i] << " -> " << i << " char " << char('a' + chars[i]) << " count " << times[i] << " end " << ends[i]  << endl;
    }
    */

    i64 ans = 0;
    REP(0, N, i) {
      i64 cur = N - i - 1;
      if(cur == 0)
	continue;

      if(ends[cur] == 1) {
	ans += counts[parents[cur]][chars[cur]] - 1;
	//cerr << " delta " << cur << " ->  " << counts[parents[cur]][chars[cur]] - 1 << endl;
      }
    }
    return ans;    
  }

  vvi nodes;
  vi ends;
  vector<char> chars;
  vi parents;
  vi times;
  vvi counts;
};

int main(int argc, char *argv[]) {
  i64 N, i;
  cin >> N;

  Trie trie;
  REP(0, N, i) {
    string S;
    cin >> S;
    reverse(all(S));
    trie.add(S);
  }

  cout << trie.solve() << endl;

  return 0;
}


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


namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int sum = int.Parse(Console.ReadLine());
                if (sum==0)
                {
                    break;
                }

                int max = 0;
                int start = 0;
                for (int i = 1; i < sum; i++)
                {
                    int sumi = (i * (i + 1)) / 2;
                    if (sumi > sum)
                    {
                        break;
                    }

                    if ((sum - sumi) % i == 0)
                    {
                        max = i;
                        start = (sum - sumi) / i;
                    }
                }

                Console.WriteLine((start+1) + " " + max);
            }
            
        }
    }
}


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

int main() {
  while(true){
    int h,w;
    cin >> h >> w;
    if(h == 0&&w == 0) return 0;
    for(int i = 0;i < h;i++){
      for(int j = 0;j < w;j++){
        cout << '#';
        if(j == w-1) cout << "" << endl;
      }
    }
    cout << "" << endl;
  }
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n){
        int t; cin >> t;
        a[i] = t - (i + 1);
    }
    
    sort(ALL(a));
    int median;
    if(n % 2 == 1){
        median = a[n/2];
    }else{
        median = (a[n/2-1] + a[n/2])/2;
    }
    
    int ans = 1e16; //INF
    reps(b, median-5, median+5){
        int t = 0;
        rep(i,n){
            t += abs(a[i] - b);
        }
        ans = min(ans, t);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1792
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	ll n;
	cin>>n;
	n--;
	ll ans=n*(n+1)/2;
	cout<<ans;
}
int main()
{
//code

fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 256
/*
Author: Srinjoy
Language: C++ 17
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define fileinput(s) freopen(s,"r",stdin)
#define MINUS(a) memset(a,0xff,sizeof(a))
typedef long long ll;
const ll mod = 1000000007;

template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }
 
template<class T>
istream& operator >> (istream& in, pair<T, T> & v){ in >> v.X >> v.Y;return in; }

void printArr(vector<int> arr){
	cout<<"\n------------------------------------\n";

	for(int i=0;i<arr.size();i++) cout<<arr[i]<<" ";
	
	cout<<"\n------------------------------------\n";
}



int main(){
	optimiza_io

	const int inf = 1000000;

	int n;
	cin>>n;

	vector<int> arr(n);
	cin>>arr;

	vector<int> dp(n);

	dp[0] = 0;

	for(int i=1;i<n;i++){
		if(i-1>=0 && i-2>=0){
			dp[i] = min ( dp[i-1]+abs(arr[i]-arr[i-1]) , dp[i-2] + abs(arr[i-2]-arr[i]) );
		}

		else if(i-1>=0){
			dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
		}

		else{

		}

	}

	//printArr(dp);

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

	
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();

        if (k == 1)
        {
            Console.WriteLine(n * n * n);
            return;
        }

        long answer = 0;
        long count = n / k;
        answer += count * count * count;

        if (k % 2 == 0)
        {
            long count2 = n / k;
            if (n % k >= k / 2)
            {
                count2++;
            }
            answer += count2 * count2 * count2;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main() {
  int N;
  cin >> N;

  int Ans = 0;
  for (int i=1; i<=N; i+=2) {
    int Count = 0;
    for (int j=1; j<=i; j++) {
      if (i%j == 0) Count++;
    }
    if (8 == Count) Ans++;
  }

  cout << Ans << endl;
}


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

const int N = 100 * 1000 + 5;

vector <pair <int, int> > adj[N];

int a[N];
bool mark[N];
void dfs(int v) {
	mark[v] = true;
	for (int i = 0; i < adj[v].size(); i++) {
		int u = adj[v][i].first, d = adj[v][i].second;
		if (!mark[u]) {
			a[u] = a[v] + d;
			dfs(u);
		}
	}
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, d;
		cin >> u >> v >> d;
		adj[u].push_back({v, d});
		adj[v].push_back({u, -d});
	}
	for (int i = 1; i <= n; i++) {
		if (!mark[i]) {
			dfs(i);
		}
	}
	bool b = true;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < adj[i].size(); j++) {
			int u = adj[i][j].first, d = adj[i][j].second;
			if (a[u] != a[i] + d) {
				b = false;
			}
		}
	}
	if (b) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
} 


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

using namespace std;

int main(int argc, char *argv[])
{
	long long a, b;
	cin >> a >> b;

	long long k = (a + b) / 2;
	if (abs(a - k) == abs(b - k))
		cout << k << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
vector<int> X;

int main() {
  cin >> N;
  X.resize(N);
  for (int i = 0; i < N; i++)
    cin >> X[i];

  int x_max = *max_element(X.begin(), X.end());
  int x_min = *min_element(X.begin(), X.end());

  int res = INT_MAX;
  for (int i = x_min; i <= x_max; i++) {
    int power = 0;
    for (int j = 0; j < N; j++) {
      power += (X[j] - i) * (X[j] - i);
    }

    if (power < res) {
      res = power;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    int n,m;
    cin>>n>>m;
    vi v(n);
    rep(i,n)cin>>v[i];
    vvi w(m);
    rep(i,n)w[v[i]%m].pb(v[i]);
    // rep(i,m){
    //     rep(j,w[i].size()){
    //         cout<<w[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    ll ans=0;
    for(int i=1;i<ceil(m/2.0);i++){
        int a=i;
        int b=m-i;
        if(w[a].size()>w[b].size()){
            swap(a,b);
        }
        int minNum = w[a].size();
        set<int> s;
        int match=0;
        rep(j,w[b].size()){
            int t=w[b][j];
            if(s.count(t)==1){
                match++;
                s.erase(s.find(t));
            } else s.insert(t);
        }
        ans+=minNum+min(match*2,(int)w[b].size()-(int)w[a].size())/2;
        //cout<<i<<" "<<minNum<<" "<<match<<" "<<(int)w[b].size()<<" "<<(int)w[a].size()<<endl;
    }
    
    int match=0;
    match+=w[0].size()/2;
    if(m%2==0){
        match+=w[m/2].size()/2;
    }
    ans+=match;
    fin(ans);
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1;
    } return res;
}

int32_t main() { fastio;
    
    int n; cin >> n;
    int hap = 1000 * (n / 500);
    n = n % 500;
    hap += 5 * (n / 5);
    cout << hap << endl;

    return 0;
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

string s, t;

LL nxt[30][202020];
bool isok[30];
int main(){
    cin >> s >> t;
    s += s;
    for(int i = (int)s.size() - 1;i >= 0;i--){
        REP(j, 26){
            if(s[i + 1] == (char)('a' + j))nxt[j][i] = 1;
            else nxt[j][i] = nxt[j][i + 1] + 1;
        }
    }
    LL n = (int)s.size() / 2;
    REP(i, n)isok[s[i] - 'a'] = true;
    LL idx = 0;
    for(int i = 0;i < (int)t.size();i++){
        if(i == 0 && s[0] == t[0])continue;
        if(!isok[t[i] - 'a']){
            cout << -1 << endl;
            return 0;
        }
        idx += nxt[t[i] - 'a'][idx % n];
    }
    cout << idx + 1 << endl;
}

Measured memory_bytes: 43756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << N); ++bit)

int main()
{
    string S;
    cin >> S;
    ll cnt = 0;
    if (S.at(0) != 'A')
    {
        puts("WA");
        return 0;
    }
    repi(i, S.length(), 1)
    {
        if (isupper(S.at(i)))
        {
            if (i == 1 || i == S.length() - 1 || S.at(i) != 'C')
            {
                puts("WA");
                return 0;
            }
            cnt++;
        }
    }
    if (cnt != 1)
    {
        puts("WA");
    }
    else
    {
        puts("AC");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,k;
    cin >> n >> k;
    ll a[n], b[n];
    REP(i,n){
        cin >> a[i];
        b[i] = max(a[i], 0LL);
    }
    ll suma[n] = {}, sumb[n] = {};
    for(int i = 0; i < n; i++){
        suma[i + 1] = suma[i] + a[i];
        sumb[i + 1] = sumb[i] + b[i];
    }
    ll ans = 0;
    for(int i = 0; i <= n - k; i++){
        ans = max(ans, sumb[i] - sumb[0] + sumb[n] - sumb[i + k]);
        ans = max(ans, sumb[i] - sumb[0] + suma[i + k] - suma[i] + sumb[n] - sumb[i + k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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

ll gcd(ll a,ll b){
  if (a%b == 0){
    return(b);
  }else{
    return(gcd(b, a%b));
  }
}
ll lcm(ll a,ll b){
  return a * b / gcd(a, b);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  ll x=A[0];
  REP(i,N-1){
    x=gcd(x,A[i+1]);
  }

  if(x!=1){
    cout << "not coprime" << endl;
  }else{
    set<ll> st;
    int flag=0;
    REP(i,N){
      for(auto p:prime_factor(A[i])){
        if(st.count(p.fi)){
          flag=1;
          break;
        }
        st.insert(p.fi);
      }
    }

    if(flag==1){
      cout << "setwise coprime" << endl;
    }else{
      cout << "pairwise coprime" << endl;
    }
  }
}

Measured memory_bytes: 14788
N, M = gets.split.map(&:to_i)
W = [0]
V = [0]

N.times do
  w, v = gets.split.map(&:to_i)
  W << w 
  V << v 
end

dp = Array.new(N + 1) do |i|
  Hash.new do |h, j|
    if j < W[i]
      h[j] = dp[i - 1][j]
    else
      h[j] = [dp[i - 1][j], dp[i - 1][j - W[i]] + V[i]].max
    end
  end
end

dp[0] = Hash.new(0)

puts dp[N][M]

Measured memory_bytes: 8444
fn main() {
    let n: usize = readln();
    let mut opens = Vec::new();
    for i in 0..n {
        let v: Vec<i32> = readln();
        let open = v.into_iter().fold(0, |acc, x| (acc << 1) | x);
        opens.push(open);
    }

    let costs: Vec<Vec<i64>> = readlns(n);

    let ans = (1..(1 << 10))
        .map(|s| {
            opens
                .iter()
                .zip(costs.iter())
                .map(|(o, c)| {
                    let i = (s & o).count_ones() as usize;
                    c[i]
                })
                .sum::<i64>()
        })
        .max()
        .unwrap();

    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		String[] s = S.split("");
		s[K-1] = s[K-1].toLowerCase();

		System.out.println(String.join("", s));
	}
}

Measured memory_bytes: 22612
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1295

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int W,D;

int main()
{
	while(cin >> W >> D && W)
	{
		vector<int> width(W,0);
		vector<int> height(D,0);

		rep(i,W){
			cin >> width[i];
		}

		rep(i,D){
			cin >> height[i];
		}

		int ans=0;
		rep(w,W)
		{
			rep(h,D)
			{
				if(width[w] == height[h])
				{
					ans += width[w];
					width[w] = 0;
					height[h] = 0;
					break;
				}
			}
		}

		ans += accumulate(ALL(width),0);
		ans += accumulate(ALL(height),0);

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

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int L[2000];
	int n=0;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}

	sort(L, L+N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < i; j++)
		{
			
			for (int k = 0; k < j; k++)
			{
				
				if (L[i]<L[j]+L[k])
				{
					n++;
				}
				
			}
		}
	}
	
	cout << n;
	return 0;

}

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

using namespace std;

vector<int> listy;

bool isGood(int n) {
	for(int i = 0; i < listy.size(); i++) {
		if(listy[i] == n) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x, n, k;
	cin >> x >> n;
	for(int i = 0; i < n; i++) {
		cin >> k;
		listy.push_back(k);
	}
	for(int i = 0; i <= 100; i++) {
		if(isGood(x-i)) {
			cout << x-i << '\n';
			return 0;
		}
		if(isGood(x+i)) {
			cout << x+i << '\n';
			return 0;
		}
	}
}

Measured memory_bytes: 3660
#include <iostream>

void DROW_SHARPnDOT(int);  //Widthの数だけ #. の順で出力
void DROW_DOTnSHARP(int);  //Widthの数だけ .# の順で出力に改行

int main(){
	int Height, Width; //入力される、長方形のたてよこ
	while (true)
	{
		std::cin >> Height >> Width;
		if (Height == 0 && Width == 0)
			break;
		for (int i = 0; i < Height; i++)
		{
			if (i % 2 == 0)
				DROW_SHARPnDOT(Width);
			else
				DROW_DOTnSHARP(Width);
		}
		std::cout << '\n';
	}
}

//Widthの数だけ #. の順で出力
void DROW_SHARPnDOT(int Width){
	for (int i = 0; i < Width; i++)
	{
		if (i % 2 == 0)
			std::cout << '#';
		else
			std::cout << '.';
	}
	std::cout << "\n";
}
//Widthの数だけ .# の順で出力に改行
void DROW_DOTnSHARP(int Width){
	for (int i = 0; i < Width; i++)
	{
		if (i % 2 == 0)
			std::cout << '.';
		else
			std::cout << '#';
	}
	std::cout << '\n';
}


Measured memory_bytes: 3056
N = int(input())
S = [input() for i in range(N)]

LR = []
for s in S:
    left, right = 0, 0
    for ss in s:
        if ss == "(":
            left += 1
        else:
            if left:
                left -= 1
            else:
                right += 1
    LR.append([left, right])
#print(LR)

plus = []
minus = []
for l, r in LR:
    if l >= r:
        plus.append([l, r])
    else:
        minus.append([l, r])
        
plus.sort(key = lambda x: x[1])
minus.sort(key = lambda x: -x[0])

cnt = 0
for l, r in plus + minus:
    cnt -= r
    if cnt < 0:
        print("No")
        exit()
    cnt += l
        
if cnt == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 376740