akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



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

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
////////////////////////////////////////////////////////////////////i

int n,m;vector<int> v;stack<int> st;string s;
signed main(){
  cin>>n>>m>>s;
  reverse(s.begin(), s.end());
  int now = 0;
  while(now < n){
    bool can = false;
    rep(i,m){
      if(now+m-i > n)continue;
      if(s[now+m-i] == '0'){
        st.push(m-i);now = now+m-i;can = true;break;
      }
    }
    if(!can){
      cout << -1 << endl;return 0;
    }
  }
  while(!st.empty()){
    cout << st.top() << (st.size() == 1 ? "\n" : " ");
    st.pop();
  }
}


Measured memory_bytes: 1196
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	VI A(N);
	cin>>A[0];
	bool K=false;
	int j=1;
	FOR(i,1,N){
		int a;
		cin>>a;
		if(A[j-1]!=a){
			A[j]=a;
			K=true;
			j++;
		}
	}
	if(!K){
		cout<<1<<endl;
		return 0;
	}
	bool F=false;
	int ans=1;
	if(A[0]<A[1])F=true;
	else F=false;
	int i=1;
	while(i<j){
		if(F){
			if(A[i-1]>A[i]){
				ans++;
				if(A[i]<A[i+1] && i+1<N)F=true;
				else F=false;
				//i++;
			}
		}
		else{
			if(A[i-1]<A[i] && i+1<N){
				ans++;
				if(A[i]<A[i+1])F=true;
				else F=false;
				//i++;
			}
		}
		i++;
	}
	cout<<ans<<endl;
	//REP(i,N)cout<<A[i]<<endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
  int cardA=0,cardB=0,cardC=0,win = 0;
  char deckA[128],deckB[128],deckC[128];
  
  fgets(deckA,sizeof(deckA),stdin);
  fgets(deckB,sizeof(deckB),stdin);
  fgets(deckC,sizeof(deckC),stdin);
  
  int turn = 1;
  while(win == 0)
  {
    switch(turn)
    {
      case 1:
        switch(deckA[cardA])
      	{
          case 'a':turn = 1; 
            	   break;
          case 'b':turn = 2; 
                   break;
          case 'c':turn = 3; 
                   break;
        }
        cardA++;
        if(strlen(deckA)+1 == cardA)
        {
          win = 1;
        }
        break;
      case 2:
        switch(deckB[cardB])
      	{
          case 'a':turn = 1; 
            	   break;
          case 'b':turn = 2; 
                   break;
          case 'c':turn = 3; 
                   break;
        }
        cardB++;
        if(strlen(deckB)+1 == cardB)
        {
          win = 2;
        }
        break;
      default:
        switch(deckC[cardC])
      	{
          case 'a':turn = 1; 
            	   break;
          case 'b':turn = 2; 
                   break;
          case 'c':turn = 3; 
                   break;
        }
        cardC++;
        if(strlen(deckC)+1 == cardC)
        {
          win = 3;
        }
        break;
    }//turn
  }//while
  switch(win)
  {
    case 1:
      puts("A");
      break;
    case 2:
      puts("B");
      break;
    case 3:
      puts("C");
      break;
    default:puts("error");
  }
    return 0;
}
      
  

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  int flag = false;
  REP(i, N){
    if(C*(N-1-i)-D*i <= abs(A-B) && abs(A-B) <= -C*i+D*(N-1-i)) flag = true;
  }

  flag? YES: NO;

  return 0;
}

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

int main() {
	

	int A, B;
	cin >> A >> B;
	
	if (A % 2 == 1 && B % 2 ==1) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	Would you please return 0;

}

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

static const int INF=1e9;

int main(){
    int N; cin >> N;
    vector<int> res;
    res.push_back(1);
    int tmp6=1;
    int tmp9=1;
    while(true){
        if(tmp6>N&&tmp9>N) break;
        tmp6*=6;
        tmp9*=9;
        res.push_back(tmp6);
        res.push_back(tmp9);
    }

    vector<long long> dp(N+10,INF);
    dp[0]=0;
    for(int i=0;i<=N;i++){
        for(int j=0;j<res.size();j++){
            if(i+res[j]<=N){
                dp[i+res[j]]=min(dp[i+res[j]],dp[i]+1);
            }
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
/* 解説AC */

#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

signed main(){
    int n, k, l;
    cin >> n >> k >> l;
    UnionFind uni_k(n);
    UnionFind uni_l(n);

    rep(i, k){
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      uni_k.unite(x, y);
    }

    rep(i, l){
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      uni_l.unite(x, y);
    }

    map<P, int> ma;
    rep(v, n){
      P p(uni_k.find(v), uni_l.find(v));
      ma[p]++;
    }

    rep(v, n){
      P p(uni_k.find(v), uni_l.find(v));
      cout << ma[p] << " ";
    }
}

Measured memory_bytes: 20592
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        _: usize,
        ss: Chars,
    }
    let mut ans = 0;
    for i in 0..1000 {
        let num: Vec<char> = format!("{:>03}", i).chars().collect();
        let mut index = 0;
        for &s in &ss {
            if s == num[index] {
                index += 1;
                if index == 3 {
                    ans += 1;
                    break;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2284
import math
a_tmp = input().split()
a = []
for i in range(3):
    a.append(int(a_tmp[i]))
cost = [0 for i in range(3)]
for i in range(3):
    for j in range(3):
        cost[i] = cost[i] + math.fabs(a[i] - a[j])
print(int(min(cost)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> C;
    cout << min((A + B), min((B + C), A + C)) << endl;
}

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

int main() {
	int N;
	cin >> N;
	int MAX = 0, Ans = 0;
	for (int i = 0; i < N; i++) {
		int H;
		cin >> H;
		if (H >= MAX) {
			Ans++;
			MAX = H;
		}
	}
	cout << Ans << endl;
}

Measured memory_bytes: 256
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));
        int r = Integer.parseInt(br.readLine());
        System.out.println(r * 2 * Math.PI);
    }
}


Measured memory_bytes: 33196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class AAirConditioner {
public:
  static void solve(istream &cin, ostream &cout) {
    int X;
    cin>>X;
    if (X >= 30)cout<<"Yes"<<endl;
    else{
      cout<<"No"<<endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  AAirConditioner solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

ll  n; string s;
ll midnum(int i,int j){
  set<int> s_mid;
  for(int k=i+1; k<j; k++){
    int i3=(int)s[k]-48;
    s_mid.insert(i3);
  }
  return s_mid.size();
}
int main() {
  cin>>n>>s;
  vector<int> v(10,0);
  vector<int> v_first, v_last;
  rep(k,n){
    int i1=(int)s[k]-48;
    if(v.at(i1)==0){
      v.at(i1)=1;
      v_first.push_back(k);
    }   
  }
  vector<int> v_(10,0);
  rep(k,n){
    int i2=(int)s[n-k-1]-48;
    if(v_.at(i2)==0){
      v_.at(i2)=1;
      v_last.push_back(n-k-1);
    }
  }
  ll count=0;
  for(int i: v_first){
    for(int j: v_last){
      if(j-i>=2){count+=midnum(i,j);}
    }
  }
  cout<<count;
}

Measured memory_bytes: 3648
from itertools import groupby

N,K=map(int,input().split())
S=input()
def condition(num):
    flag=0
    first=[int(S[i]) for i in range(0,N-num+1)]
    last=[int(S[i+num-1]) for i in range(0,N-num+1)]
    test=[]
    for i in range(0,num):
        test.append(int(S[i]))
    sub=groupby(test)
    count=0
    for key,group in sub:
        if key==0:
            count+=1
    if K>=count:
        flag=1
    for i in range(1,N-num+1):
        if first[i-1]==0 and first[i]==1:
            count-=1
        if last[i-1]==1 and last[i]==0:
            count+=1
        if K>=count:
            flag=1
    return flag==1
start=1
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test
if condition(end):
    print(end)
else:
    print(start)

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

int main()
{
    string Str;

    cin>>Str;

    long long int A[26]={0},Sum=0,Flag=0;

    for(long long int i=0;Str[i]!='\0';i++)
    {
        A[Str[i]-'a']++;
        if(A[Str[i]-'a']==1 && Flag==0)
        {
            Sum=Sum+i+1;
            Flag=1;
        }
        else
        {
            if(Flag==1)
            {
                if(A[Str[i]-'a']==1)
                {
                    Sum=Sum+i;
                }
                else
                {
                    Sum=Sum+i-A[Str[i]-'a']+1;
                }
            }
        }
    }

    cout<<Sum<<endl;

    return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,k;
	cin>>n>>k;
	if (n%k==0){
		cout<<"0";
	}
	else {
		cout<<"1";
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [input() for i in range(N)]

if len(W) != len(set(W)):
    print('No')
else:
    for i in range(N - 1):
        b = W[i]
        f = W[i + 1]
        if b[-1] != f[0]:
            print('No')
            break
        else:
            if i == N - 2:
                print('Yes')


Measured memory_bytes: 3060
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        long N = long.Parse(Console.ReadLine());
        long[] t = new long[N];
        long[] x = new long[N];
        long[] y = new long[N];

        for (int i = 0; i < N;i++)
        {
            string[] s = Console.ReadLine().Split(' ');

            t[i] = int.Parse(s[0]);
            x[i] = int.Parse(s[1]);
            y[i] = int.Parse(s[2]);
        }

        if (((x[0] + y[0]) > t[0]) || (t[0] - x[0]-y[0]) % 2 == 1)
        {
            Console.WriteLine("No");
            return;
        }

        for (int i = 1; i < N; i++)
        {
            long time = t[i] - t[i - 1];
            long delta = (x[i] - x[i - 1]) + (y[i] - y[i - 1]);

            if((delta > time)||(time-delta) %2 == 1)
            {
                Console.WriteLine("No");
                return;
            }

        }

        Console.WriteLine("Yes");
        return;

    }
}


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

int main(int argc, char const *argv[])
{
	int x;
	cin >> x;
	for (int i = 1; x != 0; i++) {
		cout << "Case " << i << ": " << x << endl; 
		cin >> x;
	}
	return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t, ans, a;
int main(){
	cin>>n>>a;
	cout<<n*n-a;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc128/tasks/abc128_b

n = int(input())
li = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    li.append((i + 1, s, p))
li.sort(key=lambda x: x[2], reverse=True)
li.sort(key=lambda x: x[1])
for i in li:
    print(i[0])


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

int main() {
	int arr[5];
	while(cin>>arr[0]){
		if(arr[0]==0){
			cout<<1<<'\n';
		}
		for(int i=2;i<=5;i++){
			cin>>arr[i-1];
			if(arr[i-1]==0){
				cout<<i<<'\n';
			}
		}
	}
}

Measured memory_bytes: 3524
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=ReadInt();
            //string[] str = Console.ReadLine().Split(' ');

            int[] nxt = ReadArray(3);
            int n = nxt[0];
            int x = nxt[1];
            int t = nxt[2];

            int ans = n / x * t;
            if (n % x != 0) ans += t;

            Cout(ans);



            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 27524
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int k,a,b;
  cin >> k >> a >> b;
  for (; a<=b; ++a) {
    if ((a%k) == 0) {
      cout << "OK" << '\n';
      return 0;
    }
  }
  cout << "NG" << '\n';
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
int a[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int x=a[i]+a[j];
            int p=lower_bound(a+1,a+1+n,x)-a;
            p--;
            ans+=p-j;
        }
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 3656
def main():
    S, T = input(), input()
    L_S, L_T = len(S), len(T)
    dp = [[(0, (0, 0)) for _ in range(L_T+1)] for _ in range(L_S+1)]
    for i in range(L_S):
        for j in range(L_T):
            if S[i] == T[j]:
                dp[i+1][j+1] = (dp[i][j][0] + 1, (-1, -1))
            else:
                dp[i+1][j+1] = max((dp[i+1][j][0], (0, -1)), (dp[i][j+1][0], (-1, 0)))
    i, j = L_S, L_T
    ans = []
    while i > 0 and j > 0:
        di, dj = dp[i][j][1]
        if di != 0 and dj != 0:
            ans.append(S[i-1])
        i, j = i + di, j + dj
    print(''.join(ans[::-1]))



if __name__ == '__main__':
    main()


Measured memory_bytes: 457480
#include <cstdio>
 
int n, m;
 
int dp[5000];

int main(){
  scanf("%d%d", &n, &m);

  for(int i = 0; i <= (n+1)/2; i++) dp[i] = 1;
  for(int i = (n+1)/2+1, j = 0; i < n; i++, j++) dp[i] = m - (1+2*j);
  
  for(int t = 0; t < 2; t++){ 
    for(int i = 0; i < n; i++){
      long long int tmp = dp[i];
      for(int j = 1; ; j++){
        int k = j * (3 * j - 1) / 2;
        if(k > i) break;
        if(j&1) tmp += dp[i - k];
        else tmp -= dp[i - k];
        k += j;
        if(k > i) break;
        if(j&1) tmp += dp[i - k];
        else tmp -= dp[i - k];
      }
      dp[i] = tmp % m;
    }
  }

  if(n & 1){
    dp[n-1] -= dp[n-1-(n+1)/2];
    if(dp[n-1] >= m) dp[n-1] -= m;
    else if(dp[n-1] < 0) dp[n-1] += m;
  }

  if(dp[n-1] < 0) dp[n-1] += m;
 
  printf("%d\n", dp[n-1]);
 
 
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
const int inf = 0x3f3f3f3f ;
const ll mod = 1e9 + 7 ;
const int maxn = 2e5 + 5 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
int n , a[maxn] ;
map<int , int> mp ;
int main()
{
	r(n) ;
	rep(i , 1 , n)  r(a[i]) ;
	ll ans = 0 ;
	rep(i , 1 , n)
	{
		int y = i - a[i] ;
		if(mp.count(y))  ans += mp[y] ;
		int x = a[i] + i ;
		if(!mp.count(x))   mp[x] = 1 ;
		else  mp[a[i] + i] ++ ;
	}
	wl(ans) , en() ;
	return 0 ;
}

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

int main() {
  int n;
  int c =0;
  cin >> n;
  vector<int> m(n*n);
  vector<int> b(n*n);
  vector<int> d = {-1,1,-n,n};
  for (int i = 0; i < n*n; i++) {
   m.at(i) = min(min(n-i%n-1,n-i/n-1),min(i%n,i/n));
  }
  for (int i = 0; i < n*n; i++) {
    int pi;
    cin >> pi;
    pi -= 1;
    b.at(pi) = 1;
    c += m[pi];
    queue<int> q;
    q.push(pi);
    while (q.empty() == 0){
      int ni;
      ni = q.front();
      q.pop();
      for (int j=0;j<4;j++){
        int dj = d.at(j);
        if ((0<=ni+dj)&&(ni+dj<=n*n-1)){
          if (b.at(ni) == 0){
            if (m.at(ni+dj) > m.at(ni)+1){
              m.at(ni+dj) = m.at(ni)+1;
              q.push(ni+dj);
            }
          }else{
              if (m.at(ni+dj)>m.at(ni)){
                m.at(ni+dj) = m.at(ni);
                q.push(ni+dj);
          }
        }  
        }
      }  
    } 
  }
  cout << c << endl;
}

Measured memory_bytes: 5092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n; cin >> n;
    map<P, ll> a;
    REP(i,n) {
        int tmp; cin >> tmp;
        a[{min(i+1,tmp), max(i+1, tmp)}] ++;
    }
    int ans = 0;
    for(auto x : a) ans += (x.second==2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, m, en, d[105][10], s[15];
ll g(ll p) {
	if (p < 1) return 1;
	else return s[p];
}
ll f(ll p, ll q) {
	ll r = 0;
	if (d[p][q] != -1) return d[p][q];
	if (p == n) return (q == en);
	r = (f(p + 1, q) * g(q - 2) * g(m - q - 1)) % M;
	if (q > 1) r = (r + f(p + 1, q - 1) * g(q - 3) * g(m - q - 1)) % M;
	if (q < m) r = (r + f(p + 1, q + 1) * g(q - 2) * g(m - q - 2)) % M;
	return d[p][q] = r;
}
int main()
{
	ll i;
	cin >> n>> m >> en;
	s[0] = 1;
	s[1] = 2;
	for (i = 2; i <= 10; i++) s[i] = s[i - 1] + s[i - 2];
	memset(d, -1, sizeof(d));
	cout << f(0, 1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int N,Q;
	while(1){
	cin>>N>>Q;if(N==0&&Q==0)break;
	int n;
	int d[10002]={};
	for(int i=0;i<N;i++)
	{cin>>n;
	for(int j=0;j<n;j++)
	{int x;	cin>>x;d[x]++;}
	}
	int c=0;int p=0;
	for(int i=0;i<10001;i++)
		if(d[i]>=Q&&d[i]>c){c=d[i];p=i;}

	cout<<p<<endl;
	}
	return 0;
}


	

Measured memory_bytes: 1204
#include<stdio.h> 
using namespace std;

int main() {
	int n,d[100];
	scanf("%d", &n);
	int i0 = 0; long result = 0;
	for(; i0<n; i0++) {scanf("%d", &d[i0]);}
	for(int i = 0; i < i0-1;i++){
		for(int j = i+1; j < i0;j++){
			result += d[i]*d[j];
		}
	}
	printf("%d", result);
	return 0;
} 

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




int main(){

	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	
	
	return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
signed main() {
	int n, k; cin >> n >> k;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main() {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  if (a+b == c+d) cout<<"Balanced"<<endl;
  else if (a+b >= c+d) cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

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



int main(){
    for(int i = 1; i <= 5; i++){
        int a; cin >> a;
        if(a == 0) { cout << i << endl; return 0; }
    }

}


Measured memory_bytes: 3456
#include<stdio.h>


int main(){
	int n,h,w;
	int a,b;
	scanf("%d %d %d",&n,&h,&w);
	int search = n;
	int count = 0;
	while(search > 0){
		scanf("%d %d",&a,&b);
		if(a >= h && b >= w){
			count++;
		}
		search--;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
	static Scanner sc = new Scanner(System.in);
	static double x1, y1, x2, y2, x3, y3, xp, yp;
	static double S_pab, S_pac, S_pbc, S_abc;
	public static void main(String[] args){
		while(read()){
			slove();
		}
	}
	static boolean read(){
		if(!sc.hasNext())
			return false;
		x1 = sc.nextDouble();
		y1 = sc.nextDouble();
		x2 = sc.nextDouble();
		y2 = sc.nextDouble();
		x3 = sc.nextDouble();
		y3 = sc.nextDouble();
		xp = sc.nextDouble();
		yp = sc.nextDouble();
		//System.out.println(x1+" "+y1+" "+x2+" "+y2+" "+x3+" "+y3+" "+xp+" "+yp);
		return true;
	}
	/**
	 * ¢PAB,¢PAC,¢PBCÌÊÏª¢ABCÆêv·éÆ«A
	 * _PÍOp`ABCÌàÉ éBÊÏÌßûÍA
	 * (0,0)(x1,y1)(x2,y2)ÌðºÅÌÊÏö®
	 * S = (1/2)|x1*y2 - x2*y1|
	 * ðp¢éB
	 * 
	 *	 			B(x2,y2)
	 * 
	 * 						C(x3,y3)
	 * 
	 * 				P(xp,yp)
	 * 
	 * 
	 * 		A
	 * 		(x1,y1)
	 */
	static void slove(){
		S_pab = Math.abs((x1-xp)*(y2-yp)-(x2-xp)*(y1-yp));
		S_pac = Math.abs((x1-xp)*(y3-yp)-(x3-xp)*(y1-yp));
		S_pbc = Math.abs((x2-xp)*(y3-yp)-(x3-xp)*(y2-yp));
		S_abc = Math.abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1));
		//System.out.println("S_abc = "+S_abc);
		//System.out.println("S_pab = "+S_pab);
		//System.out.println("S_pac = "+S_pac);
		//System.out.println("S_pbc = "+S_pbc);
		if(S_abc == S_pab + S_pac + S_pbc){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 12000
import math
range2 = 17
tables = list(map(lambda x: 2.0 ** (range2-x), range(range2+1)))
 
line = input()
N , K = list(map(int, line.split(' ')))
result = 0
for i in range(N):
    dice = i + 1.0
    if dice >= K:
        result += tables[0]
        continue
    val = math.ceil(math.log2(K / dice))
    result += tables[val]
finalResult = result / N / (2**17)
print('{:.12f}'.format(finalResult))

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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 30;
const int MOD = 1e9 + 7;

void solve() {
	int x, n;
	cin >> x >> n;
	vector<bool> used(102);
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		used[y] = true;
	}
	int one = x;
	while (used[one]) one--;
	int two = x;
	while (used[two]) two++;

	if (abs(one - x) <= abs(two - x)) cout << one;
	else cout << two;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 3624
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut t: Vec<Node> = vec![Node { parent: -1, left: -1, right: -1, depth: -1 }; n];

    let mut l: usize = 0;
    for _ in 0..n {
        let v: usize = iterator.next().unwrap().parse().unwrap();
        let d: usize = iterator.next().unwrap().parse().unwrap();
        for j in 0..d {
            let c: isize = iterator.next().unwrap().parse().unwrap();
            if j == 0 {
                t[v].left = c;
            } else {
                t[l].right = c;
            }
            l = c as usize;
            t[c as usize].parent = v as isize;
        }
    }

    let root = t.iter().position(|it| it.parent == -1).unwrap();

    rec(root, 0, &mut t);

    let mut ans = String::new();
    for i in 0..n {
        let node = &t[i];
        ans += &format!("node {}: parent = {}, depth = {}, ", i, node.parent, node.depth);
        if node.parent == -1 {
            ans += &format!("root, ");
        } else if node.left == -1 {
            ans += &format!("leaf, ");
        } else {
            ans += &format!("internal node, ");
        }

        ans += "[";
        let mut count = 0;
        let mut child = node.left;
        while child != -1 {
            if count > 0 {
                ans += ", ";
            }
            ans += &format!("{}", child);
            child = t[child as usize].right;
            count += 1;
        }
        ans += "]\n";
    }

    return ans.trim().to_string();
}

fn rec(id: usize, depth: isize, tree: &mut Vec<Node>) {
    tree[id].depth = depth;
    if tree[id].right != -1 {
        rec(tree[id].right as usize, depth, tree);
    }
    if tree[id].left != -1 {
        rec(tree[id].left as usize, depth + 1, tree);
    }
}

#[derive(Clone)]
struct Node {
    parent: isize,
    left: isize,
    right: isize,
    depth: isize,
}



Measured memory_bytes: 27400
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;

struct j {
	ll v;
	ll c;
	bool operator < (const j& rhs) const{
		return (v-c) > (rhs.v-rhs.c);
	}
};

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <j> arr(n);
	for (int z=0;z<n;z++){
		cin >> arr[z].v;
	}
	for (int z=0;z<n;z++){
		cin >> arr[z].c;
	}
	sort(arr.begin(),arr.end());
	ll answer = 0;
	for (int z=0;z<n;z++){
		if (arr[z].v-arr[z].c > 0){
			answer += arr[z].v-arr[z].c;
		} else {
			break;
		}
	}
	cout << answer << endl;
	cin >> n;
}

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

using namespace std;

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		A[i]--;
	}

	int pos = 0;
	int count = 1;
	while (A[pos] != 1 && count <= N)
	{
		pos = A[pos];

		count++;
	}

	if (count == N + 1)
		count = -1;

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1-i):
        yen=0
        k=n-i-j
        yen=10000*i+5000*j+1000*k
        if yen==y:
            print(i,j,k)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 40300
//
//  abc148_c.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

std::vector<int> permutations;

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

int main() {
  ll a, b;
  std::cin >> a >> b;

  ll lcm = a*b / gcd(a, b);
  std::cout << lcm << std::endl;
  return 0;
}



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

int main() {
  int x = 0;
  string n;
  cin >> n;
  int H = stoi(n);

  for (int i = 0; i < n.size(); i++) {
    x += n.at(i) - '0';
  }

  if (H % x == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3608
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

inline bool ok(string &s, char c) {
    for(int i = 0; i < s.size(); i++) {
        if (s[i] != c) return false;
    }
    return true;
}

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

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int ma = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        ma = max(ma, A[i]);
    }
    if (ma < K) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        int g = A[0];
        for(int i = 1; i < N; i++) {
            g = gcd(g, A[i]);
        }
        if (K % g == 0) {
            cout << "POSSIBLE" << endl;
        } else {
            cout << "IMPOSSIBLE" << endl;
        }
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

int main(){
    string s;
    cin >> s;
    int ans = 1,count = 0;
    if (s[0] != 'A') {
        ans == 0;
    }

    for (int i = 2; i <= s.size()-2;i++) {
        if (s[i] == 'C') {
            count++;
        }
    }
    if (count >1 || count == 0) {
        ans = 0;
    }
    for (int i = 0; i < s.size();i++) {
        if (s[i] != 'A' && s[i] != 'C' && s[i]>= 'A' && s[i]<='Z') {
            ans = 0;
        }
    }
    
    count = 0;
    for (int i = 0;i < s.size();i++) {
        if (s[i] == 'C') {
            count++;
        }
    }

    if (count != 1) {
        ans = 0;
    }

    count = 0;
    for (int i = 0;i < s.size();i++) {
        if (s[i] == 'A') {
            count++;
        }
    }

    if (count != 1) {
        ans = 0;
    }

    if (ans == 1) {
        cout << "AC";
    } else {
        cout << "WA";
    }

}

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

using namespace std;

typedef long long int ll;

int main(void){
  ll N;
  cin >> N;
  if(N%2 == 1){
    cout << 0 << endl;
    return 0;
  }
  
  ll den = 10;
  ll num = 0;
  while (den <= N){
    ll tmp = N/den;
    den = 5*den;
    num = num + tmp;
  }
  
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int n,i,p[200000],a,m;
 
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&p[i]);
   m=p[0];
   for (a=i=1;i<n;i++)
      if (p[i]<=m) {
         a++;m=p[i];
      }
   printf("%d\n",a);
   return 0;
}

Measured memory_bytes: 1024
#include "stdio.h"

int main() {
    int a, b;
	scanf("%d %d", &a, &b);

	if (a == b) {
	    printf("a == b\n");
	} else if (a > b) {
	    printf("a > b\n");
	} else {
	    printf("a < b\n");
	}
}



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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

ll dp[101][101][401];
int N, W;
ll w[100], v[100];

int main() {
	cin >> N >> W;
	REP(i, N) scanf("%lld %lld", w + i, v + i);
	
	memset(dp, -1, sizeof(dp));
	
	ll base = w[0];
	
	dp[0][0][0] = 0;
	
	REP(i, N) {
		REP(j, 101) {
			REP(k, 401) {
				if (dp[i][j][k] == -1) continue;
				
				ll nowW = base * j + k;
				
				if (nowW + w[i] <= W) chmax(dp[i + 1][j + 1][k + (w[i] - base)], dp[i][j][k] + v[i]);
				chmax(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	
	ll ans = 0;
	REP(i, 101) REP(j, 401) {
		ll nowW = base * i + j;
		if (nowW <= W) chmax(ans, dp[N][i][j]);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 32256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 2e6 + 7;
const ll inf = 1e9 + 5;




ll n;

int main()
{
    MohamedMotaz;
    cin >> n;
    ll s = 0;
    f(i, 1, n + 1){
        f(j,1,n + 1){
            f(x, 1,n + 1){
                s += __algo_gcd(x,__algo_gcd(i,j));
            }
        }
    }
    cout << s;
}





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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int ones;
    ones = (n%10);
    if(ones == 3) cout << "bon";
    else if(ones == 0 || ones == 1 || ones == 6 || ones == 8) cout << "pon";
    else cout << "hon";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //long longをllで表せる
 
int main() {
  int n , k , ans;
  cin >> n >> k;
  ans = 0;
  
  vector<int> ju(n);
  
  for (int i = 0; i < n; i++) {cin >> ju.at(i);}
  
  sort(ju.begin(), ju.end());
    
  for (int i = 0; i < k; i++) {ans=ans+ju.at(i);}
  
  cout << ans << endl;}

Measured memory_bytes: 3624
using System;

namespace abc139B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = A - 1;
            int D = B - 1;
            int E = D / C;
            int F = D % C;
            if (F == 0)
                E = E + 0;
            else
                E = E + 1;
            Console.WriteLine(E.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main()
{
    //fast;
    int t=1;
    while(t--)
    {
        int a,b,c,p;
        cin>>a>>b>>c;
        int k;
        cin>>k;
        while(b<=a)
        {
            b*=2;
            k--;
        }
        while(c<=b)
        {
            c*=2;
            k--;
        }
        if(k<0)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
    return 0;
}


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

int cnt=0;

void insertionSort(int* A, int n, int g){
    int i,j,v;
    for(i=g;i<n;i++){
        v = A[i];
        j = i - g;
        while(j>=0&&A[j]>v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellSort(int* A, int n){
    int m=0,*G,three=1,g=1;
    while(g<=n){
        m++;
        three *= 3;
        g += three;
    }
    g -= three;
    three /= 3;
    G = new int[m];
    cout << m << endl;
    for(int i=0;i<m;i++){
        G[i] = g;
        insertionSort(A,n,G[i]);
        if(i>0){
            cout << " ";
        }
        cout << G[i];
        g -= three;
        three /= 3;
    }
    cout << endl;
}

int main(){
    int n,*A,i;
    cin >> n;
    A = new int[n];
    for(i=0;i<n;i++){
        cin >> A[i];
    }
    shellSort(A,n);
    cout << cnt << endl;
    for(i=0;i<n;i++){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6996