akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int n , p;
  cin >> n >> p;
  string s;
  cin >> s;
  if(p == 2 || p == 5) {
      int ans = 0;
      int sum = 0;
      for(int i = 0; i < n; i++) {
          sum = (sum * 10) + (s[i] - '0');
          sum = sum % p;
          if(sum == 0) {
            ans += i + 1;
          }
      }
      cout << ans << '\n';
      return 0;
  }

  int ans = 0 , Tenp = 1 , sum = 0;
  unordered_map<int,int>Cnt;
  for(int i = n - 1; i >= 0; i--) {
    sum = (sum + (Tenp * (s[i] - '0')) ) % p;
    if(sum == 0)ans++;
    ans += (Cnt[sum]);
    Cnt[sum]++;
    Tenp = (Tenp * 10) % p;
  }
  cout << ans << '\n';
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

const int MOD = 1000000007;

int DP[111111]; // Najdluzszy
int X[111111];

int minp[111111];
int main() {
  int N;
  scanf("%d", &N);
  REP(i,N) scanf("%d", &X[i]);

  DP[0] = 1;
  FOR(i,1,N) DP[i] = min(DP[i-1] + 1, (X[i] + 1) / 2);

  int last = 1;
  LL res = 1;
  REP(i,N) {
    while (last < N && last - DP[last-1] <= i) ++last;
    res *= (last - i);
    res %= MOD;
  }
  printf("%lld\n", res);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main() {
	int N;
	scanf("%d", &N);
	int* a = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, N, sizeof(int), compare_int);

	int countSum = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			countSum += a[N - 1 - i];
		}
		else {
			countSum -= a[N - 1 - i];
		}
	}


	printf("%d", countSum);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

P get(){
    int a,b,c,d;
    scanf("%d:%d-%d:%d",&a,&b,&c,&d);
    return P(a*60+b,c*60+d);
}
vector<P>A;
vector<vector<P> >B,C;
int main(){
    int K,N,M;
    cin>>K;
    for(int i=0;i<K;i++)A.push_back(get());
    cin>>N;
    for(int i=0;i<N;i++){
        vector<P>b;
        int k;cin>>k;
        for(int j=0;j<k;j++)b.push_back(get());
        B.push_back(b);
    }
    cin>>M;
    for(int i=0;i<M;i++){
        vector<P>c;
        int k;cin>>k;
        for(int j=0;j<k;j++)c.push_back(get());
        C.push_back(c);
    }

    int ans=0;
    for(int i=0;i<K;i++){
        int a=0,b=0;

        for(int j=0;j<B.size();j++){
            bool flag=false;
            for(int k=0;k<B[j].size();k++){
                if(B[j][k].first<=A[i].first&&A[i].second<=B[j][k].second)flag=true;
            }
            if(flag)a++;
        }
        for(int j=0;j<C.size();j++){
            bool flag=false;
            for(int k=0;k<C[j].size();k++){
                if(C[j][k].first<=A[i].first&&A[i].second<=C[j][k].second)flag=true;
            }
            if(flag)b++;
        }
        ans+=min(a,b);
    }

    cout<<ans<<endl;
}

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

int main() {
  int h,w;
  cin >>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  vector<int> hantei_h(h,0);
  vector<int> hantei_w(w,0);  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        hantei_h[i]=1;
        break;
      }
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0;i<h;i++){
      if(a[i][j]=='#'){
        hantei_w[j]=1;
        break;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(hantei_h[i]==0)continue;
    for(int j=0;j<w;j++){
      if(hantei_w[j]==1)cout<<a[i][j];
    }
    cout<<endl;
  }  
  return 0;
}

Measured memory_bytes: 256
from itertools import permutations
n = int(input())
x = [i+1 for i in range(n)]
x = list(map(str, x))
pt = [''.join(p) for p in permutations(x)]
a = pt.index(''.join(input().split()))
b = pt.index(''.join(input().split()))
print(abs(a-b))

Measured memory_bytes: 11828
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
//#inlcude<stringstream>
#define ll long long
#define MODD 1000000007
using namespace std;

int main() {
    /*int n ,k;cin>>n>>k;
    int sum=0;
    for(int i=k;i<n;i++){
        sum+=n-i;
    }
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>0;j--){
            if(i%j>=k)sum++;
        }
    }
    cout<<sum<<endl;*/
    map<string, int> mp;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        string s;cin >>s;
        if(mp[s]==0)mp[s]=1;
        else mp[s]++;
    }
    int t;cin >>t;
    for(int i=0;i<t;i++){
        string s;cin >>s;
        if(mp[s]==0)continue;
        else mp[s]--;

    }int ma =0;
    for (map<string, int>::iterator ite = mp.begin(); ite != mp.end(); ++ite)
    {
       ma = max(ite->second,ma);
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	VI a, b;
	rep(i,n){
		int c; cin>>c;
		if(i%2==0) a.PB(c);
		else b.PB(c);
	}
	if(n%2){
		REP(i,a.size()) cout<<a[i]<<' ';
		rep(i,b.size()) cout<<b[i]<<' ';
	}else{
		REP(i,b.size()) cout<<b[i]<<' ';
		rep(i,a.size()) cout<<a[i]<<' ';
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main()
{
    char s[10];
    int n,k;
    cin>>n>>s>>k;
    for(int i =0;i<n;i++){
        if(s[i] != s[k-1])
            s[i] = '*';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


ll solve(){
  ll K,A,B; cin >>K >>A >>B;
  if (A >= B-2) return 1 + K;
  if (1+K < A) return 1 + K;
  ll res = A;
  K -= A-1;
  res += (K/2) * (B-A);
  K %= 2;
  res += K;
  return res;
}

int main() {
  ll res = solve();
  cout <<res <<endl;
}

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

using namespace std;

int p[100010];

void init() {
    for (int i = 0; i < 100010; ++i)
        p[i] = i;
}

int f(int x) {
    return x == p[x] ? x : p[x] = f(p[x]);
}

void merge(int x,int y) {
    p[f(y)] = p[f(x)];
}

int main() {
    int n,m;
    cin >> n >> m;
    init();
    for (int i = 0; i < m; ++i) {
        int x,y,z;
        cin >> x >> y >> z;
        merge(x,y);
    }

    int ans = 0;

    
    for (int i = 1; i <= n; ++i)
        ans += f(i) == i;

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 768
#include <set>
#include <cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(std::set<int>::iterator s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)printf("%d\n",v[++i]);}}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 200005
#define INF 1000005
#define endl "\n"
int arr[MAX];
int f[INF];
bool p[INF];
bool flag[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(lli i = 2; i<=INF; i++){
		if(!p[i]){
			for(lli j = i*i; j<=INF; j+=i){
				p[j] = true;
 			}
		}
	}
	int n;
	cin>>n;
	for(int i = 0; i<n; i++){
		cin>>arr[i];
		f[arr[i]]++;
	}
	int c = 0;
	bool flag = false;
	for(int i = 0; i<n; i++){
		flag = false;
		f[arr[i]]--;
		if(!p[arr[i]]){
			if(f[1] || f[arr[i]]){
			}
			else{
				c++;
			}
			f[arr[i]]++;
			continue;
		}
		for(int j = 1; j*j <= arr[i]; j++){
			if(arr[i]%j == 0){
				if(f[j] || f[arr[i]/j]){
					flag = true;
					break;
				}
			}
		}
		if(!flag){
			c++;
		}
		f[arr[i]]++;
	}
	cout<<c<<endl;
	
}

Measured memory_bytes: 9256
input1 = str(input())
N = int(input1[-1])


if N == 2 or N == 4 or N == 5 or N == 7 or N == 9:
    print("hon")

if N == 0 or N == 1 or N == 6 or N == 8:
    print("pon")

if N == 3:
    print("bon")


Measured memory_bytes: 9108
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

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

int main() {
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll g = gcd(a[0], a[1]);
    ll mx = max(a[0], a[1]);
    for(int i=2;i<n;i++){
        g = gcd(g, a[i]);
        mx = max(mx, a[i]);
    }

    if(mx-k<0) cout << "IMPOSSIBLE" << endl;
    else if((mx-k) % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h: u64 = read();
    let w: u64 = read();

    if h == 1 || w == 1 {
        println!("1");
    } else {
        println!("{}", (h * w + 1) / 2);
    }
}


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

char a[101][101];
int r[101], c[101], row, col;

int main()
{
    cin >> row >> col;
    for (int i = 1; i <= row; i++)
        for (int j = 1; j <= col; j++)
            cin >> a[i][j];
    
    for (int i = 1; i <= row; i++)
    {
        for (int j = 1; j <= col; j++)
        {
            if (a[i][j] == '#')
                break;
            if (j == col)
                a[i][0] = '@';
        }
    }
    for (int i = 1; i <= col; i++)
    {
        for (int j = 1; j <= row; j++)
        {
            if (a[j][i] == '#')
                break;
            if (j == row)
                a[0][i] = '@';
        }
    }
    
    for (int i = 1, k = 0; i <= row; i++, k = 0)
    {
        for (int j = 1; j <= col; j++)
            if (a[i][0] == '@')
                break;
            else if (a[0][j] == '@')
                continue;
            else
                cout << a[i][j], k = 1;
        if (k == 1 and i < row)
            cout << 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 FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string A;
  cin >> A;
  if ("a" <= A && A <= "z")
    cout << 'a' << endl;
  else
    cout << "A" << endl;
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> sum(N,0),Min(N,0);
    int Sum=0;
    for (int i=0;i<N;++i){
        string S; cin >> S;
        for (int j=0;j<S.size();++j){
            sum[i]+=(S[j]=='('?1:-1);
            Min[i]=min(Min[i],sum[i]);
        }
        Sum+=sum[i];
    }
    int ans=1;
    if (Sum!=0) ans=0;
    vector<pair<int,int>> v1,v2;
    Sum=0;
    for (int i=0;i<N;++i){
        if (Min[i]>=0) Sum+=sum[i];
        else if (sum[i]>=0) v1.emplace_back(-Min[i],sum[i]);
        else v2.emplace_back(Min[i]-sum[i],Min[i]);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    for (auto p:v1){
        if (Sum-p.first<0) ans=0;
        Sum+=p.second;
    }
    for (auto p:v2){
        int M=p.second,s=M-p.first;
        if (Sum+p.second<0) ans=0;
        Sum+=p.second-p.first;
    }
    cout << (ans?"Yes":"No") << '\n';
}

Measured memory_bytes: 15208
def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    ans = 0
    cont = [0] * (K + 1)
    for i in range(K, 0, -1):
        tmp = K // i
        if tmp == 1:
            cont[i] = 1
        else:
            cont[i] = pow(tmp, N, MOD)
            for k in range(2,100000):
                if i * k > K:
                    break
                cont[i] -= cont[i*k]
                cont[i] %= MOD

    for i in range(1,K+1):
        ans += i * cont[i]
        ans %= MOD

    if sum(cont) % MOD != pow(K,N,MOD):
        ans -= sum(cont) % MOD - pow(K,N,MOD)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 69032
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

int dy[4] = {-1, 0, +1, 0};
int dx[4] = {0, +1, 0, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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


int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    if(b / a > c){
        cout << c << endl;
    } else {
        cout << b / a << endl;
    }
}



Measured memory_bytes: 256
N, M = gets.split(' ').map(&:to_i)

lst = []
N.times do
  lst << gets.split(' ').map(&:to_i)
end

ret = lst.each_with_index.reduce([]) do |a, (e, i)|
  a2 = []
  if i == 0
    a2 = e[1..-1]
  else
    e.each_with_index do |i, j|
      next if j == 0
      if a.include?(i)
        a2 << i
      end
    end
  end
  a2
end
p ret.nil? ? 0 : ret.size


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	map<char, bool> seen;
	for (char s : S) seen[s] = true;

	if (seen['N'] + seen['S'] == 1) {
		print("No");
	} else if (seen['E'] + seen['W'] == 1) {
		print("No");
	} else {
		print("Yes");
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

int main(void)
{
	int a,b[22],i,c=0,d=0;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<a;i++){
		if(d<=b[i]){
			c++;
			d=b[i];
		}
	}
	printf("%d\n",c);
	return 0;
}

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

ll gcd(ll a,ll b) {
  return (b? gcd(b,a%b):a);
}

int main() {
  int n;
  cin>>n;
  ll t[110];
  for (int i=0; i<n; i++) {
    scanf("%lld",t+i);
  }

  ll l=t[0];
  for (int i=1; i<n; i++) {
    ll g=gcd(l,t[i]);
    l=g*(l/g)*(t[i]/g);
  }

  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,a,b,c,s;
    cin >> n ;
    for(int i = 0;i<n;i++){
        s=0;
        cin >> a >> b >> c;
        while((c>0)&&(b>0)&&(a>0)){
            c--;
            b--;
            a--;
            s++;
        }
        while((b>0)&&(a>1)){
            b--;
            a-=2;
            s++;
        }
        while(a>2){
            a-=3;
            s++;
        }
        cout << s << "\n";
    }
         
     
return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int inp[100005][3];
ll dp[105][100005];
int n, w;

ll solve(int i, int remPrice) {
    if(i == n) {
        if(remPrice == 0)
            return 0;
        return (ll) 1e17;
    }
    ll &rt = dp[i][remPrice];
    if(rt != -1)
        return rt;
    rt = solve(i + 1, remPrice);
    rt = min(rt, solve(i + 1, remPrice - inp[i][1]) + inp[i][0]);
    return rt;
}

int main() {
    IO;
    cin >> n >> w;
    for(int i = 0; i < n; i++)
        cin >> inp[i][0] >> inp[i][1];
    memset(dp, -1, sizeof dp);
    for(int i = 100000; i >= 0; i--) {
        ll rt = solve(0, i);
        if(rt <= w) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


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

string S;

int main() {

	cin >> S;

	long long cnt = 0, ans = 0;
	for (char c : S) {
		if (c == 'B') {
			cnt++;
		} else {
			ans += cnt;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
a = Base_10_to_n(n,k)
print(len(a))

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

int main() 
{
  string a,b;
  cin>>a>>b;
  int s=a.size();
  if(b.erase(s)==a)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }


  
}


Measured memory_bytes: 3600
/* ex 5_4
   riverstone */

#include <stdio.h>
#include <string.h>
 
int main(void){

    //最高文字列数は10(ヌルを入れて11)
    char sequence[11];
    //最大の長さと何文字連続しているかが入る変数
    int i,max = 0,counter=0;
    
    //入力
    scanf("%s", sequence);

    for ( i = 0; i < strlen(sequence); i++){   
        //読み取った文字が，A,C,G,Tで，
        if(sequence[i]=='A'||sequence[i]=='C'||sequence[i]=='G'||sequence[i]=='T'){
            counter += 1;
            if (counter >= max){   
                //その連続数が最高記録ならば最高記録を更新
                max = counter;
            }
        }
        else{
            counter=0;
        }
    }

    //最高連続記録の出力
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1732
import sys
from math import factorial

def solve():
    N, A, B = map(int, input().split())
    v = [int(i) for i in input().split()]
    v.sort(reverse=True)

    ave_max = sum(v[:A]) / A

    onaji = v.count(v[0])

    if onaji < A:
        k = v[:A].count(v[A - 1])
        n = v.count(v[A - 1])
        cnt = binom(n, k)
    else:
        cnt = 0

        for i in range(A, min(onaji, B) + 1):
            cnt += binom(onaji, i)

    print('{:.8f}'.format(ave_max))
    print(cnt)


def binom(n, k):
    return (factorial(n) // factorial(n - k)) // factorial(k)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n,a[100010],ans;

//ユークリッドの互除法
long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(void){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	ans=a[0];
	reg(i,1,n-1){
		ans=gcd(ans,a[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    string s; cin >> s;
    string t = s; REVERSE(t);
    Yn(s==t);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        int[] num = new int[N+1];
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < N;i++){
            num[a[i]]++;
        }
        Arrays.sort(num);
        int x; 
        int count = 0;
        x = N;
        while(x > 0){
            if(num[x] > 0){
                count++;
            }
            x--;
        }
        int kakikae = 0;
        if(count > K){
            for(int i = 0;i < N - K + 1;i++){
                kakikae += num[i]; 
            }
        }
        System.out.println(kakikae);
    }
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool flag = false;
  
  if (A == 7) {
    if (B == 5 && C == 5) {
      flag = true;
    }
  }
  if (B == 7) {
    if (A == 5 && C == 5) {
    	flag = true;
    }
  }
  if (C == 7) {
    if (A == 5 && B == 5) {
    	flag = true;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}Toge;

void koch(int, Toge, Toge);

int main(){
  int n = 0;
  int i = 0;
  Toge p1 = { 0, 0};
  Toge p2 = {100, 0};
  
  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x, p1.y);
  
  koch(n, p1, p2);

  printf("%.8f %.8f\n",p2.x, p2.y);
  
  return 0;
}

void koch(int n, Toge p1, Toge p2){
  Toge s = {0,0}, t = {0,0}, u = {0,0};
  
  if(n == 0)return;

  /* calculate s */
  s.x = ( (2 * p1.x) + (1 * p2.x) ) / 3;
  s.y = ( (2 * p1.y) + (1 * p2.y) ) / 3;
  
  /* calculate t */
  t.x = ( (1 * p1.x) + (2 * p2.x) ) / 3;
  t.y = ( (1 * p1.y) + (2 * p2.y) ) / 3;
  
  /* calculate u */
  u.x = (t.x - s.x) * cos(M_PI/3) - (t.y - s.y) * sin(M_PI/3) + s.x;
  u.y = (t.x - s.x) * sin(M_PI/3) + (t.y - s.y) * cos(M_PI/3)  + s.y;
  
  /* p1 -> s */
  koch(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y);
  
  /* s -> u */
  koch(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  
  /* u -> t */
  koch(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  
  /* t -> p2 */
  koch(n-1, t, p2);
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_2020_0217_002();
	}



	public static void solve_2020_0217_002(){


		int max = 101010;

		//prime number
		boolean[] isPrime = new boolean[max];
		for(int i=2;i<max;i++) isPrime[i] = true;
		for(int i=2; i<max; i++){
			if(!isPrime[i]) continue;
			for(int j=2;j*i<max;j++){
				isPrime[j*i] = false;
			}
		}

		//2017-like number
		int[] isLikeNum = new int[max];
		for(int i=3; i<max; i=i+2){
			if(isPrime[i] && isPrime[(i+1)/2]){
				isLikeNum[i] = 1;
			}
		}

		//cumulative sum
		int[] cs = new int[max];
		for(int i=1;i<max;i++){
			cs[i] = cs[i-1] + isLikeNum[i];
		}

		int Q =sc.nextInt();
		int[] numLikeNumber = new int[Q];

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

			int l = sc.nextInt();
			int r = sc.nextInt();
			numLikeNumber[i] = cs[r]-cs[l-1];
		}

		for(int nLN: numLikeNumber) System.out.println(nLN);
	}
}

Measured memory_bytes: 90808
while True:
    N,A,B,C,X=map(int,raw_input().split())
    if N==A==B==C==X==0:break
    Y=map(int,raw_input().split())
    i=frame=0
    while frame<=10000:
        if X==Y[i]:
            i+=1
        if i==N:
            print frame
            break
        X=(A*X+B)%C
        frame+=1
    else:
        print -1

Measured memory_bytes: 4228
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int n,m;
V<int>G[10];
int ans=0;
void dfs(int i,int from,set<int>went){
    went.insert(i);
        if(went.size()==n)
            {

                ans++;
                return;
            }
    for(int j=0;j<G[i].size();j++){
        if(went.count(G[i][j])){
            continue;
        }
        dfs(G[i][j],i,went);
    }
    went.erase(i);
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    set<int>went;
    dfs(0,0,went);
    cout<<ans<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































Measured memory_bytes: 256
#list(map(int,input().split()))
import math
import sys
import collections
n = int(input())
vvv = list(map(int,input().split()))
odd = [vvv[i] for i in range(1,n,2)]
even = [vvv[i] for i in range(0,n,2)]
c_o = collections.Counter(odd)
_, odd_c = zip(*c_o.most_common())
c_e = collections.Counter(even)
_, even_c = zip(*c_e.most_common())
if c_o.most_common()[0][0] == c_e.most_common()[0][0]:
  print(min(sum(list(odd_c)[1:]) + list(even_c)[0] + sum(list(even_c)[2:]),
      sum(list(even_c)[1:]) + list(odd_c)[0] + sum(list(odd_c)[2:])))
  sys.exit()
ans = sum(list(odd_c)[1:]) + sum(list(even_c)[1:])
print(ans)

Measured memory_bytes: 24236
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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


int main() {
    ll n, x; cin >> n >> x;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];

    ll ans = 0;
    rep(i, 0, n-1){
        if(a[i]+a[i+1]<=x) continue;
        ll di = a[i]+a[i+1]-x;
        if(di <= a[i+1]){
            a[i+1]-=di;
            ans += di;
        }else{
            a[i+1]=0;
            ans += di;
        }
    }
    co(ans);

    return 0;
}


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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define vll vector <ll>
#define vull vector <ull>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define pb push_back
#define PI acos(-1.0)
#define DEBUG 0


int main ()

{
    fast;
    
    ll n, k, news = n;
    cin >> n >> k;
    
   cout << min(n%k, ((n/k)+1)*k - n) << endl;
    	
    	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - DDCC Finals
	var X, Y int
	fmt.Scan(&X, &Y)

	var ans int
	if X == 3 {
		ans += 100000
	} else if X == 2 {
		ans += 200000
	} else if X == 1 {
		ans += 300000
	}

	if Y == 3 {
		ans += 100000
	} else if Y == 2 {
		ans += 200000
	} else if Y == 1 {
		ans += 300000
	}

	if X == 1 && Y == 1 {
		ans += 400000
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	bool yes = false;
	for(int i = 1; i <= 9; ++i) {
		if( n % i == 0 && n / i < 10 ) { 
			yes = true;
			break;
		}
	}
	
	if( yes ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue; //if double it skip
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]); //check the purpose line
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n=0;
  cin>>n;
  long long int dp[2][100000];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      dp[i][j]=0;
    }
  }
  vector<int>A(n);
  vector<int>B(n);
  vector<int>C(n);
  for(int i=0;i<n;i++)cin>>A[i];
  for(int i=0;i<n;i++)cin>>B[i];
  for(int i=0;i<n;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  long long int ans=0;
  int j=0,k=0;
  for(int i=0;i<n;i++){
    for(;j<n;j++){
      if(B[i] <= A[j])break;
    }
    if(i!=0){
      dp[1][i]=j+dp[1][i-1];
    }else{
      dp[1][i]=j;
    }
  }
  j=0;
  for(int i=0;i<n;i++){
    if(i!=0)dp[0][i]=dp[0][i-1];
    for(;j<n;j++){
      if(C[i] <= B[j])break;
    }
    dp[0][i]=dp[1][j-1];
  }
  for(int i=0;i<n;i++){
    ans+=dp[0][i];
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 2944
#include <cstdio>
int a[10],b,c,n;
bool ok;
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<10;j++) scanf("%d",&a[j]);
		b=c=0;ok=true;
		for(int j=0;j<10;j++) {
			if(a[j]>b) b=a[j];
			else if(a[j]>c) c=a[j];
			else {ok=false;break;}
		}
		printf("%s\n",ok?"YES":"NO");
	}
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
double PI=acos(-1.0);
signed main(){
    ll n;cin>>n;
    vector<pair<double,pll> >a(0);
    rep(i,n){
        ll x,y;cin>>x>>y;
        double c=atan2(y,x);
        a.pb(mp(c,mp(x,y)));
        a.pb(mp(c+2*PI,mp(x,y)));
    }
    ll ans=0;
    sort(all(a));
    rep(i,n){
        ll cntx=0;
        ll cnty=0;
        REP(j,i,i+n){
            cntx+=a[j].second.first;
            cnty+=a[j].second.second;
            ans=max(ans,cntx*cntx+cnty*cnty);
        }
    }
    cout<<fixed<<setprecision(16)<<sqrt(ans)<<endl;
}

Measured memory_bytes: 768
import sys
n = int(input())
num_list = list(map(int, input().split()))
sum = 1
for i in range(len(num_list)):
	if num_list[i] == 0:
		print(0)
		sys.exit()

for i in range(len(num_list)):
	sum *= num_list[i]
	if sum > 1000000000000000000:
		print(-1)
		sys.exit()

print(sum)

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

void solve() {
    int ans = -1;
    int n, k; cin >> k;
    set<int> st;
    int curr = 7;
    int len = 1;
    while(true) {
        int mod = curr%k;
        if(mod == 0) {
            ans = len; break;
        }
        else if(st.count(mod)){
            ans = -1;
            break;
        }
        else {
            st.emplace(mod);
        }
        curr = (mod*10) + 7;
        len ++;
    }
    cout << ans << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = (double)W * (double)H / 2.0;
    cout << fixed << setprecision(10) << ans << ln;
    if ((double)W / 2 == (double)x && (double)H / 2 == (double)y) {
        cout << 1 << ln;
    } else {
        cout << 0 << ln;
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            Console.WriteLine(Lcm(2,n));
        }

        //最小公倍数
        static long Lcm(long m, long n){
        	return (m * n) / Gcd(m, n);
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
	        while (m % n != 0){
        		var temp = n;
		        n = m % n;
		        m = temp;
	        }
        	return n;
        }
    }
}


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

const long long int INF = 1e17;

long long int dis[305][305], g[305][305];

int main(void) {
    long long int n, m, l;
    cin >> n >> m >> l;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            dis[i][j] = INF;
        }
        dis[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        dis[a][b] = dis[b][a] = c;
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (dis[i][k] + dis[k][j] < dis[i][j]) {
                    dis[i][j] = dis[i][k] + dis[k][j];
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            g[i][j] = dis[i][j] <= l ? 1LL : INF;
        }
        g[i][i] = 0;
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (g[i][k] + g[k][j] < g[i][j]) {
                    g[i][j] = g[i][k] + g[k][j];
                }
            }
        }
    }
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++) {
        int s, t;
        cin >> s >> t;
        if(g[t][s] < INF) cout << g[t][s] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 1920