akhauriyash/Code-Regression huggingface dataset:
<?php

while($line = trim(fgets(STDIN))) {
    $a = $line;
    $zitem='';
    $flg = true;
    for($i = 0; $i < strlen($a); $i++) {
        if ($i == 0) {
            $zitem = $a[$i];
            continue;
        }
        
        switch ($zitem) {
          case 'A':
              if (!in_array($a[$i], array('B','D'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'B':
              if (!in_array($a[$i], array('A','E','C'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'C':
              if (!in_array($a[$i], array('B','F'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'D':
              if (!in_array($a[$i], array('A','E','G'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'E':
              if (!in_array($a[$i], array('B','D','F','H'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'F':
              if (!in_array($a[$i], array('C','E','I'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'G':
              if (!in_array($a[$i], array('D','H'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'H':
              if (!in_array($a[$i], array('G','E','I'))) {
                  $flg=false;
                  break;
              }
              break;
          case 'I':
              if (!in_array($a[$i], array('H','F'))) {
                  $flg=false;
                  break;
              }
              break;
        }  
        $zitem = $a[$i];
    }
    if ($flg) {
        echo $a.PHP_EOL;
    }
}

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

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

  vector<int> v;

  for (int i = 0; i < q; ++i) {
    int qwery, x, p;
    cin >> qwery;
    if (qwery == 0) {
      cin >> x;
      v.push_back(x);
    }
    if (qwery == 1) {
      cin >> p;
      cout << v.at(p) << endl;
    }
    if (qwery == 2) {
      v.pop_back();
    }
  }
}


Measured memory_bytes: 3824
class Edge:

    def __init__(self, origin, to, cost):
        self.origin = origin
        self.to = to
        self.cost = cost

N, M = map(int, input().split())

edges = [None] * M

for i in range(M):
    a, b, c = map(int, input().split())
    edges[i] = Edge(a-1, b-1, -c)

#コストを最小化するような問題として読み替える

dist = [float("inf") for _ in range(N)]
dist[0] = 0
i = 0
while True:
    isUpdated = False
    for e in edges:
        if dist[e.origin] != float("inf") and dist[e.to] > dist[e.origin] + e.cost:
            dist[e.to] = dist[e.origin] + e.cost
            isUpdated = True
    i += 1

    if not isUpdated:
        break

    if i == N-1:
        break

# print(dist)

#最短経路探索が終了
#負のサイクルを検知する
isUpdated = [False for _ in range(N)]
for i in range(N):
    for e in edges:
        if dist[e.to] > dist[e.origin] + e.cost:
            dist[e.to] = dist[e.origin] + e.cost
            isUpdated[e.to] = True


if isUpdated[N-1]:
    print("inf")

else:
    print(-dist[N-1])


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

int main() {
    int a,b;
    int g;
    cin >> a >> b;
  
    if(b == 100){
      g = a * 1000 + b;
      }
    else if(b < 10){
      g = a * 10 + b;
      }
    else{
      g = a * 100 + b;
    }
  
    for(int i = 0; i < 350; i ++){
      long p = pow(i+1,2);
      if(g == p){
        cout << "Yes" << endl;
        return 0;
      }
    }
  
    cout << "No" << endl;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;

    int n ;
    cin>>n;
    vi a(n),b(n);

    for(int i = 0 ; i<n ; i++){
        cin>>a[i];
    }
    for(int i = 0 ; i<n ; i++){
        cin>>b[i];
    }

    reverse(all(b));
    int l = -1 ; 
    int r = -1;

    for(int i = 0 ; i<n ; i++){
        if(a[i]==b[i]){
            l = i ; 
            break;
        }
    }

    if(l!=-1){
    for(int i  = n-1 ; i>=0 ; i--){
        if(a[i]==b[i]){
            r = i;
            break;
        }
    }
    }

    if(l!=-1){
    for(int i= 0 ; i<n ; i++){
        if(a[i]!=a[l] and b[i]!=b[l] and l<=r){
            swap(b[i],b[l]);
            l++;
        }
    }
    }

    bool ans = true;
    if(l<=r and l!=-1){
        ans = false;
    }

    if(!ans){
        cout<<"No\n";
    }
    else{
        cout<<"Yes\n";
        printV(b);
    }


	return 0;
}


Measured memory_bytes: 8032
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
typedef pair<int, int>P;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
ll inf = -1;

int main() {
	int n; cin >> n;
	int u, v, w;
	vector<vector<int> >grid(n),cost(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v >> w;
		u--; v--;
		grid[u].push_back(v);
		grid[v].push_back(u);
		cost[u].push_back(w);
		cost[v].push_back(w);
	}
	vector<int> ans(n,inf);
	queue<int>que;
	ans[0] = 0;
	que.push(0);
	while (que.empty() == false) {
		int V = que.front();
		que.pop();
		for (int i = 0; i < grid[V].size(); i++) {
			if (ans[grid[V][i]] != -1) {
				continue;
			}
			ans[grid[V][i]] = (ans[V] + cost[V][i]) % 2;
			que.push(grid[V][i]);
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 11904
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize, m: usize, x: usize,
        arr: [[usize; m+1]; n],
    }

    let mut ans = std::usize::MAX;
    for i in 0..(1<<(n+1)) {
        let mut levels = vec![0; m+1];
        for j in 0..n {
            if i & 1<<j > 0 {
                for k in 0..m+1 {
                    levels[k] += arr[j][k];
                }
            }
        }
        let flg = levels[1..m+1].iter().all(|e| e>=&x);
        if flg && ans > levels[0] { ans = levels[0] }
    }

    if ans == std::usize::MAX {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

Measured memory_bytes: 2204
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bw = new BufferedReader(new InputStreamReader(System.in));
		String s = bw.readLine();
		int N = Integer.parseInt(s); 
		HashSet<String> set = new HashSet<String>();
		int res = 0;
		for(int i=0;i<N;i++) {
			s = bw.readLine();
			if( !set.contains(s)) {
				res++;
				set.add(s);
			}
		}
		System.out.println(res);
		bw.close();
	}
	 
	
}	



Measured memory_bytes: 66812
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        String t = scan.nextLine();
      	String t_head = t.substring(0,t.length()-1);
      
      if (s.equals(t_head)){
         System.out.println("Yes");
      }else {
         System.out.println("No");
        }
	
      	
        scan.close();
    }
}


Measured memory_bytes: 35740
n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ones = list(filter(lambda i:len(g[i])==1,range(n)))
if max([len(g[i]) for i in range(n)]) <= 2:
  print(1)
  exit()
def nbh(i):
  inext = g[i][0]
  def nbh_(xnext,x):
    return g[xnext][0] ^ g[xnext][1] ^ x
  while len(g[inext]) <= 2:
    i,inext = inext,nbh_(inext,i)
  return inext
edges = list(set([nbh(i) for i in ones]))
print(len(ones)-len(edges))

Measured memory_bytes: 27436
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    char ch; cin>>ch;
    if(ch>='A' and ch<='Z') cout<<'A';
    else cout<<'a';
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

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

set<long long> nums;

void gen(long long cur, int len) {
	if (len > 10) return;
	nums.insert(cur);
	int d = cur % 10;
	for (int i = d - 1; i <= d + 1; i++) {
		if (i >= 0 && i <= 9) {
			gen(cur * 10 + i, len + 1);
		}
	}
}

void solve() {
	int k;
	cin >> k;
	for (int i = 1; i <= 9; i++) {
		gen(i, 1);
	}
	auto it = nums.begin();
	advance(it, k - 1);
	cout << *it << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 12968
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct BIT
{
	int bit[SIZE];
	
	void init()
	{
		memset(bit,0,sizeof(bit));
	}
	void add(int k,int x)
	{
		k++;
		while(k<SIZE)
		{
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k)
	{
		k++;
		int ret=0;
		while(k>0)
		{
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
	int get(int s,int t)
	{
		return get(t)-get(s-1);
	}
	int pos(int k)//k 番目
	{
		int l=0,r=SIZE;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(get(m)<k) l=m;
			else r=m;
		}
		return r;
	}
};
BIT bit;
ll sum[SIZE];

int main()
{
	int n;
	ll K;
	scanf("%d %lld",&n,&K);
	int sz=0;
	sum[sz++]=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&sum[sz]);
		sum[sz]-=K;
		sum[sz]+=sum[sz-1];
		sz++;
	}
	vector <ll> vx;
	for(int i=0;i<sz;i++) vx.push_back(sum[i]);
	sort(vx.begin(),vx.end());
	vx.erase(unique(vx.begin(),vx.end()),vx.end());
	ll ret=0;
	for(int i=0;i<sz;i++)
	{
		int pos=lower_bound(vx.begin(),vx.end(),sum[i])-vx.begin();
		ret+=bit.get(pos);
		bit.add(pos,1);
	}
	printf("%lld\n",ret);
	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
const int N_max=51;
const int M_max=N_max*(N_max-1);
vector<int> v[51];
bool isVisited[N_max];
void initialize(){
    REP(i,N_max){
        isVisited[i]=false;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    ll dp[S.size()+1][13];
    REP(i,S.size()+1){
        REP(j,13){
            dp[i][j]=0;    
        }
    }
    ll keta;
    ll sum_keta;
    dp[0][0]=1;
    ll pow;pow=1;
    REP(i,S.size()){
        if(S[S.size()-i-1]=='?'){
            keta=-1;
        }else{
            keta=S[S.size()-i-1]-'0';
        }
        REP(j,10){
            if(keta!=-1&&keta!=j){
                continue;
            }else{
                sum_keta=pow*j;
                REP(k,13){
                    dp[i+1][(k+sum_keta)%13]+=dp[i][k];
                    dp[i+1][(k+sum_keta)%13]%=MOD;
                }
            }
        }
        pow*=10;
        pow%=13;
    }
    print(dp[S.size()][5]);
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

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

    ll n;
    cin >> n;
    string s;
    cin >> s;
    map<char, ll> mp;

    for (auto c : s) mp[c]++;
    ll ans = 1;
    for (char c = 'a'; c <= 'z'; ++c) ans = ans * (mp[c] + 1) % MOD;
    ans--;
    cout << ans << endl;
    return 0;
}

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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    ll n, w; cin>>n>>w;
    ll wei1;
    vector<int> val1, val2, val3, val4;
    for(int i=0; i<n; i++){
        int wei, val; cin>>wei>>val;
        if(i == 0){
            wei1=wei;
            val1.push_back(val);
            continue;
        }

        if(wei == wei1) val1.push_back(val);
        else if(wei == wei1 + 1) val2.push_back(val);
        else if(wei == wei1 + 2) val3.push_back(val);
        else val4.push_back(val);
    }

    ll wei1_size=val1.size(), wei2_size=val2.size(), wei3_size=val3.size(), wei4_size=val4.size();
    sort(val1.begin(), val1.end(), greater<int>());
    sort(val2.begin(), val2.end(), greater<int>());
    sort(val3.begin(), val3.end(), greater<int>());
    sort(val4.begin(), val4.end(), greater<int>());

    vector<int> val1_sum(wei1_size+10, 0), val2_sum(wei2_size+10, 0), val3_sum(wei3_size+10, 0), val4_sum(wei4_size+10, 0);
    for(int i=1; i<=wei1_size; i++){
        if(i == 1) val1_sum[i] = val1[i-1];
        else val1_sum[i] = val1_sum[i-1] + val1[i-1];
    }
    for(int i=1; i<=wei2_size; i++){
        if(i == 1) val2_sum[i] = val2[i-1];
        else val2_sum[i] = val2_sum[i-1] + val2[i-1];
    }
    for(int i=1; i<=wei3_size; i++){
        if(i == 1) val3_sum[i] = val3[i-1];
        else val3_sum[i] = val3_sum[i-1] + val3[i-1];
    }
    for(int i=1; i<=wei4_size; i++){
        if(i == 1) val4_sum[i] = val4[i-1];
        else val4_sum[i] = val4_sum[i-1] + val4[i-1];
    }

    int ans=0;
    for(ll i=0; i<=wei1_size; i++){
        for(ll j=0; j<=wei2_size; j++){
            for(ll k=0; k<=wei3_size; k++){
                for(ll l=0; l<=wei4_size; l++){
                    if((wei1)*i + (wei1+1LL)*j + (wei1+2LL)*k + (wei1+3LL)*l <= w){
                        ans = max(ans, val1_sum[i]+val2_sum[j]+val3_sum[k]+val4_sum[l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n + 1); rep (i, n + 1) cin >> a[i];
    vector<ll> s(n + 1); s[n] = a[n];
    reprev (i, n) s[i] = s[i + 1] + a[i];
    rep (i, n + 1) 
        eprintf("%lld%c", s[i], " \n"[i == n]);
    ll now = 1, ans = 0;
    rep (i, n + 1) {
        now = (i > 0 ? min(s[i], now * 2) : 1) - a[i];
        if (now < 0) {
            cout << -1 << "\n"; return 0;
        }
        eprintf("%lld%c", now, " \n"[i == n]);
        ans += now + a[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4780
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
#include<stack>
#include<queue>
using namespace std;
#define pb push_back
#define ff(i,a,b) for(int i=a;i<b;++i)
#define ffl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int md = 1000000007;
#define pi 3.141592653589793238462643383279


int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
 	int tt{},T{};
 	//cin>>tt;T=tt;
    tt=1;
 	while(tt--){
        //cout<<"------------- #"<<T-tt<<endl;
        ll n{},m{},ans{},k{},a{},b{},c{},f{};
        
        cin>>n;k=2;
        cin>>k;
        vecl v(n);
        ffl(i,0,n)cin>>v[i];
        ll dp[n+1];
        ffl(i,1,n)dp[i]=md;
        dp[0]=0;
        ffl(i,0,n){
            ffl(j,i+1,i+k+1){
                if(j<n)
                    dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
            }
        }
        cout<<dp[n-1]<<"\n";;
        
    }
    
    
	return 0;
}

Measured memory_bytes: 4776
#include"bits/stdc++.h"

typedef long long ll;

using namespace std;

#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

int main(){
	int N;

	cin >> N;

	vector<int> d(N);

	int l, i = 0;
	while (cin >> l) {
        d[i] = l;
        i++;
        if (i >= N) {
            break;
        }
    }

	// rep(i,N) cin >> d[i];

	// cout << d[1] << endl;


	ll totoal_sum = 0;

	rep(i,N){
		for(int j = i+1; j < N; j++){
			totoal_sum += d[i]*d[j];
		}
	}

	cout << totoal_sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
int main(){
	boost;
		
	vector<ll>v;
	ll n;
	cin>>n;
	rep(i,1,3*n){
		ll x;
		cin>>x;
		v.pb(x);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ll sum=0;
	for(int i=1,cnt=1;cnt<=n;cnt++,i+=2)sum+=v[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5488
#include<bits/stdc++.h>
int main(){
    int h,w,k;std::cin>>h>>w>>k;
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            if(i*j+(h-i)*(w-j)==k){
                std::cout<<"Yes"<<'\n';
                return 0;
            }
        }
    }
    std::cout<<"No"<<'\n';
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    lli n;
    cin>>n;
    std::vector<lli> v;
    rep(i,0,n)
    {
        lli a;
        cin>>a;
        v.pb(a);
    }
    lli ans = 0;
    rep(i,0,n)
    {
        for(lli j = i+1;j<n;j++)
        {
            for(lli k = j+1;k<n;k++)
            {
                lli x = v[i];
                lli y = v[j];
                lli z = v[k];
                if((x != y)&&(x != z)&&(y != z))
                {
                    if((x + y > z)&&(x + z > y)&&(y + z > x))
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = 0;
        int b = 0;
        while (true) {
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 0 && b == 0) {
                break;
            }
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < b; j++) {
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }

    }
}



Measured memory_bytes: 37856
pi = 3.1415926

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
s = input().strip()
if s == 'ABC':
    print('ARC')
else:
    print('ABC')
#print('No')
#print()



Measured memory_bytes: 61708
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	vector<int> r(N, -1);
	vector<vector<int>> t(N);
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (r[a] < 0 && r[b] < 0) {
			r[a] = a;
			r[b] = a;
			t[a].push_back(a);
			t[a].push_back(b);
		}
		else if (r[a] < 0) {
			r[a] = r[b];
			t[r[b]].push_back(a);
		}
		else if (r[b] < 0) {
			r[b] = r[a];
			t[r[a]].push_back(b);
		}
		else if (r[a] != r[b]) {
			if (t[r[a]] > t[r[b]]) {
				swap(a, b);
			}
			int tmp = r[a];
			for (auto x : t[tmp]) {
				r[x] = r[b];
				t[r[b]].push_back(x);
			}
			t[tmp].clear();
		}
	}

	int ans = 1;
	for (auto x : t) {
		ans = max((int)x.size(), ans);
	}

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


Measured memory_bytes: 15172
ls = ['dream', 'dreamer', 'erase', 'eraser']
ls = [word[::-1] for word in ls]
s = input().rstrip()[::-1]

can = 1
i = 0
while i < len(s):
    div = 0
    for word in ls:
        if s[i:i+len(word)] == word:
            div = 1
            i += len(word)
            break
    if div == 0:
        can = 0
        break

print('YES' if can else 'NO')

Measured memory_bytes: 3188
i=59,c=100,f[99],m,x,s;main(y){for(;s?++f[y*12+x+";<=0H/1GI:>T$"[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++i<178?i%12<10?m=fmax(m,f[i]),f[i]?c--:1:1:!printf("%d\n%d\n",c,m););}

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

using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    int n = S.length();
    for (int i = 0; i < n; ++i) {
        if (S[i] == '?') {
            cout << 'D';
            /*if (i < n - 1 && S[i + 1] == 'D')
                cout << 'P';
            else
                cout << 'D';*/
        } else {
            cout << S[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3680
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e,H, W;
long long A[200000]= {};
long long B[2][100000] = {};
long long C[20][200] = {};
bool f, ff;
string S[200];
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[100005];
vector <string> vs;
set<ll> llset;

struct ST
{
	long long hajime;
	long long owari;
	long long zahyou;
	int bangou;

	bool operator<(const ST& another) const
	{
		return hajime < another.hajime;//年齢を比較
	};

};



vector <ST> vst;
ST st[200005];



int main() {

	cin >> S[0];
	a = 0;

	for (int i = 0; i < S[0].size(); i++) {
		if (S[0][i] == 'x')a++;
	}

	if (a >= 8) {
		cout << "NO"<<endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;

}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=2e5+9;
int n,a[MX],ans,x;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        a[x]++;
    }
    for(int i=1;i<MX-1;i++){
        ans=max(ans,a[i]+a[i-1]+a[i+1]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
long min(long a,long b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}
  
int main(){
  long n = 0;
  long h[100000] = {};
  long dp[100000] = {};
  long i = 0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&h[i]);
  }
  dp[0] = 0;
  dp[1] = labs(h[1] - h[0]);
  for(i=2;i<n;i++){
    dp[i] = min(dp[i-2]+labs(h[i-2]-h[i]),dp[i-1]+labs(h[i-1]-h[i]));
  }
  printf("%ld",dp[n-1]);
  return 0;
}
    

Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct pt { int x, y; } ;

const double pi = acos(-1);
const double arc = 2 * 10 * pi / 4;

int LIS(vint v) {
  const int inf = 1 << 30;
  int n = v.size();
  vint result(n, inf);
  REP(i, v.size()) {
    int p = lower_bound(ALL(result), v[i]) - result.begin();
    result[p] = v[i];
  }
  REP(i, n) if (result[i] == inf) return i;
  return n;
}

double solve(pt src, pt dst, vector<pt>& v) {
  if (src.x > dst.x) {
    REP(i,v.size()) v[i].x *= -1;
    src.x *= -1;
    dst.x *= -1;
  }  
  if (src.y > dst.y) {
    REP(i,v.size()) v[i].y *= -1;
    src.y *= -1;
    dst.y *= -1;
  }

  vector<pt> u;
  REP(i,v.size()) if (src.x <= v[i].x && v[i].x <= dst.x && src.y <= v[i].y && v[i].y <= dst.y)
    u.push_back(v[i]);

  sort(ALL(u), [](const pt& a, const pt& b){ return a.x < b.x; });
  vint ys;
  REP(i,u.size()) ys.push_back(u[i].y);
  int lis = LIS(ys);
  // pp(ys);
  // cout << "lis " << lis << endl;
  if (lis == min(dst.x - src.x, dst.y - src.y) + 1) {
    return ((dst.x - src.x) + (dst.y - src.y)) * 100LL
      - 20 * (lis - 1) + arc * (lis - 1)
      - 20 + 2 * arc;
  }
  return ((dst.x - src.x) + (dst.y - src.y)) * 100LL - 20 * lis + arc * lis;
}

double simple(pt src, pt dst, vector<pt>& v) {
  // src.x == dst.x
  int sy = min(src.y, dst.y);
  int dy = max(src.y, dst.y);
  bool straight = true;
  REP(i, v.size()) if (v[i].x == src.x && sy < v[i].y && v[i].y < dy)
    straight = false;
  if (straight) return (dy - sy) * 100LL;
  else return (dy - sy) * 100LL - 20 + arc * 2;
}

int main(){
  pt src, dst;
  int n;
  while (cin >> src.x >> src.y >> dst.x >> dst.y >> n) {
    vector<pt> v(n);
    REP(i,n) cin >> v[i].x >> v[i].y;
    double result = 0;
    if (src.x == dst.x) {
      result = simple(src, dst, v);
    } else if (src.y == dst.y) {
      REP(i, v.size()) swap(v[i].x, v[i].y);
      swap(src.x, src.y);
      swap(dst.x, dst.y);
      result = simple(src, dst, v);
    } else {
      result = solve(src, dst, v);
    }

    printf("%.12lf\n", result);
  }
}


Measured memory_bytes: 6000
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        
        if(N.equals("RRR")){
            System.out.println("3");
        }else if(N.equals("SRR")||N.equals("RRS")){
            System.out.println("2");
        }else if(N.equals("RSS")||N.equals("SRS")||N.equals("SSR")||N.equals("RSR")){
            System.out.println("1");
        }else{
            System.out.println("0");
        }
        
        
    }
}


Measured memory_bytes: 35736
#include<iostream>                    
using namespace std;
int main(){
 
  int n,a[10000],i,s(1000000),b(-1000000);
  long long w=0;
  cin>>n;
  for(int i=0;i<n; i++)
  {
         cin>>a[i];
 
           w+=a[i];
		   
         if(s>a[i])
         {
	       s=a[i];
         }
        if(b<a[i])
         {      

	         b=a[i];

		}
  
  }
  cout<<s<<" "<<b<<" "<<w<<endl;


  return 0;
  }  



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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << ' '<< a << ' '<< b << endl;
}

Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int INF=mod;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<int, int>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,k,n) for(int i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)


//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////



int main(){

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


  cout << "Yes" << endl;
}

Measured memory_bytes: 3596
s = str(input())
count = 0
if s[0] == "A":
    count += 1
if s[2:-1].count("C") == 1:
    count += 1
s = s.replace("A","").replace("C", "")
if s.islower():
    count += 1
if count == 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
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 SORT(c) sort(ALL(x))
#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 double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

signed main(){
  int n,p; cin>>n>>p;
  // int a=0, b=0;
  // ll ans;
  // rep(i,n){
  //   int x; cin>>x;
  //   if(x%2) a++; else b++;
  // }
  // ans = pow(2,b);
  VI a; bool check = true;
  ll ans;
  rep(i,n){
    int x; cin>>x; a.PB(x);
    if(x%2) check = false;
  }
  if(check){
    if(p) ans = 0;
    else ans = pow(2,n);
  }else{
    ans = pow(2,n-1);
  }
  cout << ans << endl;
  return 0;
}


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

const int Maxn = 3005;
const int mod = 998244353;

int n, s;
int a[Maxn];
int dp[Maxn];

int main()
{
    scanf("%d %d", &n, &s);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        for (int j = s; j >= 0; j--) if (dp[j]) {
            if (j + a <= s)
                dp[j + a] = (dp[j + a] + dp[j]) % mod;
            dp[j] = 2ll * dp[j] % mod;
        }
    }
    printf("%d\n", dp[s]);
    return 0;
}


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

int MAX_N=262144;
vector<int64_t> seg(MAX_N*2-1);
int64_t qu(int a,int b,int k,int l, int r){
  if(r<=a||b<=l){
    return -1;
  }
  else if(a<=l&&r<=b){
    return seg[k];
  }
  else{
    int64_t X=qu(a,b,k*2+1,l,(l+r)/2);
    int64_t Y=qu(a,b,k*2+2,(l+r)/2,r);
    return max(X,Y);
  }
}
void chmax(int64_t a,int b){
  int D=MAX_N-1+b;
  seg[D]=a;
  while(D>0){
    D--;
    D/=2;
    seg[D]=max(seg[2*D+1],seg[2*D+2]);
  }
}


int main() {
  int N,l,r;
  cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    chmax(a,i);
    p[a-1]=i;
  }
  int64_t Z=0;
  for(int i=N-1;i>0;i--){
    int a=p[i-1];
    int64_t A=N-a,B=N-a,C=a+1,D=a+1;
    if(qu(a,N,0,0,MAX_N)>i){
      l=a+1,r=N;
      while(r-l>1){
        int X=(l+r)/2;
        if(qu(a,X,0,0,MAX_N)>i){
          r=X;
        }
        else{
          l=X;
        }
      }
      A=r-a-1;
      if(qu(A+1+a,N,0,0,MAX_N)>i){
        l=A+1+a,r=N;
        while(r-l>1){
          int X=(l+r)/2;
        if(qu(A+1+a,X,0,0,MAX_N)>i){
          r=X;
        }
        else{
          l=X;
        }
        }
        B=r-a-1;
      }
    }
    if(qu(0,a,0,0,MAX_N)>i){
      l=0,r=a;
      while(r-l>1){
        int X=(l+r)/2;
        if(qu(X,a,0,0,MAX_N)>i){
          l=X;
        }
        else{
          r=X;
        }
      }
      C=a-r+1;
      if(qu(0,l,0,0,MAX_N)>i){
        r=l,l=0;
        while(r-l>1){
          int X=(l+r)/2;
          if(qu(X,a-C,0,0,MAX_N)>i){
            l=X;
          }
          else{
            r=X;
          }
        }
        D=a-l;
      }
    }
    int64_t Q=A*(D-C)+(B-A)*C;
    Q*=i;
    Z+=Q;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 7728
#include <iostream>

using namespace std;

int coin[] = {289, 256, 225, 196, 169, 144, 121, 100, 81, 64, 49, 36, 25, 16, 9, 4, 1};
   
int solve(int pay, int n) {
    if (n == 16) return 1;
    if (pay < 4) return 1;
    
    int sum = 0;
    int no_can_use = pay / coin[n];
    if (no_can_use == 0) return solve(pay, n+1);
    for (int i = 0; i <= no_can_use; i++) {
        sum += solve(pay - coin[n] * i, n+1);
    }

    return sum;
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << solve(n, 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int sum[200010];
map<int, int> mp;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) sum[i + 1] += sum[i] + A[i];
    rep(i, N + 1) mp[sum[i]]++;
    int ans = 0;
    rep(i, N + 1) {
        ans += --mp[sum[i]];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int n, s[200] = {}, result = 0,lamp=1,in,ax,h,w;
	string str[106];
	cin >> h>>w;
	for (int i = 1; i <= h; i++) {
		cin >> str[i];
	}
	for (int i = 0; i <= w+1; i++) {
		cout << "#";
	}
	cout << endl;
	for (int i = 1; i <= h; i++) {
		cout << "#" << str[i] << "#" << endl;
	}
	
	for (int i = 0; i <= w + 1; i++) {
		cout << "#";
	}
}

Measured memory_bytes: 256
n = int(input())
l = [list(map(int, input().split())) for _ in range(n-1)]


for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        c = l[j][0]
        s = l[j][1]
        f = l[j][2]
        if t < s:
            t = s
        if t%f != 0:
            t = t+f - t%f
        t += c
    print(t)
print(0)

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

using i64 = int64_t;

struct Item{
    i64 w, v;
};

i64 dp[102][100005]={0};

int main(){
    i64 n, w;
    cin >> n >> w;
    vector<Item> items;
    items.push_back((Item){0, 0});
    for(int i=0;i<n;++i){
        i64 weight, value;
        cin >> weight >> value;
        items.push_back((Item){weight, value});
    }
    for(int i=0;i<=n;++i){
        for(int j=1;j<=100000;++j)dp[i][j] = LLONG_MAX;
    }

    for(int i=0;i<n;++i){
        for(i64 j=0;j<100000;++j){
            if(dp[i][j] == LLONG_MAX)continue;
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(dp[i][j]+items[i+1].w <= w){
                i64 v = j + items[i+1].v;
                dp[i+1][v] = min(dp[i+1][v], dp[i][j]+items[i+1].w);
            }
        }
    }

    i64 ans = 0;
    for(i64 i=0;i<=100000;++i){
        if(dp[n][i] != LLONG_MAX)ans = i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 79104