akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
vector<int>a;int mn=1,mx;
void solve(s64 n)
{
	if(!n)return ;
	if(n%2)
	{
		solve(n/2);
		a.push_back(++mx);
	}
	else
	{
		solve(n-1);
		a.push_back(--mn);
	}
}

int main()
{
	//freopen("1.in","r",stdin);
	s64 n;cin>>n;
	solve(n);
	printf("%d\n",a.size()*2);
	for(auto i:a)printf("%d ",i-mn+1);
	rep(i,1,a.size())printf("%d ",i);
}

Measured memory_bytes: 256
a = input().split()
if a[0] == '5' and a[1] == '5' and a[2] == '7':
    print('YES')
elif a[0] == '5' and a[1] == '7' and a[2] == '5':
    print('YES')
elif a[0] == '7' and a[1] == '5' and a[2] == '5':
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N;
    string S;
    bool ok;

    cin >> N >> S;

    rep(i, S.size()) {
        int x = S[i]-'A';
        x += N;
        x = x%26;
        S[i] = 'A' + x;
    }

    cout << S << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin>>n;
	ll son_3 = n/3 * 3;
	if(son_3) son_3 = (3 + son_3) * (son_3/3) / 2;
	ll son_5 = n/5 * 5;
	if(son_5) son_5 = (5 + son_5) * (son_5/5) / 2;
	ll son_15 = n/15 * 15;
	if(son_15) son_15 = (15 + son_15) * (son_15/15) / 2;
	cout<< n * (n+1) / 2 - son_3 - son_5 + son_15;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
    char s[128];
    int i;
    int c = 0;
    int f = 0;

    scanf("%s", s);
    for (i = 0; s[i]; ++i){
        if (s[i] == 'C') c = 1;
        if (c && s[i] == 'F') f = 1;
    }
    puts(c && f ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 128
#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>;

const int mod = 2019;

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

    int r = s.length();
    vector<int> d(r + 1);
    int ten = 1;
    for (int i = r - 1; i >= 0; --i)
    {
        d[i] = (ten * (s[i] - '0') + d[i + 1]) % mod;
        ten *= 10;
        ten %= mod;
    }

    vector<int> count(mod);
    ll ans = 0;
    rep(i, r + 1)
    {
        ans += count[d[i]];
        count[d[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4448
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  string s[H];
  for(int i = 0; i < H; i++) {
    cin >> s[i];
  }
  for(int i = 0; i < H; i++) {
    cout << s[i] << endl << s[i] << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	char str[3];
	scanf("%s",str);
	if((str[0]=='A'&&str[1]=='A'&&str[2]=='A')||(str[0]=='B'&&str[1]=='B'&&str[2]=='B'))
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
	int n[5], sub;
	
	for(int i = 0; i < 5; i++) scanf("%d", &n[i]);
	
	for(int i = 0; i < 5; i++){
		for(int j = 4; j >= i; j--){
			if(n[i] < n[j]){
				sub = n[i];
				n[i] = n[j];
				n[j] = sub;
			}
		}
	}
	
	for(int i = 0; i < 5; i++) printf("%d%c", n[i], (i == 4)? '\n' : ' ');
	
	return 0;
}

Measured memory_bytes: 1028
#include <set>
#include <cstdio>
using namespace std;
int main(){
	int n,x0,y0,x1,y1;
	for(scanf("%d",&n);n--;){
		scanf("%d%d",&x0,&y0);
		x1=(x0+99)/100;
		y1=(y0+29)/30;
		x0/=100;
		y0/=30;
		set<int>se;
		se.insert(y0*5+x0);
		se.insert(y0*5+x1);
		se.insert(y1*5+x0);
		se.insert(y1*5+x1);
		bool first=true;
		for(set<int>::iterator it=se.begin();it!=se.end();++it){
			if(!first)putchar(' ');
			first=false;
			printf("%d",*it);
		}
		puts("");
	}
}

Measured memory_bytes: 1048
// OURL: https://atcoder.jp/contests/abc135/tasks/abc135_b
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int ch = 0;
  REP(i,n) {
    int a;
    cin >> a;
    if (a != i+1) ch++;
  }
  if (ch == 2 || ch == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())

ans = ""
S, T = (i for i in input().split())  
#a = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

for i in range(N):
    ans += S[i]
    ans += T[i]

print(ans)


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

using namespace std;

int main(){

	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	int temp=0;

	for(int i=0;i<n;i++){

		if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
		
			temp++;
		}

		else{
		
			if(temp>ans){
			
				ans=temp;
			}
			temp=0;
		}
		if(temp>ans){
		
			ans=temp;
		}
	}

	cout<<ans<<'\n';
	return 0;
}


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  long double a;
  long double b;
  cin >> a >> b;
  a *= b;
  uint64_t ans = static_cast<uint64_t>(a);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3748
H = int(input())
twodevide = 0
while H>1:
    if H//2 == H/2:
        twodevide += 1
        H //= 2
    else:
        twodevide += 1
        H = (H-1)//2
result = 0
for i in range(twodevide+1):
    result += 2**i
print(result)

Measured memory_bytes: 3060
N, K = [int(i) for i in input().split(" ")]
P = []
ans = 0

def calc_num(n):
    num = 0
    while(n < K):
        num += 1
        n *= 2
    return num


for i in range(1,N+ 1):
    calc = calc_num(i)
    if calc:
        P.append(calc_num(i))
    else:
        P.append(-1)

for p in P:
    if p > 0:
        ans += (1/N) * ((1/2) ** p)
    else:
        ans += 1/N

print(ans)

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S[0]==S[2])
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e4, maxNum = 1e6; int n;
const lli mod = 1e9 + 7;
int a[maxN];
bool notPrime[maxNum + 1];
vector<int> primes;
vector<pair<lli, int>> primeFactors[maxNum + 1];

vector<pair<lli, int>> getPrimeFactors(lli num)
{
  if (num <= maxNum) return primeFactors[num];
  vector<pair<lli, int>> pf;
  for (lli i: primes)
  {
    if (i > num) break;
    if (num % i == 0)
    {
      int p = 0;
      while (num % i == 0) num /= i, p ++;
      pf.push_back({i, p});
    }
  }
  if (num != 1)
    pf.push_back({num, 1});
  return pf;
}

lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = (ans * x) % mod;
    x = (x * x) % mod, y >>= 1LL;
  }
  return ans;
}
lli inv(lli x)
{
  return modPow(x, mod - 2);
}

int main()
{
  notPrime[0] = notPrime[1] = true;
  for (int i = 2; i <= maxNum; i ++)
  {
    if (!notPrime[i]) primes.push_back(i), primeFactors[i].push_back({i, 1});
    for (int j = 0; i*primes[j] <= maxNum; j ++)
    {
      notPrime[i*primes[j]] = true;
      int p = 0, num = i * primes[j];
      while (num % primes[j] == 0) num /= primes[j], p ++;
      primeFactors[i * primes[j]].push_back({primes[j], p});
      primeFactors[i * primes[j]].insert(primeFactors[i * primes[j]].end(), primeFactors[num].begin(), primeFactors[num].end());
      if (i % primes[j] == 0) break;
    }
  }

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

    int l[primes.size()]; memset(l, 0, sizeof(l));
    for (int i = 0; i < n; i ++)
    {
      vector<pair<lli, int>> pf = getPrimeFactors(a[i]);
      for (auto &p: pf)
      {
        int pos = lower_bound(primes.begin(), primes.end(), p.first) - primes.begin();
        l[pos] = max(l[pos], p.second); 
      }
    }

    lli modLcm = 1;
    for (int i = 0; i < primes.size(); i ++)
      modLcm = modLcm * modPow(primes[i], l[i]) % mod;

    lli ans = 0;
    for (int i = 0; i < n; i ++)
      ans = (ans + modLcm * inv(a[i])) % mod;

    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 85496
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> dp(N + 1, 0);
    dp[0] = 1;

    set<int> A;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        A.insert(a);
    }

    for (int i = 1; i <= N; i++) {
        if (A.find(i) != A.end()) continue;
        dp[i] += dp[i-1];
        dp[i] %= MOD;

        if (i >= 2) {
            dp[i] += dp[i-2];
            dp[i] %= MOD;
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 5760
N = int(input())
A = list(map(int, input().split()))

c1 = {}
c2 = {}

for i in range(N):
    c1.setdefault(i + A[i], 0)
    c1[i + A[i]] += 1
    c2.setdefault(i - A[i], 0)
    c2[i - A[i]] += 1

result = 0
for k in set(c1).intersection(c2):
    result += c1[k] * c2[k]
print(result)


Measured memory_bytes: 60500
#include <iostream>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main()
{

    int N;
    cin >> N;

    unordered_map<string, int> map;
    for (int i = 0; i < N; ++i)
    {
        string s;
        cin >> s;

        map[s] = map.find(s) != map.end() ? map[s] + 1 : 1;
    }

    int M;
    cin >> M;

    for (int i = 0; i < M; ++i)
    {
        string s;
        cin >> s;

        if (map.find(s) != map.end())
        {
            map[s] -= 1;
        }
    }

    int ans = 0;
    auto itr = map.begin();
    auto end = map.end();
    for (; itr != end; ++itr)
    {
        ans = max(ans, map[itr->first]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))

dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
    tmp = dp
    dp = [0] * (N + 1)
    for j in range(N):
        if j < N:
            dp[j + 1] += tmp[j] * P[i - 1]
        dp[j] += tmp[j] * (1 - P[i - 1])

num = 0
for i in range(N // 2 + 1, N + 1):
    num += dp[i]

print(num)


Measured memory_bytes: 54876
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/6 12:34:01
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e5 + 5;

int n;
int a[N], ans[N];
vector <int> G[N];


void dfs(int u, int fa, vector <int>& v) {
    auto it = lower_bound(all(v), a[u]) - v.begin();
    int op, val;
    if (it == sz(v)) {
        v.push_back(a[u]);
        op = 0;
    } else {
        val = v[it];
        v[it] = a[u];
        op = 1;
    }
    ans[u] = sz(v);
    for (auto son : G[u]) if (son != fa) {
        dfs(son, u, v);
    }
    if (op == 0) {
        v.pop_back();   
    } else {
        v[it] = val;
    }
}

void run() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i < n; i++) {
        int u, v; scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    vector <int> v;
    dfs(1, 0, v);
    for (int i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
}

int main() {
    run();
    return 0;
}

Measured memory_bytes: 30540
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: int, B: int, X: "List[int]"):
    print(sum(
        min((xj - xi) * A, B)
        for xi, xj in zip(X, X[1:])
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, X)


if __name__ == '__main__':
    main()


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

int main() {
	int n; cin >> n;
	rep(i, n) {
		string m, s; cin >> m >> s;
		reverse(m.begin(), m.end());
		for (char c : m) {
			switch (c) {
			case'C':rotate(s.begin(), ++s.begin(), s.end()); break;
			case'J':rotate(s.begin(), --s.end(), s.end()); break;
			case'E':s = s.substr((int)s.size() / 2 + (int)s.size() % 2) + s.substr((int)s.size() / 2, (int)s.size() % 2) + s.substr(0, (int)s.size() / 2); break;
			case'A':reverse(s.begin(), s.end()); break;
			case'M':transform(s.begin(), s.end(), s.begin(), [](char c) {
				if (c == '9')return'0';
				if ('0' <= c&&c < '9')return ++c;
				return c;
			}); break;
			case'P':transform(s.begin(), s.end(), s.begin(), [](char c) {
				if (c == '0')return'9';
				if ('0' < c&&c <= '9')return --c;
				return c;
			}); break;
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3172
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
// vector<int>v[200009];
// int vis[200009]={0};
// int cnt=0;
// void dfs(int start,int par)
// {
//   vis[start]=1;
//   cnt++;
//   for(int i:v[start])
//   {
//     if(!vis[i] && i!=par)
//     dfs(i,start);
//   }
// }
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  int MAXN=1000002;
  int prime[MAXN];
  for (int i = 2; i <= MAXN; i++)
    prime[i] = i;
  for (int i = 2; i * i <= MAXN; i++)
  {
      if (prime[i] == i)
      {
          for (int j = i * i; j <= MAXN; j += i)
              if (prime[j] == j)
                  prime[j] = i;
      }
  }
  int has[1000002]={0};
	int n;
  cin>>n;
  vector<ll>v;
  
  rep(i,0,n-1)
  {
    ll x;
    cin>>x;
    v.pb(x);
  }
  int gc=v[0];
  rep(i,0,n-1)
  gc=gcd(gc,v[i]);

  int flag=0;
  rep(i,0,n-1)
  {
    map<int,int>pq;
    int num=v[i];
    while(num>1)
    {
      pq[prime[num]]++;
      if(pq[prime[num]]==1)
      {
        if(has[prime[num]]>=1)
        {
          flag=1;
          break;
        }
        else has[prime[num]]++;
      }
      num/=prime[num];
    }
    if(flag==1)
    break;
  }
  if(flag==0)
  cout<<"pairwise coprime";
  else
  {
    if(gc==1)
    cout<<"setwise coprime";
    else cout<<"not coprime";
  }
  
  
	
	
}
	

  


Measured memory_bytes: 19424
import itertools
n, m, q = map(int, input().split())
LIST = []
for i in range(q):
    t = list(map(int, input().split()))
    LIST.append(t)
# print(LIST)

l = []
for j in range(1, m+1):
    l.append(j)
ans = 0
for a in itertools.combinations_with_replacement(l, n):
    # print(a)
    # 得点を計算する
    score = 0
    for i in range(q):
        if a[LIST[i][1]-1]-a[LIST[i][0]-1] == LIST[i][2]:
            score += LIST[i][3]
    ans = max(score, ans)
print(ans)

Measured memory_bytes: 9060
#include<stdio.h>
int main(void)
{
	int i,j;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
		}	
	}
	for(i=1;i<10;i++){
		for(j=1;j<10;j++){
		printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}



Measured memory_bytes: 2056
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)


int main() {
  int n;in(n);
  ll G[n][n];
  loop(i,0,n) loop(j,0,n) in(G[i][j]);
  
  ll ans = 0;
  loop(i,0,n-1) loop(j,i+1,n) {
    bool ok = true;
    loop(k,0,n) {
      if (k==i or k==j) continue;
      // print(vector{ i, j, k});
      
      // その辺があるのに最短距離ではないというのは矛盾.
      if (G[i][j] > G[i][k] + G[k][j]) {
        print(-1);
        return 0;
      }
      
      // 他の辺の和として表せる辺は不要.
      if (G[i][j] == G[i][k] + G[k][j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans += G[i][j];
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4276
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int M;
int A[1145];
int B[1145];
int row[1145141];
int col[1145141];
int rem[3];

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  cin >> M;
  fill(row, row+N*M+1, -1);
  fill(col, col+N*M+1, -1);
  rep(i, N) {
    cin >> A[i];
    if (row[A[i]] != -1) {
      cout << "0" << endl;
      return 0;
    }
    row[A[i]] = i;
  }

  rep(i, M) {
    cin >> B[i];
    if (col[B[i]] != -1) {
      cout << "0" << endl;
      return 0;
    }
    col[B[i]] = i;
  }

  LL ans = 1;
  rreps(d, 1, N*M+1) {
    if (d == N*M) {
      if (row[d] == -1 || col[d] == -1) {
        cout << "0\n";
        return 0;
      }
    }

    if (row[d] != -1 && col[d] != -1) {
      rem[2] += rem[1]+rem[0];
      rem[0]++;
      rem[1]++;
    } else if (row[d] != -1) {
      ans *= rem[1];
      ans %= MOD;
      rem[2] += rem[1]-1;
      rem[0]++;
    } else if (col[d] != -1) {
      ans *= rem[0];
      ans %= MOD;
      rem[2] += rem[0]-1;
      rem[1]++;
    } else {
      ans *= rem[2];
      ans %= MOD;
      rem[2]--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define dor(i, a, b)    for(int i =(a);i<=(b);i++)
#define mem(a,val)      memset((a),(val),sizeof((a))); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

vector<int>adj[100001];
int dist[100001];
void bfs(int u) 
{ 
    queue<int> q; 
  
    q.push(u); 
    dist[u] = 0; 
  
    while (!q.empty()) {
        int f = q.front();   
        q.pop();   
        for (auto x : adj[f]) { 
            if (dist[x]== -1) { 
                q.push(x); 
                dist[x] = f;
            } 
        } 
    } 
} 
void solve()
{
   dist[1] = 0;
   int n;int m; 
   cin>>n>>m;
   int x,y;
   for(int i = 0;i<m;i++)
   {
      cin>>x>>y;
      adj[x].push_back(y); adj[y].push_back(x);
   }

   for(int  i = 1;i<=n;i++)
     dist[i] = -1;
   bfs(1);
   for(int i = 2;i<=n;i++)
     if(dist[i]== -1)
     {
       cout<<"No"<<endl;
       return;
     }
   
    cout<<"Yes"<<endl;
    for(int  i = 2;i<=n;i++)
    {
       cout<<dist[i]<<endl;
    }

}

signed main(void)
{
      fast();
     // w(t)
      solve();

}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    if (A == 2 || B == 2)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class CumulativeSum{
public:
  vector<int> sum;
  CumulativeSum(){}
  CumulativeSum(vector<int> A){
    int n = A.size();
    sum.resize(n+1,0);
    for(int i=1;i<=n;i++) sum[i] += sum[i-1] + A[i-1];
  }
  int get(int l,int r){assert(l>=0 && r<=(int)sum.size());return sum[r] - sum[l];} //[l,r)
};


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  int ans = 0;  
  map<int,int> M;
  int sum = 0;
  M[0]++;
  for(int i=0;i<n;i++){
    sum += A[i];
    ans += M[sum];
    M[sum]++;
  }
  
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0){
    cout<<1<<endl;
  }
  else if(b==0){
    cout<<2<<endl;
  }
  else if(c==0){
    cout<<3<<endl;
  }
  else if(d==0){
    cout<<4<<endl;
  }
  else{
    cout<<5<<endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll l = c*d / gcd(c,d);
    ll f = b - (b / c + b / d - b / l);
    ll g = a-1 - ((a-1) / c + (a-1) / d - (a-1) / l);
    cout << f - g << '\n';
    return 0;
}

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

int main(){
  int n,weight;
  int v[1000],w[1000];
  int dp[1001];
  int m,mw;
  int cnt = 0;

  while(1){
    cnt++;
    cin >> weight;
    if(!weight)break;

    cin >> n;
    for(int i=0;i<n;i++)scanf("%d,%d ",&v[i],&w[i]);


    dp[0] = 0;
    for(int i=1;i<=weight;i++)dp[i] = -1;
    
    for(int i=0;i<n;i++){
      for(int j=weight;j>=0;j--){
	if(dp[j]>=0 && j+w[i]<=weight)dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
      }
    }

    m = dp[0];
    mw = 0;
    for(int i=1;i<=weight;i++){
      if(m < dp[i]){
	m = dp[i];
	mw = i;
      }
    }
    cout << "Case " << cnt << ":\n";
    cout << m  << endl;
    cout << mw << endl;
  } 
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin>>n;
  vector<string> s(n);
  for(int i=0; i<n; ++i){
    cin>>s[i];
    sort(s[i].begin(), s[i].end());
  }
 
  sort(s.begin(), s.end());
  long long ans=0LL;
 
  long long l=1LL; string ss=s[0];
  for(int i=1; i<n; ++i){
    if(ss==s[i])++l;
    else{ans+=l*(l-1)/2; ss=s[i]; l=1;}
  }
  ans+=l*(l-1)/2;
 
  cout<<ans<<endl;
  
}


Measured memory_bytes: 7296
#include<stdio.h>

int main()
{
	int A;
	int B;
	int C;
	int k;
	int max=0;
	int sum=0;
	
	scanf("%d",&A);
	scanf("%d",&B);
	
	if(A>B)
	{
		max=A;
	}
	else
	{
		max=B;
	}
	
	scanf("%d",&C);
	
	if(C>max)
	{
		max=C;
	}
	
	scanf("%d",&k);
	
	if(max==C)
	{
		for(int i=0;i<k;i++)
		{
			C = C*2;
		}
		sum=A+B+C;
		printf("%d\n",sum);
	}
	else if(max==B)
	{
		for(int i=0;i<k;i++)
		{
			B = B*2;
		}
		sum= A+B+C;
		printf("%d\n",sum);
	}
	else if(max==A)
	{
		for(int i=0;i<k;i++)
		{
			A = A*2;
		}
		sum=A+B+C;
		printf("%d\n",sum);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define RG register
#define inf 0x7fffffff
#define mkp make_pair
#define maxn 100205
typedef unsigned int U;
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const  double eps = 1e-8;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}
int n,m;
ll t,a;
int main(){
	int i,j;
	ll x,y;
	//freopen("a.out","r",stdin);
	//freopen("a.ans","w",stdout);
	n=read();
	for(i=1;i<=n;i++){
		x=read(),y=read();
		if(!t) {t=x,a=y;continue;}
		ll l=t/x+(t%x!=0),r=a/y+(a%y!=0);
		t=x*max(l,r);
		a=y*max(l,r);
	}
	printf("%lld\n",a+t);
	return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;//vertex, event, day
struct edge{
  int to;
  bool okarina;
};
int main(int argc, char *argv[]){
  int n, m, E, s, t, r;
  cin >> n >> m >> E >> s >> t >> r;
  vector<vector<vector<edge> > >g((1<<E),vector<vector<edge> >(n, vector<edge>()));
  for (int i = 0; i < m; i++) {
    int to, from;
    cin >> to >> from;
    for (int j = 0; j < (1<<E); j++) {
      g[j][to].push_back(edge{from, 0});
      g[j][from].push_back(edge{to, 0});
    }
  }
  int a, b, c;
  map<int, int> add_edge;
  for (int i = 0; i < E; i++) {
    cin >> a >> b >> c;
    for (int j = 0; j < (1<<E); j++) {
      if(j & (1 << i)){
        g[j][a].push_back(edge{b, 0});
        g[j][b].push_back(edge{a, 0});
      }
    }
    add_edge[c] = i;
  }
  for (int i = 0; i < (1<<E); i++) {
    for (int j = 0; j < n; j++) {
      g[i][j].push_back(edge{s, 1});
    }
  }

  // for (int i = 0; i < (1<<E); i++) { 
  //   std::cout << "event:" << i << std::endl;
  //   for (int j = 0; j < n; j++) {
  //     std::cout << "v:" << j << std::endl;
  //     for (int k = 0; k < g[i][j].size(); k++) {
  //       std::cout << g[i][j][k].to << " ";
  //     }
  //     std::cout <<  std::endl;
  //   }
  //     std::cout <<  std::endl;
  // }
  queue<piii> que;
  int dp[(1<<E)][r + 1][n];
  for (int i = 0; i < (1<<E); i++) {
    for (int j = 0; j <= r; j++) {
      for (int k = 0; k < n; k++) {
        dp[i][j][k] = 1e9;
      }
    }
  }
  if(add_edge.count(s)){
    dp[(1<<add_edge[s])][0][s] = 0;
    que.push(piii(s, pii((1<<add_edge[s]), 0)));
  }else{
    dp[0][0][s] = 0;
    que.push(piii(s, pii(0, 0)));
  }
  while(!que.empty()){
    int v = que.front().first;
    int event = que.front().second.first;
    int day = que.front().second.second;
    que.pop();
    if(day == r){
      if(dp[event][0][s] > dp[event][r][v] + 1){
        dp[event][0][s] = dp[event][r][v] + 1;
        que.push(piii(s, pii(event, 0)));
      }
      continue;
    }
    int new_event = event;
    if(add_edge.count(v)){
      //std::cout << "get event:" << v << std::endl;
      new_event |= (1<<add_edge[v]);
    }
    // std::cout << "new_event:" << new_event << std::endl;
    // std::cout << "        v:" << v << std::endl;

    for (int i = 0; i < g[new_event][v].size(); i++) {
      edge e = g[new_event][v][i];
      if(!e.okarina){
        if(dp[new_event][day + 1][e.to] >
           dp[event][day][v] + 1){
          dp[new_event][day + 1][e.to] = dp[event][day][v] + 1;
          que.push(piii(e.to, pii(new_event, day + 1)));
        }
      }else{
        if(dp[new_event][0][e.to] > dp[event][day][v] + 1){
          dp[new_event][0][e.to] = dp[event][day][v] + 1;
          que.push(piii(e.to, pii(new_event, 0)));
        }
      }
    }
  }
  int ans = 1e9;
  for (int i = 0; i < (1<<E); i++) {
    for (int j = 0; j <= r; j++) {
      ans = min(ans, dp[i][j][t]);
    }
  }
  if(ans == 1e9)std::cout << -1 << std::endl;
  else std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 2848
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << (x) << endl
int dp[1<<16];
int main(){
	while(true){
		int N,L[100],b[100]={};
		cin>>N;
		if(N==0) break;
		rep(i,1<<16) dp[i]=0;
		rep(i,N){
			int M;
			cin>>M>>L[i];
			rep(j,M){
				int s,e;
				cin>>s>>e;
				for(int k=s;k<e;k++) b[i]|=1<<(k-6);
			}
		}
		rep(i,N){
			for(int j=(1<<16)-1;j>=0;j--){
				if(j&b[i]) continue;
				dp[j|b[i]]=max(dp[j|b[i]],dp[j]+L[i]);
			}
		}
		int ans=0;
		rep(i,1<<16) ans=max(ans,dp[i]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1416
n = int(input())
l = list(map(int, input().split(' ')))
ls = list(set(l))

ans = 0
for i in range(0, len(ls)):
  for j in range(i+1, len(ls)):
    for k in range(j+1, len(ls)): 
      length = ls[i] + ls[j] + ls[k]
      if length - 2 * max(ls[i], ls[j], ls[k]) > 0:
        ans += l.count(ls[i]) * l.count(ls[j]) * l.count(ls[k])
        
print(ans)

Measured memory_bytes: 9240
# INPUT
a = input()


# PROCESS
answer = ""

if(a[0] != "A"):
  answer = "WA"
else:
  a_list = list(a)
  b_list = a[2:-1]
  if (not b_list.count("C") == 1):
    answer = "WA"
  else:
    c = a[1:]
    c_index = c.find("C")
    c_list = list(c)
    c_list.pop(c_index)
    c_join = "".join(c_list)

    if(c_join.islower()):
      answer = "AC"
    else:
      answer = "WA"

# OUTPUT
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int A,B;
	cin >> A >>B;
	if (A > B){
		cout  << A - 1 << endl;
	}
	else{
		cout << A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <deque>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::string;

int
main()
{
  string S;
  int Q;
  cin >> S >> Q;
  deque<char> cq(S.begin(), S.end());
  bool reversed = false;
  for (int q = 0; q < Q; q++)
  {
    int T;
    cin >> T;
    if (T == 1)
    {
      reversed = !reversed;
    }
    else if (T == 2)
    {
      int F;
      string C;
      cin >> F >> C;
      if ((F == 1 && !reversed) || (F == 2 && reversed))
      {
        cq.push_front(C[0]);
      }
      else if ((F == 1 && reversed) || (F == 2 && !reversed))
      {
        cq.push_back(C[0]);
      }
    }
  }
  string ret;
  if (!reversed)
  {
    ret.assign(cq.cbegin(), cq.cend());
  }
  else
  {
    ret.assign(cq.crbegin(), cq.crend());
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1280
const LIMIT: i64 = 1_000_000_000_000_000_000;
fn main() {
    let mut sc = Scanner::new();
    let (a, b, _): (i64, i64, i64) = (sc.read(), sc.read(), sc.read());
    let k: usize = sc.read();

    let ans = if k % 2 == 0 { a - b } else { b - a };

    if ans.abs() > LIMIT {
        println!("Unfair");
    } else {
        println!("{}", ans);
    }

    // (a,b,c)          a-b
    // (b+c,a+c,a+b)    b-a
    // (2a+b+c,c+a+2b,b+a+2c)   a-b
    // (2a+3b+3c,2b+3a+3c,_)    b-a
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

int main(){
  double a,b,x;
  cin>>a>>b>>x;
  double S=x/a;
  double ans=0;
  double PI=acos(-1);
  double rad;
  if (S>a*b/2){
    double h=(a*b-S)*2/a;
    rad=atan2(h,a);    
  } else{
    double w=2*S/b;
    rad=atan2(b,w);
  }
  ans=rad*180/PI;
  printf("%.10f\n",ans);
  return 0;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  if(y % 2 != 0){
    cout << "No" << endl;
    return 0;
  }
  if(2 * x > y){
    cout << "No" << endl;
    return 0;
  }
  if(4 * x < y){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
  }




Measured memory_bytes: 3628
//This template belongs to Juan Carlo Vieri
#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  vc<intt> x;
  intt y;
  point() {}
  point(vc<intt> x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

// class pointHash {
//  public:
//   size_t operator()(const point& cmp1) const {
//     return (hash<vc<intt>>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
//   }
// };

// inline bool spoint(const point& cmp1, const point& cmp2) {
//   // swap(cmp1, cmp2);
//   if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
//   return cmp1.y < cmp2.y;
// }

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

map<point, intt> dp;
intt n, m, x;
intt arr[15][15], c[15];

intt rek(vc<intt> v, intt cur){
  if(cur == n){
    rep(i, 0, m){
      if(v[i] < x)return 1e9;
    }
    return 0;
  }
  // if(dp.count({v, cur})){
  //   return dp[{v, cur}];
  // }
  auto& res = dp[{v, cur}];
  res = rek(v, cur + 1);
  rep(i, 0, m){
    v[i] += arr[cur][i];
  }
  res = min(res, rek(v, cur + 1) + c[cur]);
  return res;
}

void solve() {
  cin >> n >> m >> x;
  rep(i, 0, n){
    cin >> c[i];
    rep(j, 0, m){
      cin >> arr[i][j];
    }
  }
  vc<intt> v(m, 0);
  if(rek(v, 0) >= 1e9){
    puts("-1");
    return;
  }
  cout << rek(v, 0) << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main(){
  int A,B,C;
  cin>>A;
  cin>>B;
  cin>>C;
  if(A+B>=C-1){
    cout<<B+C<<endl;
    return 0;
  }else{
    cout<<B+A+B+1<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
int n,a,b,c;
int l[1003];
int dfs(int i, int A, int B, int C, int cost){
    if(i==n){
        if(A==0||B==0||C==0)return 1000000000;
        int costsum=cost;
        int ar=a-A,br=b-B,cr=c-C;
        if(ar<0)ar*=-1;
        if(br<0)br*=-1;
        if(cr<0)cr*=-1;
        costsum+=(ar+br+cr);
        //if(A==98&&C==80)cout<<B<<" "<<cost<<endl;
        return costsum;
    }
    //Aにぶち込む
    int s=l[i];
    //cout<<l[i]<<endl;
    int res=dfs(i+1,A+s,B,C,cost+10);
    int res2=dfs(i+1,A,B+s,C,cost+10);
    int res3=dfs(i+1,A,B,C+s,cost+10);
    int res4=dfs(i+1,A,B,C,cost);
    res=min(res,min(res2,min(res3,res4)));
    return res;
}
int main(void){
    // Your code here!
    cin>>n>>a>>b>>c;
    rep(i,n) cin>>l[i];
    int res=dfs(0,0,0,0,-30);
    cout<<res<<endl;
}


Measured memory_bytes: 256
import math

n, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(n):
    weight, cost = map(int, input().split())
    for weight_already in range(W-weight, -1, -1):
        dp[weight_already+weight] = max(dp[weight_already+weight], dp[weight_already]+cost)
ans = max(dp)
print(ans)

Measured memory_bytes: 68740
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  ll n, tmp;
  cin >> n;
  vector<ll> b(n, 0);
  rep(i, n-1) {
    cin >> tmp;
    b[tmp-1]++;
  }
  for(ll x : b) cout << x << endl;
}


Measured memory_bytes: 4848
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  if (n >= 30)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
 int main(void)
 {
     char N[2];
     int i;

     scanf("%s",N);

     for(i=0;i<2;i++){
       if(N[i]=='9') { printf("Yes\n"); return 0; }
     }

     printf("No\n");

     return 0;
 }


Measured memory_bytes: 128