akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[200010];
int n;
long long dp[2][3000];
long long ans;
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) {
		dp[1][s[i] - '0'] = 1;
		for (int j = 2018; j >= 0; j--) dp[1][(j * 10 + s[i] - '0') % 2019] += dp[0][j];
		ans += dp[1][0];
		for (int j = 2018; j >= 0; j--) dp[0][j] = dp[1][j], dp[1][j] = 0;
	}
	cout << ans;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int x;

int main() {
	cin >> x;
	
	cout << (x < 1200 ? "ABC" : "ARC") << endl;
	
	return 0;
}


Measured memory_bytes: 256
let [| l; m; |] = stdin.ReadLine().Split() |> Array.map int

let rec lToM i =
    seq{
        match m - i <= 0 with
        |true -> () 
        |false -> 
            yield i
            yield! lToM (i+1)
        }

match lToM l |> Seq.exists (fun x -> x % 2019 = 0 ) with 
|true -> 0
|false -> 
    [for i in l..m do for j in i+1..m -> i,j] |> List.map (fun (x1, x2) -> (x1 % 2019, x2 % 2019))
    |> List.map (fun (x1,x2) -> x1 * x2 % 2019)
    |> List.min
|> stdout.WriteLine


Measured memory_bytes: 246024
x,y=gets.split.map(&:to_i)
a=[4,6,9,11]
b=[2]
c=[1,3,5,7,8,10,12]
flag=false
if a.include?(x) and a.include?(y)
	flag=true
elsif b.include?(x) and b.include?(y)
	flag=true
elsif c.include?(x) and c.include?(y)
	flag=true
end

puts flag ? "Yes":"No"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    set<ll> st;
    map<ll,ll> mp;
    ll a[n];rep(i,0,n){
        cin>>a[i];
        st.insert(a[i]);
        mp[a[i]]++;
    }
    
    if(*st.begin()==0){
        if(st.size()==1){
            cout<<"Yes"<<endl;
            return 0;
        }
        if(n%3!=0){
            cout<<"No"<<endl;
            return 0;
        }
        if(st.size()!=2){
            cout<<"No"<<endl;
            return 0;
        }
        if(mp[*st.begin()]==n/3){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
        return 0;
    }
    if(n%3!=0){
        cout<<"No"<<endl;
        return 0;
    }
    if(st.size()!=3){
        cout<<"No"<<endl;
        return 0;
    }
    vector<ll> v;
    for(auto itr=st.begin();itr!=st.end();itr++){
        ll u=*itr;
        if(mp[u]!=n/3){
            cout<<"No"<<endl;
            return 0;
        }
        v.push_back(u);
    }
    auto it=st.begin();
    v.push_back(*st.begin());
    it++;
    v.push_back(*it);
    rep(i,1,4){
        ll y=v[i-1]^v[i+1];
        if(y!=v[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 9344
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    int n;
    string order,str;
    set<string> set;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> order >> str;
        if(order=="insert"){
            set.insert(str);
        }
        else{
            if(set.find(str)!=set.end()){
                cout << "yes" << endl;
            }
            else cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27812
#include<stdio.h>
int main(void)
{
	int i,j;
	int data[101];
	int n,q,m,x,max,mi;
	
	while(1)	{
		scanf("%d %d",&n,&q);
		if(n==0 && q==0)	break;
		for(i=1;i<100;i++)	{
			data[i]=0;
		}
		for(i=0;i<n;i++)	{
			scanf("%d",&m);
			for(j=0;j<m;j++)	{
				scanf("%d",&x);
				data[x]++;
			}
		}
		max=-1;
		for(i=1;i<100;i++)	{
			if(data[i]>max)	{
				max=data[i];
				mi=i;
			}
		}
		if(max<q)	{
			mi=0;
		}
		printf("%d\n",mi);
	}
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    unordered_map<string, int> m;
    while(n--){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long ans = 0;
    for(auto p: m){
        ll x = (ll)p.second - 1;
        ans += (x+1)*x/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 10660
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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


Measured memory_bytes: 3056
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	char x;
	cin >> x;
	switch (x)
	{
		case 'A' : PRINT(T); break;
		case 'T' : PRINT(A); break;
		case 'C' : PRINT(G); break;
		case 'G' : PRINT(C); break; 
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXN = 2e5;
int N;
int64_t A[MAXN], F[MAXN], K;

bool isOK(int64_t th) {
  int64_t sum = 0;
  for(int i = 0; i < N; ++i) {
    int64_t a = A[i], f = F[N-1-i];
    if(a*f <= th) continue;
    int64_t newa = th/f;
    sum += (a - newa);
    if(sum > K) return false;
  }
  return true;
}

int main() {
  std::cin >> N >> K;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  for(int i = 0; i < N; ++i) std::cin >> F[i];
  std::sort(A, A+N);
  std::sort(F, F+N);
  int64_t ng = -1, ok = 0;
  for(int i = 0; i < N; ++i) ok = std::max(ok, A[i]*F[N-1-i]);
  while(ok - ng > 1) {
    int64_t mid = (ok+ng)/2;
    if(isOK(mid)) ok = mid; else ng = mid;
  }
  fin(ok);
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    string str;

    cin >> str;

    for (int i = 0; i < str.size(); i++){
        if (str[i] - 3 >= 'A'){
            printf("%c", str[i]-3);
        }
        else {
            printf("%c", str[i] - 3 + 26);
        }
    }
    puts("");

    return (0);
}

Measured memory_bytes: 1164
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

x3 = x2 - b
y3 = y2 + a

x4 = x3 - a
y4 = y3 - b

print(x3, y3, x4, y4)

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

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    ll p = 0, q = 0;
    for (int i = 0; i < n; i++) {
        if (a[i]-b[i]>0) {
            q += a[i]-b[i];
        }
        else {
            p += (b[i]-a[i]+1)/2;
            q += (b[i]-a[i])%2;
        }
    }

    if (p >= q)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int n, a[200000];
  bool f=false;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1)f=true;
  }
  if(f)cout << "first" << endl;
  else cout << "second" << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(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 Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

int main()
{
	ll n,kai=1,ans=0;
	cin >> n;
	vll x(n),c(n);
	rep(i,n) cin >> x[i];
	rep(i,n-1) kai=kai*(i+1)%mod;
	for(ll i=1;i<n;i++){
		c[i]=kai*powmod(i,mod-2)%mod;
		c[i]=(c[i]+c[i-1])%mod;
	}
	rep(i,n-1){
		ans+=(x[i+1]-x[i])*c[i+1];
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
int N,T;
vector<pair<int,int>> p;
bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> T;
  for(int n = 0; n < N ; n++){
    int c,t;
    cin >> c >> t;
    if(t > T){
      continue;
    }
    p.emplace_back(make_pair(c,t));
  }
  sort(p.begin(),p.end());
  if(p.size() == 0){
    cout << "TLE" << endl;
  }
  else{
    cout << p[0].first << endl;
  }

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    class P
    {
        public int index;
        public P parent;
        public P rightBro;
        public P leftChild;
        public P(int index)
        {
            this.index = index;
        }
        public override string ToString()
        {
            var state = "";
            if (parent.index == -1) state = "root";
            else if (leftChild.index == -1) state = "leaf";
            else state = "internal node";
            var chi = new List<int>();
            var c = leftChild;
            while (c.index != -1)
            {
                chi.Add(c.index);
                c = c.rightBro;
            }
            var depth = 0;
            var p = parent;
            while (p.index != -1)
            {
                depth++;
                p = p.parent;
            }
            return $"node {index}: parent = {parent.index}, depth = {depth}, {state}, [{string.Join(", ", chi.ToArray())}]";
        }
    }
    private static readonly P NIL = new P(-1);
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ps = new P[num];
        for (var i = 0; i < num; i++)
        {
            ps[i] = new P(i);
            ps[i].parent = NIL;
            ps[i].rightBro = NIL;
            ps[i].leftChild = NIL;
        }
        for (var i = 0; i < num; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            if (input[1] != 0)
                ps[input[0]].leftChild = ps[input[2]];
            for(var j = 0; j < input[1]; j++)
            {
                ps[input[2 + j]].parent = ps[input[0]];
                if (j != input[1] - 1)
                    ps[input[2 + j]].rightBro = ps[input[3 + j]];
            }
        }
        WriteLine(string.Join("\n", ps.Select(p => p.ToString())));
        
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 62148
import java.util.Scanner;
import java.util.Arrays;
class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
 
String S = scan.next();

  if ("ABC".equals(S)){
    System.out.println("ARC");
  }
  else{
  System.out.println("ABC");
  }
 }
}

Measured memory_bytes: 35600
using System;

namespace B___0_or_1_Swap
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] w = Console.ReadLine().Split();

            int[] p = new int[n + 1];
            p[0] = 0;

            int swap1 =0,swap2=0;
            for(int i=1;i<n+1;i++)
            {
                int nw = int.Parse(w[i-1]);
                if(i == nw)
                {
                    p[i] = nw;
                }
                else
                {
                    if (swap1 == 0)
                    {
                        swap1 = nw;
                    }
                    else
                    {
                        swap2 = nw;
                    }
                }
            }

            if (swap1 > 0)
            {
                p[swap1] = swap1;
            }
            if (swap2 > 0)
            {
                p[swap2] = swap2;
            }
           
            for(int i =1;i<n+1;i++)
            {
                if(p[i] != i)
                {
                    Console.WriteLine("NO");
                    Environment.Exit(0);
                }
            }
            Console.WriteLine("YES");
        }
    }
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n+1],b[n];
	for (int i = 0; i < n+1; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
	}
	long long ans=0LL;
	for (int i = 0; i < n; ++i)
	{
		if (a[i]<b[i])
		{
			ans+=a[i];
			b[i]-=a[i];
			if (a[i+1]<b[i])
			{
				ans+=a[i+1];
				a[i+1]=0LL;
			}
			else
			{
				ans+=b[i];
				a[i+1]-=b[i];
			}
		}
		else
		{
			ans+=b[i];
			a[i]-=b[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.lang.Math;
import java.util.Scanner;
import java.util.Arrays;

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

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

        int[][] gates = new int[2][M];

        for (int i = 0; i < M; i++) {
            gates[0][i] = sc.nextInt();
            gates[1][i] = sc.nextInt();
        }

        Arrays.sort(gates, (a, b) -> Integer.compare(a[0], b[0]));

        int ansLeft = Integer.MIN_VALUE;
        int ansRight = Integer.MAX_VALUE;

        for (int i = 0; i < M; i++) {
            ansLeft = Math.max(ansLeft, gates[0][i]);
            ansRight = Math.min(ansRight, gates[1][i]);
        }

        System.out.println(Math.max(0, ansRight - ansLeft + 1));
    }
}


Measured memory_bytes: 66896
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

from itertools import permutations


def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    p_list = [int(x) for x in sys.stdin.readline().split()]
    q_list = [int(x) for x in sys.stdin.readline().split()]
    logger.debug('{}'.format([N, p_list, q_list]))

    perm = list(permutations(range(1, N + 1)))

    a = perm.index(tuple(p_list))
    b = perm.index(tuple(q_list))

    print(abs(a - b))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 3 2
3 1 2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1"""
        output = """17517"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3
1 2 3
1 2 3"""
        output = """0"""
        self.assertIO(input, output)


Measured memory_bytes: 9148
n = int(input())

base = n // 1.08
cands = [base-1, base, base+1]
flag = False
for cand in cands:
    if cand * 1.08 >= n and n > cand * 1.08 - 1:
        print(int(cand))
        flag = True
        break

if not flag:
    print(':(')

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool check(map<int,int> a){
	if(a.size() == 2){
		vector<ip> t(2);
		int i = 0;
		for(auto x:a){
			t[i].first = x.first;
			t[i].second = x.second;
			++i;
		}
		ip x = t[0], y = t[1];
		if(max(x.second, y.second) != 2*min(x.second, y.second)){return false;}
		int nax, nin;
		if(x.second>y.second){
			nax = x.first;
			nin = y.first;
		}else{
			nax = y.first;
			nin = x.first;
		}
		// printf("[nax,nin] -> [%d,%d]\n",nax,nin);
		// int nax = max(t[0].first, t[1].first);
		// int nin = min(t[0].first, t[1].first);
		if((nax^nax) == nin && (nax^nin) == nax){return true;}
		else return false;
	}
	if(a.size() == 3){
		vector<int> t(3);
		vector<int> k(3);
		int i = 0;
		for(auto x:a){
			t[i] = x.first;
			k[i] = x.second;
			++i;
		}
		if(k[0] == k[1] && k[1] == k[2] && (t[1]^t[2]) == t[0]){return true;}
		else return false;
	}
	return false;
}

int main(){
	int N; cin>>N;
	vector<int> in(N);
	rep(i,N)cin>>in[i];
	map<int,int> cnt;
	rep(i,N){
		cnt[in[i]]++;
	}
	if(cnt.size() == 1 && cnt.count(0) == 1){cout<<"Yes"<<endl; return 0;}
	if(N%3 != 0){cout<<"No"<<endl; return 0;}
	if(cnt.size() <= 3 && check(cnt)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s[10],k,flag=0;
    for(int i=0;i<5;i++)
        scanf("%d",&s[i]);
    scanf("%d",&k);
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(s[j]-s[i]>k)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            break;
    }
    if(flag==0)
        printf("Yay!\n");
    else
        printf(":(\n");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,a=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    a+=800;
    for(j=1;j<10;j++){
      if(j*15==i)a-=200;
    }
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 128
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
constexpr int D=365;
constexpr int beam = 250;
int c[26];
int s[D][26];
int ans[D];

struct State{
    int val = 0;
    int out[D]={0};
    int cnt[26]={0};
};

constexpr bool operator< (const State &a, const State &b){
    return a.val<b.val;
}
constexpr bool operator> (const State &a, const State &b){
    return a.val>b.val;
}


void solve(int ca){
    int waste;
    scanf("%d",&waste);
    for (int i = 0; i < 26; ++i) {
        scanf("%d",c+i);
    }
    for (auto & i : s) {
        for (int & j : i) {
            scanf("%d",&j);
        }
    }

    priority_queue<State> pq[2];
    pq[0].push(State());
    for (int i = 0; i < D; ++i) {
        int prev=i&1,next = prev^1;
        for (int j = 0; !pq[prev].empty()&&j < beam; ++j) {
            auto state = pq[prev].top();
            pq[prev].pop();
            int dec=0;
            for (int k = 0; k < 26; ++k) { 
                state.cnt[k]++;
                dec+=c[k]*state.cnt[k];
            }
            for (int k = 0; k < 26; ++k) {
                const int inc = c[k]*state.cnt[k];
                const int tmp = state.cnt[k];
                const int tmp_val = state.val;
                state.val = state.val-dec+inc+s[i][k];
                state.cnt[k]=0;
                state.out[i]=k;
                pq[next].push(state);
                state.cnt[k]=tmp;
                state.val = tmp_val;
            }
        }
        pq[prev]=priority_queue<State>();
    }
    auto best = pq[D&1].top().out;
    for (int i = 0; i < D; ++i) {
        printf("%d\n",best[i]+1);
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 35720
import math
N, D = map(int, input().split(' '))

X = []

for _ in range(N):
    X.append([int(x) for x in input().split(' ')])


def kyori(x, y, D):
    sum = 0
    for i in range(D):
        sum += (x[i] - y[i]) * (x[i] - y[i])
    return math.sqrt(sum)


count = 0
for i in range(N):
    for j in range(N):
        if i < j:
            if float.is_integer(kyori(X[i], X[j], D)):
                count += 1

print(count)

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

const int MAXN = 2333;
const ll INF = 2e9;
int n;
int dp[MAXN][MAXN];
int a[MAXN + MAXN], c[MAXN + MAXN];
int p1[MAXN], p0[MAXN];
int t[MAXN + MAXN];

void add (int k, int d) { while (k <= n + n) { t[k] += d; k += k & -k; } }
int sum (int k) { int s = 0; while (k > 0) { s += t[k]; k -= k & -k; } return s; }

int main() {
	cin >> n;
	rep(i, 1, n + n) {
		char ch;
		cin >> ch >> a[i];
		if (ch == 'W') {
			p0[a[i]] = i;
			c[i] = 0;
		}
		else {
			p1[a[i]] = i;
			c[i] = 1;
		}
		add(i, 1);
	}
	p1[0] = n + n + 1;
	p0[0] = n + n + 1;
	dp[0][0] = 0;
	rep(j, 1, n) {
		add(p1[j], -1);
		dp[0][j] = dp[0][j - 1] + sum(p1[j] - 1);
	}
	rep(j, 0, n) add(p1[j], 1);
	rep(i, 1, n) {
		add(p0[i], -1);
		rep(j, 0, n) {
			add(p1[j], -1);
			dp[i][j] = INF;
			if (i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + sum(p0[i] - 1));
			if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + sum(p1[j] - 1));
		}
		rep(j, 0, n) add(p1[j], 1);
	}
	cout << dp[n][n] << "\n";
	return 0;
} 


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return abs(gcd(b,a%b));
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[b];
    uni[b]=a;
    return true;
}
signed main(void){
    int n;cin>>n;
    vector<int>V(n);rep(i,n)cin>>V[i];
    int now=0,fi=0;
    while(now<n){
        if(V[now]==(fi+1)){
            fi++;
        }
        now++;
    }
    if(fi==0)cout<<-1<<endl;
    else cout<<n-fi<<endl;
}
        


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);

		if (A <= 5) {
			System.out.println(0);
		} else if (A <= 12) {
			System.out.println((B / 2));
		} else {
			System.out.println(B);
		}
	}
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> map(H, vector<char>(W));
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            cin >> map[y][x];
        }
    }
    for (int y = -1; y <= H; y++) {
        for (int x = -1; x <= W; x++) {
            if (x == -1 || x == W || y == -1 || y == H) {
                cout << "#";
            } else {
                cout << map[y][x];
            }
        }
        cout << endl;
    }
    return 0;
}

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

using std::pair;
using std::vector;
using std::string;

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

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 3000;

int fpm(int x, int y, int mo) {
    int res = 1;
    for(; y > 0; y >>= 1) {
        if(y & 1)
            res = (ll) res * x % mo;
        x = (ll) x * x % mo;
    }
    return res;
}

int n, mo;
int pw[N * N + 5];
int c[N + 5][N + 5], f[N + 5][N + 5];

void init() {
    pw[0] = 1;
    for(int i = 1; i <= N*N; ++i) pw[i] = (pw[i-1] << 1) % mo;
        
    for(int i = 0; i <= N; ++i) {
        c[i][0] = c[i][i] = 1;
        f[i][0] = 1, f[i][i] = 1;

        for(int j = 1; j < i; ++j) {
            c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mo;
            f[i][j] = ((ll) f[i-1][j] * (j + 1) + f[i-1][j-1]) % mo;
        }
    }
}

int calc(int x) {
    int ans = 0, coe = fpm(2, fpm(2, n - x, mo - 1), mo);

    for(int z = 0; z <= x; ++z) {
        ans = (ans + (ll) coe * f[x][z] % mo * pw[(n - x) * z]) % mo;
    }
    return ans;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(mo); init();

    int ans = 0, sgn = 1;
    for(int i = 0; i <= n; ++i) {
        int coe = (ll) sgn * c[n][i] % mo;
        ans = (ans + (ll) coe * calc(i)) % mo;
        sgn = mo - sgn;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 104704
(let* ((N (read))
       (member-number (make-array N :initial-element 0))
       (boss-list (loop for i below (- N 1)
                        collect (read))))
  (dolist (x boss-list)
    (incf (aref member-number (- x 1))))
  (loop for i below N
        do (print (aref member-number i)))
  (fresh-line))


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

using namespace std;

void chmax( string &a, string b){
 if( a == "-"){ a = b;}// aが未更新だった場合
  //それ以外の場合はaとbの大小比較
  if( b.size() > a.size()){ a = b;}

  else{
    //aとbの桁数が一致した時、最高位から順に調べていく
   a = max( a, b); }
     }

 
 
  
int match[] = {0,2,5,5,4,5,6,3,7,6};


string dp[10100];
//dpは入力が整数で出力がstring

int main(){
int N,M; cin >> N >> M;
  vector<char> A(M);
  for(int i = 0; i < M; i++){ cin >> A[i];}
  for(int i = 0; i < 10100; i++){ dp[i] = "-";}
  //-は未記入 テーブルを記入していく
  dp[0] = ""; 
  for(int i = 0; i < 10010; i++){
    for(int j = 0; j < M; j++){
      //配るDP
   if( dp[i] != "-"){
   chmax( dp[i + match[A[j] - '0']], dp[i] + A[j]); }}}
  
  cout << dp[N] << endl; return 0;}


Measured memory_bytes: 46336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int ans = 0;
		if(n<10) ans = n;
		else if(n<100) ans = 9;
		else if(n<1000) ans = 9 + n - 99;
		else if(n<10000) ans = 909;
		else if(n<100000) ans = 909 + n - 9999;
		else if(n<1000000) ans = 90909;
		System.out.println(ans);
		in.close();

	}

}


Measured memory_bytes: 21588
#define _USE_MATH_DEFINES
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int main()
{
	double a, b;
	int C;
	double rad;
	
	double S, L, h;

	scanf("%lf %lf %d", &a, &b, &C);
	
	rad = C * M_PI / 180.0;
	
	// ??¢???S
	S = 0.5 * a * b * sin(rad);
	// ??¨?????????L
	L = a + b + sqrt(pow(a, 2) + pow(b, 2) -2 * a * b * cos(rad));
	// ??????h
	h = b * sin(rad);
	
	printf("%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

// bool comp(vector<int> v1, vector<int> v2)
// {
//     return v1[1] < v2[1];
// }

int main()
{
    char b; cin >> b;

    if (b == 'A')
    cout << 'T' << endl;
    if (b == 'T')
    cout << 'A' << endl;
    if (b == 'C')
    cout << 'G' << endl;
    if (b == 'G')
    cout << 'C' << endl;

    return 0;
}

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

long long int h, w;
long long int ans = 1e18;

void solve(){
	for(int i=1; i<=h/2; ++i){
		long long int t1, t2, t3;
		t1 = i * w;
		if((h-i)%2==0||w%2==0){
			t2 = t3 = (h-i)*w/2;
		}else{
			long long int s1 = max(h-i, w);
			long long int s2 = min(h-i, w);
			t2 = s1/2*s2;
			t3 = s1*s2-t2;
		}
		ans = min(ans, max(t1, max(t2, t3))-min(t1, min(t2, t3)));
	}
}

int main(){
	scanf("%lld %lld", &h, &w);

	solve();
	swap(h, w);
	solve();

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

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 2e5 + 100;
int h,w,n;
set<int> gd[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> h >> w >> n;
  R(i,n){
    int a,b;
    cin >> a >> b;
    a--;b--;
    gd[b].insert(a);
  }
  int res = h;
  int akx = 0;
  int aky = 0;
  while(aky < res){
    auto xx = gd[akx].lower_bound(aky);
    while(xx != gd[akx].end() && *xx == aky){
      aky++;
      xx++;
    }
    if(xx != gd[akx].end()){
      mini(res,*xx);
    }
    akx ++;
    aky ++;
  }
  cout << res << "\n";
  
}


Measured memory_bytes: 19072
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 605;

vector<int> go[N];
vector<pair<int,int>> edges;
int n, outdeg[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int m;
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		edges.push_back(make_pair(u, v));
		go[u].push_back(v);
		outdeg[u]++;
	}
	vector<double> P(n, 0);
	P[0] = 1;
	for(int i=0;i<n-1;i++) {
		for(auto v : go[i]) P[v] += P[i] / outdeg[i];
	}
	vector<double> E(n, 0);
	for(int i=n-2;i>=0;i--) {
		for(auto v : go[i]) E[i] += E[v] / outdeg[i];
		E[i]++;
	}
	double ans = E[0];
	for(int i=0;i<m;i++) {
		int from = edges[i].first, to = edges[i].second;
		if(outdeg[from] == 1) continue;
		double en = E[from] - 1;
		en = en * outdeg[from] - E[to];
		en = en / (outdeg[from] - 1) + 1;
		ans = min(ans, (en-E[from])*P[from] + E[0]);
	}
	cout << setprecision(10) << fixed << ans;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, M, A; cin >> N >> M;
  rep(i, 0, M) {
  	cin >> A; N -= A;
  } 
  if (N < 0) cout << -1 << endl;
  else cout << N << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

bool solve(string s){
    if(s == "ABC") return true;

    bool exist = false;
    set<char> se;
    for (int i = 0; i < s.size(); ++i) {
        if(i + 2 < s.size() && s.substr(i,3) == "ABC"){
            i += 2;
            exist = true;
        }else se.insert(s[i]);
    }
    if(se.size() != 2) return false;
    if(!exist) return false;
    char c = 'A';
    while(se.count(c)) c++;

    string ns = "";
    for (int i = 0; i < s.size(); ++i) {
        if(i+2 < s.size() && s.substr(i,3) == "ABC"){
            i += 2;
            ns += c;
        }else ns += s[i];
    }
    return solve(ns);
}


int main() {
    string s;
    cin >> s;
    if(solve(s)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 200010;
const int ML = 19;

int N, V;
int v[ML];
int x[MN];
int tor[2][ML][MN];
int dp[2][1 << ML];
int imos[MN];

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

	int L = 0;
	v[L++] = V;

	while (V > 0) {
		V /= 2;
		v[L++] = V;
	}

	rep(i, N) cin >> x[i];

	rep(tt, 2) {
		rep(j, L) {
			tor[tt][j][N] = N;
			tor[tt][j][N-1] = N-1;
		}

		for (int i = N-2; i >= 0; --i) {
			rep(j, L) {
				if (x[i+1] - x[i] <= v[j]) {
					tor[tt][j][i] = tor[tt][j][i+1];
				} else {
					tor[tt][j][i] = i;
				}
			}
		}

		dp[tt][0] = 0;
		rep(i, 1 << L) {
			rep(j, L) {
				if (!((i >> j) & 1)) {
					dp[tt][i | (1 << j)] = max(dp[tt][i | (1 << j)], tor[tt][j][dp[tt][i]] + 1);
				}
			}
		}

		reverse(x, x + N);
		rep(i, N) x[i] *= -1;
	}

	int B = (1 << L) - 2;

	rep(i, 1 << L) {
		if (i & 1) continue;
		int j = B ^ i;
		int l = dp[0][i], r = N - dp[1][j];

		if (l >= r) {
			imos[0]++;
			imos[N]--;
		} else {
			if (tor[0][0][l] + 1 >= r) {
				int p = tor[0][0][l];
				int u = N-1-tor[1][0][N-1-p];
				imos[u]++;
				imos[p+1]--;
			}
		}
	}

	rep(i, MN-1) {
		imos[i+1] += imos[i];
	}

	rep(i, N) {
		puts(imos[i] > 0 ? "Possible" : "Impossible");
	}
	
	return 0;
}

Measured memory_bytes: 37760
N = gets.to_i

ans = ''
9.times{|i|
  9.times{|j|
    if (i+1) * (j+1) == N then
      ans = 'Yes'
      break
    end
  }
  if ans == 'Yes' then
    break
  end
}

if ans == 'Yes' then
  puts ans
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <stdio.h>
#define MAXLEN 10000

int main()
{
    int x[MAXLEN] = {0};
    int i = 0;
    
    while(i < MAXLEN)
    {
        scanf("%d",x+i);
        
        if(x[i] == 0) break;
        
        i++;
    }
    
    int length = i;
    
    for(i = 0;i < length; i++)
    {
        printf("Case %d: %d\n",i+1,x[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll q,n;
ll a[2000005];
ll b[2000005];
int main()
{
    //IOS;
    while(cin>>n)
    {
        rep1(i,n) cin>>a[i];
        vector<ll> ans;
        for(int i=n;i>=1;i--)
        {
            ll cnt=0;
            for(int j=i+i;j<=n;j+=i)
            {
                if(j%i==0) if(b[j]==1) cnt++;
            }
            if(a[i]==1)
            {
                if(cnt%2==0) b[i]=1;
                else b[i]=0;
            }
            else
            {
                if(cnt%2==1) b[i]=1;
                else b[i]=0;
            }
            if(b[i]==1) ans.pb(i);
        }
        reverse(ans.begin(),ans.end());
        cout<<ans.size()<<"\n";
        for(auto i:ans) cout<<i<<" ";
        cout<<"\n";

    }
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, p;
	cin >> n >> p;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if(a % 2) {
			cout << (long long) pow(2, n - 1) << endl;
			return 0;
		}
	}
	if(p == 0) cout << (long long) pow(2, n) << endl;
	else cout << 0 << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int n,m;cin>>n>>m;
  pair<int,int> ans[100000];
  vector<vector<pair<int,int>>> y(n);
  rep(i,m){
    int pp,yy;cin>>pp>>yy;
    pp--;
    y[pp].push_back({yy,i});
  }
  rep(i,n){
    sort(y[i].begin(),y[i].end());
    rep(j,y[i].size())ans[y[i][j].second] = {i,j};
  }
  rep(i,m){
    cout << setfill('0') << right << setw(6) << ans[i].first+1;
    cout << setfill('0') << right << setw(6) << ans[i].second+1;
    cout << endl;
  }
}

Measured memory_bytes: 7808
#include <stdio.h>

int main(void)
{
	char id_S[11];
	char id_T[12];
	int i, c;

	scanf("%s", id_S);
	scanf("%s", id_T);

	c = 0;

	for (i = 0; id_S[i] != '\0'; i++)
	{
		if (id_S[i] != id_T[i])
		{
			c++;
			break;
		}
	}

	if (c == 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        
        PriorityQueue<Integer>[] que = new PriorityQueue[3];
        for (int i = 0; i < 3; i++) {
            que[i] = new PriorityQueue<>(Collections.reverseOrder()); // 降順で
        }
        
        for (int i = 0; i < a; i++) {
            que[0].add(sc.nextInt());
        }
        for (int i = 0; i < b; i++) {
            que[1].add(sc.nextInt());
        }
        for (int i = 0; i < c; i++) {
            que[2].add(sc.nextInt());
        }
        
        long ans = 0;
        PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder()); // 降順で
        for (int i = 0; i < x; i++) {
            queue.add(que[0].poll());
        }
        for (int i = 0; i < y; i++) {
            queue.add(que[1].poll());
        }
        for (int i = 0; i < c; i++) {
            queue.add(que[2].poll());
        }
        
        for (int i = 0; i < x + y; i++) {
            ans += (long)queue.poll();
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 99816
gets

ll = r_ = _l = rr = 0 # (ll, r_)(_l, rr)
r_min1 = r_min2 = l_min1 = l_min2 = [1000001,0]
$<.each{|s|
	z = s.size-1 # -1 for "\n"
	r = l = i = 0
	r = i = s.index(?(,0)||z if s[0] == ?)
	until i == z
		j = s.index(?),i)||z # i(((j
		k = s.index(?(,j)||z # j)))k

		cr = k-j-j+i-l
		if 0<cr
			r += cr
			l = 0
		else
			l = -cr
		end

		i = k
	end
	# r), (l

	if r == 0
		ll += l
	elsif l == 0
		rr += r
	else
		r_ += r
		_l += l
		if r < r_min2[0]
			if r < r_min1[0]
				r_min2 = r_min1
				r_min1 = [r,$.]
			else
				r_min2 = [r,$.]
			end
		end
		if l < l_min2[0]
			if l < l_min1[0]
				l_min2 = l_min1
				l_min1 = [l,$.]
			else
				l_min2 = [l,$.]
			end
		end
	end
}

if ll+_l == r_+rr and ll>=r_ && _l<=rr || [r_min1,r_min2].product([l_min1,l_min2]).any?{|(r,ri),(l,li)| ri!=li && ll>=r && l<=rr }
	puts'Yes'
else
	puts'No'
end


Measured memory_bytes: 14308
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int mod=998244353;
const int N=2e5+10;

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

}
int main()
{
    ll x,y;
    cin>>x>>y;
    ll g=gcd(x,y);
    ll cnt=1;
    for(ll i=2; i*i<=g; i++)
    {
        if(g%i==0)
            cnt++;
        while(g%i==0)
        {
            g=g/i;
        }
    }
    if(g>1)
    {
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3656
n,m = gets.split.map(&:to_i)
dp = (n+3).times.map{0}
dp[0] = 1
w = (n+3).times.map{true}
m.times.map{
  i = gets.to_i
  w[i] = false
}

mod = 10**9+7

n.times{|i|
  dp[i+1] += dp[i] if w[i+1]
  dp[i+1] %= mod 
  dp[i+2] += dp[i] if w[i+2]
  dp[i+2] %= mod 
}

p dp[n]%mod


Measured memory_bytes: 4532
#include <iostream>

using namespace std;
int mat[100001][3];
int main()
{
  int n,a,b,c;
  cin >> n;
  for(int i=1; i<=n; i++) {
    cin >> a >> b >> c;
    mat[i][0]=a+max(mat[i-1][1],mat[i-1][2]);
    mat[i][1]=b+max(mat[i-1][0],mat[i-1][2]);
    mat[i][2]=c+max(mat[i-1][0],mat[i-1][1]);
  }
  cout << max(mat[n][0],max(mat[n][1],mat[n][2])) <<'\n';
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
	unsigned long long h,w;	cin>>h>>w;
	unsigned long long ans;
	if(h==1||w==1)
		cout<<"1"<<endl;
	else if(h*w%2==1)
		cout<<(h*w/2)+1<<endl;
	else
		cout<<h*w/2<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	// cout<<INT_MAX;
	fast
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	ll g,i;
	vector<pair<ll,ll> > v;
	for(i=0;i<a;i++)
	{
		cin>>g;
		v.push_back(make_pair(g,1));
	}
	for(i=0;i<b;i++)
	{
		cin>>g;
		v.push_back(make_pair(g,2));
	}
	for(i=0;i<c;i++)
	{
		cin>>g;
		v.push_back(make_pair(g,3));
	}
	ll s=0,cp=0,cq=0,cr=0;
	i=0;
	sort(v.begin(),v.end(),greater<pair<ll,ll>>());
	while((cp+cq+cr) != (x+y))
	{
		if(v[i].second==1)
		{
			if(cp!=x)
			{
				s+=v[i].first;
				cp++;
			}
		}
		if(v[i].second==2)
		{
			if(cq!=y)
			{
				s+=v[i].first;
				cq++;
			}
		}
		if(v[i].second==3)
		{
			s+=v[i].first;
			cr++;
		}
		i++;
	}
	cout<<s;
}

Measured memory_bytes: 10348
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <stdlib.h>
#include <functional>
#define ll long long
#define llu unsigned long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
using namespace std;

int n, m;
vector<int> vec[210];

int main()
{
	int i, num, k;
	string s;
	cin >> s >> k;
	
	for (i = 0; i < s.size(); ++i) {
		num = s[i] - '0';
		if (num == 1 && k - 1 == i) {
			printf("1\n");
			return 0;
		}
		else if (num != 1) {
			printf("%d\n", num);
			return 0;
		}
	}
	

}

Measured memory_bytes: 256