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

int main(){
  int A,B,C;
  cin >>A;
  
  string s="No";
  if (A/100==7) s="Yes";
  if ((A%100)/10==7) s="Yes";
  if ((A%10)==7) s="Yes";
  cout << s <<endl;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

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

void solve()
{
    int n;
    cin>>n;
    //ll cnt=0;
    vl ans(n+1,0);
    for(int i=1;i<=100;i++) {
        for(int j=1;j<=100;j++) {
            for(int k=1;k<=100;k++) {
                int x = i * i + j * j + k * k + i * j + i * k + j * k;
                if (x <= n) {
                    ans[x]++;   
                }
            }
        }
    }
    for(int i=1;i<n+1;i++) {
        cout<<ans[i]<<newl;
    }
}

int main()
{
    fastio;
    int t;
    t = 1;
    //cin >> t;
    //int test=t;
    
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

long long int f(int n){
	if(n==1) return 1;
	return n*f(n-1);
}

int main(){
	int n;
	while(cin>>n){
		cout<<f(n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	string s;
	while (cin >> s, s != "#"){
		stack<bool> sb;
		while (s.length()){
			if (s[0] == 'n'){
				s.erase(0, 5);
				sb.push(false);
			}
			else if (s[0] =='w' ){
				s.erase(0, 4);
				sb.push(true);
			}
		}
		int d = (int)pow(2,sb.size()-2);
		int a = 0;
		int c = -100;
		if (sb.size() > 2){
			while (!sb.empty()){
				bool b = sb.top();
				a *= 2;
				if (b){
					a += 45;	
				}
				else{
					a -= 45;
					if (a < 0)a = 0;
				}
				
				sb.pop();
			}
			cout << a << "/" << d << endl;
		}
		else if(sb.size()==2){
			cout << 45 << endl;
		}
else{
			if (sb.top())a = 90;
			if (!sb.top())a = 0;
			cout << a << endl;
		}
		
		
	}
}

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

int Rank[1000005];
int Tmp[1000005];
int kc,len;

bool compare_sa(int i,int j){
  return
    Rank[i]!=Rank[j]?
    Rank[i]<Rank[j]:
    (i+kc<=len?Rank[i+kc]:-1)<(j+kc<=len?Rank[j+kc]:-1);
}

void construct_sa(char* S,int *sa){
  len=strlen(S);
  for(int i=0;i<=len;i++){
    sa[i]=i;
    Rank[i]=i<len?S[i]:-1;
  }
  for(kc=1;kc<=len;kc*=2){
    sort(sa,sa+len+1,compare_sa);
    Tmp[sa[0]]=0;
    for(int i=1;i<=len;i++){
      Tmp[sa[i]]=Tmp[sa[i-1]]+compare_sa(sa[i-1],sa[i]);
    }
    for(int i=0;i<=len;i++)Rank[i]=Tmp[i];
  }
}


int n,m;
char str[1000005];
char t[1000005];
int sa[1000005];

int main(){
  scanf("%s",str);
  n=strlen(str);
  construct_sa(str,sa);
  scanf("%d",&m);
  while(m--){
    scanf("%s",t);
    int k=strlen(t);
    int l=0,r=n+1,m;
    while(l+1<r){
      m=(l+r)/2;
      if(strncmp(str+sa[m],t,k)<=0)l=m;
      else r=m;
    }
    printf("%d\n",(strncmp(str+sa[l],t,k)==0));
  }
  return 0;
}



Measured memory_bytes: 15968
#include <iostream>
using namespace std;
const int mod=1e9+7;
int main() {
  int n;cin >> n;
  long long temp = 1;
  for(int  i = 1; i <= n;i++){
    temp = (temp * i) %mod;
  }
  cout << temp << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.Array

main = do
  s <- getLine
  let ans = compute s
  print ans

{-
sを両側から突き合わせる。
両方同じ文字なら、消費する。
両方違う非x文字なら、失敗する。
片方がxでもう片方が違うなら、x入れたことにして消費する。
同じ文字にたどり着くか行きすぎたら成功。
-}

compute :: String -> Int
compute s = loop 0 1 n
  where
    n = length s
    arr = listArray (1,n) s
    loop cnt i j
      | i >= j = cnt
      | c == d = loop cnt (succ i) (pred j)
      | c == 'x' = loop (succ cnt) (succ i) j
      | d == 'x' = loop (succ cnt) i (pred j)
      | True   = -1
      where
        c = arr ! i
        d = arr ! j

Measured memory_bytes: 9212
#include "bits/stdc++.h"
using namespace std;

#define MAX 100002

int n;
int m;

vector<int> v;

struct st {
	int l;
	int r;
	int id;
};

vector<st> query;

vector<int> ev[MAX];
vector<int> en[MAX];

vector<pair<int, int> > vv;

int calc(int i, int x) {
	if (x != -1) {
		if (vv[i].first <= vv[i].second) {
			if (vv[i].first <= x&&x <= vv[i].second) {
				return vv[i].second - x;
			}
		}
		else {
			if (vv[i].first <= x || x <= vv[i].second) {
				return (vv[i].second + m - x)%m;
			}
		}
	}
	return (vv[i].second + m - vv[i].first) % m;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		a--;
		v.push_back(a);
	}
	for (int i = 0; i+1 < v.size(); i++) {
		int a = v[i];
		int b = v[i + 1];
		if (a <= b) {
			query.push_back({ a,b,i });
		}
		else {
			query.push_back({ a,m - 1,i });
			query.push_back({ 0, b, i });
		}
		vv.push_back(make_pair(a, b));
	}
	for (int i = 0; i < query.size(); i++) {
		int I = query[i].id;
		if (vv[I].first == vv[I].second)continue;
		if (vv[I].first > vv[I].second) {
			if (query[i].l) {
				ev[query[i].l].push_back(query[i].id);
			}
			en[query[i].r].push_back(query[i].id);
			continue;
		}
		ev[query[i].l].push_back(query[i].id);
		en[query[i].r].push_back(query[i].id);
	}
	long long int sum = 0;
	long long int mv = 0;
	for (int i = 0; i < vv.size(); i++) {
		if (vv[i].first > vv[i].second) {
			sum += calc(i, 0)+1;
			mv++;
		}
		else {
			sum += calc(i, -1);
		}
	}
	long long int ans = sum;
	for (int i = 0; i < m; i++) {
		sum -= mv;
		ans = min(ans, sum + mv);
		for (int j = 0; j < ev[i].size(); j++) {
			sum -= calc(ev[i][j], -1);
			sum += calc(ev[i][j], i);
			mv++;
		}
		for (int j = 0; j < en[i].size(); j++) {
			sum -= calc(en[i][j], i);
			mv--;
			sum += calc(en[i][j], -1);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

void chmax(string &a, string b) {
  if(a.size() == b.size()) {
    if(a < b) a = b;
  } else if(a.size() < b.size()) a = b;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i, 0, M) cin >> A[i];
  int cost[9] = {2,5,5,4,5,6,3,7,6};
  vector<string> dp(N + 10, "0");
  dp[0] = "";
  rep(i, 0, N) {
    if(dp[i] == "0") continue;
    rep(j, 0, M) chmax(dp[i+cost[A[j]-1]], dp[i] + to_string(A[j]));
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 33024
n, k = map(int, input().split())
a = list(map(int, input(). split()))

res = 1 << 60
for i in range(1<<n):
    if(i%2 == 0): continue
    
    use_idx = [0 for _ in range(n)]
    use_cnt = 0
    for j in range(n):
        if(i & (1<<j)):
            use_idx[j] = 1
            use_cnt += 1
    
    if(use_cnt != k): continue
    
    sm = 0
    mx = a[0]
    for j in range(1, n):
        
        if(use_idx[j]):
            if(a[j] <= mx):
                sm += mx+1 - a[j]
                mx += 1
        
        mx = max(mx, a[j])
    
    res = min(res, sm)

print(res)

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

#define int long long

using namespace std;

int a[100001];
int sm[100001];
int nxt[100001];
int ans;
map <int ,int> ok, first, second, del;
vector <int> pr, primes;

bool check (int x) {
	for (int i = 2;i * i <= x;i ++) {
		if (x % i == 0) return 0;
	}
	return 1;
}

 main () {
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		nxt[i] = 1;
	}
	for (int i = 2;i * i * i <= 10000000000;i ++) {
		int x = i;     
		if (check (x)) pr.push_back (x * x * x);
		if (check (x)) primes.push_back (x);
	}
	for (int i = 2;i * i <= 10000000000;i ++) {
		int x = i;
		if (check (x)) ok[x * x] = 1;
	}
	for (int i = 1;i <= n;i ++) {
		int x = a[i];
		for (int j = 0;j < pr.size ();j ++) {
			while (x % pr[j] == 0) {
				x /= pr[j];
			}
		}
		sm[i] = x;
	}
	for (int i = 1;i <= n;i ++) {
		int x = a[i];
		for (int j = 0;j < primes.size ();j ++) {
			int cnt = 0;
			while (x % primes[j] == 0) {
				cnt ++;
				x /= primes[j];
			}
			cnt %= 3;
			if (cnt > 0) cnt = 3 - cnt;
			while (cnt) {
				cnt --;
				nxt[i] *= primes[j];
			}
		}
//		cout << x << ' ';               
		if (ok[x]) {
			nxt[i] *= sqrt (x);
		}
		else nxt[i] *= x * x;
	}
//	cout << endl;
	for (int i = 1;i <= n;i ++) {    
	//	cout << sm[i] << ' ' << nxt[i] << endl;
		if (sm[i] == 1 && ans == 0) ans ++;
		first[sm[i]] ++;                             
		second[nxt[i]] ++;
	}
	for (int i = 1;i <= n;i ++) {
		if (del[sm[i]] || sm[i] == 1) continue;
		del[sm[i]] = 1;
		del[nxt[i]] = 1;
		ans += max (first[sm[i]], second[sm[i]]);
	}
	cout << ans;
	return 0;                   
}

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

int main() {
  int N, t, sum = 0;
  string X, s;
  map<string, int> M;
  cin >> N;
  while (N-- && cin >> s >> t) sum += t, M[s] = sum;
  cin >> X;

  cout << sum - M[X];
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int N,M;
	cin>>N>>M;
	vector<P> a(N),c(M);
	rep(i,N){
		int x,y;
		cin>>x>>y;
		a[i]=P(x,y);
	}
	rep(i,M){
		int x,y;
		cin>>x>>y;
		c[i]=P(x,y);
	}
	rep(i,N){
		int dis=1<<29,ans;
		rep(j,M){
			int tmp=llabs(a[i].first-c[j].first)+llabs(a[i].second-c[j].second);
			if(dis>tmp){
				dis=tmp;
				ans=j+1;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split("\\s+");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split("\\s+");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}

//......................................@uthor_Alx..............................................
static long mod=(long)1e9+7;

public static void main(String[] args) throws  IOException{
                assign();
               int n=int_v(read());
               long[] a=long_arr();
               long[] b=a.clone();
               for(int i=n-2;i>=0;i--){
                    a[i]+=a[i+1];
                    a[i]%=mod;
               }
               long res=0;
               for(int i=0;i<n-1;i++){
                    res+=Modmul(b[i],a[i+1],mod);
                    res%=mod;
               }
                out.write((res%mod)+"");
                out.flush();

    }
}

Measured memory_bytes: 65228
N, K = map(int, input().split())
S = [1 if s == 'L' else 0 for s in input().strip()] + [-1]

pre = None
ans = 0
cnt = -2
for s in S:
    if s == pre:
        ans += 1
    else:
        cnt += 1
    pre = s

print(ans + min(N-ans-1, 2*min(K, cnt)))

Measured memory_bytes: 47088
#include<iostream>
#include<algorithm>
using namespace std;
int map[101][101];
int main(){
	int n,a;
	cin>>n;
	for(int i=0;i<=n;i++)map[i][0]=0;
	for(int j=0;j<=n;j++)map[0][j]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a;
			map[i][j]=map[i-1][j]+map[i][j-1]-map[i-1][j-1]+a;
		}
	}
	int ans=-1000000000;
	for(int i=0;i<n;i++){
		for(int is=i+1;is<=n;is++){
			for(int j=0;j<n;j++){
				for(int js=j+1;js<=n;js++){
					ans=max(ans,map[is][js]-map[is][j]-map[i][js]+map[i][j]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1200
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        s: chars,
    }
    // 最大の回数を出力する
    // bとwを交換してずらしていくと考えると, 最終的にwとbがそれぞれ並ぶことになる
    // wの個数分, bの個数分
    // bをずらす(wをずらす)回数は,（原点からのwiの距離) = (wiより手前にあるwの個数)
    // をwの個数分足すことでわかる
    // wの個数をカウントする変数とインデックスで計算すればいい

    let mut count = 0;
    let mut ans = 0;
    for i in 0..s.len() {
        if s[i as usize] == 'W' {
            ans += i - count;
            count += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])
 
def bfs(n,g):
    dis = [-1 for _ in range(n)]
    que = deque([])
    que.append(0)
    dis[0] = 0
    ODD = []
    EVEN = [0]
    while que:
        go = que.pop()
        for i in range(len(g[go])):
            if dis[g[go][i]] != -1:
                continue
            dis[g[go][i]] = dis[go] + 1
            if dis[g[go][i]]%2 == 0:
                EVEN.append(g[go][i])
            else:
                ODD.append(g[go][i])
            que.append(g[go][i])
    return EVEN,ODD
 
def main():
    n = inp()
    g = [[] for _ in range(n)]
    for _ in range(n-1):
        a,b = inpm()
        g[a-1].append(b-1)
        g[b-1].append(a-1)
    EVEN,ODD = bfs(n,g)
    ans = [0 for _ in range(n)]
    check = [1 for _ in range(n)]
    mod0 = deque()
    mod1 = deque()
    mod2 = deque()
    for i in range(1,n+1):
        if i%3 == 0:
            mod0.append(i)
        if i%3 == 1:
            mod1.append(i)
        if i%3 == 2:
            mod2.append(i)
    if len(ODD) <= n//3:
        x = 1
        while ODD:
            index = ODD.pop()
            ans[index] = 3*x
            check[3*x-1] = 0
            x += 1
        i = 0
        while EVEN:
            index = EVEN.pop()
            while not check[i]:
                i += 1
            ans[index] = i+1
            i += 1
        print(*ans)
        return
    if len(EVEN) <= n//3:
        x = 1
        while EVEN:
            index = EVEN.pop()
            ans[index] = 3*x
            check[3*x-1] = 0
            x += 1
        i = 0
        while ODD:
            index = ODD.pop()
            while not check[i]:
                i += 1
            ans[index] = i+1
            i += 1
        print(*ans)
        return
    if len(ODD) <= len(EVEN):
        while mod1:
            index = EVEN.pop()
            ans[index] = mod1.pop()
        while mod2:
            index = ODD.pop()
            ans[index] = mod2.pop()
    else:
        while mod1:
            index = ODD.pop()
            ans[index] = mod1.pop()
        while mod2:
            index = EVEN.pop()
            ans[index] = mod2.pop()
    while mod0:
        if EVEN:
            index = EVEN.pop()
        else:
            index = ODD.pop()
        ans[index] = mod0.pop()
    print(*ans)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 108184
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		String A = scan.next();
		String B = scan.next();
		String C = scan.next();

		char[] x = B.toCharArray();

		System.out.println("A" + x[0] + "C");
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

int main() {
    int n,k;
    cin >> n >> k;
    long long ans = k;
    if(n > 2) {
        for(int i = 2; i <= n; i++) {
            ans *= (k-1);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	map <int, int> m;
	int n, a;

	cin >> n;

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

	int count = 0;
	for (auto it : m)
	{
		if (it.second == 1)
		{
			count += 1;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	list<int> lst;
	REP(i,n){
		int a;
		cin >> a;
		if(i%2==0)
			lst.push_back(a);
		else
			lst.push_front(a);
	}
	if(n%2==0)
	REP(i,n-1){
		cout << lst.front() << " ";
		lst.pop_front();
	}
	else
		REP(i,n-1){
		cout << lst.back() << " ";
		lst.pop_back();
	}
	cout << lst.front() << "\n";
	return 0;
}	

Measured memory_bytes: 8448
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int N = scan.nextInt();

        ArrayList<Integer> result = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            result.add(0);
        }
        for (int i = 0; i < N - 1; i++) {
            int tmp = scan.nextInt();
            result.set(tmp - 1, result.get(tmp - 1) + 1);
        }

        for (Integer r : result) {
            System.out.println(r);
        }

    }
}


Measured memory_bytes: 60828
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, w[100];

int main() {
	cin >> n;
	inc(i, n) { cin >> w[i]; }
	
	int ans = 1e5;
	inc(i, n - 1) {
		int s[2] = { 0, 0 };
		inc(j, n) { s[(j <= i ? 0 : 1)] += w[j]; }
		setmin(ans, abs(s[0] - s[1]));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

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

  vector<string> name(n);
  vector<int> time(n);
  for(int i=0;i<n;i++) {
    cin >> name[i] >> time[i];
  }

  queue<int> que;
  for(int i=0;i<n;i++) {
    que.push(i);
  }

  int totalTime = 0;
  while( !que.empty() ) {
    int id = que.front(); que.pop();

    if(time[id] <= q) {
      totalTime += time[id];
      time[id] = 0;
      cout << name[id] << " " << totalTime << endl;
    } else {
      totalTime += q;
      time[id] -= q;
      que.push(id);
    }
  }

}

Measured memory_bytes: 6168
n = int(input())
a = list(map(int,input().split()))
cnt = 0
flag = 0
for i in range(n):
    if a[i]%2==0:
        cnt += 1
        if a[i]%3==0 or a[i]%5==0:
            flag += 1
else:
    if cnt == flag:
        print('APPROVED')
    else:
        print('DENIED')

Measured memory_bytes: 3064
# 解説を参考に作成


def solve():
    N, K, C = map(int, input().split())
    S = input()

    left = []
    rest = 0
    work = 0
    for i in range(N):
        if S[i] == 'o' and rest == 0:
            left.append(i)
            rest = C + 1
            work += 1
        if rest > 0:
            rest -= 1
        if work == K:
            break

    right = []
    rest = 0
    work = 0
    for i in reversed(range(N)):
        if S[i] == 'o' and rest == 0:
            right.append(i)
            rest = C + 1
            work += 1
        if rest > 0:
            rest -= 1
        if work == K:
            break
    right = list(reversed(right))

    # print(left)
    # print(right)
    for i in range(len(left)):
        if left[i] == right[i]:
            print(left[i] + 1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 26888
a, b, c = map(int, input().split())

count = 0
while all([a % 2 == 0, b % 2 == 0, c % 2 == 0]):
    if a == b and b == c:
        print(-1)
        exit()
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fast        ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein      freopen("input.txt","r",stdin)
#define fileout     freopen("output.txt","w",stdout)
#define ll          long long
#define pii         pair<int,int>
using namespace std;

const ll mod = 1000000007;

ll fact[2007], finv[2007], inv[2007];

void factorial()
{
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2005; i++)
    {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

long long ncr(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main()
{
    fast;
    factorial();

    int n,k;
    cin>>n>>k;

    ll ans = 0;


    for(int i=1; i<=k; i++)
    {
        ans = (ncr(n-k+1,i)*ncr(k-1,i-1))%mod;
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
iN = int(input())
iM = iN // 2
aV = [int(x) for x in input().split()]

aV0={}
aV1={}
for i in range(iN):
    iA = aV[i]
    if i % 2 == 0:
        if iA in aV0:
            aV0[iA] += 1
        else:
            aV0[iA] = 1
    else:
        if iA in aV1:
            aV1[iA] += 1
        else:
            aV1[iA] = 1
aV0[0]=0
aV1[0]=0

aV0dec = sorted(aV0,key=aV0.get,reverse=True)
aV1dec = sorted(aV1,key=aV1.get,reverse=True)

iMax1aV0 = aV0dec[0]
iMax1aV1 = aV1dec[0]

if iMax1aV0 != iMax1aV1:
    print(iN - aV0[iMax1aV0] - aV1[iMax1aV1])
else:
    iMax1aV0sum =aV0[iMax1aV0]
    iMax1aV1sum =aV0[iMax1aV1]
    #ilenaV0 = len(aV0dec)
    #ilenaV1 = len(aV0dec)
    #if iMax1aV0sum == iMax1aV1sum :
    #       print(iN - iMax1aV0sum - max(aV0[aV0dec[1]],aV1[aV1dec[1]]))
    #else:
    print(iN - max(iMax1aV0sum,iMax1aV1sum) - max(aV0[aV0dec[1]],aV1[aV1dec[1]]))


Measured memory_bytes: 17056
A, B, C, k = map(int, open(0).read().split())
for a in range(k + 1):
  for b in range(k + 1 - a):
    for c in range(k + 1 - a - b):
      if A * 2**a < B * 2**b < C * 2**c:
        print("Yes");exit()
print("No")

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

using namespace std;

typedef long long int ll;

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else{
    k = k - (a + b);
    cout << a - k << endl;
  }
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dfs(int bar_num);
class data{
public:
   int left,right,red,blue;
   data(){}
   data(int _left,int _right,int _red,int _blue){
      left = _left; right = _right; red = _red; blue = _blue;
   }
};

data bar[101];

int in(){int x; scanf("%d",&x); return x;}
int main(void){
   int n;
   while(scanf("%d",&n),n){
      int flag[101] = {0};
      REP(i,1,n+1){
         scanf("%d%d%d%d",&bar[i].left,&bar[i].right,&bar[i].red,&bar[i].blue);
         flag[bar[i].red] = 1; flag[bar[i].blue] = 1;

      }
      int start;
      REP(i,1,n+1){
         if(flag[i] == 0) start = i;
      }
      printf("%d\n",dfs(start));
   }
}

int dfs(int bar_num){
   if(bar_num == 0){
      return 1;
   }
   int red = dfs(bar[bar_num].red),blue = dfs(bar[bar_num].blue);
   int left = bar[bar_num].left,right = bar[bar_num].right;
   int lcm = (red*left)/__gcd(red*left,blue*right)*(blue*right);
   return lcm/left+lcm/right;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <cstdlib>
#include <cctype>

int main()
{
    char ch[1200];
    char alphabet;
    int number, counter[26];
    int int_alpha;

    for(int i = 0; i < 26; i++) counter[i] = 0;

    while(scanf("%s", ch) != EOF){
        for(int i = 0; ch[i] != '\0';i++){
            if(isupper(ch[i])) ch[i] = tolower(ch[i]);
            number = ch[i] - 'a';
            counter[number]++;
        }
    }

    for(int i = 0; i < 26; i++){
        int_alpha = 'a' + i;
        alphabet = static_cast<char>(int_alpha);
        printf("%c : %d\n", alphabet, counter[i]);
    }
    return 0;
}

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

bool isPrime(ll x) {
    ll i;
    if(x < 2)
        return 0;
    else if(x == 2)
        return 1;
    if(x % 2 == 0)
        return 0;
    for(i = 3; i * i <= x; i += 2)
        if(x % i == 0)
            return 0;
    return 1;
}

int main() {
    ll X;
    cin >> X;
    for(ll i = X; i < 100005; i++) {
        if(isPrime(i)) {
            cout << i << endl;
            exit(0);
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    string s;
    cin >> s;
    bool ok = true;
    if(s.length() != 3){
        ok = false;
    }
    rep(i,3){
        if(s[i] != 'A' && s[i] != 'B'){
            ok = false;
        }
    }
    if(s == "AAA" || s == "BBB"){
        ok = false;
    }
    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(){

int n; string s;
cin >> n >> s;
ll r=0, g=0, b=0;
rep(i,n){
    if (s[i]=='R') r++;
    else if (s[i]=='G') g++;
    else b++;
}
ll seki=r*g*b;

ll hiku=0;
//int i=0, j=0;

for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
        int k=2*j-i;
        if(k<n && s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]) hiku++;
    }
}

cout << seki-hiku << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int H,W,all,h,c;
int64 K;
char s[1005][1005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
struct Matrix {
    int f[2][2];
    Matrix() {memset(f,0,sizeof(f));}
    friend Matrix operator * (const Matrix &a,const Matrix &b) {
	Matrix c;
	for(int i = 0 ; i < 2 ; ++i) {
	    for(int j = 0 ; j < 2 ; ++j) {
		for(int k = 0 ; k < 2 ; ++k) {
		    update(c.f[i][j],mul(a.f[i][k],b.f[k][j])); 
		}
	    }
	}
	return c;
    }
}a,ans;
Matrix fpow(Matrix x,int64 c) {
    Matrix res,t = x;
    res.f[0][0] = res.f[1][1] = 1;
    while(c) {
	if(c & 1) res = res * t;
	t = t * t;
	c >>= 1;
    }
    return res;
}
int fpow(int x,int64 c) {
    int64 res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void Solve() {
    read(H);read(W);read(K);
    if(K == 0 || K == 1) {puts("1");return;}
    for(int i = 1 ; i <= H ; ++i) scanf("%s",s[i] + 1);
    for(int i = 1 ; i <= H ; ++i) {
	for(int j = 1 ; j <= W ; ++j) {
	    if(s[i][j] == '#') {
		++all;
		if(s[i][j + 1] == '#') ++h;
		if(s[i + 1][j] == '#') ++c;
	    }
	}
    }
    bool f1 = 0;int c1 = 0;
    for(int i = 1 ; i <= H ; ++i) {
	if(s[i][1] == '#' && s[i][W] == '#') {f1 = 1;++c1;}
    }
    bool f2 = 0;int c2 = 0;
    for(int i = 1 ; i <= W ; ++i) {
	if(s[1][i] == '#' && s[H][i] == '#') {f2 = 1;++c2;}
    }
    if(f1 && f2) {puts("1");return;}
    if(!f1 && !f2) {
	out(fpow(all,K - 1));enter;return;
    }
    if(f1) {
	a.f[1][0] = MOD - h;
	a.f[1][1] = c1;
    }
    else if(f2) {
	a.f[1][0] = MOD - c;
	a.f[1][1] = c2;
    }
    a.f[0][0] = all;
    ans = fpow(a,K - 1);
    out(inc(ans.f[0][0],ans.f[1][0]));enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

bool ok(vector<int> &ws, int k, int p)
{ 
  int sum = 0, cnt = 0;
  for (int i = 0; i < ws.size(); i++) {
    sum += ws[i];
    if (sum > p) {
      if (ws[i] > p) return false;
      sum = ws[i];
      cnt++;
    }
  }
  return (cnt+1 <= k) && (sum <= p);
}

int main()
{
  int n, k; cin >> n >> k;
  vector<int> ws = vector<int>(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> ws[i];
    sum += ws[i];
  }

  int lb = 0, rb = sum;
  while (lb+1 != rb) {
    int p = lb+(rb-lb)/2;
    // printf("(%d, %d) : %d\n", lb, rb, p);
    if (ok(ws, k, p))
      rb = p;
    else
      lb = p;
  }
  cout << rb << endl;

  return EXIT_SUCCESS;
}



Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        while (a > 0 && c>0){
            c-=b;
            if(c > 0){
                a-=d;
            }else{
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35796
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String[] s = str.split("");

		int max = 0;
		int count = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i].equals("A")) {
				for (int j = i; j < s.length; j++) {
					count++;
					if (s[j].equals("Z")) {
						max = Math.max(max, count);
					}
				}
				break;
			}
		}

		System.out.println(max);

	}
}


Measured memory_bytes: 52788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 10000000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<ll> A(N), B(N);
	ll res = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		B[i] = A[i];
	}
	map<ll, ll> m;
	SORT(B);
	rep(i, N) {
		m[B[i]] = i;
	}
	rep(i, N) {
		if (i%2 == 0 && abs(m[A[i]] - i)%2 == 1) res++;
	}
	
	cout << res << endl;
	
	return 0;
}



Measured memory_bytes: 8064
#include <stdio.h>
int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a%3==0 || b%3==0 || (a+b)%3==0)
  {
    printf("Possible\n");
  }
  else
  {
    printf("Impossible\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	int liACnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liACnt);

	// 配列 - 取得
	int liBCnt = 0;
	int liNow = 1;
	for (i = 0; i < liACnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);

		// 破壊するかチェック
		if (liNow == liVal) {
			liNow++;
		}
		else {
			liBCnt++;
		}
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 破壊数
	if (liBCnt == liACnt) {
		return -1;
	}

	return liBCnt;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
s = input()
b, c = 0, 0
if "N" in s and "S" in s:
  b = 1
elif "N" not in s and "S" not in s:
  b = 1
if "E" in s and "W" in s:
  c = 1
elif "E" not in s and "W" not in s:
  c = 1
if b and c:
  print("Yes")
else:
  print("No")

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

//macro
#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, n, m) for(int i = m; i < n; ++i)
#define LL long long

using namespace std;

typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;

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

    REP(i, s.size()){
        if(s[i] == ','){
            s[i] = ' ';
        }
    }

    cout << s << endl;
}

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

typedef long long ll;

const ll mod = 1e9+7;

ll dp[22][1<<22];
int c[22][22];

ll solve(int i,ll b, int n)
{
	if(dp[i][b]!=-1)
		return dp[i][b];
	
	if(i==n-1)
	{
		for(int j=0;j<n;j++)
		{
			if((((1<<j)&b)==0) && (c[i][j]==1))
			{
				dp[i][b] =1;
				return 1;
			}
		}
		return 0;
	}
	
	dp[i][b]=0;
	for(int j=0;j<n;j++)
	{	
		if((((1<<j)&b)==0) && (c[i][j]==1))
			dp[i][b]= (dp[i][b]%mod+solve(i+1, b|(1<<j),n)%mod)%mod;
	}
	return dp[i][b]%mod;
}

int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>c[i][j];
			
	memset(dp,-1,sizeof(dp));
	cout<<solve(0,0,n)%mod;
	return 0;
}

Measured memory_bytes: 721280
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> Ais(N);
	rep(i,0,N) {
		cin >> Ais[i];
	}
	vector<ll> sum(N+1);
	rep(n,1,N+1) {
		sum[n] = sum[n-1] + Ais[n-1];
	}
	vector<ll> pos_sum(N+1);
	rep(n,1,N+1) {
		pos_sum[n] = pos_sum[n-1] + max((ll)0, Ais[n-1]);
	}
	ll ans = numeric_limits<ll>::min();
	rep(i,0,N-K+1) {
		ll ans_loc = pos_sum[i] + (pos_sum[N] - pos_sum[i+K]) + max((ll)0, sum[i+K]-sum[i]);
		ans = max(ans, ans_loc);
	}
	cout << ans << endl;
}


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

using namespace std;

const int MAX_N = 110;

int n, ai[MAX_N];
vector<int> seq;

int main()
{
    bool valid = true;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ai[i]), seq.push_back(ai[i]);
    stack<int> st;
    while (!seq.empty())
    {
        int pos = 0;
        for (int i = 0, siz = seq.size(); i < siz; i++)
            if (seq[i] == i + 1)
                pos = i + 1;
        if (pos == 0)
            puts("-1"), exit(0);
        seq.erase(seq.begin() + pos - 1);
        st.push(pos);
    }
    while (!st.empty())
        printf("%d\n", st.top()), st.pop();
    return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
typedef pair<ll,ll> RR;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

#define LEN 100000

#define mod 998244353

ll powmod(ll x,int n){
    ll ans=1,y=x;
    int k=n;
    while(k){
        if(k&1) ans= (ans*y)%mod;
        y=(y*y)%mod;
        k/=2;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,x;
    cin >>N;
    vector<ll> TR(N,0);
    bool hasroot=false;
    rep(i,N){
        cin >> x;
        TR[x]++;
        if(i==0 && x==0)hasroot=true;
    }
    ll ans = (hasroot && TR[0]==1) ? TR[0]%mod : 0,
        sum=TR[0];
    repd(i,1,N){
        sum+=TR[i];
        ans = ans * powmod(TR[i-1],TR[i]);
        ans%=mod;
        if(sum==N)break;
    }


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

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>


int main() {
	int N;
	int K;
	int h;
	int ans = 0;

	scanf("%d %d", &N, &K);
	
	for (int i = 0; i < N; i++) {
		scanf("%d", &h);
		if (h >= K){
			ans = ans + 1;

		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
int main(){	
	ll n,a,b; cin>>n>>a>>b;
	ll x=n/(a+b);
	ll p=x*a;
	ll y=n%(a+b);
	if(y<a) cout<<p+y;
	else {
		ll z=min(y,a);
		cout<<p+z;
		}
		}
			
	

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

using namespace std;

int main(){
  int n,k,s;
  cin >> n >> k >> s;
  if(s==1000000000){
      if(k==0){
          for(int i=0;i<n;i++){
              cout << setprecision(30);
              cout << 1;
              if(i<n-1){
                  cout << ' ';
              }
          }
          return 0;
      }
      for(int i=0;i<k;i++){
          cout << setprecision(30);
          cout << s;
          if(i<k-1){
              cout << ' ';
          }
      }
      if(k<n){
          cout << ' ';
      }
      for(int i=k;i<n;i++){
          cout << 1;
          if(i<n-1){
              cout << ' ';
          }
      }
      return 0;
  }
  if(k==0){
      for(int i=0;i<n;i++){
          cout << setprecision(30);
          cout << s+1;
          if(i<n-1){
              cout << ' ';
          }
      }
      return 0;
  }
  for(int i=0;i<k;i++){
      cout << setprecision(30);
      cout << s;
      if(i<k-1){
          cout << ' ';
      }
  }
  if(k<n){
      cout << ' ';
  }
  for(int i=k;i<n;i++){
      cout << setprecision(30);
      cout << s+1;
      if(i<n-1){
          cout << ' ';
      }
  }
  cout << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

ll money = 1000;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];

  for(int i=0;i<n-1;i++){
    if(a[i+1]>a[i]){
      ll v=money/a[i];
      money=(money-v*a[i])+(a[i+1]*v);
    }
  }
  cout<<money<<"\n";
  return 0;
}

Measured memory_bytes: 3620