akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e5+6;
const ll M=1e9+7;

int main()
{
	int n;
	scn(n);
	int a[n][3];
	for(int i=0;i<n;i++)
	{
		scn(a[i][0]);
		scn(a[i][1]);
		scn(a[i][2]);
		if(i)
		{
			a[i][0]+=max(a[i-1][1],a[i-1][2]);
			a[i][1]+=max(a[i-1][0],a[i-1][2]);
			a[i][2]+=max(a[i-1][0],a[i-1][1]);
		}
	}
	pri(max({a[n-1][0],a[n-1][1],a[n-1][2]}));

}

Measured memory_bytes: 1408
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)
const int INF = 1e8;

struct edge { int from, to, cost; };

int main () {
  int V, E, r;
  cin >> V >> E >> r;
  edge edges[E];
  int d[V];

  REP(i,E){
    edge e;
    cin >> e.from >> e.to >> e.cost;
    edges[i] = e;
  }

  REP(i,V)d[i] = INF;
  d[r] = 0;

  bool updated = true;
  int count = 0;
  while(updated) {
    updated = false;
    REP(i,E) {
       edge e = edges[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        updated = true;
      }
    }
    count++;
    if(updated && count == V) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  REP(i,V) {
    if(d[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << d[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int b[110000];
bool f[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	std::sort(b,b+a);
	int cnt=0;
	for(int i=0;i<a;i++){
		if(b[i]>0)cnt++;
	}
	vector<pair<int,int> > v;
	for(int i=1;i<a-1;i++){
		if(b[i]>=0){
			v.push_back(make_pair(b[0],b[i]));
			b[0]-=b[i];
			f[i]=true;
		}
	}
	for(int i=0;i<a-1;i++){
		if(f[i])continue;
		v.push_back(make_pair(b[a-1],b[i]));
		b[a-1]-=b[i];
	}
	printf("%d\n",b[a-1]);
	for(int i=0;i<a-1;i++){
		printf("%d %d\n",v[i].first,v[i].second);
	}
}


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>
using namespace std;
int n, k;
int a[200001]; 

bool canCut(int x) {
  int count = 0;
  for (int i = 0; i < n; i++) {
    count += (a[i] - 1) / x;
    if (count > k) return false;
  }
  if (count <= k) return true;
  else return false;
}

void solve() {
  // 二分探索
  int ub = 0, lb = 10e9;
  while (lb - ub > 1) {
    int mid = (ub + lb) / 2;
    if (canCut(mid)) {
      lb = mid;
    } else {
      ub = mid;
    } 
  }
  printf("%d", lb);
}

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

Measured memory_bytes: 4452
s = str(input())

t = list(s)
t_ = list(reversed(t))

n = len(s)
p = list(s[0:(n-1)//2])
q = list(s[(n+3)//2-1:n])

p_ = list(reversed(p))
q_ = list(reversed(q))

#print(p)
#print(p_)
#print(q)
#print(q_)

for i in range(n):
    if t[i] != t_[i]:
        print('No')
        exit()

for i in range(len(p)):
    if p[i] != p_[i]:
        print('No')
        exit()

for i in range(len(q)):
    if q[i] != q_[i]:
        print('No')
        exit()
else:
    print('Yes')


Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
	int i,min1,min2;
	int a[4];
	for(i=0;i<4;i++)
		scanf("%d",&a[i]);
	if(a[0]<=a[1])
		min1=a[0];
	else
		min1=a[1];
	if(a[2]<=a[3])
		min2=a[2];
	else
		min2=a[3];
	printf("%d",min1+min2);
	return 0;
}
	

	

Measured memory_bytes: 128
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

S = SINGLE_STRING()
counter = 15

for c in S:
    if c == 'x':
        counter -= 1

if counter > 7:
    print('YES')
else:
    print('NO')

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

ll vert[100007];//ある深さの頂点の個数
ll leaves[100007];//ある深さから深さnまでの葉の枚数
int main(){
    bool z = true;
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> a(n + 1);
    rep(i, n + 1) cin >> a[i];
    leaves[n + 1] = 0;
    for (ll i = n; i >= 0;i--){
        leaves[i] = leaves[i + 1] + a[i];
    }
    vert[0] =1;
    for (ll i = 1; i < n; i++){
        if(vert[i-1]<=a[i-1]){//条件を満たす二分木が存在するかどうか
            z = false;
            break;
        }
        if((vert[i-1]-a[i-1])*2<=a[i])z = false;
        vert[i] = min((vert[i - 1] - a[i - 1]) * 2, leaves[i]); //深さ d − 1 の頂点のうち葉ではないものの個数の2倍と深さiから深さnまでの葉の枚数のうちの小さい方
        ans += vert[i];
    }
    ans += a[n];
    if(n!=0&&(vert[n-1]-a[n-1])*2<a[n])z = false;
    if(n==0&&a[0]==1)ans = 1;
    if(n==0&&a[0]!=1)z = false;
    if (z)
    {
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 5580
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: "List[int]", B: "List[int]"):
    tasks = sorted(zip(B, A))
    cum = 0
    for bi, ai in tasks:
        cum += ai
        if cum > bi:
            print(NO)
            return
    print(YES)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]"
    B = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32592
from itertools import product
from copy import deepcopy

n = int(input())
mod = 10 ** 9 + 7

comp = {"A": 0, "C": 1, "G": 2, "T": 3}

dp = [[0] * (4 ** 3) for _ in range(n + 1)]

bad = [0b001001, 0b000110, 0b100001]
for i in range(4 ** 3):
    if not i in bad:
        dp[3][i] = 1


def is_ok(li):
    for i in range(4):
        tmp = deepcopy(li)
        if i >= 1:
            tmp[i-1], tmp[i] = tmp[i], tmp[i-1]

        if "".join(tmp).count("AGC") >= 1:
            return False

    return True


def comp2int(li):
    ret = 0
    for i, e in enumerate(li):
        ret += comp[e] << 2 * (2 - i)

    return ret


for i in range(3, n):
    for j in product(comp.keys(), repeat=3):
        for k in comp.keys():
            last4 = list(j) + [k]
            if is_ok(last4):
                j_prev = comp2int(j)
                j_nxt = comp2int(last4[1:])
                dp[i+1][j_nxt] += dp[i][j_prev]
                dp[i+1][j_nxt] %= mod

ans = 0
for i in range(4 ** 3):
    ans += dp[n][i]
    ans %= mod

print(ans)


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    cout << fixed << setprecision(10) << (N+1)/2/(double)N << endl;
    return 0;   
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	string s,t;
	int count=0;
	cin>>s>>t;
	rep(i,s.size()){
		if(s[i]==t[i])count++;
	}
	cout<<s.size()-count;
	return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Maxn=1e5+10;
ll A[Maxn],sum[2][Maxn];
int main() {
    ios::sync_with_stdio(false);
    ll N = 0;
    cin>>N;
    for(ll i=1;i<=N;i++){
        cin>>A[i];
        if(i%2){
            sum[0][i]=sum[0][i-1]+A[i];
            sum[1][i]=sum[1][i-1]-A[i];
        }else{
            sum[0][i]=sum[0][i-1]-A[i];
            sum[1][i]=sum[1][i-1]+A[i];
        }
    }
    for(ll i=1;i<=N;i++){
        if(i%2){
            cout<<sum[1][i-1]+(sum[0][N]-sum[0][i-1])<<" ";
        }else{
            cout<<sum[0][i-1]+(sum[1][N]-sum[1][i-1])<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 5996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    
    vector<int> A(N),B(N);
    for(auto& in:A) cin >> in;
    for(auto& in:B) cin >> in;
    
    int j = 0, pre = -1;
    for(int i = 0; i < N;i++){
        if(pre != A[i]){
            j = 0;
        }
        
        if(A[i] == B[i]){
            for(; j<N; j++){
                if(A[j] != A[i] && B[j] != A[i]){
                    swap(B[i],B[j]);
                    break;
                }
            }
            
            if(A[i] == B[i]){
                cout << "No" << endl;
                return res;
            }
        }
        pre = A[i];
    }
    
    cout << "Yes" << endl;
    cout << B << endl;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 4760
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)

fun isSquare(x: Int): Boolean{
    if (x == 1 || x == 0){
        return true
    }
    for (i in 1..x){
        if (x%i == 0 && i*i == x){
            return true
        }
    }
    return false
}

fun solve(N: Int, D: Int, X: Array<IntArray>){
    var ans = 0
    for (i in 0 until N){
        for (j in i+1 until N){
            val dest = IntArray(D){ X[i][it] - X[j][it] }.map{ it*it }.sum()
            if (isSquare(dest)) ans++
        }
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val D = sc.next().toInt()
    val X = Array<IntArray>(N){ IntArray(D) }
    for (i in 0 until N) {
        for (j in 0 until D) {
            X[i][j] = sc.next().toInt()
        }
    }
    solve(N, D, X)
}



Measured memory_bytes: 31480
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int n = s.length();
    int diff;
    int diffMin = -1;
    int x;
    for(int i = 0; i < n - 2; i++){
      x = 100 * (s.charAt(i) - 48) + 10 * (s.charAt(i + 1) - 48) + (s.charAt(i + 2) - 48);
      diff = x - 753;
      if(diff < 0) diff = -diff;
      if(diffMin == -1 || diff < diffMin) diffMin = diff;
    }
    
    System.out.println(diffMin);
  }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Diagnostics;

namespace CompetitiveProgramming
{

  class Solve 
  {
    public Solve() 
    {
      string s = Console.ReadLine();

      bool isUnbalance = false;
      s = "A" + s;
      for (int i = 2; i < s.Length && !isUnbalance; i++)
      {
        if (s[i - 1] == s[i])
        {
          Console.WriteLine("{0} {1}", (i - 1), i);
          isUnbalance = true;
          break;
        }
        if (s[i - 2] == s[i])
        {
          Console.WriteLine("{0} {1}", (i - 2), i);
          isUnbalance = true;
          break;
        }
      }
      if (!isUnbalance)
      {
        Console.WriteLine("-1 -1");
      }
    }
  }
  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }

}

Measured memory_bytes: 3288
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			if(n==1){
				System.out.println(2);
				break;
			}
			int count=1;
			int sum=2;
			for(int i=3;count<n;i+=2){
				boolean flag=true;
				for(int j=2;j<Math.sqrt(i)+1;j++){
					if(i%j==0){
						flag=false;
						break;
					}
				}
				if(flag){
					sum+=i;
					count++;
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 18988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    for (int i = 0; i < N; ++i)
        cin >> B[i];

    int idx = 0;
    queue<int> que;
    for (int i = 0; i < N; ++i) {
        while (idx < N && B[i] == B[idx])
            idx++;
        if (A[i] == B[i]) {
            if (idx < N) {
                swap(B[i], B[idx]);
            } else {
                while (!que.empty()) {
                    int t = que.front();
                    que.pop();
                    if (A[t] != B[i] && B[t] != A[i]) {
                        swap(B[t], B[i]);
                        break;
                    }
                }
                if (A[i] == B[i]) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        if (A[i] != B[i])
            que.push(i);
    }

    cout << "Yes" << endl;
    for (auto i : B)
        cout << i << ' ';
    cout << endl;

    return 0;
}


Measured memory_bytes: 5600
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    n,m = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    red = [0] * n
    red[0] = 1
    ball = [1] * n
    for i in range(m):
        x,y = map(int, stdin.readline().rstrip().split())
        if red[x-1] != 0 and ball[x-1] != 1:
            red[y-1] = 1
            ball[x-1] -= 1
            ball[y-1] += 1
        elif red[x-1] != 0 and ball[x-1] == 1:
            red[x-1] = 0
            red[y-1] = 1
            ball[x-1] -= 1
            ball[y-1] += 1
        else:
            ball[x-1] -= 1
            ball[y-1] += 1
    print(sum(red))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 10540
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> ans(n+1);
  for(int i = 0; i < n-1; i++){
      cin >> a.at(i);
      ans[a[i]]++;
  }
  for(int i = 1; i < n+1; i++){
      cout << ans[i]<< endl;
  }
}


Measured memory_bytes: 4840
N = int(input())
X = [0] * N
for i in range(N):
    a = int(input()) - 1
    X[a] = i

ma = 1
s = 0
for i in range(1, N):
    if X[i] < X[i-1]: s = i
    ma = max(ma, i - s + 1)

print(N - ma)

Measured memory_bytes: 47444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	ll h, w;
	cin >> h >> w;
    if (h==1 | w==1) {
        cout << 1 << endl;
        return 0;
    } else {
        cout << ((h+1)/2)*((w+1)/2) + (h/2)*(w/2) << endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=0;i<=1000000000;i++){
        if(abs(a-i)==abs(b-i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
#include<sstream>
using namespace std;
#define all(a) a.begin(),a.end()
typedef vector<int> vi;

int main()
{
	double a,b,c,d;
	const double r = 6378.1;
	while(cin>>a>>b>>c>>d&&b>=0)
	{
		a*=2*M_PI/360.0;
		b*=2*M_PI/360.0;
		c*=2*M_PI/360.0;
		d*=2*M_PI/360.0;
		double s=acos(cos(a)*cos(c)*cos(b-d)+sin(a)*sin(c));
		cout<<(int)(abs(r*s)+0.5)<<endl;
	}
}

Measured memory_bytes: 3480
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n>>m;
 string t,s;
 cin>>s>>t;
 ll l=lcm(n,m);
 map<ll,char>x;
 map<ll,bool>visited;
 ll c;
 rep(i,0,n){
  c=l/n*i+1;
  x[c]=s[i];
  visited[c]=true;
 }
 rep(i,0,m){
  c=l/m*i+1;
  if(visited[c]&&x[c]!=t[i]){
   puts("-1");return 0;
  }
 }
 pr(l);
 return 0; }



Measured memory_bytes: 18936
N = gets.to_i
W = gets.chomp.split.map(&:to_i)

p (0..N-2).map{|i|
    a = (0..i).inject(0){|sum, j| sum + W[j]}
    b = (i+1..N-1).inject(0){|sum, k| sum + W[k]}
    (a - b).abs
}.min

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

using namespace std;

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

const ll N = 100005;
const ll INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

struct E {
    ll a, b, c;
} arr[N];

ll n, dp[N][3];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i].a >> arr[i].b >> arr[i].c;
    
    dp[0][0] = arr[0].a;
    dp[0][1] = arr[0].b;
    dp[0][2] = arr[0].c;

    for(int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i].a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i].b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i].c;
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << endl;
}




Measured memory_bytes: 4992
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	last := map[int]int{}

	dbl := makeGrid(64, n+1)
	for i := n - 1; i >= 0; i-- {
		last[aa[i]] = i + n
	}
	for i := n - 1; i >= 0; i-- {
		if last[aa[i]] >= n {
			if last[aa[i]]+1 == n<<1 {
				dbl[0][i] = n
			} else {
				dbl[0][i] = (last[aa[i]] + 1) % n
			}
		} else {
			dbl[0][i] = dbl[0][(last[aa[i]]+1)%n]
		}
		last[aa[i]] = i
	}
	for i := 1; i < 64; i++ {
		for j := 0; j < n+1; j++ {
			dbl[i][j] = dbl[i-1][dbl[i-1][j]]
		}
	}
	p := 0
	for i := 60; i >= 0; i-- {
		if (k-1)>>uint(i)&1 == 1 {
			p = dbl[i][p]
		}
	}
	stack := make([]int, 0)
	m := map[int]int{}
	for i := p; i < n; i++ {
		if m[aa[i]] == 0 {
			m[aa[i]] = 1
			stack = append(stack, aa[i])
			continue
		}
		l := len(stack)
		for stack[l-1] != aa[i] {
			delete(m, stack[l-1])
			stack = stack[:l-1]
			l--
		}
		delete(m, stack[l-1])
		stack = stack[:l-1]
	}
	if len(stack) == 0 {
		fmt.Fprintln(writer, "")
		return
	}
	for i := 0; i < len(stack); i++ {
		fmt.Fprintln(writer, stack[i])
	}
}
func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


Measured memory_bytes: 142896
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

void Str2Year(char* str, int& year, int& month, int& day)
{
	char* tp;
	tp = strtok(str, "/");
	year = atoi( tp );

	tp = strtok(NULL, "/");
	month = atoi(tp);

	tp = strtok(NULL, "/");
	day = atoi(tp);
}

int main(void)
{
	char str[100];
	int year, month, day;

	scanf("%s", str);
	Str2Year(str, year, month, day);

	if (year<=2019 && month<=4 && day <=30){
		printf("Heisei");
	}
	else
	{
		printf("TBD");
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  string t = "";
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 2; j++){
      string tmp;
      if (i == 0){
        tmp += 'S';
      } else {
        tmp += 'W';
      }
      if (j == 0){
        tmp += 'S';
      } else {
        tmp += 'W';
      }
      for (int k = 2; k < N; k++){
        if ((tmp[k - 1] == 'S') ^ (s[k - 1] == 'o') ^ (tmp[k - 2] == 'S')){
          tmp += 'S';
        } else {
          tmp += 'W';
        }
      }
      bool ok = true;
      if ((tmp[N - 2] == 'S') ^ (tmp[N - 1] == 'S') ^ (tmp[0] == 'S') ^ (s[N - 1] == 'o')){
        ok = false;
      }
      if ((tmp[N - 1] == 'S') ^ (tmp[0] == 'S') ^ (tmp[1] == 'S') ^ (s[0] == 'o')){
        ok = false;
      }
      if (ok){
        t = tmp;
      }
    }
  }
  if (t == ""){
    cout << -1 << endl;
  } else {
    cout << t << endl;
  }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for(int i = 0; i < 3; i++) {
    if(S.at(i) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        int kazu = int.Parse(ReadLine());
        string[] reader = ReadLine().Split(' ');
        int hp = int.Parse(reader[0]);
        int attack = int.Parse(reader[1]);
        
        int count = hp / attack;
        if(attack * count >= hp){
            WriteLine(count);
        }else{
            WriteLine(count+1);
        }
        
/*        string[] hyokol = ReadLine().Split(' ');
        double minsa = 99999999;
        int titen = 0;
        for(int i=0;i<kazu;i++){
            int hyoko = int.Parse(hyokol[i]);
            double hiku = (double)(hyoko*6)/1000;
            double kionh = (double)kion - hiku;
            double sa = Abs(kionh - (double)moku);
//            WriteLine(kionh);
//            WriteLine(sa);
            if(minsa > sa){
                minsa = sa;
                titen = i+1;
            }
        }
        WriteLine(titen);*/
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include    <algorithm>
#include    <vector>
#include    <string>
#include <cmath>
#include <limits>

using namespace std;

	
int main(){
	long k,s;
	cin >> k >> s;

	long count = 0;
	int max_x = min(k,s);
	for(int x=0;x<=max_x;x++){
		int max_y = min(k,s-x);
		for(int y=0;y<=max_y;y++){
			int z = s-x-y;
			if(z>=0 && z<=k) count += 1;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
ABC = list(map(int, input().split()))
K = int(input())

r = ABC[0]
b = ABC[1]
g = ABC[2]

for i in range(K):
    if (r < b and b < g):
        print("Yes")
        exit()
    elif (r >= b):
        b *= 2
    elif (b >= g):
        g *= 2

if (r < b and b < g):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));//p^num
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 1110000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    comb_init();
    auto res = prime_factorize(m);
    ll ans = 1;
    for(auto x : res){
        ans *= comb(x.second+n-1, x.second);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 26240
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <iterator>
using namespace std;

int main() {
	string s;
	for (;;) {
		cin >> s;
		if (s == "0") {
			break;
		}
		int n = 0;
		for (char c : s) {
			n += c - '0';
		}
		cout << n << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

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())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

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


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  string s;
  cin >> s;

  int min_count = 1e9;
  int max_count = -1e9;
  for (char ch : {'a', 'b', 'c'}) {
    const int cnt = count(ALL(s), ch);
    mini(min_count, cnt);
    maxi(max_count, cnt);
  }

  const bool good = max_count - min_count <= 1;

  cout << (good ? "YES\n" : "NO\n");
}


Measured memory_bytes: 512
n, m = (int(x) for x in input().split())
ans = [None for _ in range(n)]
fail = False
for _ in range(m):
    s,c = (int(x) for x in input().split())
    s -=1
    if ans[s] is None:
        ans[s] = c
    elif ans[s] != c:
        fail = True
        break
if fail or (ans[0] == 0 and n > 1):
    print(-1)
else:
    if ans[0] is None and n > 1:
        ans[0] = 1
    elif ans[0] is None and n == 1:
        ans[0] = 0
    print(''.join((str(i) if i is not None else '0' for i in ans)))

Measured memory_bytes: 38256
n, q = map(int, input().split())
com, x, y = [0] * q, [0] * q, [0] * q
for i in range(q):
    com[i], x[i], y[i] = map(int, input().split())

#初期化 par:親の番号 rank:高さ
par = [i for i in range(n)]
rank = [0 for _ in range(n)]
#木の根を求める
def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x] 
#xとyが同じ集合に属するか否か
def same(x, y):
    return root(x) == root(y)
#xとyの属する集合を併合
def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
    if rank[x] == rank[y]:
        rank[x] += 1

#クエリ
for i in range(q):
    if com[i] == 0:
        unite(x[i], y[i])
    else:
        if same(x[i], y[i]):
            print(1)
        else:
            print(0)


Measured memory_bytes: 15216
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int f(int x) {
   int res = 0;
   while (x) {
      res += x % 10;
      x /= 10;
   }
   return res;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   cin >> n;
   if (!(n % f(n)))
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[114514];
signed main() {
	cin >> n;
	int ma = 0, mi = 114514;
	rep(i, n) {
		cin >> a[i];
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	if (ma == mi) {
		if (ma == n - 1 || ma <= n / 2)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (ma - mi == 1) {
		int micnt = 0;
		rep(i, n)if (a[i] == mi)micnt++;
		if (micnt < ma&&mi <= (n - micnt) / 2 + micnt - 1)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		cout << "No" << endl;
	}
	endre;
}

Measured memory_bytes: 1024
import java.util.Scanner

import scala.annotation.tailrec

object Main extends App {
  val sc = new Scanner(System.in)
  val s = sc.next

  @tailrec
  def solve(s: String) : String = {
    s match {
      case "" => "YES"
      case _ if s startsWith "dreameraser" => solve(s.drop(11))
      case _ if s startsWith "dreamerase"  => solve(s.drop(10))
      case _ if s startsWith "dreamer"     => solve(s.drop(7))
      case _ if s startsWith "dream"       => solve(s.drop(5))
      case _ if s startsWith "eraser"      => solve(s.drop(6))
      case _ if s startsWith "erase"       => solve(s.drop(5))
      case _ => "NO"
    }
  }

  println(solve(s))
}


Measured memory_bytes: 115344
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
A = LI()
A = sorted(A)

if N == 1:
    print(1)
    exit()

if A[0] == 1:
    if N >= 2 and A[1] == 1:
        print(0)
        exit()
    else:
        print(1)
        exit()

B = [0]*(10**6+1)
C = [0]*(10**6+1)
for i in range(len(A)):
    if B[A[i]] == 0:
        C[A[i]] = 1
    for j in range(A[i]*2,10**6+1,A[i]):
        B[j] = 1

from collections import Counter

c = Counter(A)

for i in c.keys():
    if c[i] >= 2:
        C[i] = 0

print(sum(C))

Measured memory_bytes: 130064
#include <stdio.h>

int main()
{
	double a, b, c, d, e, f;
	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF)
	{
		double y = (a*f - c*d) / (a*e - b*d);
		double x = (c - b*y) / a;

		printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1080
num = [int(i) for i in str(input())]
for i in range(1<<3):
    bin_i = format(i, '03b')
    count = num[0]
    ans = str(num[0])
    for j in range(3):
        if bin_i[j]=='1':
            count+= num[j+1]
            ans += '+'+str(num[j+1])
        else:
            count+= -num[j+1]
            ans += '-'+str(num[j+1])
    if count==7:
        print(ans+'=7')
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 3) {
    ans += 100000;
  } else if (x == 2) {
    ans += 200000;
  } else if (x == 1) {
    ans += 300000;
  }
  if (y == 3) {
    ans += 100000;
  } else if (y == 2) {
    ans += 200000;
  } else if (y == 1) {
    ans += 300000;
  }
  if (x == 1 && y == 1) {
    ans += 400000;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<stdlib.h>
#include<time.h>
using namespace std;
struct point { double x; double y; };

int main() {
	int n;
	int l[11];
	int sum = 0;
	int check = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		sum = sum + l[i];
	}
	for (int i = 0; i< n; i++) {
		int b;
		b = sum - l[i];
		if (l[i] >= b)check++;
	}
	if (check > 0) cout << "No"<<endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        q:usize,
        s:chars,
        lr: [(usize, usize);q],
    }
    let mut cur=vec![0;n];
    for i in 0..n-1 {
        if s[i]=='A' && s[i+1]=='C' {
            cur[i+1]+=1;
        }
    }
    for i in 0..n-1 {
        cur[i+1]+=cur[i];
    }
    // for i in cur {
    //     println!("{}", i);
    // }
    for (l, r) in lr {
        println!("{}", cur[r-1] - cur[l-1]);
        // println!("{} {}", l, r);
    }
}

Measured memory_bytes: 6908
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int a, b, c; cin >> a >> b >> c;

    int cnt = 0;
    for (int i = a; i <= b; i++) {
        if (!(c % i)) {
            cnt++;
        }
    }
    cout << cnt << '\n';
}



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

int countDivisibles(int A, int B, int M) 
{  
	int counter = 0; 
	for (int i = A; i <= B; i++) 
		if (i % M == 0) 
			counter++; 

	return counter; 
} 


int main() 
{ 
	 int A, B, M;
	 cin >> A >> B >> M;
	cout << countDivisibles(A, B, M) << endl; 
	return 0; 
} 


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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  int ak = a / k;
  int bk = b / k;
  if (a % k == 0 || b % k == 0 || bk - ak != 0) cout << "OK" <<endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using llong = long long;

llong n, m;
vector<llong> maxv;
vector<llong> minv;
vector<llong> max_l;
vector<llong> max_r;

llong solve() {
  maxv.assign(n + 1, 0);
  minv.assign(n + 1, 0);
  max_l.assign(n + 1, 0); // [0, i)
  max_r.assign(n + 1, 0); // (i, n-1]

  for (int i = 0; i < m; i++) {
    int s, c;
    cin >> s >> c;
    for (int i = 0; i < c; i++) {
      int id;
      cin >> id;
      maxv[id] += s;
      if (c == 1) minv[id] += s;
    }
  }

  for (int i = 1; i <= n; i++) {
    max_l[i] = max(max_l[i - 1], maxv[i - 1]);
  }
  for (int i = n - 1; i > 0; i--) {
    max_r[i] = max(max_r[i + 1], maxv[i + 1]);
  }

  llong ans = 0;
  for (int i = 1; i <= n; i++) {
    llong mv = max(max_l[i], max_r[i]);
    ans = max(ans, mv - minv[i] + 1);
  }

  return ans;
}

int main() {
  while (cin >> n >> m, n != 0) {
    cout << solve() << endl;
  }
}



Measured memory_bytes: 3356
#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
def main():
    S = input()
    K = int(input())
    output = solve(S, K)
    print(output)
    return

def solve(S, K):
    if K <= len(S) and S[:K] == "1"*K:
        # 文字列の1番目からK番目までがすべて1だった場合、
        # それ以降の文字列に1以外の数字があっても1が答え
        return "1"
    for s in S:
        if not s == "1":
            return s  # Sの"1"ではない、最初の数字が答え
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
bool boin(char c){
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') return true;
  return false;
}
int main(){
  int n;
  cin >> n;
  while(n!=0){
    int max_size=0;
    bool same;
    string s[n],code[n],subcode[n];
    for(int i=0;i<n;i++){
      cin >> s[i];
      code[i]=s[i][0];
      for(int j=0;j<s[i].size()-1;j++){
        if(boin(s[i][j])) code[i]+=s[i][j+1];
      }
      max_size=(max_size>code[i].size())?max_size:code[i].size();
    }
    for(int k=1;k<=max_size;k++){
      for(int j=0;j<n;j++){
        subcode[j]=code[j].substr(0,k);
      }
      same=false;
      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
          if(subcode[i]==subcode[j]){
            same=true;
            break;
          }
        }
        if(same) break;
      }
      if(same==false){
        cout << k<<endl;
        break;
      }
      if(same==false) break;
    }
    if(same==true) cout << "-1\n";
    cin >> n;
  }
}



Measured memory_bytes: 3180