akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ans;

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

  if(a+b<c) ans = a+b+1+b;
  else ans = b+c;

  cout << ans << endl;


}



Measured memory_bytes: 256
N, A, B, C, D = map(int,input().split())
S = input()
slist = list(S)
buf = "".join(slist[A:max(C,D)-1])
 
judge = buf.find("##")
 
if judge != -1:
  print("No")
else:
  if C < D:
    print("Yes")
  else:
    s_change= "".join(slist[B-2:D+1])
    judge = s_change.count("...")
    if judge > 0:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 6580
import sys
n, m, x, y = map(int, input().split())
x1 = max(list(map(int, input().split())))
y1 = min(list(map(int, input().split())))


for i in range(x+1, y+1):
    if x1 < i <= y1:
        print('No War')
        sys.exit()
print('War')



Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>
#include <list>

#define MOD (1000000000 + 7)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}
// テーブルを作る前処理
void COMinit() {
    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 COM(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;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 

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

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll ret = 0;
    for(ll one = '0'; one <= '9'; one++) {
        for(ll two = '0'; two <= '9'; two++) {
            for(ll three = '0'; three <= '9'; three++) {
                bool flag_one = false;
                bool flag_two = false;
                bool flag_three = false;
                for(ll i = 0; i < S.size(); i++) {
                    if(flag_one == false && S[i] == one) {
                        flag_one = true;
                        continue;
                    } else if(flag_one == true && flag_two == false && S[i] == two) {
                        flag_two = true;
                        continue;
                    } else if(flag_one == true && flag_two == true && flag_three == false && S[i] == three) {
                        ret++;
                        break;
                    }
                } 
            }
        }
    }

    cout << ret << endl;
}



Measured memory_bytes: 3788
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n; cin >> n;
	vector<int>p(n); for (auto& e : p)cin >> e;
	vector<int>pa(n); for (int i = 0; i < n; ++i)pa[i] = i + 1;

	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (cnt > 2) { cout << "NO" << endl; return 0; }
		if (p[i] != pa[i])++cnt;
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
struct Edges { int to, next; } e[MAXN * 2];
int head[MAXN], tot;
int f[MAXN], g[MAXN];
int a[MAXN], b[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
  e[++tot] = (Edges){from, head[to]};
  head[to] = tot;
}

void Get(int now, int fa, int &node, int dis, int &mx) {
  if (dis > mx) mx = dis, node = now;
  f[now] = fa;
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != fa)
      Get(e[i].to, now, node, dis + 1, mx);
}

void Check(int now, int last, int x, int y, int dis, int &sum) {
  if (dis == 2) puts("-1"), exit(0);
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != x && e[i].to != y && e[i].to != last) 
      Check(e[i].to, now, x, y, dis + 1, sum), ++sum;
}
void Solve(int S, int *a) {
  memset(g, 0, sizeof(g));
  int T, mx;
  mx = 0, Get(S, 0, T, 0, mx);
  int now = T, last = 0, cur = 1;
  while (666) {
    Check(now, 0, f[now], last, 0, g[now]);
    last = now;
    now = f[now];
    if (now == S) break;
  }
  now = T;
  while (666) {
    for (RI i = cur; i < cur + g[now]; ++i)
      swap(a[i], a[i + 1]);
    cur += g[now] + 1;
    now = f[now];
    if (now == S) break;
  }
}

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1, x, y; i < n; ++i)
    read(x), read(y), addedge(x, y);
  int S, T, mx;
  mx = -1, Get(1, 0, S, 0, mx);
  mx = -1, Get(S, 0, T, 0, mx);
  for (RI i = 1; i <= n; ++i)
    a[i] = b[i] = i;
  Solve(S, a);
  Solve(T, b);
  int flag = 0;
  for (RI i = 1; i <= n; ++i)
    if (a[i] < b[i]) break;
    else if (a[i] > b[i]) { flag = 1; break; }
  for (RI i = 1; i <= n; ++i)
    printf("%d ", flag ? b[i] : a[i]);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 11520
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int main() {

	int a, b, i;

	cin >> a >> b;

	if (a >= b) {
		for (i = 0; i < a; i++) {
			cout << b;
		}
	}
	else {
		for (i = 0; i < b; i++) {
			cout << a;
		}
	}

	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);
		
		int n = sc.nextInt();
		int w = sc.nextInt();
		
		int []wei = new int [n];
		int []val = new int [n];
		
		for(int i = 0 ; i < n ; i++) {
			wei[i] = sc.nextInt();
			val[i] = sc.nextInt();
		}
		long [][]dp = new long [n+1][w+1];
		
		for(int i = 0; i < n ;i++) {
			for(int j = 0 ; j <= w ; j++) {
				if(j - wei[i] >= 0) {
					dp[i+1][j] = Math.max(dp[i][j] ,dp[i][j -wei[i]] + val[i]);
				}
				else {
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		System.out.println(dp[n][w]);

	}

}


Measured memory_bytes: 126032
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  int a[20];
  cin>>n;
  rep(i,n) cin>>a[i];
  int cnt=0;
  repi(i,1,n-1){
    if(a[i]>a[i-1] && a[i]<a[i+1]) cnt++;
    else if(a[i]<a[i-1] && a[i]>a[i+1]) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
d = defaultdict()

for _ in range(n):
    a = input()
    if '.' in a:
        b = a.split('.')
        a = int(b[0] + b[1])
        cnt2 = -len(b[1])
        cnt5 = -len(b[1])
    else:
        a = int(a)
        cnt2 = 0
        cnt5 = 0
    while a % 2 == 0:
        cnt2 += 1
        a //= 2
    while a % 5 == 0:
        cnt5 += 1
        a //= 5
    if (cnt2, cnt5) in d:
        d[(cnt2, cnt5)] += 1
    else:
        d[(cnt2, cnt5)] = 1

ans = 0

for k1, v1 in d.items():
    for k2, v2 in d.items():
        x1, y1 = k1
        x2, y2 = k2
        if k1 != k2:
            if x1 + x2 >= 0 and y1 + y2 >= 0:
                ans += v1 * v2
        else:
            if x1 + x2 >= 0 and y1 + y2 >= 0:
                ans += v1 * (v1 - 1)

print(ans // 2)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  while(true) {
    int n;
    cin >> n;

    if(n == 0) {
      break;
    }

    V<int> a(n);

    rep(i, n) {
      cin >> a[i];
    }

    V<V<int>> dp(n, V<int>(n));
    rep(i, n) {
      dp[i][i] = 0;
      int j = i + 1;
    }

    int len = 2;
    for(int i = 0; i + len <= n; i++)  {
      int j = i + len - 1;

      if(abs(a[i] - a[j]) <= 1) {
        dp[i][j] = 2;
      } else {
        dp[i][j] = 0;
      }
    }

    for(len = 3; len <= n; len++) {
      for(int i = 0; i + len <= n; i++) {
        int j = i + len - 1;

        int cand1 = 0;
        if(dp[i + 1][j - 1] == len - 2) {
          cand1 = len - 2;

          if(abs(a[i] - a[j]) <= 1) {
            cand1 += 2;
          }
        }


        int cand2 = 0;
        repf(k, i, j) {
          cand2 = max(cand2, dp[i][k] + dp[k + 1][j]);
        }

        dp[i][j] = max(cand1, cand2);
      }
    }
    cout << dp[0][n - 1] << endl;
  }
}


Measured memory_bytes: 3296
N=int(input())
ab=[list(map(int,input().split())) for i in range(N-1)]
data=[[] for i in range(N+1)]
for a,b in ab:
    data[a].append(b)
    data[b].append(a)
flag=[-1]*(N+1)
flag[1]=0
que=[1]
l=1
while que:
    h=[]
    for u in que:
        for v in data[u]:
            if flag[v]==-1:
                flag[v]=l
                h.append(v)
    l+=1
    que=h
ind=0
num=0
for i in range(1,N+1):
    if num<flag[i]:
        num=flag[i]
        ind=i
flag=[-1]*(N+1)
flag[ind]=0
que=[ind]
l=1
while que:
    h=[]
    for u in que:
        for v in data[u]:
            if flag[v]==-1:
                flag[v]=l
                h.append(v)
    l+=1
    que=h
num=max(flag)+1
if num%3==2:
    print("Second")
else:
    print("First")

Measured memory_bytes: 121252
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 500005;

int main()
{
    int n,p,q;
    ll a[MAX_N];
	scanf("%d%d%d",&n,&p,&q);
	rep(i,n){
		scanf("%lld",&a[i]);
        a[i] += (ll)i*p;
	}
    sort(a,a+n);
    ll ch = 0;
    ll lh = 0;
    ll mx = 0;
    rep(k,n){
        lh += a[k];
        ch += (ll)p*(q + 2*k);
        if(ch - lh > mx){
            mx = ch-lh;
        }
    }
    ll sub = 0;
    rep(i,n-1){
        sub += (ll)(i+1)*p;
    }
    printf("%lld\n",accumulate(a,a+n,0LL) + mx - sub);
	return 0;
}

Measured memory_bytes: 7172
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define bitcount(n) __builtin_popcount(n)

int main(){
    string S;
    cin >> S;
    cout << 700 + character_count(S, 'o') * 100 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int f[100];
int main(void){
    // Your code here!
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i < b; i++) {
        int rem = a * i % b;
        f[rem]++;
    }
    if (f[c] == 0) cout << "NO" << endl;
    else cout << "YES" << endl;
}


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

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

    double p[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        p[i] = (p[i] + 1) / 2;
    }

    double mx = 0;
    double now = 0;
    for (int i = 0; i < N; i++) {
        if (i < K) {
            now += p[i];
            mx = now;
            continue;
        }
        now = now + p[i] - p[i - K];
        mx = max(mx, now);
    }

     printf("%.12f", mx);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi B(M),C(M);
  map<int,int> m;
  rep(i,0,N) m[A[i]]++;
  for(auto p:m){
    int X=p.first,Y=p.second;
    B[X%M]+=Y;
    C[X%M]+=Y/2;
  }
  int ans=0;
  rep(i,1,(M+1)/2){
    ans+=min(B[i],B[M-i]);
    if(B[i]>B[M-i]) ans+=min((B[i]-B[M-i])/2,C[i]);
    else ans+=min((B[M-i]-B[i])/2,C[M-i]);
  }
  ans+=B[0]/2;
  if(M%2==0) ans+=B[M/2]/2;
  cout<<ans<<endl;
  }



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> s_p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        s_p[i] = p[i];
    }
    sort(s_p.begin(), s_p.end());
    int w_c = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != s_p[i]) w_c++;
    }
    if(w_c > 2){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){for(Scanner s=new Scanner(System.in);s.hasNext();){int i,r=0,j;double[][]p=new double[4][6];for(i=0;i<3;++i)for(j=0;j<2;++j)p[j][i]=p[j][i + 3]=s.nextDouble();p[3]=new double[]{s.nextDouble(),s.nextDouble()};double l=0,t;for(i=0;i<3;p[2][0]+=p[0][i]*t,p[2][1]+=p[1][i++]*t,l+=t)t=Math.sqrt(Math.pow(p[0][i+1]-p[0][i+2],2)+Math.pow(p[1][i+1]-p[1][i+2],2));for(i=0;i<3;++i)if(java.awt.geom.Line2D.Double.linesIntersect(p[2][0]/l,p[2][1]/l,p[3][0],p[3][1],p[0][i],p[1][i],p[0][i+1],p[1][i+1]))r=1;System.out.println(r>0?"NO":"YES");}}}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    long i; bool kt = true;
    for (i = 1; i < S.length(); i++)
    {
        if (S[i] == S[i - 1]) 
        {
            cout << "Bad" << endl;
            kt = false;
            break;
        }
    }
    if (kt) cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ll l,r;
		cin>>l>>r;
		ans+=(r-l+1);
	}
	cout<<ans;
	return;
}
int main()
{
	fast;
	int q;
	q=1;
	// cin>>q;
	while(q--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3596
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    if (sc.next().matches("^[0-9]{${a}}-[0-9]{${b}}$".toRegex())) {
        println("Yes")
    } else {
        println("No")
    }
}

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

// macros
#define M 1000000007
#define addmod(a,b,m) (a%m + b%m)%m
#define submod(a,b,m) (a%m - b%m)%m
#define mulmod(a,b,m) ((a%m)*(b%m))%m
#define F first
#define S second
#define APSUM(a,b,n) n*((a*.5)+(b*.5))
#define GPSUM(a,b,k) (b*k-a)/(k-1)
#define INFGP(a,k) a/(1-r)
#define CEIL(a,b) ceil(double(a)/double(b))
#define FLOOR(a,b) floor(double(a)/double(b))
#define T(t) while(t--)
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

//typedefs
typedef long long int ll ;
typedef vector<ll> vi ;
typedef pair<ll,ll> pi ;
typedef map<ll,ll> mps;

ll power(ll base,ll val)
{
    ll res=1;
    while(val)
    {
        if(val&1)
    {
        res = (res*base)%M;
    }
     base = (base*base)%M;
     val/=2;
    }
    return res;
}
ll digit(ll n)
{
    double phi = (1 + sqrt(5))/2;
    ll value = round(pow(phi,n)/(sqrt(5)));
    ll count=0;
    while(value)
    {
        count++;
        value/=10;
    }
    return count;
}
set<tuple<ll,ll,ll> > ss;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
/*
when files are giving the inputs and outputs
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);

*/
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll>red,green,blue;

    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            red.push_back(i);
        }
        else if(s[i]=='B')
        {
            blue.push_back(i);
        }
        else
            green.push_back(i);
    }
    if(blue.size()==0||green.size()==0||red.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
            ll sum=0;
    for(ll i=0;i<n;i++)
    {

        for(ll j=i+1;j<n;j++)
        {
           // cout<<i<<" "<<j<<endl;
            if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R'))
            {
                ll ind = lower_bound(green.begin(),green.end(),j) - green.begin();
                //cout<<ind<<endl;
                sum+=green.size()-ind;
                //cout<<sum<<endl;
                ll check = lower_bound(green.begin(),green.end(),j + j-i) - green.begin();
                    if(green[check]==j+ j-i)
                        sum--;
            }
            else if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R'))
            {
                    ll ind = lower_bound(blue.begin(),blue.end(),j) - blue.begin();
                  //  cout<<ind<<endl;
                sum+=blue.size()-ind;
            //    cout<<sum<<endl;
                ll check = lower_bound(blue.begin(),blue.end(),j + j-i) - blue.begin();
                    if(blue[check]==j+ j-i)
                        sum--;
            }
            else if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G'))
            {
                   ll ind = lower_bound(red.begin(),red.end(),j) - red.begin();
                //cout<<ind<<endl;
                sum+=red.size()-ind;
                //cout<<sum<<endl;
                ll check = lower_bound(red.begin(),red.end(),j + j-i) - red.begin();
                    if(red[check]==j+ j-i)
                        sum--;
            }
        }
    }
    cout<<sum<<endl;
    }

}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int n;
    string s;
    vector<pair<int, int>> ss;
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>s;
        int cnt = 0;
        int mn = INF;
        for (char c: s) {
            if (c == '(') cnt++;
            else cnt--;
            mn = min(mn, cnt);
        }
        ss.push_back({cnt, mn});
    }
    sort(ss.begin(), ss.end(), [] (pair<int, int> x, pair<int, int> y) {
        return min(x.second, x.first + y.second) > min(y.second, y.first + x.second);
    });
    int cnt = 0;
    for (pair<int, int> p: ss) {
        if (cnt + p.second < 0) {
            cout<<"No"<<endl;
            return 0;
        }
        cnt += p.first;
    }
    if (cnt == 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 19772
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>  
#include <iterator>    
#include <set>
#include <iomanip>
using namespace std;

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


    double count = 0;
    vector <long long > v(N);
    cin >> v[0];
    

    for (int i =1 ; i < N ; i++){
        cin >> v[i];
    }


    sort(v.begin(), v.end());
    count = v[0];
    for (int i =1 ; i < N ; i++){
        count = (count + v[i]) / 2;
    }

    cout << count << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

vector<int> ans,ball;

int main() {
    int n;
    cin >> n;
    ball.resize(n+1);
    vector<int> a(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; --i) {
        int tmp = n/i,cnt = 0,ma;
        ma = tmp*i;
        for (int j = ma; j > i; j-=i) {
            cnt += ball[j];
        }
        if(cnt %2 != a[i]){  // 足し算して偶奇違ったら入れる
            ball[i] = 1;
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll; typedef vector<int> vi;
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; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, H, W;
string s;

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

    write(min(C, B / A));
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<string>
#include<algorithm>
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
int a;
cin>>a;
for(int i=0;i<a;i++){
int t;
  cin>>in>>t;
string tmp=in;
p[i]=make_pair(make_pair(in,-t),i);
}
sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);
}


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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;


int res(vector<int>&v){
     vector<int>dp(v.size()+1,INT_MAX);
     dp[0]=0;
     dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<v.size();i++){
        dp[i] = min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
    }
    return dp[v.size()-1];
}
void solve(){
    int x;
    cin>>x;
    vector<int>v(x);
    for(int i=0;i<x;i++){
        cin>>v[i];
    }
    cout<<res(v);
}

int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
  return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mxn 2010
using namespace std;

int a[mxn*2],n,x;
int mn[mxn*2][mxn*2];
int main()
{
	ll ans=(ll)inf*inf,tmp;
	memset(mn,63,sizeof(mn));
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),a[n+i]=a[i];
	for(int i=1;i<=n*2;i++)	for(int j=i;j<=n*2;j++)
		mn[i][j] = min(mn[i][j-1],a[j]);
	for(int i=0;i<=n;i++)
	{
		tmp = (ll)x*i;
		for(int j=1;j<=n;j++)
			tmp += mn[n+j-i][n+j];
		ans=min(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> D(N);
  for(int i = 0; i < N; ++i){
    cin >> D[i];
  }
  ll ans = 0;
  for(int p = 0; p <= min(N, K); p++){
    for(int q = 0; p + q <= min(N, K); q++){
      vector<int> d;
      ll sum = 0;
      for(int i = 0; i < p; ++i){
	sum += D[i];
	d.push_back(D[i]);
      }
      for(int i = 0; i < q; ++i){
	sum += D[N-1-i];
	d.push_back(D[N-1-i]);
      }
      sort(d.begin(), d.end());
      for(int i = 0; i < K - p - q && i < d.size(); ++i){
	if(d[i] < 0) sum -= d[i];
      }
      ans = max(ans, sum);
    }
  }
  cout << ans << endl;
  
}


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

#define ll long long
#define ull unsigned long long
#define mem(Arr,x) memset(Arr,x,sizeof(Arr))

const int maxN=101000;
const int maxM=maxN*2;
const ull base=20729;
const int inf=2147483647;

int n;
int edgecnt=0,Head[maxN],Next[maxM],V[maxM];
ull W[maxN];

void dfs(int u);

int main()
{
	mem(Head,-1);
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int a,b;scanf("%d%d",&a,&b);
		edgecnt++;Next[edgecnt]=Head[a];Head[a]=edgecnt;V[edgecnt]=b;
	}
	dfs(1);
	sort(&W[1],&W[n+1]);
	//for (int i=1;i<=n;i++) cout<<W[i]<<" ";cout<<endl;
	ll Ans=0;
	W[++n]=inf;
	for (int i=1,j=0;i<=n;i++) if (W[i]!=W[j]) Ans=Ans+1ll*(ll)(i-1-j+1)*(ll)(i-1-j)/2,j=i;
	printf("%lld\n",Ans);
	return 0;
}

void dfs(int u)
{
	W[u]=1;
	for (int i=Head[u];i!=-1;i=Next[i])
	{
		dfs(V[i]);
		W[u]=W[u]+W[V[i]]*base;
	}
	return;
}



Measured memory_bytes: 8292
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,l,id,tot=1<<30,ans;
int main(){
	in(n);in(l);
	for(int i=1;i<=n;i++){
		int x=l+i-1;
		if(x==0){
			id=i;
			break;
		}
		if(abs(x)<abs(tot)){
			id=i;
			tot=x;
		}
	}
	for(int i=1;i<=n;i++){
		if(i!=id)ans+=(l+i-1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    r = a % b
    while r != 0:
        a, b = b, r
        r = a % b

    return b


x, y = map(int, input().split())
a = []
i, g = 0, 0

while True:
    if len(a) == 0:
        g = x
    elif len(a) == 1:
        g = x * 2
    else:
        g = a[i-1]*a[i-2]/gcd(a[i-1], a[i-2])
        if g == a[i-1]:
            g *= 2

    if g > y:
        break
    else:
        a.append(g)
        i += 1

print(len(a))


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  for (int i = 0; i < N; i++) {
	  int c, t;
	  cin >> c >> t;
	  if (t <= T) {
		  ans = min(ans, c);
		}
	}
  if (ans == 10000) {
	  cout << "TLE" << endl;
	} else {
	  cout << ans << endl;
	}
  return 0;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = a;
	int cnt = 1;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	while (ans < b){
		ans += a - 1;
		cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

mp = defaultdict(lambda: [0, 0])
for i in range(1, N+1):
    L = i + A[i-1]
    R = i - A[i-1]
    mp[L][0] += 1
    mp[R][1] += 1

ans = 0
for v in mp.values():
    ans += v[0] * v[1]
print(ans)

Measured memory_bytes: 151440
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A * B % 2 == 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int K, X; cin >> K >> X;

    int left = max((int)-1e6, X-K+1);
    int right = min(X+K-1, (int)1e6);

    cout << left;
    for(int i=left+1; i<=right; i++) {
        cout <<" " << i;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
k,n = list(map(int,input().split()))
A = list(map(int,input().split()))

max_distance = 0

for i in range(n):
  if max_distance < abs(A[i] - A[i-1]):
    max_distance = min(abs(A[i] - A[i-1]),k - abs(A[i] - A[i-1]))

print(k - max_distance)

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

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

 int main() {
   ll X, Y;
   int ans = 0;
   cin >> X >> Y;
   while(X <= Y) {
     ans++;
     X *= 2;
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
from itertools import groupby

# 出力
N, M = map(int, input().split())
a = list(map(int, input().split()))
x, y = (
    zip(*(map(int, input().split()) for _ in range(M))) if M else
    ((), ())
)


class UnionFindTree:
    def __init__(self, n):
        self.p = [i for i in range(n + 1)]
        self.r = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.p[x] != x:
            self.p[x] = self.find(self.p[x])
        return self.p[x]

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.r[px] < self.r[py]:
                self.p[px] = py
            else:
                self.p[py] = px
                if self.r[px] == self.r[py]:
                    self.r[px] += 1

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


# 各連結成分のうち、a_iが最小の頂点は必ず使う
# 不足している分はa_iが小さい頂点から順に補えばよい
uft = UnionFindTree(N - 1)
for X, Y in zip(x, y):
    uft.union(X, Y)

C = [
    sorted(c, key=lambda i: a[i])
    for _, c in groupby(
        sorted(range(N), key=uft.find),
        uft.find
    )
]

K = 2 * (len(C) - 1)
S = {c[0] for c in C}

ans = (
    'Impossible' if K > N else
    0 if K == 0 else
    sum(a[s] for s in S) +
    sum(sorted(a[i] for i in range(N) if i not in S)[:(K - len(C))])
)

# 出力
print(ans)


Measured memory_bytes: 61656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  
  if (b == 'A'){ cout << 'T' <<endl;}
  if (b == 'T'){ cout << 'A' <<endl;}
  if (b == 'G'){ cout << 'C' <<endl;}  
  if (b == 'C'){ cout << 'G' <<endl;}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
que = [-1, -1, -1]
ans = 1
for i in range(n):
  if que[0]+1 == a[i]:
    if que[0] == que[1] and que[0] == que[2]:
      ans *= 3
      ans %= (10**9 + 7)
    elif que[0] == que[1]:
      ans *= 2
      ans %= (10**9 + 7)
    que[0] = a[i]
  elif que[1]+1 == a[i]:
    if que[1] == que[2]:
      ans *= 2
      ans %= (10**9 + 7)
    que[1] = a[i]
  elif que[2]+1 == a[i]:
    que[2] = a[i]
  else:
    ans = 0
    break
print(ans)


Measured memory_bytes: 14072
#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()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n];
    ll ans = 0 ,tmp;
    rep(i,n) cin >> a[i];
    rep(i,n-1) {
        if (a[i]>a[i+1]) {
            tmp = a[i] - a[i+1];
            ans += tmp;
            a[i+1] += tmp;
        }
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 5208
#include <stdio.h>
  
#define M 100001
#define MAX(a,b) ((a) < (b) ? (b) : (a))
  
int par[M],sib[M],deg[M];
int height[M],deph[M];
  
void init(int);
int depth(int,int);
  
int main(void){
  int n,i,id,l,r,t;
  
  scanf("%d" ,&n); 
  init(n);  
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&t);
  
 
    if(l != -1){
      par[l] = id;
      deg[id]++;
    }
    if(t != -1){
      par[t] = id;
      deg[id]++;
    }
    if(l != -1 && t != -1){
      sib[l] = t;
      sib[t] = l;
    }
  }
  
  for(i = 0 ; i < n ; i++){
    deph[i] = depth(i,0);
  }
  
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, sibling = %d, "
       ,i, par[i], sib[i]);
  
    printf("degree = %d, depth = %d, height = %d, "
       , deg[i], deph[i], height[i]);
      
    if(par[i] == -1){
      printf("root\n");
    }else if(deg[i] != 0){
      printf("internal node\n");
    }else{
      printf("leaf\n");
    }
  }
  
  return 0;
}
  
void init(int n){
  int i;
  
  for(i = 0 ; i < n ; i++){
    par[i] = sib[i] = -1;
    deg[i] = height[i] = 0;
  }
}
  
int depth(int x,int dep){
  height[x] = MAX(height[x],dep);
  if(par[x] == -1){
    return dep;
  }else{
    return depth(par[x],dep+1);
  }
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		int a, b, c, k;
		cin >> a >> b >> c >> k;
		int x = 0;
		while (1) {
			// cout << a << " " << b << " " << c << endl;
			if (a < b && b < c)break;
			if (a >= b) {
				b *= 2;
				x++;
			}
			if (b >= c) {
				c *= 2;
				x++;
			}
		}
		if (x <= k) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;

 
 




int main(){
     
    IOS;
    
   // freopen("input.in", "r", stdin);
    //freopen("output.in", "w", stdout);
     


    int n;
    cin>>n;
    
     ll sum =0;

     FOR(i,1,n+1){
     	if(i%3 !=0 && i%5 !=0)
     		sum += i;
     }

     cout<<sum;
  return  0 ;
   	    
 }

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

int main() {
	string S;
	cin >> S;
	vector<int>D( 12 );
	int hatena = -1;
	for( size_t i = 0; i < 12; i++ ) {
		if( S[i] == '?' ) {
			hatena = i;
		} else {
			D[i] = S[i] - '0';
		}
	}
	if( hatena == 11 ) {
		int num = 0;
		for( size_t i = 0; i < 11; i++ ) {
			int n;
			if( i <= 4 ) {
				n = 6 - i;
			} else {
				n = 12 - i;
			}
			num += D[i] * n;
		}
		num %= 11;
		if( num <= 1 ) {
			num = 0;
		} else {
			num = 11 - num;
		}
		cout << num << endl;
	} else {
		int ans = -1;
		int anscount = 0;
		for( size_t j = 0; j < 10; j++ ) {
			D[hatena] = j;
			int num = 0;
			for( size_t i = 0; i < 11; i++ ) {
				int n;
				if( i <= 4 ) {
					n = 6 - i;
				} else {
					n = 12 - i;
				}
				num += D[i] * n;
			}
			num %= 11;
			if( num <= 1 ) {
				num = 0;
			} else {
				num = 11 - num;
			}
			if( num == D[11] ) {
				ans = j;
				anscount++;
			}
		}
		if( anscount > 1 || anscount == 0 ) {
			cout << "MULTIPLE" << endl;
		} else {
			cout << ans << endl;
		}
	}
}

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

#define llint long long int

using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    int max = K;
    int i;

    for(i = 1; i <= 100; i ++){
        if(N < max){
            break;
        }else{
            max *= K;
        }
    }
    cout << i << endl;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  a <- map (read::String->Int) . lines <$> getContents
  putStr . unlines . map show $ top3 a []
  where
    top3 [] res = res
    top3 (x:xs) res = top3 xs (take 3 $ insert res)
      where
        insert [] = [x]
        insert (y:ys)
          | x > y = x: y : ys
          | otherwise = y : insert ys


Measured memory_bytes: 3660
#include<stdio.h>
#define N 100

int main(){
  int n,i,l,j,k;
  int p[N],m[N][N];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i] = 0;

  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1;
      m[i][j] = 1000000;
      
      for(k=i;k<=j-1;k++){
        if(m[i][j] > m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]){
          m[i][j] = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        }
        
      }
    }
  }
  
  printf("%d\n",m[1][n]);
  
  
  
  return 0;
}



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

int main(){
  char c;
  cin >> c;
  if( c >= 97 ){
    cout << 'a' << endl;
  }else{
    cout << 'A' << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 1; i <= N; i++) cin >> A[i];

  vector<int> l(N + 2, 0), r(N + 2, 0);
  r[0] = l[N] = 0;

  for (int i = 1; i <= N; i++) {
    r[i] = gcd(r[i - 1], A[i]);
  }

  for (int i = N; i >= 1; i--) {
    l[i] = gcd(l[i + 1], A[i]);
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, gcd(r[i - 1], l[i + 1]));
  }

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


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

long long gcm(long long a, long long b){
  if(a % b == 0) return b;
  a = a % b;
  return gcm(b, a);
}

long long lcm(long long a, long long b){
  return a / gcm(a, b) * b;
}

int main() {
  int n;
  cin >> n;
  long long ans = 1;
  for(int i = 0; i < n; i++){
    long long k;
    cin >> k;
    ans = lcm(ans, k);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main() {

	char step[100];
	int i,check=0;

	scanf("%s", &step);
	for (i = 0;i <= 99&&step[i]!='\0';i = i + 1) {
		if (i % 2 == 0) {
			if (step[i] != 'R' && step[i] != 'U' && step[i] != 'D') {
				check = 1;
				break;
			}
		}else {
			if (step[i] != 'L' && step[i] != 'U' && step[i] != 'D') {
				check = 1;
				break;
			}
		}
	}

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

Measured memory_bytes: 128
n=input()
for i in range(n):
	if i==0:
		num_1=input()
	elif i==1:
		num_2=input()
		maxv=num_2 - num_1
		MIN=min(num_1,num_2)
	else:
		num_3=input()
		if (num_3-MIN)>maxv:
			maxv=num_3-MIN
		if (num_3)<MIN:
			MIN=num_3
print(maxv)

Measured memory_bytes: 12632
import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		final char BOMB = '#';
		final char EMPTY = '.';
		final int MAX_H = 50;
		final int MAX_W = 50;
		char[][] grid = new char[MAX_H + 2][MAX_W + 2];
		final int[] DR = {-1, -1, -1, 0, 0, 1, 1, 1};
		final int[] DC = {-1,  0,  1,-1, 1,-1, 0, 1};

		while(input.hasNext()){
			int H = input.nextInt();
			int W = input.nextInt();		
			
			for(int i = 1; i <= H; ++i){
				System.arraycopy(input.next().toCharArray(), 0, grid[i], 1, W);
			}
			
			for(int i = 1; i <= H; ++i){
				for(int j = 1; j <= W; ++j){
					
					if(grid[i][j] == EMPTY){
						int bombNum = 0;
						for(int d = 0; d < DR.length; ++d){
							if(grid[i + DR[d]][j + DC[d]] == BOMB){
								++bombNum;
							}
						}
						
						grid[i][j] = (char) (bombNum + '0');
					}
				}
			}
			
			for(int i = 1; i <= H; ++i){
				System.out.println(new String(grid[i], 1, W));
			}
		}
	}

}


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

int main(){
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i=0;i<N;i++){
    cin >> p[i];
  }
  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));
  dp[0][0] = 1.0;
  double S = 0.0;
  for (int i=0;i<N;i++){
    dp[0][i+1] = dp[0][i] * (1 - p[i]);
    for (int j=1;j<=i+1;j++){
      dp[j][i+1] = dp[j-1][i] * p[i] + dp[j][i] * (1 - p[i]);
    }
  }
  for (int i=N/2+1;i<=N;i++){
    S += dp[i][N];
  }
  printf("%.18lf\n", S);
  return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-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 pf(s): return print(s, flush=True)


def main():
    a = I()
    s = set([a])
    i = 2
    while 1:
        if a % 2 == 0:
            a //= 2
        else:
            a = a * 3 + 1
        if a in s:
            return i
        s.add(a)
        i += 1

    return -1



print(main())




Measured memory_bytes: 6220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = 998244353;
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 500010;
int jc[N], ijc[N], n, k;
void prework(int sz) {
  jc[0] = 1;
  rep (i, 1, sz) jc[i] = 1ll * jc[i-1] * i % MOD;
  ijc[sz] = power(jc[sz], MOD - 2);
  rrp (i, sz-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
}
int comb(int a,int b) {
  if (a < b || b < 0) return 0;
  return 1ll * jc[a] * ijc[b] % MOD * ijc[a-b] % MOD;
}
int solve(int num) {
  if (num < n || num - (k - num) < 0)
    return 0;
  if (num == k-num) {
    int ret = comb(k-1, num);
    Sub(ret, comb(k-1, k-num-1 - (num-n) - 1));
    return ret;
  }
  int tmp = num - n;
  int ret = comb(k, num);
  Sub(ret, comb(k, k-num - tmp - 1));
  return ret;
}
int main() {
  read(n), read(k);
  prework(k);
  int ans = 0;
  rep (i, 0, k) Add(ans, solve(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n ;
  cin >> n ;
  map<int,int> mp ;
  ll ans = 0 ;
  rep(i,n){
	int m ;
    cin >> m ;
    mp[m]++ ;
  }
  for(auto p :mp ){
    int a = p.first ;
    int b = p.second ;
    if( b-a >= 0 )ans += b - a ;
    else ans += b ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(1, n+1):
    a[i] += a[i-1]
for i in range(1, m+1):
    b[i] += b[i-1]

ans = 0
b_cnt = m
for a_cnt in range(n+1):
    if a[a_cnt] > k: break
    while a[a_cnt] + b[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt + b_cnt)

print(ans)


Measured memory_bytes: 119520