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

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;

  rep(i,c - a) cout << "R";
  rep(i,d - b) cout << "U";
  rep(i,c - a) cout << "L";
  rep(i,d - b) cout << "D";
  cout << "D";
  rep(i,c - a + 1) cout << "R";
  rep(i,d - b + 1) cout << "U";
  cout << "L";
  cout << "U";
  rep(i,c - a + 1) cout << "L";
  rep(i,d - b + 1) cout << "D";
  cout << "R";
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
void conv_str(char *str)
{
    int i;
     
    i = 0;
    while (str[i] != '\0'){
        if (str[i] == ' ' || str[i] == '.'){
            str[i] += 0;
        }
        else if (str[i] != 'z'){
            str[i] += 1;
        }
        else {
            str[i] = 'a';
        }
        i++;
    }
}
 
int main(void)
{
    char str[100];
    int next_flag;
    int i, j;
     
    while (scanf("%[a-z .]", str) != EOF){
        getchar();
         
        next_flag = 0;
        for (i = 0; i < 26; i++){
            for (j = 0; j < strlen(str) - 2; j++){
                if (strncmp(&str[j], "this", 4) == 0 || strncmp(&str[j], "that", 4) == 0 || strncmp(&str[j], "the", 3) == 0){
                    printf("%s\n", str);
                    next_flag = 1;
                    break;
                }
            }
            if (next_flag == 1){
                break;
            }
            conv_str(str);
        }
        memset(str, '\0', sizeof(str));
    }
     
    return (0);
}

Measured memory_bytes: 524
def gcd(x, y):
    while x % y > 0:
        x, y = y, x % y
    return y

a,b,c,d=map(int, input().split())

cd = c * d // gcd(c, d)

res_b = b - b // c - b // d + b // cd
a -= 1
res_a = a - a // c - a // d + a // cd

print(res_b - res_a)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int m;
    rep(i,n) if(a[i] == 1) m = i;
    cout << 1+(n-2)/(k-1) << endl;
}


Measured memory_bytes: 640
function Main(input) {
	input = input.split("\n");
	
	var n = parseInt(input[0], 10);
	
	var result = Array(n);
	result.fill(0);
	
	for (var x = 1; x < 105; x++) {
	for (var y = 1; y < 105; y++) {
	for (var z = 1; z < 105; z++) {
	
	
	var a = Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2) + x * y + y * z + z * x;
	result[a - 1] = result[a - 1] + 1;
	}
	}
	}
	
	for (var i = 0; i < n; i++) {
	
	console.log(result[i]);
	
	}
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    Sort(a);Sort(b);

    if(n%2==0){
        cout<<b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1<<endl;
    }
    else{
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4844
N = int(input())

def fact(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr

ans = 0
if N == 1:
    print(0)
    quit()
for i in fact(N):
    temp = i[1]
    x = 1
    while temp > 0:
        x += 1
        temp -= x
        ans += 1
print(ans)

Measured memory_bytes: 9456
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(
            Math.Abs(n[0] - n[1]) < Math.Abs(n[0] - n[2]) ? 
            "A" : "B");
    }
}


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

int main() {
  long long H;
  cin >> H;
  long long ans=1;
  long long cnt=0;
  while(H>=2){
    cnt++;
    H/=2;
  }
  for(long long i = 0; i < cnt; i++){
    ans = ans*2+1;
  }
  cout << ans;
}


Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int A, B, C, D;

  sc.scan(A, B, C, D);

  while (1) {
    C -= B;
    if (C < 1) {
      writeln("Yes");
      return;
    }

    A -= D;
    if (A < 1){
      writeln("No");
      return;
    }
  }
}


Measured memory_bytes: 2716
H, W, D = map(int, input().split())

field = {}
for i in range(H):
    A = list(map(int, input().split()))
    for j in range(W):
        field[A[j]] = (i,j)

Q = int(input())


cum = [0] * (H*W+1)
for i in range(1,D+1):
    tmp = 0
    cum[i] = 0
    n = D
    while i+n <= H*W:
        cum[i+n] = cum[i+n-D] + abs(field[i+n][0] - field[i+n-D][0]) + abs(field[i+n][1] - field[i+n-D][1])
        n += D


for i in range(Q):
    L, R = map(int, input().split())
    print(cum[R] - cum[L])



Measured memory_bytes: 22596
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

char a[10][10];
int xdir[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ydir[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

struct St{
  int c, x, y;
  vector<int> dir;
  St() {}
  St(int _y, int _x, int _c): y(_y), x(_x), c(_c) {}
};
vector<St> vec;

bool mcomp(const St& s1, const St& s2)
{
  if(s1.c == s2.c){
    if(s1.y == s2.y) return s1.x < s2.x;
    return s1.y < s2.y;
  }
  
  return s1.c > s2.c;
}

bool ccomp(const St& s1, const St& s2)
{
  if(s1.c == s2.c){
    if(s1.y == s2.y) return s1.x > s2.x;
    return s1.y > s2.y;
  }

  return s1.c > s2.c;
}

void aprint()
{
  for(int i = 0; i < 8; ++i){
    for(int j = 0; j < 8; ++j)
      cout << a[i][j];
    cout << endl;
  }

  return ;
}

int dfs(int y, int x, int d, int c, char gl)
{
  int dy = y+ydir[d], dx = x+xdir[d];

  if(0 <= dy && dy < 8 && 0 <= dx && dx < 8){
    if(a[dy][dx] == gl) return c;
    if(a[dy][dx] == '.') return 0;

    return dfs(dy, dx, d, c+1, gl);
  }

  return 0;
}

void check(char ch)
{
  int res;

  for(int i = 0; i < 8; ++i)
    for(int j = 0; j < 8; ++j)
      if(a[i][j] == '.'){
	St st = St(i, j, 0);
	for(int k = 0; k < 8; ++k){
	  res = dfs(i, j, k, 0, ch);
	  if(res > 0){
	    st.dir.push_back(k);
	    st.c += res;
	  }
	}
	if(st.c > 0) vec.push_back(st);
      }

  return ;
}

void dfs2(int y, int x, int d, char ch)
{
  if(a[y][x] != ch){
    a[y][x] = ch;
    dfs2(y+ydir[d], x+xdir[d], d, ch);
  }
  return ;
}

void update(St st, char ch)
{
  a[st.y][st.x] = ch;
  for(int i = 0; i < st.dir.size(); i++){
    int dy = st.y+ydir[st.dir[i]], dx = st.x+xdir[st.dir[i]];
    dfs2(dy, dx, st.dir[i], ch);
  }

  return ;
}

void solve()
{
  int cnt = 0, tm = 0;
  bool tn = true;

  for(int i = 0; i < 8; ++i)
    for(int j = 0; j < 8; ++j)
      if(a[i][j] == '.') ++cnt;
  
  for(int i = 0; i < cnt && tm < 2; ++i, tn = !tn){
    vec.clear();
    check((tn? 'o': 'x'));
    if(vec.empty()){
      --i;
      tm++;
      continue;
    }

    if(tn) sort(vec.begin(), vec.end(), mcomp);
    else sort(vec.begin(), vec.end(), ccomp);

    update(vec[0], (tn? 'o': 'x'));
    tm = 0;
  }

  return ;
}

int main()
{
  while(cin>>a[0][0]){
    for(int i = 1; i < 8; ++i) cin >> a[0][i];
    for(int j = 1; j < 8; ++j)
      for(int i = 0; i < 8; ++i) cin >> a[j][i];

    solve();
    aprint();
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        for (;;) {
            a = sc.nextInt();
            b = sc.nextInt();
            if (a == 0 && b == 0)
                break;
            for (int j = 0; j < a; j++) {
                for (int k = 0; k < b; k++) {
                    if(j==0||j==a-1||k==0||k==b-1)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }

            System.out.println();
        }
    }
}



Measured memory_bytes: 35144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;
const int target = 100000;

vector<int> is_prime(target+1, 1);
vector<int> like(target+1, 0);
vector<int> cs(target+1, 0);

void eratosthenes() {
    is_prime[0] = 0;
    is_prime[1] = 0;
    for(int i = 2; i <= target; i++) {
        if(!is_prime[i]) continue;
        for(int j = i*2; j <= target; j += i) is_prime[j] = 0;
    }
}

void like2017() {
   for(int i = 0; i <= target; i++) {
       if(i % 2 == 0) continue;
       if(is_prime[i] && is_prime[(i+1)/2]) like[i] = 1;
   }

   for(int i = 0; i <= target; i++) cs[i+1] = cs[i] + like[i];
}

int main() {
    eratosthenes();
    like2017();

    int Q; cin >> Q;
    vector<int> ret;
    for(int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        r++;
        ret.push_back(cs[r] - cs[l]);
    }

    for(auto &r: ret) cout << r << endl;
}


Measured memory_bytes: 2296
a = 5.times.map { gets.to_i }

k = gets.to_i



def can_communicate(a, k)
  
  (0..4).each do |i|
    
    (0..4).each do |j|
      
      return false if (a[i] - a[j]).abs > k
      
    end
    
  end
  
  true
  
end



puts can_communicate(a, k) ? 'Yay!' : ':('



Measured memory_bytes: 1788
//IDE
#include<bits/stdc++.h>
#include<algorithm>

using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
//#define for(i,a,b) for(int i = a; i < b; i++)
#define ROF(i,a,b) for(int i = a; i > b; i--)
#define REP(i,a) FOR(i,0,a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;
//using vi = vector<int>;
vector< vector<int> >v(24);
ll ma=-1008610086,mi=1008610086;
//int a[1005];
//int cnt[10005];

int main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int k;
    cin>>k;
    string s="ACL";
    while(k--){
        cout<<s;
    }
    cout<<endl;
    return 0;
    
}


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

using namespace std;

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

	int n;
	cin >> n;
	double total = 0;
	while(n--){
		double x; string s;
		cin >> x >> s;
		if(s=="JPY") total += x;
		else total += 380000.0*x;
	}
	cout << fixed << setprecision(5) << total;
	return 0;
}

Measured memory_bytes: 3732
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var KX = ReadSplitInt();
            YesOrNo(500 * KX[0] >= KX[1]); 
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

const ll M=1e9+7;

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    	cin>>a[i];

    ll ans=0,sum=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
    	ans=(ans+(a[i]*sum)%M)%M;
    	sum=(sum+a[i])%M;
    }

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

Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=10000000000;
int main(){
int N;
  cin>>N;
  int64_t sum=0; int64_t MIN=INF;
  for(int i=0;i<N;i++){
  int64_t a,b; cin>>a>>b;
   sum+=a;
    if(b<a){if(b<MIN) MIN=b;}
  }if( MIN==INF)
    cout<<0<<endl;
  else{
  cout<<sum-MIN<<endl;
  }
   return 0;
}

Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    n -= a[i]

if n >= 0 :
    print(n)
else :
    print(-1)


Measured memory_bytes: 9944
import bisect

def brute():
    N=int(input())
    S=input()

    R=[]
    G=[]
    B=[]

    ans=0
    for i,c in enumerate(S):
        if c=="R":
            R.append(i)
        elif c=="B":
            B.append(i)
        else:
            G.append(i)

    for mid in range(1,N-1):
        if S[mid]=="R":
            low_1=bisect.bisect_left(G,mid)
            low_2 =bisect.bisect_left(B,mid)
            high_1=len(G)-low_1
            high_2=len(B)-low_2
        elif S[mid]=="B":
            low_1=bisect.bisect_left(G,mid)
            low_2 =bisect.bisect_left(R,mid)
            high_1=len(G)-low_1
            high_2=len(R)-low_2
        else:#G
            low_1=bisect.bisect_left(B,mid)
            low_2 =bisect.bisect_left(R,mid)
            high_1=len(B)-low_1
            high_2=len(R)-low_2

        dup = sum([1 if a!=b and a!=S[mid] and b!=S[mid]else 0 for a,b in zip(reversed(S[:mid]),S[mid+1:])])
        t = low_1*high_2 + low_2*high_1
        ans+=t
        ans -= dup
    print(ans)

brute()


Measured memory_bytes: 71380
h, w = map(int, input().split())
ans = 0
if h == 1 or w == 1:
    ans = 1
elif h % 2 == 1 and w % 2 == 1:
    ans = (h * w + 1) // 2
else:
    ans = (h * w) // 2
print(ans)

Measured memory_bytes: 3060
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long H, long W, long h, long w) {
    return (H - h) * (W - w);
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long H;
    H = input.front.to!long;
    input.popFront;

    long W;
    W = input.front.to!long;
    input.popFront;

    long h;
    h = input.front.to!long;
    input.popFront;

    long w;
    w = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(H, W, h, w);
    else
        solve(H, W, h, w).writeln;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int ans = 0, b[n] = {};
  for (int i = 0; i < n; i++) {
    int t = 0;
    while (1) {            
      if (a[i] % 2 == 0) {
        t++;
        a[i] /= 2;
      } else {
        b[i] = t;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ans += b[i];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 384
S = int(input())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません

preAns = A[0] < A[1]
count = 0
for a in zip(A[1:], A[2:]):
  temp = a[0] < a[1]
  if (preAns and temp) or (not preAns and not temp):
    count += 1
  preAns = temp
print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int main()
{
	string s;
	int i,j,k,n,m;
	cin>>s;
	if(s[0]!='A'||s[1]<='Z'||s[s.size()-1]<='Z')
	{
		printf("WA\n");
		return 0;
	}
	m=0;
	for(i=2;i<s.length()-1;i++)
	{
		if(s[i]=='C')
		{
			m++;
		}
		else if(s[i]<='Z')
		{
			m=100;
		}
	}
	if(m==1)
	{
		printf("AC\n");
	}
	else
	{
		printf("WA\n");
	}
}


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

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i=0; i<n-2; i++) {
        if (s.substr(i, 3) == "ABC") ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
(n,),*d=[list(map(int,c.split()))for c in open(0)]
for i in range(n-1):
 t=0
 for j in range(i,n-1):c,s,f=d[j];t=[t+(f-t%f)%f,s][t<s]+c
 print(t)
print(0)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mid = sum(A) / 2
    x = 0
    near_length = 0
    for a in A:
        x += a
        if x >= mid:
            if x - mid > abs(x - a - mid):
                near_length = abs(x - a)
            else:
                near_length = x
            break
    ans = int(abs(mid-near_length) * 2)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 79696
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int>a(n);
	int x = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x^=a[i];
	}
	int ans;
	for(int i=0;i<n;i++){
		ans = x ^ a[i];
		printf("%d ", ans);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 4044
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	n := scanInt()
	a := scanInts(n-1)
	c := make([]int, n)
	for i := 0; i < n-1; i++ {
		c[a[i]-1]++
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(w, c[i])
	}
}

Measured memory_bytes: 6668
N,M = map(int,raw_input().split())
ans_done = [[0 for i in range(3)] for j in range(N)]

for i in range(M):
  p,S = raw_input().split()
  p = int(p)-1
  if ans_done[p][0] == 0:
    ans_done[p][0] = p+1
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1
  elif ans_done[p][1] == 2:
    if S == "AC":
      ans_done[p][1] = 1
    else:
      ans_done[p][1] = 2
    if ans_done[p][1] == 2:
      ans_done[p][2] = ans_done[p][2] + 1

pen = 0
ans = 0
for i in ans_done:
  if i[1] == 1:
    ans = ans + 1
    pen = pen + i[2]
print ans,pen


Measured memory_bytes: 20720
#include <bits/stdc++.h>
using namespace std;
//C++ as C#
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) 
{
	int s = 0;
	char f[4];
	while (x) 
	{
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int rowMax[2000];
int columnAccum[2000];
int main()
{
	int h = read(), w = read();
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			if (getchar_unlocked() & 1)
			{
				var sum = columnAccum[j] + rowMax[j];
				if (max < sum) max = sum;
				for (size_t k = j - currentChain; k < j; k++)
					if (rowMax[k] < currentChain) rowMax[k] = currentChain;
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else 
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		for (size_t j = w - currentChain; j < w; j++)
			if (rowMax[j] < currentChain)
				rowMax[j] = currentChain;
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++) 
	{
		var sum = columnAccum[i] + rowMax[i];
		if (max < sum) max = sum;
	}
	writeline(max - 1);
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

template <typename T, typename C>
std::array<std::vector<T>,2> Dijkstra(std::vector<C> g, T istart){
    auto n = g.size();
    priority_queue<std::array<T,2>> q;
    std::vector<T> d(n, numeric_limits<T>::max());
    std::vector<T> prev(n, numeric_limits<T>::max());

    d[istart] = 0;
    q.push(std::array<T,2>{d[istart], istart});

    while(!q.empty()){
        auto u = q.top()[1]; q.pop();
        for(auto v : g[u]){
            auto alt = d[u] + 1;
            if(alt < d[v]){
                d[v] = alt;
                prev[v] = u;
                q.push(std::array<T,2>{-alt, v});
            }
        }
    }
    return std::array<std::vector<T>,2>{d, prev};
}

int main()
{
    ll N, M;
    cin >> N >> M;
    ll ui, vi;
    ll S, T;
    vector<set<ll>> G(3*N);
    for(int i=0;i<M;i++){
        cin >> ui >> vi;
        ui--; vi--;
        G[3*ui+0].insert(3*vi+1);
        G[3*ui+1].insert(3*vi+2);
        G[3*ui+2].insert(3*vi+0);
    }
    cin >> S >> T;
    S--; T--;

    auto r = Dijkstra(G, 3*S);

    if(r[0][3*T]==numeric_limits<ll>::max()){
        cout<<"-1"<<endl;
    }else{
        cout<<r[0][3*T]/3<<endl;
    }

    return 0;
}



Measured memory_bytes: 65920
import numpy as np
N, M, Q = map(int, input().split())
table = np.zeros((N, N), np.int64)
for _ in range(M):
    L, R = map(lambda n: int(n) - 1, input().split())
    table[L][R] += 1
table = np.rot90(np.rot90(table, k=-1).cumsum(axis=0).cumsum(axis=1), k=1)
for _ in range(Q):
    p, q = map(lambda n: int(n) - 1, input().split())
    print(table[p][q])

Measured memory_bytes: 18276
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = 
    loop 
    where
    loop = do
        ns@[x,y] <- readDigits
        unless (x == 0 && y == 0) $ do
            putStrLn . unwords . map show $ sort ns
            loop

Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();

			int x = scanner.nextInt();
			int y = scanner.nextInt();

			long sum = a * x + b * y;

			int abmin = Math.min(x, y);
			long temp = c * abmin * 2;
			if (x > y) {
				temp += a * (x - y);
			} else if (x < y) {
				temp += b * (y - x);
			}
			if (temp < sum) {
				sum = temp;
			}

			int abmax = Math.max(x, y);
			temp = abmax * 2 * c;
			if (temp < sum) {
				sum = temp;
			}

			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 21716
import {stdin} from 'process';
let input = "";
stdin.on('data', x => {input += x});
stdin.on('end', () => {
    let [n, aline] = input.split('\n');
    let alist = aline.split(' ')
        .map(x=>x.trim()).map(x=>parseInt(x));
    let count = 0;
    for (let a of alist) {
        while (a % 2 === 0) {
            a = a / 2;
            count += 1;
        }
    }
    console.log(count);
});

Measured memory_bytes: 10808
#include <iostream>
#include <string>

#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

#include <algorithm>


int main()
{
	int H, W;
	int N;
	std::map<int, int> pos;
	std::vector<int> ypos;

	std::cin >> H >> W >> N;
	ypos.resize(H);
	for (int i = 0; i < H; ++i)
		ypos[i] = -1;
	for (int i = 0; i < N; ++i) {
		int x, y;
		std::cin >> x >> y;
		--x;
		--y;
		if (y > x)
			continue;
		int z = x - y;
		if (ypos[z] == -1)
			ypos[z] = x;
		else if (ypos[z] > x)
			ypos[z] = x;
	}
	for (int i = 0; i < H; ++i) {
		if (ypos[i] != -1)
			pos[ypos[i]] = i;
	}

	int aoki_pass = 0;
	for (auto it = pos.begin(); it != pos.end(); ++it) {
		if (it->second == aoki_pass) {
			++aoki_pass;
			continue;
		} else {
			std::cout << it->first << "\n";
			return 0;
		}
	}
	std::cout << H << "\n";
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define MOD 1000000007 
#define invp(a,p) pom(a,p-2,p)
ll pom(ll a,ll n,int m){
  ll x=1;
  for(a%=m;n;n/=2)
    n&1?x=x*a%m:0,a=a*a%m;
  return x;}
ll fact[3000];
ll choose(int n,int r){
  if(n-r<0||r<0)
    return 0;
  return fact[n]*invp(fact[n-r],MOD)%MOD*invp(fact[r],MOD)%MOD;
}
int i;
int main(){
  int k,n;
  fact[0]=1;
  for(i=1;i<2100;i++)
    fact[i]=fact[i-1]*i%MOD;
  scanf("%d%d",&n,&k);
  for(i=1;i<k+1;i++)
    printf("%lld\n",choose(n-k+1,i)*choose(k-1,i-1)%MOD);
}



Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut v = vec![];
    for a in a {
        let p = v.reverse_lower_bound(&a);
        if p == v.len() {
            v.push(a);
        } else {
            v[p] = a;
        }
    }

    println!("{}", v.len());
}

trait BinarySearch<T: Ord> {
    fn bsearch<F: std::ops::Fn(&T, &T) -> bool>(&self, x: &T, cmp: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize {
        self.bsearch(x, |m, x| m >= x)
    }
    fn upper_bound(&self, x: &T) -> usize {
        self.bsearch(x, |m, x| m > x)
    }
    fn reverse_lower_bound(&self, x: &T) -> usize {
        self.bsearch(x, |m, x| m < x)
    }
    fn reverse_upper_bound(&self, x: &T) -> usize {
        self.bsearch(x, |m, x| m <= x)
    }
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn bsearch<F: std::ops::Fn(&T, &T) -> bool>(&self, x: &T, cmp: F) -> usize {
        let mut l = -1 as i64;
        let mut r = self.len() as i64;
        while r - l > 1 {
            let m = ((l + r) / 2) as usize;
            if cmp(&self[m], x) {
                r = m as i64;
            } else {
                l = m as i64;
            }
        }
        r as usize
    }
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int N;
vector <pair <int, int> > G[100005];
int V[100005], Ap[100005];
int DP[(1 << 16) + 5];
void Read()
{
    cin >> N;
    for(int i = 1; i < N; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        ++x;
        ++y;
        G[x].push_back(make_pair(y, c));
        G[y].push_back(make_pair(x, c));
    }
}

void precalcV()
{
    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j < G[i].size(); j++)
        {
            int neighb = G[i][j].first;
            V[i] ^= G[i][j].second;
        }
    }
}

void precalcDP()
{
    for(int conf = 1; conf < (1 << 16); conf++)
    {
        vector <int> Aux;
        DP[conf] = -1;
        for(int j = 0; j < 16; j++)
            if((conf & (1 << j)))
            {
                Aux.push_back(j);
            }
        int sz = Aux.size();
        for(int k = 1; k < (1 << sz); k++)
        {
            int sum = 0, c = 0;
            for(int j = 0; j < sz; j++)
                if((k & (1 << j)))
                    sum ^= Aux[j], c += (1 << Aux[j]);
            if(sum == 0 && DP[conf ^ c] != -1)
                DP[conf] = max(DP[conf], DP[conf ^ c] + 1);
        }
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        Ap[V[i]]++;
    }
    ans += Ap[0];
    int c = 0;
    for(int i = 1; i <= 15; i++)
    {
        ans += Ap[i] / 2;
        Ap[i] %= 2;
        if(Ap[i] == 1)
            c += (1 << i);
    }
    if(DP[c] != -1)
        ans += DP[c];
    cout << N - ans << "\n";
}
int main()
{
    Read();
    precalcV();
    precalcDP();
    return 0;
}


Measured memory_bytes: 8832
def main():
  a, b, c, k = map(int, input().split())

  if k <= a:
    print(1 * k)
    return
  else:    
    if k <= a + b:
      print(1 * a)
      return
    
    if k <= a + b + c:
      count = k
      ans = 1 * ( a )
      count -= a

      ans += 0 * ( b )
      count -= b

      if count <= c:
        ans -= 1 * count
      else:
        ans -= 1 * c

      print(ans)
      return

if __name__ == "__main__":
  main()

Measured memory_bytes: 9140
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    for (int c = M / N; c > 0; c--) {
      if (M % c == 0) {
        System.out.println(c);
        return;
      }
    }
  }
}

Measured memory_bytes: 23764
n, x = map(int, input().split())
A = [int(i) for i in input().split()]
D = []

for i in range(n):
    D.append(abs(x - A[i]))
    
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

for i in range(n - 1):
    D[i + 1] = gcd(D[i], D[i + 1])
    
print(D[-1])

Measured memory_bytes: 14224
//Yazar: Mehmet Kutay Bozkurt
//Auther: Mehmet Kutay bozkurt
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
typedef long long int lo;
#define pb push_back
#define st first
#define nd second
lo a,b,c,d,e,n,m,x,y,z,a1[500005],a2[100005],k,t;
char c1,c2,c3,c4;
string s1,s2,s3,s4,den[3];
bool av=false;
map <char,lo> mp;
vector <lo> v;
vector <lo> v1;
map <lo,lo> dp;
lo f(lo nn){
    if(nn==1) return 1;
    if(nn<1) return 0;
    if(dp[nn]!=0)return dp[nn];
    return dp[nn]=f(nn/2)+f(nn/2)+1;
}
int main() {
    // freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
	cin>>a;
    cout<<f(a);
    return 0;
}

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

using namespace std;

//////////////////////////////////////////////////
class SegmentTree
{
public:
    typedef long long Int;
    static const Int DEFAULT_VALUE = 1LL << 60; 
    vector<Int> data;
    Int N;

    inline Int func(Int x, Int y) {
        return min(x, y);
    }

    SegmentTree(vector<Int> vec) {
        Int x = 1;
        while (x < (Int)vec.size()) {
            x *= 2;
        }
        this->N = x;
        data = vector<Int>(2 * x, DEFAULT_VALUE);
        for (int i = 0; i < (Int)vec.size(); i++) {
            update(i, vec[i]);
        }
    }

    Int get(Int l, Int r) {
        return getSub(l, r, 0, N, 1);
    }

    void update(Int index, Int val) {
        Int v = index + N;
        data[v] = val;

        v /= 2;
        while (v > 0) {
            data[v] = func(data[2 * v], data[2 * v + 1]);
            v /= 2;
        }
    }

    Int getSub(Int l, Int r, Int myl, Int myr, Int v) {
        if (myr <= l || r <= myl) return DEFAULT_VALUE;
        if (l <= myl && myr <= r) return data[v];

        Int mid = (myl + myr) / 2;
        return func(getSub(l, r, myl, mid, 2 * v),
                   getSub(l, r, mid, myr, 2 * v + 1));
    }
};
//////////////////////////////////////////////////

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree seg(vector<long long>(n, (1LL << 31) - 1));
    for (int i = 0; i < q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.get(x, y + 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6020
import sys
a = int(input())
numlist = [a]
for i in range(2,1000):
    if a % 2 ==0:
        a //= 2
        numlist.append(a)
    else:
        a = a*3 + 1
        numlist.append(a)
#print(numlist)
kind = {}
count = 0
for s in numlist:
    count += 1
    if s in kind:
        print(count)
        sys.exit()
    else:
        kind[s] = 1

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"time"
)

func main() {
	S := nextString()
	YYMM := "0601"
	MMYY := "0106"
	t1, err1 := time.Parse(YYMM, S)
	t2, err2 := time.Parse(MMYY, S)
	if err1 == nil && err2 == nil {
		fmt.Println("AMBIGUOUS")
		log.Println(t1, t2)
	} else if err1 == nil && err2 != nil {
		fmt.Println("YYMM")
		log.Println(t1)
	} else if err1 != nil && err2 == nil {
		fmt.Println("MMYY")
		log.Println(t2)
	} else if err1 != nil && err2 != nil {
		fmt.Println("NA")
	}
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type pairs []Pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
N = int(input())
A = [int(_) for _ in input().split()]
A.sort()
while len(A) != 1:
    k = 0
    for i in range(1,len(A)):
        if A[i-k]%A[0] == 0:
            del A[i-k]
            k += 1
        else:
            A[i-k] = A[i-k] % A[0]
    A.sort()
print(A[0])

Measured memory_bytes: 14252
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int a, b;
			String op1;
			a = sc.nextInt();
			op1 = sc.next();
			b = sc.nextInt();
			char op = op1.charAt(0);

			if (op == '+') {
				System.out.println(a + b);
			} else if (op == '-') {
				System.out.println(a - b);
			} else if (op == '*') {
				System.out.println(a * b);
			} else if (op == '/') {
				System.out.println(a / b);
			} else {
				break;
			}
		}
	}
}



Measured memory_bytes: 26304
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    REP(i, 0, len) {
        REP(j, i, len) {
            //cout << i << " " << j << endl;
            string tmp = S;
            auto itf = tmp.begin() + i;
            auto ite = tmp.begin() + j;
            tmp.erase(itf, ite);
            
            if (tmp == "keyence") {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}


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

int n, c, a[32], b[32], dp[32][65536], st[32][65536];

int bit_count(int x){
	int res = 0;
	for(int i = 0 ; i < 16 ; i++ ){
		if( x & (1 << i) ) res++;
	}
	return res;
}

int main(){	
	while( cin >> n >> c, n || c ){
		fill(a, a + 32, 0);
		fill(b, b + 32, 0);
		for(int i = 0 ; i < n ; i++ ){
			for(int j = 0 ; j < 16 ; j++ ){
				int e;
				cin >> e;
				a[i] |= e << j;
			}
		}
		for(int i = 0 ; i < c ; i++ ){
			for(int j = 0 ; j < 16 ; j++ ){
				int e;
				cin >> e;
				b[i] |= e << j;
			}
		}
		b[c] = 0;
		c++;
		
		for(int i = 0 ; i < c ; i++ ){
			for(int j = 0 ; j < (1 << 16) ; j++ ){
				st[i][j] = bit_count(j & b[i]);
			}
		}
		
		for(int i = 0 ; i < 32 ; i++ ) fill(dp[i], dp[i] + 65536, -1);
		dp[0][0] = 0;
		int ans = 0;
		for(int i = 0 ; i < n ; i++ ){
			for(int j = 0 ; j < (1 << 16) ; j++ ){
				if( dp[i][j] == -1 ) continue;
				
				int nx = j | a[i];
				for(int k = 0 ; k < c ; k++ ){
					int tx = nx & ~b[k];
					dp[i+1][tx] = max(dp[i+1][tx], dp[i][j] + st[k][nx]);
					ans = max(ans, dp[i+1][tx]);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 17544
// ※※※ 解答不能 ※※※
// tourist氏.
// https://atcoder.jp/contests/cf16-relay-open/submissions/8967185
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    int n;
    scanf("%d", &n);
    const int MAX = 86400;
    vector<int> bal(MAX);
    int t = 0, add = 0;
    rep(i, n){
        int a, b;
        scanf("%d %d", &a, &b);
        t = (t + a) % MAX;
        bal[t] += 1;
        int nt = (t + 3 * 3600 + 1) % MAX;
        bal[nt] -= 1;
        if(nt < t) ++add;
        t = (t + b) % MAX;
    }
    int ans = 0, cur = 0;
    rep(i, MAX){
        cur += bal[i];
        ans = max(ans, cur);
    }
    printf("%d\n", ans + add);
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int a[3]={0};
  for(int i=0;i<n;i++){
    if(s[i]=='a') a[0]++;
    else if(s[i]=='b') a[1]++;
    else a[2]++;
  }
  sort(a,a+3);
  cout << (a[2]-a[0]<=1?"YES":"NO") << endl;
}


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

using namespace std;

int main() {
    int n,k;

    cin >> n >> k;

    vector<int> children(n);
    for (int i = 0; i < n; i++) {
        children[i] = 0;
    }

    for (int i = 0; i < k; i++) {
        int count;
        cin >> count;
        for (int j = 0; j < count; j++) {
            int index;
            cin >> index;
            children[index - 1] += 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (children[i] == 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
/*** I came, I saw, I conquered. ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;typedef unsigned long long ull;
#define sc(a) cin >> a
#define pf(a) cout << a << endl
#define forIn(arr, num) for(ll i = 0; i < num; i++) cin >> arr[i];
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define mod 1000000007
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define GET_SET_BITS(a) (__builtin_popcount(a))
#define GET_SET_BITSLL(a) ( __builtin_popcountll(a))
#define GET_TRAIL_ZERO(a) (__builtin_ctz(a))
#define GET_LEAD_ZERO(a) (__builtin_clz(a))
#define GET_PARITY(a) (__builtin_parity(a))
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
void go() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
/*----------------------------------------------------------------*/
void solve() {
    int n;
    cin >> n;

    vector<int> a, b;
    int x, y;
    for(int i = 0;i < n;i++) {
        cin >> x >> y;
        a.pb(x + y);
        b.pb(x - y);
    }

    sort(all(a));
    sort(all(b));

    pf(max(a.back() - a.front(), b.back() - b.front()));
}

int main() {
    go();
    solve();
    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string ans = "YAKI";
    string S;
    cin >> S;
    if (S.substr(0, 4) == ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i, s, l) for (int i = s; i < l; i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long, long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();
    ll n;
    cin>>n;
    unordered_map<int,int> mp;
    r(i,0,n-1)
    {
    	int x;
    	cin>>x;
    	mp[x]++;
    }
    r(i,1,n+1)
    cout<<mp[i]<<endl;
  
    return 0;
}

Measured memory_bytes: 11492
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n; i++)

#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef long long ll;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6 + 13;
//=======================
vi g[N];
int a[N];
//=======================

void solve()
{
  int x;
  cin >> x;
  if (x >= 400 && x < 600)
    cout << 8 << endl;
  else if (x < 800)
    cout << 7 << endl;
  else if (x < 1000)
    cout << 6 << endl;
  else if (x < 1200)
    cout << 5 << endl;
  else if (x < 1400)
    cout << 4 << endl;
  else if (x < 1600)
    cout << 3 << endl;
  else if (x < 1800)
    cout << 2 << endl;
  else if (x < 2000)
    cout << 1 << endl;
}

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

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int t = 1;

  // cin >> t;

  while (t--)
  {
    solve();
  }

  return 0;
}

Measured memory_bytes: 50528