akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    int la,lb;
    if(x-a < 0) la = a-x;
    else la = x-a;
    if(x-b < 0) lb = b-x;
    else lb = x-b;

    if(la < lb) cout << 'A' << endl;
    else cout << 'B' << endl;
 }

Measured memory_bytes: 256
s,t = input(), input()

S = list(s)
T = list(t)

N = len(s) - 1
i = 0
counter = 0

while N + 1 != i:
    if S[i] != T[i]:
        S[i] = T[i]
        counter += 1
    i += 1

print(counter)

Measured memory_bytes: 12484
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll inf_long = 9223372036854775807;

struct Point{
    ll x;
    ll y;
    Point(ll _x, ll _y){
        x = _x;
        y = _y;
    }
};

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

    // input
    int N, K;
    cin >> N >> K;

    vector<ll> X(N);
    vector<ll> Y(N);
    vector<Point> P;
    P.reserve(N);

    FOR(i, 0, N){
        ll x, y;
        cin >> x >> y;
        X[i] = x;
        Y[i] = y;
        auto p = Point(x, y);
        P.push_back(p);
    }

    sort(ALL(X));
    sort(ALL(Y));

    ll min_area = inf_long;
    FOR(i, 0, N-1){
        FOR(j, i+1, N){
            FOR(k, 0, N-1){
                FOR(l, k+1, N){
                    ll x_left = X[i];
                    ll x_right = X[j];
                    ll y_lower = Y[k];
                    ll y_upper = Y[l];

                    ll count = 0;
                    // その中に点は含まれるか
                    for(auto p : P){
                        if(x_left <= p.x && p.x <= x_right && y_lower <= p.y && p.y <= y_upper){
                            count++;
                        }
                    }
                    if(count >= K){
                        ll area = (x_right - x_left) * (y_upper - y_lower);
                        min_area = min(min_area, area);
                    }
                }
            }
        }
    }

    p(min_area);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

 int sequence[51],n;

bool check(){
    int l;
    for (l=1; l<n; l++) {
        if (sequence[l]>sequence[l+1]) {
            return false;
        }
    }
    return true;
}

int main() {
    int i,j,k,t;
    cin >> n;
    for (k=1; k<=n; k++) {
        scanf("%d",&sequence[k]);
    }
    if (check()==true) {
        cout << "YES";
        return 0;
    }
    for (i=1; i<n; i++) {
        for (j=i+1; j<=n; j++) {
            t=sequence[i];
            sequence[i]=sequence[j];
            sequence[j]=t;
            if (check()==true) {
                cout << "YES";
                return 0;
            }
            t=sequence[i];
            sequence[i]=sequence[j];
            sequence[j]=t;
        }
    }
    cout << "NO";
    
    
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
mod = [0] * K
for i in range(1, N + 1):
  mod[i % K] += 1
res = 0
#print(mod)
for x in range(K):
  t = mod[x] * mod[(K - x) % K]
  y = (-x) % K
  z = (-((K - x) % K)) % K
  if y == z:
    t *= mod[y]
    res += t
print(res)

Measured memory_bytes: 40944
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//229
	int a,b,k;
	cin>>a>>b>>k;
	int mx = min(a,b);
	int req = 1;
	set<int> s;
	for(int i=1;i<=mx;i++) {
		if(a%i==0&&b%i==0)s.insert(i);
	}
	for(auto i=s.rbegin();i!=s.rend();++i) {
		k--;
		if(k==0){cout<<*i;break;}
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
    string s;
    cin >> s;
    rep(i,s.le){
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D')
            continue;
        else {c("No")return 0;}
     
        }
        else{
            if(s[i]=='L' || s[i]=='U' || s[i]=='D')
            continue;
        else {c("No")return 0;}
        }
    }
    c("Yes")
}

Measured memory_bytes: 256
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); c.sort()
ans = 0
for i in range(n) :
    l_a = bisect.bisect_left(a, b[i])
    r_c = bisect.bisect_right(c, b[i])
    ans += l_a * (n - r_c)

print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        while (true) {
            LL a, b; char op; cin >> a >> op >> b;
            if (op == '?') return;
            switch (op) {
            case '+': cout << (a + b) << endl; break;
            case '-': cout << (a - b) << endl; break;
            case '*': cout << (a * b) << endl; break;
            case '/': cout << (a / b) << endl; break;
            }
        }
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] months={31,29,31,30,31,30,31,31,30,31,30,31};
		while(sc.hasNext()){
			int month=sc.nextInt();
			int day=sc.nextInt();
			if(month==0){
				break;
			}
			int days=0;
			for(int i=0;i<month-1;i++){
				days=days+months[i];
			}
			days=days+day;
			int today=days%7;
			if(today==0){
				System.out.println("Wednesday");
			}else if(today==1){
				System.out.println("Thursday");
			}else if(today==2){
				System.out.println("Friday");
			}else if(today==3){
				System.out.println("Saturday");
			}else if(today==4){
				System.out.println("Sunday");
			}else if(today==5){
				System.out.println("Monday");
			}else{
				System.out.println("Tuesday");
			}
		}
	}
}

Measured memory_bytes: 17204
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a-c)<=d||(abs(a-b)<=d && abs(b-c)<=d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N ; i++){
   string S;
   cin >> S;
    
    if(S == "Y"){
   cout << "Four" << endl;
     break;
    }
    
    if(i == N - 1){
   cout << "Three" << endl;
    }
  }

}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    aii = [0 for _ in range(N)]
    negajj = [0 for _ in range(N)]
    for i, a in enumerate(A):
        i += 1
        aii[i-1] = a + i
        negajj[i-1] = -(a - i)
    setaii = collections.Counter(aii)
    setnegajj = collections.Counter(negajj)
    cnt = 0
    for elem in aii:
        cnt += setnegajj[elem]
    print(cnt)
main()



Measured memory_bytes: 64796
(function(stdin) {

  // Define Function
  function splitCols(line, sep) {
    return line.split(sep);
  }

  function Compare(num1, num2) {
    return{
      getAns: function() {
        if (num1 > num2) { return 'a > b'; }
        if (num1 < num2) { return 'a < b'; }
        if (num1 === num2) { return 'a == b'; }
      }
    };
  }

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');
  const cols  = splitCols(inputs[0],' ').map(Number);

  // Main Procedure
  const result = (function(a,b) {
    const comp = Compare(a,b);
    return (comp.getAns());

  }(cols[0], cols[1]
    ));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15596
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int N;
  string S;
  cin >> N;
  
  for (int i=0; i<N; i++)
    {
      cin>>S;
        if (S =="Y")
          {
            S="Four";
            break;
          }
        else
        S="Three";	              
    }
 cout<<S<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int X, A, B;
    cin >> X >> A >> B;
    cout << (abs(X - A) < abs(X - B) ? 'A' : 'B') << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	int n, k;
	scanf("%d%d", &n, &k);
	vi ps(n+1);
	for (int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		ps[i+1] = ps[i] + a;
	}

	int ans = 0;
	for (int i = 0; i + k <= n; i++)
		ans = max(ans, ps[i+k] - ps[i]);
	printf("%.6f\n", (double)(ans + k) / 2.0);
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  int K;
  scanf("%d",&K);
  if((K==4)||(K==6)||(K==9)||(K==10)||(K==14)||(K==21)||(K==22)||(K==26)||(K==25)){
    printf("2");
  }
  else if((K==8)||(K==12)||(K==18)||(K==20)||(K==27)){
    printf("5");
  }
  else if(K==16){
    printf("14");
  }
  else if(K==24){
    printf("15");
  }
  else if((K==28)||(K==30)){
    printf("4");
  }
  else if(K==32){
    printf("51");
  }
  else{
    printf("1");
  }
  return 0;
}
  
  
  
  


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);

        double temp = n / 1.08;
        int zeinuki = (int) temp;

        double temp2 = zeinuki * 1.08;
        int zeikomi1 = (int) temp2;
        double temp3 = (zeinuki + 1) * 1.08;
        int zeikomi2 = (int) temp3;

        if (n == zeikomi1) {
            System.out.println(zeinuki);
        } else if (n == zeikomi2) {
            System.out.println(zeinuki + 1);
        } else {
            System.out.println(":(");
        }

    }

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

int main() {
  string S; cin >> S;
  reverse(ALL(S));

  string d[4] = {"dreamer", "eraser","dream",  "erase"};
  REP(i, 4){
    reverse(ALL(d[i]));
  }

  int i = 0;
  int n = S.size();
  while(i < n){
    REP(j, 4){
      int l = d[j].size();
      if(i+l <= n && S.substr(i, l) == d[j]){
        i += l;
        break;
      }else if(j == 3){
        cout << "NO" << endl;
        return 0;
      }
    }
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    cin >> n;

    reps(i, 1, 9){
        reps(j, 1, 9){
            if(i*j == n){
                ans(true);
                return 0;
            }
        }
    }

    ans(false);

    return 0;
}


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

int main(){
  string s1, s2;
  cin >> s1 >> s2;
  
  string ans = "No";
  
  vector<char> vec1(s1.size());
  vector<char> vec2(s2.size());
  
  for(int i=0; i<s1.size(); i++){
    vec1.at(i) = s1.at(i);
  }
  for(int j=0; j<s2.size(); j++){
    vec2.at(j) = s2.at(j);
  }
  
  sort(vec1.begin(), vec1.end());
  sort(vec2.begin(), vec2.end());
  reverse(vec2.begin(), vec2.end());
  
  int x = min(s1.size(), s2.size());
  
  for(int k=0; k<x; k++){
    if(vec1.at(k) < vec2.at(k)){
      ans = "Yes";
      break;
    }
    if(vec1.at(k) > vec2.at(k)){
      ans = "No";
      break;
    }
    if(k == x -1 && s1.size() < s2.size()){
     ans = "Yes";
    }
    if(k == x -1 && s1.size() > s2.size()){
     ans = "No";
    }
    if(k == x -1 && s1.size() == s2.size()){
      ans = "No";
    }
  } 
  cout << ans << endl;  
}

Measured memory_bytes: 764
N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int,  input().split())
    A.append(a)
    B.append(b)
ans = []
ans.append(N * (N - 1) / 2)

n = [-1 for i in range(N)]

def find(x):
    if n[x] < 0:
        return x
    n[x] = find(n[x])
    return n[x]

def size(x):
    return -n[find(x)]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if size(x) < size(y):
        x, y = y, x
    n[x] += n[y]
    n[y] = x
    return 1

for i in range(1, M):
    sab = size(A[-i] - 1) * size(B[-i] - 1)
    if unite(A[-i] - 1, B[-i] - 1) == 0:
        ans.append(ans[i - 1])
    else:
        ans.append(ans[i - 1] - sab)
for i in range(1, M + 1):
    print(int(ans[-i]))


Measured memory_bytes: 17652
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string s;
    cin >> s;
    char prev = s[0];
    rep(i,s.size()-1){
        if(prev=='A'&&s[i+1]=='C'){
            out("Yes");
            return 0;
        }
        prev = s[i + 1];
    }
    out("No");
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)

vector<int> to[200100];
vector<int> ans;
// Write From This Line
void dfs(int v, int p = -1) {
	for(int u:to[v]) {//vの子を操作する
		if(u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}
int main()
{
	int n, q;
	cin >> n >> q;
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		--a,--b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	ans.resize(n);
	rep(i,q){
		int p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	dfs(0);
	rep(i,n){
		cout << ans[i] << endl;
	}
}


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

int main()
{
    int t, r;
    for(int i = 0;i < 5;i++){
        cin >> t;
        if(t < 40){
            r += 40;
        }else{
            r += t;
        }
    }
    cout << r / 5 << endl;
    
    return 0;
}

Measured memory_bytes: 3048
use proconio::input;

const MOD: usize = 1_000_000_007;

fn main() {
    input! {
        s: usize,
    }

    let mut dp = vec![0; s+1];

    dp[0] = 1;

    for i in 3..=s {
        dp[i] = dp[i-1] + dp[i-3];
        dp[i] %= MOD;
    }

    println!("{}", dp[s]);
}


Measured memory_bytes: 2120
s = input()
t = input()
count = 0
stock = 0
check = 0

for i in t:
    if check==0:
        if i in s:
            stock = s.index(i)
            check = 1
        else:
            count = -1
            break
    else:
        if i in s:
            if stock==len(s)-1:
                count += 1
                stock = s.index(i)
                continue
            if i in s[stock+1:]:
                stock = s[stock+1:].index(i) + stock + 1
                continue
            else:
                count += 1
                stock = s.index(i)
                continue
        else:
            count = -1
            break
        
if count==-1:
    print(count)
else:
    print(count*len(s)+stock+1)

Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,m;
vector<int> f[5005];
int main(void){
  cin >> n >> m;
  for(int i = 0; i <= n+5; i++){
    f[i].resize(i+5,0);
  }

  for(int i = 0; i < m; i++){
    int a,b,x;
    cin >> a >> b >> x;
    f[a][b]++;
    f[a][b+1]--;
    f[a+x+1][b]--;
    f[a+x+2][b+1]++;
    f[a+x+1][b+x+2]++;
    f[a+x+2][b+x+2]--;
  }

  for(int i = 1; i <= n; i++){
    for(int j = i; j <= n; j++){
      f[j][i] += f[j-1][i];
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      f[i][j] += f[i][j-1];
    }
  }

  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      f[i][j] += f[i-1][j-1];
    }
  }

  int res = 0;
  for(int i =1; i <= n; i++){
    for(int j = 1; j <= i; j++){
      if(f[i][j]>0) res++;
    }
  }
  cout << res << endl;
}

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

int main() {
    string a, b;
  	cin >> a >> b;
  	if(a.length() < b.length()){
    	cout << "LESS" << endl;
      	return 0;
    }else if(a.length() > b.length()) {
    	cout << "GREATER" << endl;
      	return 0;
    }
  	
  	rep(i, a.length()){
    	if(a[i] - '0' < b[i] - '0'){
        	cout << "LESS" << endl;
      		return 0;
        }
        if(a[i] - '0' > b[i] - '0'){
              cout << "GREATER" << endl;
              return 0;
          }
    }
  	cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <time.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define X first
#define Y second

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 200047;
const LD EPS = 1e-6;
const LD PI = acos(-1.0);

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, x = 1, y;
	cin >> n;
	if (n == 3)
	{
		cout << "2 5 63";
		return 0;
	}
	if (n == 4)
	{
		cout << "2 5 20 63";
		return 0;
	}
	if (n == 6)
	{
		cout << "2 3 4 6 9 12";
		return 0;
	}
	if (n == 19999)
	{
		int cur = 2;
		while (cur < 30000)
		{
			cout << cur << ' ';
			cur += 2;
		}
		cur = 3;
		REP(i, 5000)
		{
			cout << cur << ' ';
			cur += 6;
		}
		return 0;
	}
	x = (n & 1 ? 1 : 2);
	while (n - 3 * x > 0 && x <= 5000)
		x += 2;
	x -= 2;
	y = (n - 3 * x) / 2;
	int cur = 0;
	REP(i, 3 * x)
	{
		cur += 2;
		cout << cur << ' ';
	}
	cur = 3;
	REP(i, 2 * y)
	{
		cout << cur << ' ';
		cur += 6;
	}
	return 0;
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int h, w, d[110][110];
bool g[110][110];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> h >> w;
  char c;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> c, g[i][j] = c == '#', d[i][j] = h + w + 10;
  d[0][0] = 0;
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) {
      if (d[i][j] + (g[i][j] != g[i][j + 1]) < d[i][j + 1])
        d[i][j + 1] = d[i][j] + (g[i][j] != g[i][j + 1]);
      d[i + 1][j] = d[i][j] + (g[i][j] != g[i + 1][j]);
    }
  cout << (d[h - 1][w - 1] + g[0][0] + 1) / 2 << "\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long int maximumweight(vector<int> w,vector<int> v,int W, int N)
{
  if(N==0)
    return 0;
  long long int dp[N+1][W+1];
  memset(dp,0,sizeof(dp));
  for(int i=1;i<=N;i++)
  {
    for(int j=1;j<=W;j++)
    {
      if(j>=w[i-1])
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  return dp[N][W];
}
int main()
{
  int N,W;
  cin>>N>>W;
  vector<int> w(N);
  vector<int> v(N);
  for(int i=0;i<N;i++)
  {
    cin>>w[i]>>v[i];
  }
  cout<<maximumweight(w,v,W,N);
  return 0;
}

Measured memory_bytes: 79104
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N, X, M = list(map(int, input().split()))

    return N, X, M


def f(x: int, m: int) -> int:
    """
    xをmで割った余りを返す.

    Args:\n
        x (int): 整数
        m (int): 整数

    Returns:\n
        int: xをmで割った余り
    """
    return x % m


def main(N: int, X: int, M: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数(1 <= N <= 10^{10})
        X (int): 整数(0 <= X <= M <= 10^5)
        M (int): 整数(0 <= X <= M <= 10^5)
    """
    # 求解処理
    A = [X]
    s = {X}
    i = 0
    while True:
        A_next = f(A[-1]**2, M)
        if A_next in s:
            i = A.index(A_next)
            break
        else:
            A.append(A_next)
            s.add(A_next)

    loop_length = len(A) - i
    loop_cnt = (N - i) // loop_length
    loop_res = (N - i) % loop_length
    ans = sum(A[:i]) + loop_cnt * sum(A[i:]) + sum(A[i: i + loop_res])

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, X, M = get_input()

    # メイン処理
    main(N, X, M)


Measured memory_bytes: 13216
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define double long double
vector<long long> solve(vector<long long> v) {
	int N = v.size();
	vector<double> pot(N), sum(N);
	for (int i = 0; i < N; ++i) pot[i] = log2(v[i]) / 2; // = log4(v[i])
	for (int i = 1; i < N; ++i) {
		double diff = pot[i] - pot[i - 1] + 32 + 1.0e-11L;
		sum[i] = sum[i - 1] + (diff - int(diff));
	}
	vector<double> eval(N);
	for (int i = 0; i < N; ++i) eval[i] = sum[i] - pot[i];
	vector<long long> ans(N);
	vector<int> st;
	double cur = 0, tailsum = 0;
	for (int i = N - 1; i >= 0; --i) {
		while (!st.empty() && eval[st.back()] >= eval[i]) {
			int last = N;
			if (st.size() >= 2) last = st[st.size() - 2];
			cur -= eval[st.back()] * (last - st.back());
			st.pop_back();
		}
		cur += eval[i] * ((st.empty() ? N : st.back()) - i);
		st.push_back(i);
		tailsum += eval[i];
		ans[i] = tailsum - cur;
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<long long> cpos = solve(A);
	reverse(A.begin(), A.end());
	vector<long long> cneg = solve(A);
	reverse(A.begin(), A.end());
	reverse(cneg.begin(), cneg.end());
	long long ans = (1LL << 60);
	for (int i = 0; i <= N; ++i) {
		ans = min(ans, (i == N ? 0 : cpos[i]) * 2 + (i == 0 ? 0 : cneg[i - 1]) * 2 + i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15932
var
  a:array[1..100001] of longint;
  n,i,s,sum:longint;
 procedure kp(l,r:longint);
  var
    i,j,t,mid:longint;
  begin
    i:=l; j:=r; mid:=a[(i+j) div 2];
    repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then
        begin
          t:=a[i]; a[i]:=a[j]; a[j]:=t;
          inc(i); dec(j);
        end;
    until i>j;
    if i<r then kp(i,r);
    if j>l then kp(l,j);
  end;
begin
  readln(n);
  for i:=1 to n do readln(a[i]);
  kp(1,n);
  s:=1;
  for i:=2 to n+1 do
    if a[i]=a[i-1] then inc(s)
      else
        begin
          if odd(s) then inc(sum);
          s:=1;
        end;
  writeln(sum);
end.

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
  int n,sum,cnt;
  while (true){
    cin>>n;
    if (n==0) return 0;
    sum=cnt=0;
    for (int i=1;i<=sqrt(n);i++)
      if (n%i==0)
        sum+=i+n/i;
    if (sqrt(n)==(int)sqrt(n))
      sum-=n+(int)sqrt(n);
    else
      sum-=n;
    if (sum==n)
      puts("perfect number");
    else if (sum<n)
      puts("deficient number");
    else
      puts("abundant number");
  }
}

Measured memory_bytes: 1116
#include <iostream>
#include <array>

using namespace std;

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

    const int pi[10] = {-1, 0};
    const int pj[10] = {0, -1};

    int n;
    array<array<int, 256>, 4> a;
    array<array<int, 256>, 4> dp;
    cin >> n;

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

    // dp[i][j] は位置[i][j]の最大アメ数
    dp[0][0] = a[0][0]; // 初期値を与える
    // n_mv:移動回数
    // ある移動回数の探索
    for (int n_mv = 0; n_mv < n; n_mv++)
    {
        // 1回移動したあとの座標[i][j]を調べる
        for (int k = 0; k <= n_mv + 1; k++)
        {
            int i = k, j = n_mv + 1 - k;
            if (i < 0 || i > 2 || j < 0 || j > n)
                continue;
            // 1回移動したあとの座標[i][j]のdpを探索
            array<int, 10> prev_dp;
            int ii, jj;
            // 上と左のdpを探索
            for (int l = 0; l < 2; l++)
            {
                ii = i + pi[l];
                jj = j + pj[l];
                if (ii < 0 || ii > 2 || jj < 0 || jj > n)
                    prev_dp[l] = -1;
                else
                    prev_dp[l] = dp[ii][jj];
            }
            dp[i][j] = max(prev_dp[0], prev_dp[1]) + a[i][j];
        }
    }

    cout << dp[1][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    while(cin >> H >> W){
        //H=0,W=0なら終了
        if(H==0 and W==0) break;
        
        //先頭行
        for(int i = 0; i < W; i++){
            cout << "#";
        }
        cout << endl;
        
        //中間行
        for(int i = 0; i < H - 2; i++){
            cout << "#";
            for(int j = 0; j < W - 2; j++){
                cout << ".";
            }
            cout << "#" << endl;
        }
        
        //最終行
        for(int i = 0; i < W; i++){
            cout << "#";
        }
        cout << endl;
        
        //データセット後の1行空ける
        cout << endl;
    }
}

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

int main(void){
  int n;
  int result = 0;
  int a=0;
  int b=0;
  cin >> n;
  while(1){
    while(a<360){
      a+=n;
      result++;
    }
    if(a==360){
      break;
    } else {
      a = a % 360;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif
  int x;
  scanf("%d", &x);
  printf("%d\n", x ^ 1);

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

// 参考にしました。
// ttp://kazune-lab.net/contest/2019/08/17/agc037/#模範解答

int main() {
  string s;
  cin >> s;
  s = '#' + s;  // 1-indexed にするため。
  int len = s.size();
  int dp[200010][5];  // dp[i][j]
                      // i 文字目時点で最後の分割が S[i-j,i) であるときの分割数
                      // i, j : 1-indexed
  for (int i = 0; i < 200010; i++) {
    for (int j = 0; j < 5; j++) {
      dp[i][j] = 0;
    }
  }
  dp[1][1] = 0;  // 最後の分割は'#'なので無効
  for (int i = 1; i < len; i++) {
    for (int j = 1; j <= 4; j++) {
      // 最後の分割 S[i-j,i) を決定
      if (i - j < 0) continue;
      string bef = s.substr(i - j, j);
      for (int k = 1; k <= 4; k++) {
        // 新しい分割 S[i,i+k) を決定
        if (i + k > len) continue;
        string aft = s.substr(i, k);
        // 分割が不一致なら遷移を計算
        if (bef != aft) {
          dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
        }
      }
    }
  }

  int ans = 0;
  for (int i = 1; i < 5; i++) {
    ans = max(ans, dp[len][i]);
  }

  cout << ans << endl;
}

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

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

  if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output3(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;



//今の時間よりも後の最速の便のインデックスを求める。
int search(vector<int> v,int time){
    return distance(v.begin(),lower_bound(v.begin(),v.end(),time));
}

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

signed main(){
    string s; cin>>s;
    int n=s.length();

    map<char,int> moji;
    for(int i=0;i<n;i++){
        moji[s[i]]++;
    }

    int ans=100;
   

    for(int i=0;i<26;i++){
        char choice='a'+i;
        if(moji[choice]==0)continue;
        string t=s;
        int cnt=0;

        while(check(t)==false){
            string t_dash="";
            for(int j=0;j<t.length()-1;j++){
                if(t[j]==choice||t[j+1]==choice) t_dash+=choice;
                else t_dash+=t[j];
            }
            t=t_dash;
            //cout<<t<<" "<<choice<<endl;
            cnt++;
        }

        ans=min(ans,cnt);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool sortbysec(const pair<int, int>& a,
	const pair<int, int>& b)
{
	return (a.second < b.second);
}
int arr[100007];
int main() {
	string s; cin >> s;
	//Sunny, Cloudy, or Rainy.

	if (s == "Sunny")
			cout << "Cloudy" << endl;
	else if (s == "Cloudy")
		cout << "Rainy" << endl;
	else {
		cout << "Sunny" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

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

const int N = (int) 1e6 + 7;
const int MOD = (int) 1e9 + 7;

int n;
int a[N];

int main() {
  #ifdef LOCAL
  freopen("in.txt", "r", stdin);
  #endif

  cin >> n;

  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  long long ans = (long long) 9e18;
  long long pf = 0;
  for (int i = 1; i < n; i++) {
    pf += a[i];
    long long y = sum - pf;
    ans = min(ans, abs(pf - y));
  }
  cout << ans;


  return 0;
}

Measured memory_bytes: 1024
'use strict';

function main(arg) {
    const N = parseInt(arg.split("\n")[0]);
    
    if(N < 4) {
        console.log("No");
        return;
    }
    
    if(N % 4 === 0 || N % 7 === 0 ) {
        console.log("Yes");
        return;
    }
    
    for(let i=0; i<N; i=i+4) {
        if((N - i) % 7 === 0) {
            console.log("Yes");
            return;
        }
    }
    
    for(let i=0; i<N; i=i+7) {
        if((N - i) % 4 === 0) {
            console.log("Yes");
            return;
        }
    }
    
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;


int main()
{
    ll n;
    cin>>n;
    ll arr[n+1]={0};
    for(ll i=0;i<n-1;i++){
        ll temp;
        cin>>temp;
        arr[temp]++;
    }
    for(ll i=1; i<=n; i++){
        cout<<arr[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int mm(int n, int r) {
	int x = 1;
	for(int i = n; i >= n - r + 1; i--) {
		x *= i;
		x /= 1 + (n - i);
	}
	return x;
}

int n, a, b, u[55];
vector<int> ta;
int ans, cnt1, cnt2;
double d;

signed main() {
	cin >> n >> a >> b;
	rep(i, n)cin >> u[i];
	sort(u, u + n);
	reverse(u, u + n);
	rep(i, a) {
		ta.push_back(u[i]);
		d += u[i];
	}
	printf("%.8f\n", d / a);
	int l = ta.size() - 1;
	if (ta[0] == ta[l]) {
		rep(i, n) {
			if (u[i] == ta[0])cnt1++;
		}
		for (int i = a; i <= b; i++) {
			ans += mm(cnt1, i);
		}
	}
	else {
		rep(i, l + 1) {
			if (ta[l] == ta[i])cnt2++;
		}
		rep(i, n) {
			if (ta[l] == u[i])cnt1++;
		}
		ans = mm(cnt1, cnt2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//シミュレートして，その局面ごとの最善手をうち続ければいい。
//（未完）

int main(void){
	int r,g,b;
	cin>>r>>g>>b;
	int ans = r*100+g*10+b;
	if(ans%4==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];

    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i) {
        if (i % 2 == 0) {
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	
        // 行列の長さ
        long n = sc.nextLong();
      	long result=0;//条件を満たした
      	long nine=1;//9は含むが条件を満たしていない
      	long zero=1;//0は含むが条件を満たしていない
      	long non=8;//0,9を含まない(初期条件として長さが1の時を先に入れている)
          
      	for(int i=2;i<=n;i++){
          result=result*10+nine+zero;
          nine=nine*9+non;
          zero=zero*9+non;
          non=non*8;
          result=result%(long)(Math.pow(10,9)+7);
          nine=nine%(long)(Math.pow(10,9)+7);
          zero=zero%(long)(Math.pow(10,9)+7);
          non=non%(long)(Math.pow(10,9)+7);
         // System.out.println(result);
        }
		

      	System.out.println(result);

    }
}

Measured memory_bytes: 35684
n,y=map(int,input().split())
for i in range(0,min(n+1,y//10000+1)):
    for j in range(0,min(n-i+1,(y-10000*i)//5000+1)):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print(i,j,n-i-j)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
import sys
from bisect import bisect_left, bisect

sys.setrecursionlimit(10 ** 5 + 5)


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def solve(n, m, aaa, bbb, lll, rrr):
    aaa, bbb = map(list, zip(*sorted(zip(aaa, bbb))))
    b_diff = [bbb[0]] + [b0 ^ b1 for b0, b1 in zip(bbb, bbb[1:])] + [bbb[-1]]
    cords = [set() for _ in range(n + 1)]
    uft = UnionFind(n + 1)
    for i, (l, r) in enumerate(zip(lll, rrr), start=1):
        li = bisect_left(aaa, l)
        ri = bisect(aaa, r)
        if li == ri or uft.find(li, ri):
            continue
        cords[li].add((ri, i))
        cords[ri].add((li, i))
        uft.union(li, ri)

    use_cords = set()

    def dfs(v, p):
        res = b_diff[v]
        for u, cord in cords[v]:
            if u == p:
                continue
            ret = dfs(u, v)
            if ret == 1:
                use_cords.add(cord)
            b_diff[u] = 0
            res ^= ret
        return res

    for v in range(n + 1):
        if b_diff[v]:
            b_diff[v] = dfs(v, -1)

    if sum(b_diff) == 0:
        print(len(use_cords))
        print(*sorted(use_cords))
    else:
        print(-1)


inp = list(map(int, sys.stdin.buffer.read().split()))
n, m = inp[:2]
aaa = inp[2:2 * n + 2:2]
bbb = inp[3:2 * n + 2:2]
lll = inp[2 * n + 2::2]
rrr = inp[2 * n + 3::2]
solve(n, m, aaa, bbb, lll, rrr)


Measured memory_bytes: 81260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
int64_t A,B,K;
  cin >> A >> B >> K;
  if(A - K <0){
    B = B - (K - A);
    if (B < 0){
     B = 0;
    }
    A = 0;
  }else{
     A = A - K; 
    }
  cout << A << " " << B << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> A(1100);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    double ans;
    double m = 0;
    for (int i = 0; i < n; i++) {
        m += (double) 1 / A[i];
    }

    ans = (double) 1 / m;

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//gcc -std=gnu11 -O2 -o a.out main.c -lm

#include <stdio.h>

#if 0
long f(long n, long x) {
    if (n >= 0) {
        return n / x + 1;
    }
    return 0;
}

int main(void)
{
    int res;

    long a, b, x;
    long n;

    // input
    res = scanf("%ld%ld%ld", &a, &b, &x);
    // output
    printf("%ld\n", f(b, x) - f(a - 1, x));

	return 0;
}
#else
int main(void)
{
    int res;

    long a, b, x;
    long n;
    long d, min;

    // input
    res = scanf("%ld%ld%ld", &a, &b, &x);

    d = (a % x);
    min = d ? (a + (x - d)) : (a);

    if (min > b) {
        n = 0;
    } else {
        n = (b - min) / x + 1;
    }
    printf("%ld\n", n);
    // output

	return 0;
}

#endif



Measured memory_bytes: 128
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  REP(i, n) cin >> a[i];

  VI b(n);
  b[0] = a[0];
  FOR(i, 1, n) b[i] = a[i] + b[i-1];

  int ret = 0;
  map<int,int> mp;
  for(int i=n-1; i>=0; --i) {
    ret += mp[b[i]];
    // b[i]の個数
    mp[b[i]]++;
  }
  cout << ret+mp[0] << endl;

  return 0;
}


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

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c=list(Counter(prime_factorize(n)).values())

if len(c)==0:
	print(0)
	exit()
ans=0

for i in c:
	for j in range(1,10**7):
		i-=j
		if i>=0:
			ans+=1
		else:
			break

print(ans)

Measured memory_bytes: 9404