akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String[] s = new String[n];
      for(int i = 0;i < n;i++)s[i] = sc.next();
      int m = sc.nextInt();
      String[] t = new String[m];
      for(int i = 0;i < m;i++)t[i] = sc.next();
      int count = -1;
      int max = 0;
      for(int i = 0;i < n;i++){
      	for(int j = 0;j < n;j++){
        	if(s[i].equals(s[j]))count++;
        }
        for(int k = 0;k < m;k++){
        	if(s[i].equals(t[k]))count--;
        }
        max = Math.max(max,count);
        count = 0;
      }
      System.out.println(max);
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll m){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % m;
        r = r * r % m;
        n /= 2;
    }
    return res;
}

ll primroot(ll m, int inv = 0){
    if(!inv){
        if (m == 2) return 1;
        if (m == 167772161) return 3;
        if (m == 469762049) return 3;
        if (m == 754974721) return 11;
        if (m == 998244353) return 3;
    }
    else{
        if (m == 2) return 1;
        if (m == 167772161) return 55924054;
        if (m == 469762049) return 156587350;
        if (m == 754974721) return 617706590;
        if (m == 998244353) return 332748118;
    }
    return -1;
}

vector<ll> NTT(const vector<ll> &f, int k, const ll &m, ll *z){
    vector<ll> Ff = f;
    for(int j = 1; j <= k; j++){
        vector<ll> newFf(1 << k);
        ll zz = 1;
        for(int i = 0; i < (1 << j); i++){
            for(int l = 0; l < (1 << (k - j)); l++){
                newFf[(i << (k - j)) + l] =
                    (Ff[((i << (k - j + 1)) + l) & ((1 << k) - 1)] +
                     Ff[((i << (k - j + 1)) + l + (1 << (k - j))) & ((1 << k) - 1)] * zz) % m;
            }
            zz = zz * z[j] % m;
        }
        swap(Ff, newFf);
    }
    return Ff;
}

vector<ll> Convolution(vector<ll> a, vector<ll> b, const ll m){
    int k = 0;
    while((1 << k) < (int)a.size() + (int)b.size() - 1) k++;
    ll z[2][30];
    for(int j = 0; j < 2; j++){
        for(int i = 0; i <= k; i++){
            z[j][i] = modpow(primroot(m, j), m / (1 << i), m);
        }
    }
    a.resize(1 << k);
    b.resize(1 << k);
    vector<ll> Fa = NTT(a, k, m, z[0]), Fb = NTT(b, k, m, z[0]);
    vector<ll> Fc(1 << k);
    for(int i = 0; i < (1 << k); i++) Fc[i] = Fa[i] * Fb[i] % m;
    vector<ll> c = NTT(Fc, k, m, z[1]);
    ll r = modpow((1 << k), m - 2, m);
    for(int i = 0; i < (1 << k); i++) c[i] = c[i] * r % m;
    return c;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<ll> c = Convolution(a, b, 998244353);
    for(int i = 0; i < n + m - 1; i++) cout << c[i] << " ";
    cout << endl;
}


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

long long times[101];

long long gcd(long long a, long long b) 
{
    return b == 0 ? a : gcd(b, a % b);
}

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

int main()
{
    long long n;

    cin >> n;

    for (int i = 0; i < n; ++i)
        cin >> times[i];

    cout << (long long)(accumulate(times, times + n, (long long)1, lcm)) << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
#define EPS (1e-5)

bool has_solution(vector< vector<double> > A){
  int n = A.size(), m = A[0].size(), t = 0;
  for(int i = 0; i < m; ++i){
    int pivot = t;
    for(int j = t; j < n; ++j){
      if(abs(A[j][i]) > abs(A[pivot][i])) pivot = j;
    }
    swap(A[t], A[pivot]);

    if(abs(A[t][i]) <= EPS){
      A[t][i] = 0;
      continue;
    }
    
    for(int j = i+1; j < m; ++j) A[t][j] /= A[t][i];
    A[t][i] = 1.0;
    
    for(int j = 0; j < n; ++j){
      if(j == t) continue;
      double c = A[j][i];
      for(int k = i; k < m; ++k){
        A[j][k] -= A[t][k]*c;
      }
    }
    ++t;
  }
  for(int i = n-1; i >= 0; --i){
    for(int j = 0; j < m-1; ++j){
      if(abs(A[i][j]) > EPS) return true;
    }
    if(abs(A[i].back()) > EPS) return false;
  }
  return false;
}

vector< vector<double> > cofactor(vector< vector<double> > A, int x, int y){
  //余因子A_xy
  //x = -1 or y = -1 とすると、一方のみを除く
  vector< vector<double> > ret;
  for(int i = 0; i < A.size(); ++i){
    if(i == x) continue;
    ret.push_back(vector<double>());
    for(int j = 0; j < A[0].size(); ++j){
      if(j == y) continue;
      ret.back().push_back(A[i][j]);
    }
  }
  return ret;
}

int solve(vector<double> V, int d){
  vector< vector<double> > A(d+3, vector<double>(d+2));
  for(int i = 0; i < d+3; ++i){
    A[i][0] = 1.0;
    for(int j = 1; j < d+1; ++j) A[i][j] = A[i][j-1]*(i+1);
    A[i].back() = V[i];
  }
  for(int i = 0; i < d+3; ++i){
    if(has_solution(cofactor(A,i,-1))) return i;
  }
  return -1;
}

int main(){
  int d;
  while(cin >> d, d){
    vector<double> V(d+3);
    for(int i = 0; i < d + 3; ++i){
      cin >> V[i];
    }
    cout << solve(V, d) << endl;
  }
  return 0;
}



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

using namespace std;

int main(){
  string s; cin >> s;
  if(s[0]==s[1] && s[0]!=s[2] && s[2]==s[3]){
    cout << "Yes" << endl;
  }
  else if(s[0]==s[2] && s[0]!=s[1] && s[1]==s[3]){
    cout << "Yes" << endl;
  }
  else if(s[0]==s[3] && s[0]!=s[1] && s[1]==s[2]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long

ll absl(ll x){return x>0?x:-x;}
ll minl(ll x,ll y){return x<y?x:y;}

int main(void){
	ll x,y;
	scanf("%lld%lld",&x,&y);
	ll ans=1e10;
	ll X[4]={x,-x,x,-x},Y[4]={y,y,-y,-y};
	for(int i=0;i<4;i++){
		ll tmp = Y[i]-X[i];
		if(i==1||i==2)tmp++;
		if(i==3)tmp+=2;
		if(tmp>0)ans = minl(ans,tmp);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  int n,a,b;
  c3(n,a,b);
  int dig,c=0;
  rep(i,1,n+1){
    dig=i/10000+i%10000/1000+i%1000/100+i%100/10+i%10;
    if(a<=dig && dig<=b) c+=i;
  }
  co(c);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var k = int.Parse(Console.ReadLine());
            var odd = (k % 2 == 0 ? k : k + 1) / 2;
            var even = k / 2;
            Console.WriteLine(odd * even);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<ll> a(200001, 0);

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
    
    vector<ll> s;
    for(int i = 0; i < N; ++i) s.push_back(a[i] - (i + 1));
    sort(s.begin(), s.end());
    
    ll ans = 0;
    if(N % 2){
        ll b = s[N / 2];
        for(int i = 0; i < N; ++i) ans += abs(a[i] - (b + (i + 1)));
    }
    else{
        ll b1 = s[N / 2 - 1], b2 = s[N / 2];
        ll num1 = 0, num2 = 0;
        for(int i = 0; i < N; ++i) num1 += abs(a[i] - (b1 + (i + 1))), num2 += abs(a[i] - (b2 + (i + 1)));
        ans = min(num1, num2);
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 3956
def gcd(a,b):
    if (b==0):
        return a
    return gcd(b,a%b)


n = int(input())
a = list(map(int,input().split()))
l = [0 for x in range(n+1)]
r = [0 for x in range(n+1)]

#
##
for x in range(n):
    l[x+1] = gcd(l[x],a[x])
    r[n-x-1] = gcd(r[n-x],a[n-x-1])

##
#
#print(a)
#print(l,r)
ans = 0
for x in range(n):
    #print(ans,l[x],r[x+1],gcd(l[x],r[x+1]))
    ans = max(ans,gcd(l[x],r[x+1]))

print(ans)


Measured memory_bytes: 14436
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323



void solve()
{
       int n;
       cin>>n;
       cout<<180*(n-2)<<endl;
}

int main()
{
       speed_up;
       //pre();
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
K = int(input())
a = [7%K]
for i in range(1, K):
  a.append((a[i-1]*10+7)%K)

isCorrect = False
for i in range(K):
  if a[i] == 0:
    print(i+1)
    isCorrect = True
    break
if not isCorrect:
  print("-1")

Measured memory_bytes: 141144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
const ll inf=1e18;
ll dp[555][555],sum[2][555][555];
ll cal(int t,int l1,int r1,int l2,int r2)
{
    if(!r1||!r2)return 0;
    return sum[t][r1][r2]-sum[t][l1-1][r2]-sum[t][r1][l2-1]+sum[t][l1-1][l2-1];
}

int main()
{
    int n;scanf("%d",&n);
    rep(i,1,n+1)rep(j,1,n+1)
    if(i!=j)
    {
        scanf("%lld",&sum[0][i][j]);
        if(i<j)sum[1][i][j]=sum[0][i][j];
    }
    rep(k,0,2)rep(i,1,n+1)rep(j,1,n+1)
        sum[k][i][j]+=sum[k][i-1][j]+sum[k][i][j-1]-sum[k][i-1][j-1];
    rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,0,n+1)
    rep(j,0,n+1)if(dp[i][j]!=inf)
    {
        rep(k,j+1,n+1)
        dp[j][k]=min(dp[j][k],dp[i][j]+cal(0,j+1,k,1,i)+cal(1,j+1,k,j+1,k));
    }
    ll res=inf;
    for(int i=n-1;i>=0;i--)res=min(res,dp[i][n]);
    printf("%lld\n",res);
}


Measured memory_bytes: 7168
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll l, r; cin >> l >> r;

    ll ans = 1e18;

    r = min(l + 2019, r);

    reps(i, l, r){
        reps(j, i+1, r+1){
            ans = min(ans, i*j % 2019);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a=1;
  int b=n;
  for(int i=0; i<m; i++){
    int L,R;
    cin>>L>>R;
    a=max(a,L);
    b=min(b,R);
  }
  if(a<=b){
    cout<<b-a+1<<endl;
  }else{
    cout<<"0"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import combinations

D = defaultdict(list)
N = int(input())
for i in range(N):
    s = input().strip()
    if s[0] in 'MARCH':
        D[s[0]].append(s)

if len(D.keys()) < 3:
    print(0)
    exit()

C = combinations(list(D.keys()), 3)

ans = 0
for c in C:
    ans += len(D[c[0]]) * len(D[c[1]]) * len(D[c[2]])

print(ans)


Measured memory_bytes: 10468
#include<bits/stdc++.h>
using namespace std;
//int dp[3001][3001];
const int mod=1e9+7;
#define pb push_back
#define ll long long
int main()
{
    int a[5];
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0) {cout<<i+1<<endl;break;}
    }

}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv( maxN+5, 1 );
vcL fac( maxN+5, 1 );

void ADD(lli &x, lli y) {
	x += y;
	if ( x >= mod ) x -= mod;
	if ( x < 0 ) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = ( x%mod + mod ) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if ( e&1 ) MUL( ans, b );
		MUL( b, b );
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow( n, mod-2 );
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod-mod/i) * inv[ mod%i ] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[ i-1 ] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if ( a < b ) return 0;

	MUL( ans, inv[ fac[ a-b ] ] );
	MUL( ans, inv[ fac[b] ] );
	MUL( ans, fac[a] );

	return ans;
}

lli Lucas(lli n, lli m) {
	if ( m == 0 ) return 1;
	return cm( n%mod, m%mod ) * Lucas( n/mod, m/mod ) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas( n, m );
}

/// coding area ///

void precal() {

	return;
}

bool cmp(pll a, pll b) {
	if ( a.Y == b.Y ) return a.X < b.X;
	else return a.Y < b.Y;
}

void solve() {
	lli n = 1, m, sum = 0, ans = 0, cnt = 0, nTime = 0;
	bool flag = true;
	string s;
	cin >> n;

	vPL num(n);

	for (auto &x : num) {
		cin >> x.X >> x.Y;
	}
	
	sort( ALL(num), cmp );
	
	for (auto x : num) {
		nTime += x.X;
		if ( nTime > x.Y ) flag = false;
	}
	
	if ( flag ) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}




Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<vector> 

int main(){
    int H,W;
    std::cin>>H>>W;
    std::vector<std::vector<int>> A(H,std::vector<int>(W)); 

    int a;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            std::cin>>a;
            A[i][j]=a;
        }
    }

    int min=-1,tmp;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            tmp=0;
            for(int k=0;k<H;k++){
                for(int l=0;l<W;l++){
                  tmp+=A[k][l]*std::min( fabs(i-k),fabs(j-l) );  
                }
            }
            if( tmp<min || min<0 ) min=tmp;
        }
    }
    std::cout<<min<<"\n";

    return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>
#include<stdlib.h>
int main()
{
long n,m,sum=0,i;
scanf("%ld",&n);
i=n;
while(n!=0)
{
sum+=n%10;
n=n/10;

}
if(i%sum==0)
printf("Yes");
else
printf("No");



}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    String s;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        s = sc.next();
        solve();
    }

    void solve() {
        if (s.length() % 2 == 0 ^ s.charAt(0) == s.charAt(s.length() - 1)) {
            System.out.println("Second");
        } else {
            System.out.println("First");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
static const int INFTY = (1 << 21);
int D[10000][10000];
int V, E, r;

int main() {
    cin >> V >> E >> r;
    rep(i, V)rep(j, V) D[i][j] = INFTY;
    rep(i, V) D[i][i] = 0;

    rep(i, E){
        int s, t, d;
        cin >> s >> t >> d;
        D[s][t] = d;
    }

    rep(k, V)
    rep(i, V)
    rep(j, V)
    {
        if(D[i][k] != INFTY && D[k][j] != INFTY){
            D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
        }
    }

    bool flag = false;
    rep(i, V){
        if(D[r][i] != INFTY && D[i][i] < 0) flag = true;
    }

    if(flag){
        cout << "NEGATIVE CYCLE" << endl;
    }
    else{
        rep(i, V){
            cout << (D[r][i] == INFTY ? "INF" : to_string(D[r][i])) << endl;
        }
    }
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

ll dp[101][8];  // i回進んで位置jにいるパターン
ll waru = 1e9 + 7;
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  int wwp = pow(2, w - 1);  // 線の引き方の総数
  dp[0][0] = 1;
  repi(h) repj(w) repk(wwp) {
    bool valid = true;
    repl(w - 1) {
      if ((k & (1 << l)) && (k & (1 << (l + 1)))) {
        valid = false;
        break;
      }
    }
    if (valid) {
      if (j != 0 && (k & (1 << (j - 1)))) {
        dp[i + 1][j - 1] += dp[i][j];
        dp[i + 1][j - 1] %= waru;
      } else if (j != w - 1 && (k & (1 << j))) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j + 1] %= waru;
      } else {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= waru;
      }
    }
  }
  cout << dp[h][k - 1] << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
    }

    let mut colors = HashSet::new();
    colors.insert(A);
    colors.insert(B);
    colors.insert(C);

    let ans = colors.len();
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  int A,B;
  cin>>A>>B;
  cout<<A*B-A-B+1<<"\n";
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    string s,t;
    cin>>s>>t;
    bool b=false;
    rep(i,s.size()){
        if(s[i]==t[i]) continue;
        b=true;
        break;
    }
    if(b) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
     return 0;

}
///Alhamdulillah



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

AC = WA = TLE = RE = 0
for i in range(0, N, 1):
  t = str(input())
  if t == "AC":
    AC += 1
  elif t == "WA":
    WA += 1
  elif t == "TLE":
    TLE += 1
  else:
    RE += 1

print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

Measured memory_bytes: 9068
import math
import bisect
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
n,m,k=map(int,input().split())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
pa=[0]*n
pb=[0]*m
pa[0]=a[0]
pb[0]=b[0]
for i in range(1,n):
	pa[i]=pa[i-1]+a[i]
for i in range(1,m):
	pb[i]=pb[i-1]+b[i]

ans=0
for i in range(n):
	if pa[i]<=k:
		p=bisect.bisect_right(pb,k-pa[i])
		ans=max(ans,i+1+p)

p=bisect.bisect_right(pb,k)
ans=max(ans,p)
print(ans)











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

#define watch(x) cout << (#x) << " = " << x << endl;
#define mkp make_pair
#define mkt make_tuple
#define pb push_back
#define ll long long
#define ld long double

using namespace std;

int n;
ld p[3001], dp[3001][3001];

int main(){
	scanf("%d", &n);

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

	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
			if(j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i];
		}
	}

	ld ans = 0;

	for(int i = (n + 1) / 2; i <= n; i++) ans += dp[n][i];

	printf("%.10Lf\n", ans);

	return 0;
}

Measured memory_bytes: 140928
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int n,cnt = 0,check = 0;
	cin >> n;
	int a[n];
	
	rep(i,0,n){
		cin >> a[i];
	}
	
	sort(a,a+n);
	
	rep(i,1,n){
		if(a[i] != a[i-1]){
			if(check % 2 == 0){
				cnt++;
			}
			check = 0;
		}
		else{
			check++;
		}
	}
	
	if(check % 2 == 0){
		cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 500005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b,c;
   cin>>a>>b>>c;
   int ans=c-(a-b);
   cout<<max(0LL,ans)<<endl;
}


Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

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

    if(A==B&&B!=C){
        cout<<"Yes"<<endl;
    }
    else if(B==C&&C!=A){
        cout<<"Yes"<<endl;
    }
    else if(C==A&&A!=B){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

N,M = [int(x) for x in stdin.readline().rstrip().split()]

hyo = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
sort_hyo = sorted(hyo, reverse=True)
point = sum(hyo)
target = math.ceil(point / (4*M))
for i in range(len(hyo)):
    if sort_hyo[i] >= target:
        sort_hyo[i] = "Yes"
    else:
        sort_hyo[i] = "No"
        
print(sort_hyo[M-1])

Measured memory_bytes: 3064
#include<iostream>
#include<queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

vector<vector<pair<int, int> > > edge;
int mem[400];

int solve(int n) {
  if (mem[n] != -1) return mem[n];
  int res = 0;
  rep (i, edge[n].size()) {
    res = max(res, solve(edge[n][i].first) + edge[n][i].second);
  }
  return mem[n] = res;
}

int main() {
  int n, m;
  cin >> n >> m;
  edge.resize(n);
  rep (i, n) mem[i] = -1;
  mem[0] = 0;
  rep (i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    edge[b].push_back(make_pair(a, c));
  }
  cout << solve(n - 1) << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
  string str1;
  cin >> str1;
  int num = 0;
  int ren = 0;
  for (int i = 0; i < 3; ++i){
    if(str1[i] == 'R'){
      if(ren >= 1){
        if(ren>=2){
          num = num +1;
          ren = ren +1;
        }
         else{
        ren = ren +1;
        num = num +1;
      	}
      }
        else{
      ren = 1;
      num = 1;
    }
    }
      
   
    else{
    ren = 0;
  }
    
  }
  
  cout << num << endl;
  
  return 0;
  
  
 
  
}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

#define MAX_V 200000

struct edge{
	int to;
	long long int cost;
    edge(int to_, long long int cost_){
        to = to_;
        cost = cost_;
    }
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// O(ElogV)

void shortest_path(int s, int V){
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
	while(true){
		int c, n, m, s, g;
		cin >> c >> n >> m >> s >> g;
		if(c == 0){
			break;
		}
		s -= 1;
		g -= 1;
		for(int i = 0; i < m; i++){
			int a, b, f;
			cin >> a >> b >> f;
			a -= 1;
			b -= 1;
			G[a].emplace_back(b, f);
			G[b].emplace_back(a, f);
			for(int j = 0; j < c; j++){
				G[a + n * j].emplace_back(b + n * (j + 1), f / 2);
				G[b + n * j].emplace_back(a + n * (j + 1), f / 2);
			}
			for(int j = 0; j <= c; j++){
				G[a + n * j].emplace_back(b + n * j, f);
				G[b + n * j].emplace_back(a + n * j, f);
			}
		}
		shortest_path(s, n * (c + 1));
		long long int ans = INF;
		for(int i = 0; i <= c; i++){
			ans = min(ans, d[g + n * i]);
		}
		cout << ans << endl;
		for(int i = 0; i < n * (c + 1); i++){
			G[i].clear();
		}
	}
	return 0;
}


Measured memory_bytes: 8184
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	int n,x,max;
    	int count = 0;
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
        	x = sc.nextInt();
        	if(n ==0 && x ==0){
        		break;
        	}
        	max = n >= x ? x:n;

        	for(int i = 1; i <= max-2 ;i++){
        		for(int j = i+1; j <= max-1 ;j++){
        			for(int k = j+1; k <= max ;k++){
        				if(i+j+k == x){
        					count++;
        					break;
        				}
        			}
        		}
        	}
            System.out.println(count);
            count = 0;
    	}

    }
}

Measured memory_bytes: 26556
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n,m,t;
  cin>>n>>m>>t;
  vi times(t+1,0);
  rep(i,n){
    int a;
    cin>>a;
    times[a-m]++;
    if(a+m<=t)times[a+m]--;
  }
  for(i=1;i<=t;i++)
    times[i]+=times[i-1];
  int ans=0;
  rep(i,t)
    if(times[i]==0)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 3080
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

int main(){
	ll N,K;cin>>N>>K;
	vector<ll>A(N);
	rep(i,N){
		cin>>A[i];
		A[i]--;
	}
	vector<ll>sum(N+1,0);
	map<ll,ll>mp;
	
	rep(i,N){
		sum[i+1]=sum[i]+A[i];
		sum[i+1]%=K;
	}
	ll ans=0;
	rep(i,N+1){
		if(i-K>=0)mp[sum[i-K]]--;
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	
	cout<<ans<<endl;
}


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

map<ll,ll>DP;

ll dp(ll x)
{
    if(DP[x])
        return DP[x];
    else
        return DP[x]=(dp(x/2)+dp((x-1)/2)+dp((x-2)/2))%mod;
}

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

    ll N;
    cin>>N;

    DP[0]=1;
    DP[1]=2;
    //dp(N);

    cout<<dp(N)<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = [0]*n
cnt = 0

for i in range(n):
    A[i] = int(input())



def shellSort(A, n):
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join([str(i) for i in G]))
    for i in range(m):
        insertionSort(A, n, G[i])

def insertionSort(A, n, g):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            global cnt
            cnt += 1
        A[j+g] = v
        
shellSort(A, n)
print(cnt)
for i in A:
    print(i)


Measured memory_bytes: 45476
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    queue<int> que;
    bool flag=true;
    for(int i=2;i<n-1;i++){
        if(s[i]=='C') que.push(i);
    }
    if(s[0]!='A') flag=false;
    if(que.size()!=1) flag=false;
    if(flag){
        rep(i,n){
            if(i!=0&&i!=que.front()){
                if(s[i]<'a'){
                    flag=false;
                    break;
                }
            }
        }
    }
    if(flag) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    A, P = map(int, line_input())
    total = P + A * 3
    print(total//2)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3568
from itertools import groupby, accumulate
N, K = map(int, input().split())
S = input()
g_cnt = [len(list(v)) for k, v in groupby(S)]
ans = 1

if S[0]=="0":
    g_cnt = [0] + g_cnt
if S[-1]=="0":
    g_cnt = g_cnt + [0]
    
accum = [0] + list(accumulate(g_cnt))
ans = 0
for i in range(0, len(accum), 2):
    r = i+2*K+1
    if r>=len(accum):
        r = len(accum)-1
    ans = max(ans , accum[r]-accum[i])
print(ans)

Measured memory_bytes: 8804
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
using namespace std;

int n,dia;
int a[101],cnt[101];

int main(){
	scanf("%d",&n);
	F(i,1,n) scanf("%d",a+i), ++cnt[a[i]];
	sort(a+1,a+n+1); dia=a[n];
	if(n==2) {puts("Possible"); return 0;}
	if(n==3) {puts(a[1]==1&&a[2]==2&&a[3]==2?"Possible":"Impossible"); return 0;}
	F(i,1,(dia+1>>1)-1) if(cnt[i]) {puts("Impossible"); return 0;}
	if(dia&1) {if(cnt[dia+1>>1]!=2) {puts("Impossible"); return 0;}}
	else {if(cnt[dia+1>>1]!=1) {puts("Impossible"); return 0;}}
	F(i,(dia+1>>1)+1,dia) if(cnt[i]<=1) {puts("Impossible"); return 0;}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    if length(s)==2
        println(s)
    else
        println(reverse(s))
    end
end
main()

Measured memory_bytes: 164816
#include<iostream>
int main(){
    int X,Y;
    int numKame,numTuru;
    std::cin>>X>>Y;
    numKame=(Y-2*X)/2;
    numTuru=X-numKame;
    if(numKame>=0 && numTuru>=0 && numKame*4+numTuru*2==Y){
        std::cout<<"Yes";
    }else{
        std::cout<<"No";
    }
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main()
{
	int a, b;
  cin >> a >> b;
  
  for (int i = 0; i < 1250; i++) {
    if ((int)(i * 0.08) == a && (int)(i * 0.10) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long flag=1;
    for(long long i=sqrt(n)+1;i>=2;--i){
        if(n%i==0){
            flag=i;
            break;
        }
    }
    long long ans=0;
    n/=flag;
    ans=n+flag-2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m := iScan(), iScan()
	ab := make([][]int, n)
	for i := 0; i < n; i++ {
		ab[i] = []int{iScan(), iScan()}
	}
	sort.Slice(ab, func(i, j int) bool { return ab[i][0] < ab[j][0] })
	h := &IntHeap{0}
	heap.Init(h)
	ans := 0
	for i := 1; i <= m; i++ {
		for len(ab) != 0 {
			if ab[0][0] <= i {
				heap.Push(h, ab[0][1])
				ab = ab[1:]
			} else {
				break
			}
		}
		if h.Len() != 0 {
			ans += heap.Pop(h).(int)
		}
	}
	fmt.Println(ans)
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 12204
#include <iostream>

using namespace std;
int main()
{
    int k,a,b;
    cin >> k >> a >> b;
    int rem = a % k;
    if(rem == 0){
        cout << "OK" << endl;
    }
    else if((a - rem + k) >= a && (a - rem + k) <= b){
        cout << " OK" << endl;
    }else
    {
        cout << "NG" << endl;
    }
     
    return 0;
}


Measured memory_bytes: 3632
package main

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

func solve() {
	x := getInt()

	ans := func() int {
		ret := x / 11 * 2
		if x%11 > 6 {
			ret += 2
		} else if x%11 > 0 {
			ret++
		}

		return ret
	}()

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define ld long double
#define vvi vector<vi>
#define vll vector<ll>
#define vld vector<ld>
#define vvll vector<vll>
#define vvld vector<vld>
#define MOD 1000000007
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/
const int M = 1e4+1;
int D, n;
string K;

int dp[M][2][101];

int recurse(int pos, int tight, int sum){
	if (pos == n){
		return ((sum == 0) ? 1 : 0);
	}
	if (dp[pos][tight][sum] != -1){
		return dp[pos][tight][sum];
	}

	int ans = 0;

	int up = (tight ? (K[pos] - '0') : 9);
	for (int d = 0; d <= up; d++){
		ans = (ans + recurse(pos+1, (tight && !(d < K[pos] - '0')), (sum + d) % D)) % MOD;
	} 

	return (dp[pos][tight][sum] = ans);
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		cin >> K;
		cin >> D;
		n = K.length();
		memset(dp, -1, sizeof(dp));
		cout << (recurse(0, 1, 0) -1 + MOD) % MOD;

	}
}


Measured memory_bytes: 12340