akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int ch[300010], cw[300010];
map<P,int> ma;
int main() {
  int H,W,m;
  cin >> H >> W >> m;
  vi h(m),w(m);
  rep(i,m){
    cin >>h[i]>>w[i];
    ch[h[i]-1]++;
    cw[w[i]-1]++;
    ma[make_pair(h[i]-1,w[i]-1)] = 1;
  }
  int qh,qw;
  int tmp = 0;
  rep(i,H){
    if(tmp<ch[i]){
      tmp=ch[i];
      qh = i;
    }
  }
  tmp = 0;
  rep(i,W){
    if(tmp<cw[i]){
      tmp=cw[i];
      qw = i;
    }
  }
  int ans = 0;
  rep(i,W){
    int cnt = ch[qh]+cw[i];
    if(ma[make_pair(qh,i)])cnt--;
    maxs(ans,cnt);
  }
  rep(i,H){
    int cnt = ch[i]+cw[qw];
    if(ma[make_pair(i,qw)])cnt--;
    maxs(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 64176
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	set<ll> x;
	vector<pair<ll, ll>> p(m);
	for (ll i = 0; i < m; i++)
	{
		ll a, b;
		cin >> a >> b;

		p[i].first = a;
		p[i].second = b;

		if (a == 1)
		{
			x.insert(b);
		}
	}

	string res = "IMPOSSIBLE";
	for (ll i = 0; i < m; i++)
	{
		if (p[i].second == n)
		{
			if (x.count(p[i].first))
			{
				res = "POSSIBLE";
			}
		}
	}

	println(res);
}


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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //


// --------- library end - //


int main(){

  ll N = il();
  ll A, B;
  cin >> A >> B;
  ll a = 0;
  ll b = 0;
  ll c = 0;
  rep(i, N){
    ll p = il();
    if (p <= A) a++;
    else if (p <= B) b++;
    else c++;
  }

  cout << min(a, min(b, c)) << endl;




}

Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
int main() {
	cin >> n >> m;
	vector<int> x(m), y(m); vector<pair<int, int> > st(m);
	for (int i = 0; i < m; i++) cin >> x[i] >> y[i], y[i]--, st[i] = make_pair(x[i], y[i]);
	sort(st.begin(), st.end());
	for (int i = 0; i < m; i++) x[i] = st[i].first, y[i] = st[i].second;
	vector<vector<int> > ps(n - 1);
	for (int i = 0; i < m; i++) ps[y[i]].push_back(i);
	vector<int> pl(m, -1), pr(m, -1);
	for (int i = 0; i < m; i++) {
		if (y[i] >= 1) {
			int ptr = lower_bound(ps[y[i] - 1].begin(), ps[y[i] - 1].end(), i) - ps[y[i] - 1].begin() - 1;
			if (ptr >= 0) pl[i] = ps[y[i] - 1][ptr];
		}
		if (y[i] <= n - 3) {
			int ptr = lower_bound(ps[y[i] + 1].begin(), ps[y[i] + 1].end(), i) - ps[y[i] + 1].begin() - 1;
			if (ptr >= 0) pr[i] = ps[y[i] + 1][ptr];
		}
	}
	vector<int> dpl(m), dpr(m);
	for (int i = 0; i < m; i++) {
		if (pl[i] != -1) dpl[i] = dpl[pl[i]] + 1;
		if (pr[i] != -1) dpr[i] = dpr[pr[i]] + 1;
	}
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		int ret = -1;
		if (i <= n - 2 && ps[i].size()) ret = dpl[ps[i].back()] + dpr[ps[i].back()];
		if (i >= 1 && ps[i - 1].size()) ret = max(ret, dpl[ps[i - 1].back()] + dpr[ps[i - 1].back()]);
		cout << ret + 2;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 13116
def main():
    N = int(input())
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))

    def pleaseAC():
        for i in range(N):
            u = sum(A1[:i+1])
            d = sum(A2[i:])
            yield u+d

    print(max(pleaseAC()))
    

main()

Measured memory_bytes: 2940
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

enum Direction {
    Left,
    Right,
}

fn main() {
    use Direction::*;

    let input = read_vec::<usize>();
    let (_n, k) = (input[0], input[1]);
    let chars = read::<String>().chars().collect::<Vec<_>>();

    let mut count = 0;
    let mut rl = 0;
    let mut lr = 0;

    let mut prev: Option<Direction> = None;
    for c in chars {
        match c {
            'R' => {
                match prev {
                    Some(Left) => {
                        lr += 1;
                    },
                    Some(Right) => {
                        count += 1;
                    }
                    None => {}
                }
                prev = Some(Right);
            },
            'L' => {
                match prev {
                    Some(Left) => {
                        count += 1;
                    },
                    Some(Right) => {
                        rl += 1;
                    },
                    None => {}
                }
                prev = Some(Left);
            },
            _ => {},
        }
    }

    for _ in 0..k {
        if lr > 0 && rl > 0 {
            lr -= 1;
            rl -= 1;
            count += 2;
        } else if lr > 0 {
            lr -= 1;
            count += 1;
        } else if rl > 0 {
            rl -= 1;
            count += 1;
        } else {
            break;
        }
    }

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

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);
  ll INF = 1e18;
  vecll dp(n, INF);

  rep(i,n){
    auto tmp = lower_bound(all(dp), a[i]);
    *tmp = a[i];
  }

  auto ans = lower_bound(all(dp), ll(1e18)-1);
  prt(ans-dp.begin());

}



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

int main(){
  int A, B, C, K;

  cin >> A >> B >> C >> K;

  int count = 0;

  while(true){
    if (A >= B){
      B *= 2;
      count += 1;
    }
    else
    {
      break;
    }
  }

  while(true){
    if (B >= C){
      C *= 2;
      count += 1;
    }
    else
    {
      break;
    }
  }
  
  if (count > K){
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int tak, ao;
    tak = a;
    ao = c;
    while(true){
        ao = ao - b;
        if(ao<=0){
            cout << "Yes" << endl;
            break;
        }
        tak = tak - d;
        if(tak<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fto(i, s, e) for(int i = (s); i <= (e); ++i)
#define fto1(i, s, e) for(int i = (s); i < (e); ++i)
#define fdto(i, s, e) for(int i = (s); i >= (e); --i)
#define fit(it, var) for(auto it = (var).begin(); it != (var).end(); ++it)
#define frit(it, var) for(auto it = (var).rbegin(); it != (var).rend(); ++it)

#define bc __builtin_popcountll
#define onb(x, bit) (((x >> bit) & 1) != 0)
#define y1 ansdj

#define ll long long
#define ii pair<int, int>
#define x first
#define y second
#define pb push_back
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()

template<class T1, class T2> ostream& operator<< (ostream &os, pair<T1, T2> const &v) {
	return os << '(' << v.x << ", " << v.y << ')';
}

template<class T> ostream& operator<< (ostream &os, vector<T> const &v) {
	for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i < sz(v)-1) os << ' '; }
	return os;
}

template<class T> void bug(T const &v) { cout << v << endl; }
template<class T, class... Args> void bug(T const &v, Args const&... args) { cout << v << ' '; bug(args...); }

double const pi = acos(-1);
#define oo 1000000007
#define OO 1000000000000000003LL
int const maxn = 5e5+3;

int n;
string s;
int a[maxn];

int main() {
	#ifdef KITTENS
		freopen("main.inp", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> s;
	n = sz(s);
	s = " " + s;

	fto (i, 1, n) {
		int j = i;
		while (s[j] == s[i]) ++j;
		--j;
		if (s[i] == '<') {
			a[i] = max(a[i], 0);
			fto (k, i+1, j+1) a[k] = max(a[k], a[k-1] + 1);
		} else {
			a[j+1] = max(a[j+1], 0);
			fdto (k, j, i) a[k] = max(a[k], a[k+1] + 1);
		}
		i = j;
	}

	ll ans = 0;
	fto (i, 1, n+1) ans += a[i];
	bug(ans);

	#ifdef KITTENS
		cerr << 0.001*clock() << endl;
	#endif
	return 0;
}


Measured memory_bytes: 2864
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;



void solve() {
  ll k; string s; cin >> k >> s;

  if (s.length() > k) {
    cout << s.substr(0, k) << "...\n";
  } else {
    cout << s << '\n';
  }
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int n; cin >> n;
    int r = ((n+1000-1)/1000)*1000 - n; 
    cout <<r << endl;
    return 0;
}

Measured memory_bytes: 3636
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
nissuu = [0] * 26
key = ""
for k in range(26):
  ans = 0  
  for i in range(D):
    t = (i+k) % 26 + 1
    for j in range(26):
        if j == t-1:
            nissuu[j] = 0
        else:
            nissuu[j] += 1
        ans -= c[j]*nissuu[j]
    ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)

Measured memory_bytes: 9396
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll cnt = 0;
	ll min = INF;

	rep(i, n) {
		if (s[i] == '.') {
			cnt++;
		}
		min = cnt;
	}
	rep(i, n) {
		if (s[i] == '.') {
			cnt--;
		}
		else {
			cnt++;
		}
		if (cnt < min)min = cnt;
	}
	cout << min;
	return 0;
}


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

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

    string p;
    string q;
    string tmp;
    // 文字列pの作成
    rep(i, n)
    {
        cin >> tmp;
        p += tmp;
    }
    // 文字列qの作成
    rep(i, n)
    {
        cin >> tmp;
        q += tmp;
    }

    // 順列の内一番小さいやつをvectorで持つ
    vector<int> v(n);
    rep(i, n)
    {
        v.at(i) = i + 1;
    }

    int countP = 0;
    int countQ = 0;

    int count = 0;

    // vectorで順列を全探索
    do
    {
        // 何番目の順列か？
        count++;

        // 順列の文字列の作成
        string s = "";
        for (auto i : v)
        {
            s += to_string(i);
        }

        // 一致していたらその何番目か確定
        if (s == p)
        {
            countP = count;
        }
        if (s == q)
        {
            countQ = count;
        }
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(countP - countQ) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
int main() {
    // prepare variables
    int init_value = 100;
    long int target_value;
    cin >> target_value;

    // calculate answer
    int ans = 0;
    long int stock = init_value;
    while(ans <= 1e18){
        stock =(long int)(stock*1.01);
        ans++;
        if (stock >= target_value){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

const int N_MAX = 100003;
int a[N_MAX];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int odd[2], cntOdd = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &a[i]);
    if (a[i] & 1) {
      if (cntOdd > 1) {
        printf("Impossible\n");
        return 0;
      }
      odd[cntOdd] = i;
      ++cntOdd;
    }
  }
  if (m == 1) {
    if (n > 1)
      printf("%d\n2\n%d 1\n", n, n - 1);
    else
      printf("1\n1\n1\n");
    return 0;
  }
  if (m == 2) {
    if (a[1] > 1)
      printf("%d %d\n2\n%d %d\n", a[1], a[2], a[1] - 1, a[2] + 1);
    else
      printf("%d %d\n1\n%d\n", a[1], a[2], n);
    return 0;
  }
  
  if (cntOdd > 0) {
    std::swap(a[1], a[odd[0]]);
  }
  if (cntOdd > 1) {
    std::swap(a[m], a[odd[1]]);
  }
  for (int i = 1; i < m; ++i)
    printf("%d ", a[i]);
  printf("%d\n%d\n", a[m], m - (a[1] == 1));
  if (a[1] > 1)
    printf("%d ", a[1] - 1);
  for (int i = 2; i < m; ++i)
    printf("%d ", a[i]);
  printf("%d\n", a[m] + 1);
  return 0;
}


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

int n, m ,q;
vec a, b, c, d;
int ans;

void dfs(vec e) {
  if (e.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (e[b[i]] - e[a[i]] == c[i]) {
        now += d[i];
      }
    }
    ans = max(ans, now);
    return;
  }

  if (e.empty()) {
    e = {1};
  } else {
    e.push_back(e.back());
  }
  while (e.back() <= m) {
    dfs(e);
    e.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vec(q);

  rep (i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  dfs(vec(0));

  cout << ans << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

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

    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            int x = i * 4 + j * 7;

            if (x == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


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

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

  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {cin >> a[i];}
  sort(a.begin(), a.end());
  cout << a[n-1] - a[0] << '\n';
  return 0;
}

Measured memory_bytes: 256
import bisect

INF = 10000000000

n = int(input())
a = [0] * n

for i in range(n):
    a[i] = int(input())
    a[i] = - a[i]

dp = [INF] * n

for i in range(n):
    dp[bisect.bisect_right(dp,a[i])] = a[i]
    
print(bisect.bisect_left(dp,INF))

Measured memory_bytes: 9332
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String st = sc.next();

		int max = 0;

		final int ALPHABET_SIZE = 26;

		for(int n=1;n<N-1;n++){
			boolean left[] = new boolean[ALPHABET_SIZE];
			boolean right[] = new boolean[ALPHABET_SIZE];
			Arrays.fill(left,false);
			Arrays.fill(right,false);

			for(int k=0;k<n;k++){
				left[st.charAt(k) - 'a'] = true;
			}
			for(int k=n;k<st.length();k++){
				right[st.charAt(k) - 'a'] = true;
			}
			int cnt = 0;
			for(int a=0;a<ALPHABET_SIZE;a++){
				if(left[a] && right[a]) cnt++;
			}
			if(cnt > max) max = cnt;
		}

		System.out.println(max);

	}
}

Measured memory_bytes: 22228
// Problem : D - Insertion
// Contest : AtCoder - AtCoder Beginner Contest 064
// URL : https://atcoder.jp/contests/abc064/tasks/abc064_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	string str;
	cin>>str;
	int val=0;
	int res=0;
	F0R(x,N)
	{
		if(str[x]=='(')
		{
			val++;
		}
		else if(val==0)
			res++;
		else
			val--;
	}
	F0R(x,res)
		cout<<'(';
	cout<<str;
	F0R(x,val)
		cout<<')';
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll a,b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;

  return 0;
}

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

int main() {
  int A, B, a=0, b=0, c=0, d=0, e=0, f, j, k, l;
  cin >> A >> B;

  int s = 0;
  int i;
    
  for (i = A; i <= B; i++){

    k = 0;
    
    for (j = 0; j < 5; j++){
      
      l = 5 - j;
      f = 1;
      while(l > 1){
        f *= 10;      
        l--;
      }
     
      if (j == 0){
        a = i / f;
        k += a*f;
      }
      
      if (j == 1){
        b = (i - k) / f;
        k += b*f;
      }
      
      if (j == 2){
        c = (i - k) / f;
        k += c*f;
      }
      
      if (j == 3){
        d = (i - k) / f;
        k += d*f;
      }
      
      if (j == 4){
        e = (i - k) / f;
      }

    }
    
    if (a == e && b == d){
        s++;
    }
  }  
  cout << s << endl;
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int mod = 1e9 + 7;
const int MAXN = 5e5 + 5;

int main() {
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    map<ll,ll> a;
    REP(i,N) {
        int t;
        cin>>t;
        if (a.find(t)!=a.end()) {
            a[t]++;
        }
        else {
            a[t] = 1;
        }
    }
    ll ans = 0;
    for (auto t:a) {
        if (t.fi!=t.se) {
            if (t.fi < t.se) {
                ans += t.se - t.fi;
            }
            else {
                ans += t.se;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n , y;
    int a,b;
    cin >> n >> y;
    bool ans = false;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            if(10000*i+5000*j+1000*(n-i-j) == y && (n-i-j) >= 0) {
                ans = true;
                a = i;
                b = j;
                break;
            }
        }
        if(ans) break;
    }
    if(ans) cout << a << " " << b <<" " << n-a-b << endl;
    else cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,n,c,d,b,f,r,v,kami[4][3][10]={{{0}}};
	scanf("%d",&a);
	for(n=0;n<a;n++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		b-=1;
		f-=1;
		r-=1;
		kami[b][f][r]+=v;
	}
		for(b=0;b<4;b++){
			for(f=0;f<3;f++){
				for(r=0;r<10;r++){
					
					printf(" %d",kami[b][f][r]);
				}
				printf("\n");
				
			}
			if(b<3){
			printf("####################\n");
			}
			
		}
		
	
	return 0;
}

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

#define INF 100100100
#define MOD 1000000007

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

using namespace std;
using ll = long long;
using ull = unsigned long long ;

struct edge{ll to,cost;};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll N,M;
   cin >> N >> M;
   ll ans = 1;
   ll B;
   for(ll i = 1;i*i<=M;i++){
      B = M / i;
      if(M % i == 0){
         if(i <= M/N) ans = max(ans,i);
         if(B <= M/N) ans = max(ans,B); 
      }
   }
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int h, m, s, input;
    scanf("%d", &input);
    h = input/3600;
    input -= 3600*h;
    m = input/60;
    s = input - m*60;
    
    printf("%d:%d:%d\n", h, m, s);
    return 0;
    
}



Measured memory_bytes: 2144
#include<iostream>

int main(){
    while(1){
        int h, w;
        std::cin >> h >> w;
        
        if(h == 0 && w == 0) break;
        
        for(int i = 0; i < h; i++){
            if(i % 2 == 0){
                for(int j = 0; j < w; j++){
                    if(j % 2 == 0){
                        std::cout << '#';
                    }
                    else{
                        std::cout << '.';
                    }
                }
            }
            else{
                for(int j = 0; j < w; j++){
                    if(j % 2 == 0){
                        std::cout << '.';
                    }
                    else{
                        std::cout << '#';
                    }
                }
            }
            std::cout << "" << std::endl;
        }
        std::cout << "" << std::endl;
    }
}


Measured memory_bytes: 3080
#!/usr/bin/env python3
import sys
import functools
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, K: int):

    def NN(a):
        return K//a

    @functools.lru_cache(maxsize=None)
    def f(a):
        ans = pow(NN(a), N, MOD)
        for i in range(2, K+1):
            if i*a > K:
                break
            ans -= f(i*a)
            ans %= MOD
        return ans % MOD

    ans = 0
    for i in range(1, K+1):
        # print(i*f(i))
        ans += i*f(i)
        ans %= MOD
    print(ans)

    return


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
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81040
N = int(input())
A = [int(i) for i in input().split()]

A_sorted = sorted(A, reverse=True)

Alice_point = 0; Bob_point = 0

for i in range(N):
    
    if i % 2 == 0:
        Alice_point += A_sorted[i]
    else:
        Bob_point += A_sorted[i]
    
ans = Alice_point - Bob_point

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define RG register
#define R RG int
#define C(i,j,k) {a[1]=i;if(j>k)a[2]=j,a[3]=k;else a[2]=k,a[3]=j;}
using namespace std;
const int N=309,YL=1e9+7;
int he[N],ne[N],l[N],r[N],x[N],f[N][N][N],a[9];
int main(){
	R n,m,p,tmp,ans=0;
	scanf("%d%d",&n,&m);
	for(R i=1;i<=m;++i){
		scanf("%d%d%d",l+i,r+i,x+i);
		ne[i]=he[r[i]];he[r[i]]=i;
	}
	f[0][0][0]=1;
	for(R i=0;i<=n;++i)
		for(R j=0;j<=n;++j)
			for(R k=0;k<=n;++k){
				if(!f[i][j][k])continue;
				if(i>j){if(i>k)C(i,j,k)else C(k,i,j)}
				else   {if(j>k)C(j,i,k)else C(k,i,j)}
				for(p=he[a[1]];p;p=ne[p])
					if(a[x[p]]<l[p]||l[p]<=a[x[p]+1])break;
				if(p){f[i][j][k]=0;continue;}
				p=a[1]+1;tmp=f[i][j][k];
				(f[p][j][k]+=tmp)%=YL;
				(f[i][p][k]+=tmp)%=YL;
				(f[i][j][p]+=tmp)%=YL;
			}
	for(R i=0;i<n;++i)
		for(R j=0;j<n;++j){
			(ans+=f[n][i][j])%=YL;
			(ans+=f[i][n][j])%=YL;
			(ans+=f[i][j][n])%=YL;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 112896
// alt + tab to switch tab


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 


using namespace __gnu_pbds;
using namespace std ;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define ll long long
#define int long long
#define pb push_back
#define p1da(a,n) for(int i=0;i<(n);i++) cout << *( (a) + (i)) << " "; cout<<endl;
#define g1da(a,n) for(int i=0;i<(n);i++) cin >> *( (a) + (i)) ;
#define fi first
#define se second
#define f(i,n) for(int (i)=0;(i)<(n) ; (i)++ )
#define fr(i,s,e) for(int (i)=s;(i)<=(e) ; (i)++ )
#define pii pair <int,int>
#define p2da(a,row,col) f(i,row){f(j,col) cout << a[(i)][(j)]  <<" "; cout<<endl; }
#define g2da(a,row,col) f(i,row) f(j,col) cin >> a[(i)][(j)] ;
#define p1dv(v) f(i,v.size())cout<<v[(i)]<<" "; cout << endl ;
#define g1dv(v) f(i,v.size()) cin>>v[i] ;
#define debug(...)       dbg (#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void dbg(const char* n, Arg1&& arg1) {cerr << n << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void dbg(const char* n, Arg1&& arg1, Args&&... args) {const char*c = strchr(n + 1, ','); cerr.write(n, c - n) << " : " << arg1 << " || "; dbg(c + 1, args...);}
clock_t startTime ; void mainstart(); void mainEnd() ;
#define mod  998244353
#define N 50001



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


  int tt = 1 ;
  //cin >> tt ;
  //   https://www.guru99.com/node-js-tutorial.html

// int tc = 1 ;

  while (tt--)
  {
    double r ;
    cin >> r ;
    cout << r * 6.283185 << endl ;


  }

  mainEnd() ;
  return 0 ;
}

void mainstart()
{
#ifndef ONLINE_JUDGE
  freopen("Input.txt", "r", stdin) ;
  freopen("Output.txt", "w", stdout) ;
#endif
  startTime = clock() ;
}
void mainEnd()
{
  fclose (stdout);
  fclose (stdin);
  clock_t endTime = clock() ;
  cerr << "Run Time is : " << (float)( endTime - startTime ) / CLOCKS_PER_SEC << endl ;
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

string s;
int n;
int ans = 0;

bool f(string t){
    if(t.size() < s.size())return true;
    if(t.size() > s.size())return false;
    rep(i,n){
        if(s[i] < t[i])return false;
        if(s[i] > t[i])return true;
    }
    return true;
}
void dfs(string t){
    if(f(t) == false)return;
    int a = 0, b = 0, c = 0;
    rep(i,t.size()){
        if(t[i] == '3')a++;
        if(t[i] == '5')b++;
        if(t[i] == '7')c++;
    }
    if(a && b && c)ans++;
    dfs(t + "3");
    dfs(t + "5");
    dfs(t + "7");
}

signed main(void) {
    cin >> s;
    n = s.size();
    dfs("");
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	int x, y;
	cin >> x >> y;
	int ans=0;
	for (int i = 0; i <= x; i++) {
		if (y == i * 2 + (x-i) * 4)ans++;
	}
	if (ans==1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3620
from collections import defaultdict

def b173(n, slist):

    countdict = defaultdict(int)

    for s in slist:
        countdict[s] += 1

    return countdict

def main():
    tlist = ["AC", "WA", "TLE", "RE"]
    n = int(input())
    slist = [str(input())for i in range(n)]
    countdict = b173(n, slist)

    for t in tlist:
        print(t + " x " + str(countdict.get(t, 0)))

if __name__ == '__main__':
    main()

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

#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

const ll mod = 1e9 + 7;
const ll N = 1e6 + 6;
const ll maxN = 1e6 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

ll n;
ll a[maxN];
int hash1[maxN];
int h1[maxN];

vt<int> spf(maxN);
void spfsieve() {
	for (int i = 2; i < maxN; i += 2)
		spf[i] = 2;
	for (int i = 3; i < maxN; i += 2) {
		if (spf[i] == 0) {
			spf[i] = i;
			for (int j = 2 * i; j < maxN; j += i) {
				if (spf[j] == 0)
					spf[j] = i;
			}
		}
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in6.txt", "r", stdin);
	freopen("out2.txt", "w", stdout);
#endif
	FIO
	spfsieve();
	cin >> n;
	ll g = 0;
	set<int> s[n];
	FOR(i, n) {
		cin >> a[i];
		g = __gcd(g, a[i]);
		ll t = a[i];
		while (t != 1) {
			s[i].insert(spf[t]);
			t = t / spf[t];
		}
	}
	ll f1 = 0;
	for (int i = 0; i < n; ++i) {
		for (auto& it : s[i]) {
			if (h1[it] == 1) {
				f1 = 1; break;
			}
			h1[it] = 1;
		}
	}
	if (f1 == 0)
		cout << "pairwise coprime";
	else if (g == 1)
		cout << "setwise coprime";
	else
		cout << "not coprime";
	return 0;
}


Measured memory_bytes: 298512
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
   "sort"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()

  var cards []int
  for i := 0; i < n; i++ {
	  val := nextInt()
      cards = append(cards, val)
  }

  sort.Sort(sort.Reverse(sort.IntSlice(cards)))

  alice := 0
  bob := 0
  for i := 0; i < n ;i++ {
	  if i % 2 == 0 {
		  alice = alice + cards[i]
	  } else {
		  bob = bob + cards[i]
	  }
  }
  fmt.Println(alice - bob)

}

func nextString() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;


int main() {
    string s; 
    int k;
    cin >> s >> k;
    int n = s.size();
    vector<int> ds(n, 0);
    rep(i, n) {
        int d = s[i] == 'a' ? 0 : 'z' - s[i] + 1;
        if (k >= d) {
            k -= d;
        } else ds[i] = s[i] - 'a';
    } 
    if (k > 0) {
        ds[n-1] += k;
        ds[n-1] %= 26;
    }
    string ret = "";
    rep(i, n) ret += ds[i] + 'a'; 
    cout << ret << endl;
    return 0;
}

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

int H,W;



int main(){
	cin >> H >> W;
	char s[H+2][W+2];
	// for(int i=0;i<W+2;i++){
	// 	s[0][i] = '.';
	// 	s[H+1][i] = '.';
	// }
	// for(int j=0;j<W+2;j++){
	// 	s[j][0] = '.';
	// 	s[j][W+1] = '.';
	// }
	for(int j=1;j<H+1;j++){
		for(int i=1;i<W+1;i++){
			cin >> s[j][i];
		}
	}
	for(int j=1;j<H+1;j++){
		for(int i=1;i<W+1;i++){
			if(s[j][i] == '#' && s[j][i+1] != '#' && s[j][i-1] != '#' && s[j+1][i] != '#' && s[j-1][i] != '#' ){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

//const int INF = -1e4;

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int A, B; cin >> A >> B;
    int ans;
    ans = max(A+B, A-B);
    ans = max(ans, A*B);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String op;
		Scanner scan = new Scanner(System.in);
		while(true){
			int a = scan.nextInt();
			op = scan.next();
		    int b = scan.nextInt();

		    if(op.equals("?")){
		    	break;
		    }

		    if(op.equals("+")){
		    	System.out.println(a+b);
		    }
		    if(op.equals("-")){
		    	System.out.println(a-b);
		    }
		    if(op.equals("*")){
		    	System.out.println(a*b);
		    }
		    if(op.equals("/")){
		    	System.out.println(a/b);
		    }
		}
	}

}

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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 5e3 + 5;
const int maxm = 2e2 + 5;
const int logn = log2(maxn) + 1;

int n , m , a[maxn] , b[maxm][maxn] , ln[maxn] , P[maxm][maxn][logn];
ll sum[maxn];
void enter()
{
    cin >> n >> m;
    for(int i = 2 ; i <= n ; ++i){
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    for(int i = 1 ; i <= n ; ++i)
        for(int j = 1 ; j <= m ; ++j)
        cin >> b[j][i];
}

// f[l] - > optimal r so that val(l,r) -> optimal
// f[l] <= f[l + 1]
// assume f[l] > f[l + 1] then why (l,f[l + 1]) is worse than (l,f[i]) ??-> false

void Cal(int b[maxn] , int P[maxn][logn])
{
    for(int i = 1 ; i <= n ; ++i){
        P[i][0] = b[i];
        if((1 << (ln[i - 1] + 1)) == i)ln[i] = ln[i - 1] + 1;
        else ln[i] = ln[i - 1];
    }
    for(int j = 1 ; j < logn ; ++j)
        for(int i = 1 ; i <= n ; ++i)
        {
            P[i][j] = P[i][j - 1];
            if(i > (1 << (j - 1)))
                P[i][j] = max(P[i][j],P[i - (1 << (j - 1))][j - 1]);
        }
}

int query(int type , int l , int r)
{
    int len = ln[r - l + 1];
    return max(P[type][r][len] , P[type][l + (1 << len) - 1][len]);
}
ll compute(int l , int r)
{
    if(l > r)return -1e18;
    ll res = 0;
    for(int i = 1 ; i <= m ; ++i)
        res += query(i , l , r);
    return res - (sum[r] - sum[l]);
}

ll res = 0;

void Cal(int l , int r , int optl , int optr)
{
    if(l > r)return;
    int mid = l + r >> 1;
    int opt = mid;ll ans = 0;
    for(int i = max(mid , optl) ; i <= optr ; ++i)
    {
        ll now = compute(mid , i);
        if(now > ans)
        {
            ans = now;
            opt = i;
        }
    }
    res = max(res , ans);
    Cal(l , mid - 1 , optl , opt);
    Cal(mid + 1 , r , opt , optr);
}

#define brute 0

void solve()
{
    for(int j = 1 ; j <= m ; ++j)
        Cal(b[j] , P[j]);
    if(brute)
    {
        ll res = 0;
        for(int i = 1 ; i <= n ; ++i)
            for(int j = i ; j <= n ; ++j)
                res = max(res , compute(i,j));
        cout << res;
    }
    else
    {
        Cal(1,n,1,n);
        cout << res;
    }
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    enter();
    solve();
}


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

int H, W, h, w;

int main() {
    scanf("%d %d %d %d", &H, &W, &h, &w);
    if(H % h == 0 && W % w == 0) {
        printf("No");
        return 0;
    }
    printf("Yes\n");

    int q1 = H / h;
    int q2 = W / w;
    int x = (q1 + 1) * (q2 + 1);
    int y = h*w*x - x - 1;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(i % h == 0 && j % w == 0) printf("%d ", y);
            else printf("%d ", -x);
        }
        printf("\n");
    }
}


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

int main()
{
    char s[101];

    while(scanf("%s", s) != EOF)
    {
        int len = strlen(s);

        int frequency[26] = {0};

        for(int i=0; i<len; i++) frequency[s[i] - 'a']++;

        bool beautiful = true;

        for(int i=0; i<26; i++)
        {
            if(frequency[i] % 2!=0)
            {
                beautiful = false;
                break;
            }
        }

        if(beautiful) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;
int n;
int main(){
  // freopen("input.txt","r",stdin);
  cin>>n;
  if(n%1000 == 0){
    cout<<"0"<<endl;
  }
  else{
    int now = ((n/1000)+1)*1000;
    cout<<now-n<<endl;
  }
  return 0;
}


Measured memory_bytes: 3644