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

int main()
{
  int n;
  cin>>n;
  set<int> s;
  int m=n;
  int ans=0;
  while(m--)
  {
    int h;
    cin>>h;
    s.insert(h);
    if(*s.begin()==h)
      ans++;
  }
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 9600
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
c_l = c.most_common()
l = []
for e in c_l:
    if e[1] >= 4:
        l.append(e[0])
        l.append(e[0])
    elif e[1] >= 2:
        l.append(e[0])
l.sort()
if len(l) >= 2:
    print(l[-1]*l[-2])
else:
    print(0)

Measured memory_bytes: 21668
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [h, w, k] <- getIntList
  g <- VB.fromList <$> replicateM h BS.getLine

  let countBlack y x maskH maskW res
        | y >= h = res
        | x >= w = countBlack (y+1) 0 maskH maskW res
        | otherwise = let c = (g VB.! y) `BS.index` x
                          oky = ((maskH `shiftR` y) .&. 1 == 0)
                          okx = ((maskW `shiftR` x) .&. 1 == 0)
                          res' = if c == '#' && oky && okx
                                 then res + 1
                                 else res
                      in countBlack y (x+1) maskH maskW res'

      maxH = 1 `shiftL` h
      maxW = 1 `shiftL` w

      solve :: Int -> Int -> Int -> Int
      solve maskH maskW res
        | maskH >= maxH = res
        | maskW >= maxW = solve (maskH + 1) 0 res
        | otherwise = let ct = countBlack 0 0 maskH maskW 0
                          res' = if ct == k
                                 then res + 1
                                 else res
                      in solve maskH (maskW + 1) res'

  print $ solve 0 0 0


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

long long solve(long long x, long long y){
	if(x <= y) return y - x;
	return 1e15;
}

int main(){
	long long x, y;
	cin >> x >> y;
	long long ans = 1e15;
	ans = min(ans, solve(x, y));
	ans = min(ans, solve(-x, y) + 1);
	ans = min(ans, solve(x, -y) + 1);
	ans = min(ans, solve(-x, -y) + 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, Q;
  cin >> N >> Q;

  // adj は木の隣接のリスト
  vector<vector<size_t>> adj(N);
  for (int i = 1; i < N; ++i) {
    size_t a, b;
    cin >> a >> b;
    // 0 始まりに
    --a;
    --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  // 根にだけ保持されたカウンタ
  vector<long> counter(N);
  for (int i = 0; i < Q; ++i) {
    size_t p;
    long x;
    cin >> p >> x;
    --p;
    counter[p] += x;
  }

  // adj を深さ優先探索で伝播

  // 訪問済みかどうか
  vector<bool> visited(N);

  stack<size_t> S;
  S.push(0);
  while (!S.empty()) {
    auto now = S.top();
    S.pop();
    visited[now] = true;
    for (auto next : adj[now]) {
      if (visited[next]) {
        continue;
      }
      counter[next] += counter[now];
      S.push(next);
    }
  }

  for (auto e : counter) {
    cout << e << " ";
  }
  cout << "\n";
}


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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int cnt=0;
  rep(i,n) if((i+1)%2==1 and a[i]%2==1) cnt++;
  cout << cnt << "\n" ;
  
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static long keisan(int ax,int ay,int bx,int by){
		int sx = bx-ax;
        int sy = by-ay;
        if(sx>=0&&sy>=0)return Math.max(sx, sy);
        else if(sx<=0&&sy<=0)return Math.max(-sx, -sy);
        else if(sx>0&&sy<0)return sx-sy;
        else return sy-sx;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt(); int h = sc.nextInt(); int n = sc.nextInt();
		int sx = sc.nextInt() - 1; int sy = sc.nextInt() - 1;
		long result = 0;
		for(int i = 1; i < n; i++){ //N
			int ax = sc.nextInt() - 1;
			int ay = sc.nextInt() - 1;
			result += keisan(sx,sy,ax,ay);
				sx = ax; sy = ay;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 25484
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, tpn, tpm, a, b;
char s[MAXN][MAXN];
int main() {
	read(n), read(m), read(a), read(b), tpn = n, tpm = m;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
		s[i][j] = '.';
	if (n & 1) {
		for (int i = 2; i <= m; i += 2)
			if (a) {
				a--;
				s[n][i - 1] = '<';
				s[n][i] = '>';
			}
		n--;
	}
	if (m & 1) {
		for (int i = 2; i <= n; i += 2)
			if (b) {
				b--;
				s[i - 1][m] = '^';
				s[i][m] = 'v';
			}
		m--;
	}
	if (tpn % 2 && tpm % 2 && 2 * (a + b) == n * m && a % 2) {
		a--, b--;
		s[n - 1][m - 1] = '<', s[n - 1][m] = '>';
		s[n + 1][m] = '<', s[n + 1][m + 1] = '>';
		s[n - 1][m + 1] = '^', s[n][m + 1] = 'v';
		s[n][m - 1] = '^', s[n + 1][m - 1] = 'v';
	}
	for (int i = 2; i <= n; i += 2)
	for (int j = 2; j <= m; j += 2) {
		if (a) {
			a--;
			s[i][j - 1] = '<';
			s[i][j] = '>';
			if (a) {
				a--;
				s[i - 1][j - 1] = '<';
				s[i - 1][j] = '>';
			}
		} else if (b) {
			b--;
			s[i - 1][j] = '^';
			s[i][j] = 'v';
			if (b) {
				b--;
				s[i - 1][j - 1] = '^';
				s[i][j - 1] = 'v';
			}
		}
	}
	if (a + b) puts("NO");
	else {
		puts("YES");
		for (int i = 1; s[i][1] != 0; i++)
			printf("%s\n", s[i] + 1);
	}
	return 0;
}

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


if 0 in a:
    print(0)
else:
    ans=1
    i=0
    while ans<=10**18 and i<n:
        ans*=a[i]
        i+=1

    if ans>10**18:
        print("-1")
    else:
        print(ans)

Measured memory_bytes: 21652
n = int(input())
p = list(map(int, input().split()))
p_l = sorted(p)
count =0

if p == p_l:
    print("YES")

else:
    for i in range(n):
        if not p[i] == p_l[i]:
            count +=1

    if count ==2:
        print("YES")
    else:
        print("NO")

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

#define N 8
#define FREE  -1
#define NOT_FREE 1

int X[N][N],row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void initialize(){
  int i,j;
  for(i=0;i<N;i++){
    row[i] = FREE;
    col[i] = FREE;

    for(j=0;j<N;j++){
      X[i][j]=0;
  }
  }
  for(j=0;j<2*N-1;i++){
    dpos[j]=FREE;
    dneg[j]=FREE;
  }
}


void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) {
          printf("Q");
      }
      else {
          printf(".");
    }
}
  printf("\n");
  }
  return;
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard(); 
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]  == NOT_FREE  || 
       dpos[i+j] == NOT_FREE ||
       dneg[i-j + N-1] == NOT_FREE ) {
           continue;
}
    row[i]=j; col[j] = dpos[i+j] = dneg[i-j + N-1] = NOT_FREE;

    recursive(i+1);

    row[i] = col[j] = dpos[i+j] = dneg[i-j + N-1] = FREE;
  }
}

int main(){
    int i,j,x,y,n;

    //initialize();
  for(i=0;i<N;i++){
    row[i] = FREE;
    col[i] = FREE;

    for(j=0;j<N;j++){
      X[i][j]=0;
  }
  }
  
  for(j=0;j<2*N-1;j++){
    dpos[j]=FREE;
    dneg[j]=FREE;
}
    scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    X[x][y]=1;
  }
  recursive(0);
}



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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_N=30;

int n,w;
int a[MAX_N],b[MAX_N];

char s[8];

int main(){
	scanf("%d",&w);
	scanf("%d",&n);
	REP(i,n){
		scanf("%s",s);
		int l=strlen(s);
		b[i]=-1;
		REP(j,l){
			if (s[j]!=','){
				if (b[i]==-1){
					a[i]*=10;
					a[i]+=s[j]-'0';
				}
				else{
					b[i]*=10;
					b[i]+=s[j]-'0';
				}
			}
			else{
				b[i]=0;
			}
		}
	}
	FOR(i,1,w+1){
		int c=i;
		for(int j=n-1;j>=0;j--){
			if (c==a[j]){
				c=b[j];
			}
			else if (c==b[j]){
				c=a[j];
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

using namespace std;

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

  for(int i = 1;; i++) {
    if(i * (i + 1) / 2 >= N) {
      for(int j = i; j >= 1; j--) {
        if(N - j >= 0) {
          cout << j << endl;
          N -= j;
        }
      }
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1001001001;
const ll INFL = 1e17;
const int MOD = 1e9+7;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n) cin >> a[i];
    b[n-1] = 0;
    for(int i=n-1; i>0; --i){
        b[i-1] = b[i]+a[i];     
    }
    ll ans = 0;
    for(int i=0; i<n; i++){
        ll now = (a[i]*(b[i]%MOD))%MOD;
        ans = (ans+now)%MOD;
    }

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

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;

ll x,k,d;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>x>>k>>d;
    x=abs(x);
    ll need=x/d;
    if(need>=k) cout<<x-(k*d);
    else{
        ll remain=x%d;
        k-=need;
        if(k%2==0) cout<<remain;
        else cout<<abs(remain-d);
    }
    return 0;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; cin >> n; std::vector<int> vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i];
	sort(begin(vec), end(vec));
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(vec.back() % vec[i] == 0) continue;
		int mi = 1 << 30;
		for(int j = 1; j * j <= vec.back(); j++) {
			if(vec.back() % j) continue;
			if(j > vec[i]) mi = std::min(mi, j - vec[i]);
			if(vec.back() / j > vec[i]) mi = std::min(mi, vec.back() / j - vec[i]);
		}
		ans += mi;
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3264
n = int(input())
*A, = map(int, input().split())
A = [0] + A
X = [0 for i in range(n + 1)]
for i in range(n, 0, -1):
    j = 2 * i
    while j <= n:
        X[i] += X[j]
        j += i
    X[i] = (X[i] + A[i]) % 2
print(sum(X))
B = []
for i in range(1, n+1):
    if X[i] == 1:
        B.append(i)
print(*B)


Measured memory_bytes: 14124
#include <set>
#include <iostream>
#include <cmath>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

double exp(){
  int n, m;
  cin >> n >> m;

  double rs = 0.0;
  double ret = 0.0;

  REP(i,m){
    double r, v;
    cin >> v >> r;

    rs += r;
    ret += r * v;
  }

  return ret / rs;
}

int main(){
  int t; cin >> t;
  double my = 0.0;
  REP(i,t) my = max(my, exp());
  double en = exp();
  if(my > en + 0.0000001)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
int a, b, c, d, e;
scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
if (a-c-e < 0) {
	printf("No\n");
} else if (b-d-e < 0) {
	printf("No\n");
} else if (c-e < 0) {
	printf("No\n");
} else if (d-e < 0){
	printf("No\n");
} else {
	printf("Yes\n");
}

return 0;
}

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

bool palindrome(string s){
  int n = s.size();
  for(int i = 0; i < n / 2; ++i){
    if(s[i] != s[n-i-1])return false;
  }
  return true;
}

int main(){
  string s;
  cin>>s;
  int n = s.size();
  bool ok = true;
  if(!palindrome(s))ok = false;
  if(!palindrome(s.substr(0, (n - 1) / 2)))ok = false;
  if(!palindrome(s.substr((n + 2) / 2)))ok = false;
  if(ok){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl; 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A1,A2,A3,sum;
    cin>>A1>>A2>>A3;
    sum= A1+A2+A3;
    if(sum>=22)
    {
        cout<<"bust"<<endl;

    }
    else{
        cout<<"win"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;
 
int lcs(string X, string Y) {
    int c[N + 1][N + 1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = " " + X;
    Y = " " + Y;
    for(int i = 0; i <= m; i++) c[i][0] = 0;
    for(int j = 0; j <= n; j++) c[0][j] = 0;
     
    for(int i = 1; i <= m; i++) {
        for(int j = 1; j <= n; j++) {
            if(X[i] == Y[j]) {
            c[i][j] = c[i - 1][j - 1] + 1;
        } else {
            c[i][j] = max(c[i - 1][j], c[i][j - 1]);
        }
        maxl = max(maxl, c[i][j]);
        }
    }
     
    return maxl;
}  
 
int main() {
    string s1, s2;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;  
    }
     
    return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



int N, M, Q;
vi L, R;
vvi imo;

void prepare() {
    imo.assign(N+1, vi(N+1, 0));

    rep(i,M){
        int from = L[i], to = R[i];
        ++imo[from][to];
    }

    for (int r=N; r>0; --r){
        rep1(c,N) {
            imo[r][c] += imo[r][c-1];
        }
        if (r < N) {
            rep(c,N+1)
                imo[r][c] += imo[r+1][c];
        }
    }
#ifdef DEBUG
    for (int r=1;r<=N;++r) {
        for (int c=1;c<=N;++c) {
            fprintf(stderr, " %2d", imo[r][c]);
        }
        fprintf(stderr, "\n");
    }
#endif
}

int query(int p, int q) {
    return imo[p][q];
}

int main() {
    // cin >> N >> M >> Q;
    scanf("%d %d %d", &N, &M, &Q);
    L.resize(M); R.resize(M);
    rep(i,M) {
        // cin >> L[i] >> R[i];
        scanf("%d %d", &L[i], &R[i]);
    }

    prepare();

    rep(i,Q) {
        int p,q; // cin >> p >> q;
        scanf("%d %d", &p, &q);
        // cout << query(p,q) << endl;
        printf("%d\n", query(p,q));
    }
    return 0;
}


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

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

  vector<int> a(n);
  int sum = 0;

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

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] >= (double)sum / (4 * m)) count++;
  }

  if (count >= m)
    cout << "Yes" << endl;
  else if (count < m)
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
  
  int A,B,C;
  int sum = 0;
  
  scanf("%d""%d""%d",&A,&B,&C);
  
  if(A+B+1>=C){
    sum = B+C;
  }else{
  	sum = B*2+A+1;
  }

  printf("%d\n", sum);
  return 0;
  
}

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

int main() {
  int n,m,a,b;
  cin>>n>>m;
  vector<int>x(n);
  for(int i=0;i<m;i++){
    cin>>a>>b;
    x[a-1]++;
    x[b-1]++;
  }
  for(int i=0;i<n;i++)
    cout<<x[i]<<endl;
}
      


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
  int w,n,tmp;
  int lod[N]; int lis[N][3];
  while(cin >> n >> w){
  for(int i = 0;i<n;i++){
    lod[i] = i+1;
  }

  for(int i=0;i<w;i++){
    scanf("%d,%d",&lis[i][0],&lis[i][2]);
  }
  for(int i=0;i<w;i++){
    tmp = lod[lis[i][0]-1];
    lod[lis[i][0]-1] = lod[lis[i][2]-1];
    lod[lis[i][2]-1] = tmp;
  }
  for(int i=0;i<n;i++){
    cout << lod[i] << endl;
  }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    vector<int> arr(5, 0);
    for(auto& val: arr)
        cin >> val;
    for(int i = 0; i < 5; i++) {
        if (arr[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main(){
    int n, ac=0, wa=0, tle=0, re=0;
    char string[10];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", &string);
        if (strcmp(string,"AC")==0) ac+=1;
        if (strcmp(string,"WA")==0) wa+=1;
        if (strcmp(string,"TLE")==0) tle+=1;
        if (strcmp(string,"RE")==0) re+=1;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

Measured memory_bytes: 1680
def main():
    X, Y = map(int, input().split(' '))

    if X % Y == 0:
        print(-1)
        return

    i = 0
    A = X

    while A <= 10e18:
        if A % Y != 0:
            print(A)
            return
        else:
            i += 1
            A = (i+1)*X

    print(-1)

main()


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

template <typename T>
bool Query(T v) {
  cout << "? " << v << endl;
  string res;
  cin >> res;
  return res == "Y";
}

bool Query(vector<int> d) {
  int64_t v = 0;
  for (int i = 0; i < d.size(); ++i) {
    v = v * 10 + d[i];
  }
  return Query(v);
}

int main() {
  int64_t ten = 1, k = -1;
  for (int i = 1; i <= 11; ++i) {
    bool v = Query(ten);
    if (v) k = i;
    ten = ten * 10;
  }
  if (k == 11) {
    int64_t val = 9;
    for (int i = 1; i <= 11; ++i) {
      if (Query(val)) {
        cout << "! 1";
        for (int j = 0; j < i - 1; ++j) cout << "0";
        cout << endl;
        return 0;
      }
      val = val * 10 + 9;
    }
  }
  assert(k != -1);
  vector<int> d(k + 1);
  for (int i = 0; i < k; ++i) {
    for (int g = 5; g >= 0; --g) {
      if (d[i] + (1 << g) >= 10) continue;
      d[i] += (1 << g);
      if (Query(d)) d[i] -= (1 << g);
    }
    if (i == 0 && d[i] == 0) {
      cout << "! 1";
      for (int j = 0; j < k - 1; ++j) cout << "0";
      cout << endl;
      return 0;
    }
  }
  cout << "! ";
  d[k - 1]++;
  for (int i = 0; i < k; ++i) cout << d[i];
  cout << endl;
}


Measured memory_bytes: 668
#include <cstdio>
#include <algorithm>

struct stu {
    int a, index;
};

bool cmp(stu a, stu b) {
    return a.a<b.a;
}

int main() {
    int n;
    scanf("%d", &n);
    stu a[n];
    for(int i=0;i<n;i++){scanf("%d",&a[i].a);a[i].index=i+1;}
    std::sort(a,a+n,cmp);
    for(int i=0;i<n;i++)printf("%d ", a[i].index);
    return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll tmp=0,n,sum=0,v,res=0;
  cin >> n;
  vector<ll> a(n+1);
  REP(i,n)cin >> a[i];
  if(a[0] != 0){
    v = abs(a[0])/a[0];
    sum = a[0];
    for(int i=1;i<n;i++){
      if(v == -1){
        if(a[i] + sum <= 0){
          tmp += abs(1-a[i]-sum);
          sum = 1;
        }else{
          sum += a[i];
        }
      }else{
        if(a[i] + sum >= 0){
          tmp += abs(-1-a[i]-sum);
          sum = -1;
        }else{
          sum += a[i];
        }
      }
      v = -v;
    }
    v = -abs(a[0])/a[0];
    sum = v;
    res += abs(a[0])+1;
    for(int i=1;i<n;i++){
      if(v == -1){
        if(a[i] + sum <= 0){
          res += abs(1-a[i]-sum);
          sum = 1;
        }else{
          sum += a[i];
        }
      }else{
        if(a[i] + sum >= 0){
          res += abs(-1-a[i]-sum);
          sum = -1;
        }else{
          sum += a[i];
        }
      }
      v = -v;
    }
    res = min(res,tmp);
  }else{
    v = 1;
    tmp++;
    sum = 1;
    for(int i=1;i<n;i++){
      if(v == -1){
        if(a[i] + sum <= 0){
          tmp += abs(1-a[i]-sum);
          sum = 1;
        }else{
          sum += a[i];
        }
      }else{
        if(a[i] + sum >= 0){
          tmp += abs(-1-a[i]-sum);
          sum = -1;
        }else{
          sum += a[i];
        }
      }
      v = -v;
    }


    v = -1;
    res++;
    sum = -1;
    for(int i=1;i<n;i++){
      if(v == -1){
        if(a[i] + sum <= 0){
          res += abs(1-a[i]-sum);
          sum = 1;
        }else{
          sum += a[i];
        }
      }else{
        if(a[i] + sum >= 0){
          res += abs(-1-a[i]-sum);
          sum = -1;
        }else{
          sum += a[i];
        }
      }
      v = -v;
    }
    
    res = min(res,tmp);
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N, M, X, Y;
int x[110], y[110];

int main() {
	cin >> N >> M >> X >> Y;
	REP(i, N) cin >> x[i];
	REP(i, M) cin >> y[i];
	sort(x, x + N, greater<int>());
	sort(y, y + M);
	for (int i = X + 1; i <= Y; i++) {
		if (x[0] < i && i <= y[0]) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# import numpy as np

# 7.n = 7 * 1.n = 101
7777


def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer)


if __name__ == "__main__":
    main()


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { 
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i);
    if (sum >= A && sum <= B) {
      total += i;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 3516
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		x: usize,
		t: usize,
	}

	println!("{}", (((n-1) / x) + 1) * t);
}



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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'



using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	 ll n;
	 cin>>n;
	 ll a[n],i,j;
	 rep(i,0,n)
	 {
	     cin>>a[i];
	     
	 }
	 sort(a,a+n);
	 ll s=0LL;
	 rep(i,0,n-1)
	 {
	     s+=a[i];
	 }
	 if(a[i]<s)
	 {
	     cout<<"Yes";
	 }
	 else
	 {
	     cout<<"No";
	 }
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static MyIO;


public class A
{
	public static void Main()
	{
		Regex regex = new Regex(",");
		Console.WriteLine(regex.Replace(GetString(), " "));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 15836
#include<iostream>
#include<string>
#include<tuple>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define loop(i, n) for (int i = 0; i < n; ++i)
#define loop1(i, n) for (int i = 1; i < n; ++i)
#define ti tuple<int, int, int>

const int N = 2e5 + 7, MOD = 998244353;

int f[N] = {1}, rf[N] = {1}, deg[N] = {1};

int binpow (int x, int d) {
    int ans = 1;
    while (d) {
        if (d & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        d >>= 1;
    }
    return ans;
}

int binom (int n, int k) {
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

void solve() {
    loop1(i, N - 1) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = binpow(f[i], MOD - 2);
    }
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    loop1(i, N - 1)
        deg[i] = deg[i - 1] * (m - 1) % MOD;
    loop(i, k + 1) 
        ans = (ans + binom(n - 1, i) * m % MOD * deg[n - i - 1]) % MOD;
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 8340
# -*- coding: utf-8 -*-
def main():                                                                                                               
  # input
  s = raw_input()
  K = int(raw_input())
  ch = [123-ord(c) for c in s]
  for i in range(len(s)):
    if ch[i] == 26 and i != len(s)-1:
      continue
    elif ch[i] < K:
      K = K - ch[i]
      ch[i] = 26
    elif ch[i] == K:
      K = K - ch[i]
      ch[i] = 26
      break
    elif ch[i] > K and i != len(s)-1:
      continue
    else:
      tmp = ch[i]
      ch[i] = ch[i] - K
      K = K - tmp
      if ch[i] <= 0:
        ch[i] == 26
  if K > 0:
    ch[len(s)-1] = ch[len(s)-1] - K%26
  # output
  ch = [str(unichr((27-c)+96)) for c in ch]
  print ''.join(ch)
main()

Measured memory_bytes: 11192
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readStringSplit(by: " ").map{$0.toArray()}
let (A, B, C) = (input[0], input[1], input[2])
print(A[A.count-1]==B[0]&&B[B.count-1]==C[0] ? "YES" : "NO")


Measured memory_bytes: 5608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	left := make([]int, n+1)
	right := make([]int, n+1)

	for i := 0; i < n; i++ {
		left[i+1] = gcd(left[i], a[i])
	}

	for i := n - 1; i >= 0; i-- {
		right[i] = gcd(right[i+1], a[i])
	}

	res := 0.0
	for i := 0; i < n; i++ {
		l := left[i]

		r := right[i+1]

		chmax(&res, float64(gcd(l, r)))
	}
	fmt.Println(int(res))

	// slice := make([]int, n)
	// for i := 0; i < n; i++ {
	// 	slice[i] = nextInt()
	// }

	// max := -1

	// for i := 0; i < n; i++ {
	// 	for j := 0; j < n; j++ {
	// 		if i == j {
	// 			continue
	// 		}

	// 		res := gcd(slice[i], slice[j])

	// 		if max < res {
	// 			max = res
	// 		}
	// 	}
	// }
}

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

}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 4736
#include<stdio.h>
typedef long int lint;

lint n, k;
lint A[100000];

lint check(lint p){ //最大積載量と車の数
    lint i=0;
    for(int j=0; j<k; j++){ //k回繰り返す
        lint sum = 0;
        while(sum + A[i] <= p){
            sum+=A[i];
            i++;
            if(i==n) return n;
        }
    } 
    return i;
}

lint binarySearch(){    //最大積載量ｐで二分探索
    lint left = 0;
    lint right = 100000*10000;
    lint mid;
    while(left+1<right){
        mid = (left+right)/2;
        lint v = check(mid);
        if(v>=n) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    scanf("%ld %ld", &n, &k);
    for(int i=0; i<n; i++){
        scanf("%ld", &A[i]);
    }
    lint ans = binarySearch();
    printf("%ld\n", ans);
    return 0;
}


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

typedef long long lint;
typedef pair<lint,lint> pll;
typedef long double louble;

#define so(x) ((int)((x).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 133333 , __ = _<<1;
const lint linf = 0x3f3f3f3f3f3f3f3f;

int to[__],ne[__],ev[__],he[_]={0},ecnt=1;
inline void adde(int a,int b,int c){to[++ecnt]=b,ev[ecnt]=c,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b,int c){adde(a,b,c),adde(b,a,c);}

int n;

vector<pll> dfs(int x,int ff,lint lim)
{
	int lc=0,rc=0,vlc=0,vrc=0;
	for(int i=he[x];i;i=ne[i]){int b=to[i];if(b==ff)continue;if(!lc)lc=b,vlc=ev[i];else rc=b,vrc=ev[i];}

	if(!lc && !rc)return {pll(0,0)};
	vector<pll> lx=dfs(lc,x,lim),rx=dfs(rc,x,lim);

	vector<pll> templ,tempr;
	for(int i=0,j=0;i<so(lx);i++)
	{
		while(j+1<so(rx) && lx[i].second+rx[j+1].first+vlc+vrc<=lim)j++;
		if(j<so(rx) && lx[i].second+rx[j].first+vlc+vrc<=lim)
			templ.emplace_back(lx[i].first+vlc,rx[j].second+vrc);
	}
	for(int i=0,j=0;i<so(rx);i++)
	{
		while(j+1<so(lx) && rx[i].second+lx[j+1].first+vlc+vrc<=lim)j++;
		if(j<so(lx) && rx[i].second+lx[j].first+vlc+vrc<=lim)
			tempr.emplace_back(rx[i].first+vrc,lx[j].second+vlc);
	}

	vector<pll> ret;
	lint las=linf;
	for(int i=0,j=0;i<so(templ) || j<so(tempr);)
	{
		if(i<so(templ) && (j>=so(tempr) || templ[i]<tempr[j]))
		{
			if(templ[i].second<las)las=templ[i].second,ret.emplace_back(templ[i]);
			i++;
		}
		else
		{
			if(tempr[j].second<las)las=tempr[j].second,ret.emplace_back(tempr[j]);
			j++;
		}
	}

	return ret;
}

inline int able(lint lim)
{
	return !dfs(1,0,lim).empty();
}

int main()
{
	n=ty();
	for(int i=2,a,b;i<=n;i++)a=ty(),b=ty(),addde(i,a,b);
	
	lint l=0,r=1145141919810,ans=r;
	
	while(r>=l)
	{
		lint mid=(l+r)>>1;
		if(able(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int n;
    cin>>n;
    vector<int>v;
    while(n!=0){
        v.push_back(n%10);
        n/=10;
    }
    int f=0;
    reverse(v.begin(),v.end());
    //for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    for(int i=1;i<v.size();i++){
        if(v[0]<v[i]){
            f=1;
            break;
        }
    }
    if(f==0)cout<<v[0]<<v[0]<<v[0];
    else cout<<v[0]+1<<v[0]+1<<v[0]+1;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll mod = 1e9 + 7;

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

bool pairCompare(const P &firstElof, const P &secondElof) {
    return firstElof.second < secondElof.second;
}

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if(t * s >= d) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    cout << "\n";
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int sum=0, tail=0, n,c;

void enqueue(int,int);

int main(){
  int i, q;
  scanf("%d%d",&n,&q);
  tail = n;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  i=1;
  while(i!=tail+1)
    {
      enqueue(q,i);
      i++;
if(i>LEN)i=1;
    }
  
  return 0;
}

void enqueue(int q,int i)
{
  int y;
  y = Q[i].t - q;
  if(y<=0)
    {
      sum+=Q[i].t;
      printf("%s %d\n",Q[i].name,sum);
     
    }
  else
    {
      sum+=q;
      tail = tail + 1;
if(tail>LEN)tail=1;
      strcpy(Q[tail].name,Q[i].name);
      Q[tail].t = y;
    }
}

Measured memory_bytes: 10764
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
bool isPrime(int num)
{
    if (num < 2)
        return false;
    else 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;
}
signed main()
{
    int n;
    cin >> n;
    int ans = 0;
    int ncopy = n;
    map<int, int> m;
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (ncopy == 1)
            break;
        while (ncopy % i == 0)
        {
            ncopy /= i;
            m[i]++;
        }
    }
    if (ncopy != 1)
        m[ncopy]++;
    for (auto itr = m.begin(); itr != m.end(); itr++)
    {
        for (int i = 1;; i++)
        {
            if (itr->second >= i)
            {
                ans++;
                itr->second = itr->second - i;
            }
            else
                break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string S; cin >> S;
  string result = (S.length()>=4&&S.substr(0,4)=="YAKI") ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++) cin >> a[i];
    if(n % 2 == 0){
        for(int i = n; i >= 1; i--){
            if(i % 2 == 0) cout << a[i] << " ";
        }
        for(int i = 1; i <= n; i++){
            if(i % 2 == 1) cout << a[i] << " ";
        }
    }
    if(n % 2 == 1){
        for(int i = n; i >= 1; i--){
            if(i % 2 == 1) cout << a[i] << " ";
        }
        for(int i = 1; i <= n; i++){
            if(i % 2 == 0) cout << a[i] << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
def bubble_sort(a)
    n = a.length
    c = 0
    for i in 0..n-1
        (n-1).downto(i+1) do |j|
            if a[j] < a[j-1]
                tmp    = a[j]
                a[j]   = a[j-1]
                a[j-1] = tmp
                c += 1
            end
        end
    end
    return a, c
end
gets
a = gets.strip.split(" ").map{|i| i.to_i}
res = bubble_sort(a)
puts res[0].join(" ")
puts res[1]


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

signed main(){
    int n,k;
    cin >> n;
    priority_queue<int> a;
    for(int i=0;i<n;i++){
        cin >> k;
        a.push(k);
    }
    priority_queue<int> b;
    int t=1;
    int x,y;
    int ans=0;
    for(int i=0;i<n;i++){
        x =a.top();
  
        
            while(!b.empty()&&b.top()>x)b.pop();
        if(!b.empty()&&b.top()==x){
            ans++;
            b.pop();
        }else{
            t=1;
            while(t<=x)t =t*2;
           // cout << t-x<<endl;
            b.push(t-x);
        }
        a.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2036
x,y = map(int,input().split())
result = 0
if x in [1,3,5,7,8,10,12] and y in [1,3,5,7,8,10,12]:
  print("Yes")
elif x in [4,6,9,11] and y in [4,6,9,11]:
  print("Yes")
elif x in [2] and y in [2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input;
		while((input = br.readLine()) != null) {
			String[] p = input.split(",");
			float[] pf = new float[p.length];
			for (int i = 0; i < p.length; i++) {
				pf[i] = Float.parseFloat(p[i]);
				// System.out.printf("pf[%d] = %f\n", i, pf[i]);
			}
			float v1x = pf[2] - pf[0];
			float v1y = pf[3] - pf[1];
			float v2x = pf[4] - pf[2];
			float v2y = pf[5] - pf[3];
			float v3x = pf[6] - pf[4];
			float v3y = pf[7] - pf[5];
			float v4x = pf[0] - pf[6];
			float v4y = pf[1] - pf[7];

			float ext1 = exterior(v1x, v1y, v2x, v2y);
			float ext2 = exterior(v2x, v2y, v3x, v3y);
			float ext3 = exterior(v3x, v3y, v4x, v4y);
			float ext4 = exterior(v4x, v4y, v1x, v1y);

			boolean[] sign = new boolean[4];

			sign[0] = (ext1 > 0);
			sign[1] = (ext2 > 0);
			sign[2] = (ext3 > 0);
			sign[3] = (ext4 > 0);

			boolean result = true;
			for (int i = 0; i < 4; i++) {
				if (sign[i] != sign[0]) {
					result = false;
					break;
				}
			}
			if (result) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}

	public static float exterior(float x1, float y1, float x2, float y2) {
		float ext =  x1 * y2 - y1 * x2;
		// System.out.println(ext);
		return ext;
	}
}

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

const int MAX = 20;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, c+a}) << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]

a = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            a[i][j] = "#"
            for p in [-1, 0, 1]:
                for q in [-1, 0, 1]:
                    if i + p >= 0 and j + q >= 0 and i + p < H and j + q < W and S[i + p][j + q] != "#":
                        a[i + p][j + q] += 1

for i in range(H):
    print(''.join(map(str, a[i])))

Measured memory_bytes: 41456
import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;

public class Main {
    public static void main(String[] args) throws IOException {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        DecimalFormat df=new DecimalFormat("0.0000");
        double r=in.nextInt();
        double ans=2*r*Math.PI;
        System.out.println(df.format(ans));
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan());
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }
    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan());
        StringBuilder sb = new StringBuilder();
        for (; c !=10 && c!=13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }
    char nextChar() throws IOException{
        int c;
        for (c = scan(); c <= 32; c = scan());
        return (char)c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan());
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan());
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


Measured memory_bytes: 35276
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	char c[n]; cin >> c;
  	int r[n], g[n], b[n];
  	for (int i = 0; i < n; i++) {
    	if (i > 0) {
        	r[i] = r[i-1];
          	g[i] = g[i-1];
          	b[i] = b[i-1];
        }
      	else {
        	r[i] = g[i] = b[i] = 0;
        }
      	if (c[i] == 'R') r[i]++;
      	if (c[i] == 'G') g[i]++;
      	if (c[i] == 'B') b[i]++;
    }
  	long long ans = 0LL;
  	for (int i = 0; i < n; i++) {
    	for (int j = i + 1; j < n; j++) {
        	if (c[i] == c[j]) continue;
          	int oC = 0;
          	if (c[i] != 'R' && c[j] != 'R') oC += r[n-1] - r[j];
          	if (c[i] != 'G' && c[j] != 'G') oC += g[n-1] - g[j];
          	if (c[i] != 'B' && c[j] != 'B') oC += b[n-1] - b[j];
          	if (2 * j - i < n && c[2 * j - i] != c[i] && c[2 * j - i] != c[j]) oC--; 
          	ans += oC;
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 3588