akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <time.h>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(c) (c).begin(), (c).end()
#define P pair<int, int>
#define chmin(x, y) x = min(x, y)

int main()
{
  ll n;
  int x, m;
  cin >> n >> x >> m;
  vector<int> a;
  map<int, int> mp;
  int cnt = 0;
  ll tot = 0;
  while (mp.count(x) == 0)
  {
    a.push_back(x);
    mp[x] = cnt;
    tot += x;
    x = (ll)x * x % m;
    cnt++;
  }
  if (n <= cnt)
  {
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
      ans += a[i];
    }
    cout << ans << endl;
    return 0;
  }
  ll c = 0;
  for (int i = mp[x]; i < cnt; i++)
  {
    c += a[i];
  }
  ll ans = tot;
  int lp = cnt - mp[x];
  n -= cnt;
  ans += n / lp * c;
  n %= lp;
  for (int i = 0; i < n; i++)
  {
    ans += a[mp[x] + i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    int k, cnt = 0;
    cin >> s >> k;
    vector<int> d;
    rep(i, s.size())d.push_back(s[i]-'0');
    vector<vector<vector<int>>> dp(d.size()+1, vector<vector<int>>(k+1, vector<int>(2, 0)));
    dp[0][0][1] = 1;
    rep(i, d.size()){
        rep(j, k+1){
            dp[i+1][j][0] += dp[i][j][0];
            if(d[i] == 0)dp[i+1][j][1] += dp[i][j][1];
            else{
                dp[i+1][j][0] += dp[i][j][1];
                if(j != 0){
                    dp[i+1][j][1] += dp[i][j-1][1];
                    dp[i+1][j][0] += dp[i][j-1][1] * (d[i]-1);
                }
            }
            if(j != 0)dp[i+1][j][0] += dp[i][j-1][0] * 9;
        }
    }
    cout << dp[d.size()][k][0] + dp[d.size()][k][1] << endl;
}

Measured memory_bytes: 256
n, c = map(int, input().split())
xv = [list(map(int, input().split())) for _ in range(n)]

cw = []
cw2 = [0]
v_sm = 0
for x, v in xv:
    v_sm += v
    cw.append(v_sm - x)
    cw2.append(v_sm - 2 * x)

ccw = []
ccw2 = [0]
v_sm = 0
for x, v in xv[::-1]:
    v_sm += v
    ccw.append(v_sm - (c - x))
    ccw2.append(v_sm - 2 * (c - x))

cw_mx = [0]
ccw_mx = [0]
for e in cw:
    cw_mx.append(max(cw_mx[-1], e))
for e in ccw:
    ccw_mx.append(max(ccw_mx[-1], e))

ans = 0
for i, e in enumerate(cw2):
    mx = e + ccw_mx[n-i]
    ans = max(ans, mx)

for i, e in enumerate(ccw2):
    mx = e + cw_mx[n-i]
    ans = max(ans, mx)

print(ans)


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

int main(){
  int K;
  cin >> K;
  int score = 1;
  deque<pair<int,int>> dq;
  dq.push_back(make_pair(1,1));
  set<int> st;
  while (true){
    pair<int,int> a = dq.front();
    dq.pop_front();
    if (a.first == 0){
      cout << a.second << endl;
      return 0;
    }
    if (st.find(a.first) == st.end()){
      dq.push_front(make_pair((a.first*10)%K,a.second));
      dq.push_back(make_pair((a.first+1)%K, a.second+1));
      st.insert(a.first);
    }
  }
}


Measured memory_bytes: 5760
#include <iostream>
#include <cmath>

using namespace std;
int main(){
	int N,M,hasil;
	cin>>N;
	hasil=0;
	for(int i=1;i<4;i++){
		M=pow(N,i);
		hasil+=M;
		
	}
	cout<<hasil<<endl;
	
	
	return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1 ,0};
int R,C;
int sy, sx, gy, gx;
string c[50];
int field[50][50];

ll di(ll N){
	ll count = 0;
	while(1){
		count += N%10;
		N = N/10;
		if(N==0){
			break;
		}
	}
	return count;
}

int main(){
	ll N;
	cin >> N;
	ll unko = di(N);
	if(N%unko == 0){
		puts("Yes");
		return 0;
	}else{
		puts("No");
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,sum[3][100005],maxsum=0x8fffffff;
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int x;
			cin>>x;
			sum[i][j]=sum[i][j-1]+x;
		}
	}
	for(int i=1;i<=n;i++)
	{
		int s=sum[1][i]+sum[2][n]-sum[2][i-1];
		maxsum=max(maxsum,s);
	}
	cout<<maxsum;
	return 0;
}

Measured memory_bytes: 256
H, W = [int(hw) for hw in input().split()]
S = [["."]*(W+2)]
for h in range(H):
  S.append(["."]+[s for s in input()]+["."])
S.append(["."]*(W+2))
for h in range(1, H+1):
  for w in range(1, W+1):
    if S[h][w] == "#":
      if (S[h-1][w]==".")and(S[h+1][w]==".")and(S[h][w-1]==".")and(S[h][w+1]=="."):
        print("No")
        break
  else:
    continue
  break
else:
  print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, m, a[100], sum = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	double sumd = sum / (4.0 * m);
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= sumd)count++;
	}
	if (count >= m)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
H,N = map(int,input().split())
p = []
for i in range(N):
    t = list( map( int, input().split() ) )
    p.append(t)

a = max(p)[0]
dp = [10**9] * (H+1+a)
dp[0] = 0

for i in range(H+1+a):
    for j in range(N):
        if i-p[j][0] >= 0:
            dp[i] = min(dp[i],dp[i-p[j][0]]+p[j][1])

print(min(dp[H:H+a]))

Measured memory_bytes: 42604
package main

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

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

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

func GCD(a, b, c int) int {
	return gcd(gcd(a, b), c)
}

func main() {
	n := readInt()

	res := 0
	for a := 1; a <= n; a++ {
		for b := 1; b <= n; b++ {
			for c := 1; c <= n; c++ {
				res = res + GCD(a, b, c)
			}
		}
	}

	fmt.Println(res)
}

/*-------------------inputs-------------------*/

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}


Measured memory_bytes: 1776
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int check(int x) {
    if(x == 1){
        return 300000;
    }else if(x == 2){
        return 200000;
    }else if(x == 3){
        return 100000;
    }else{
        return 0;
    }
}

int main()
{
    int x, y;
    cin >> x >> y;
    int prize = 0;
    prize += check(x);
    prize += check(y);
    if(x == 1 && y == 1) {
        prize += 400000;
    }
    cout << prize << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<long long, int> P;
vector<P> p;
int main(void){
    long long n;
    cin >> n;
    for(int i=0;i<=200;i++){
        long long v = 1;
        for(int j=0;j<5;j++){
            v *= i;
        }
        p.push_back(P(v, i));
        p.push_back(P(-v, -i));
        // cout << v << endl;
    }
    for(P x: p){
        for(P y: p){
            if(x.first-y.first == n){
                cout << x.second << " " << y.second << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3208
#include <stdio.h>
#include <math.h>
 

int main(void)
{

	int  a,b,c;
	double	d,S,L,H,C,PI =3.14159265;
	
	
	scanf("%d %d %d",&a,&b,&c);

	
	C = PI * c/180;
	d = 0.5;

	S =  d * a * b * sin(C);
	
	L = a*a + b*b -2*a*b*cos(C);

	L = sqrt(L);

	L = a + b + L;

	H = sin(C) * b;

	

	printf("%f\n",S);

	printf("%f\n",L);

	printf("%f\n",H);



	
	
	return 0;

}

Measured memory_bytes: 636
H,W = map(int,input().split())
s = ['.'*W]
s += [input() for i in range(H)]
s += ['.'*W]
for h in range(H+2):
  s[h] = '.'+s[h]+'.'

for h in range(H):
  for w in range(W):
    if s[h][w] == '#':
      count = 0
      for i,j in [(0,1),(1,0),(-1,0),(0,-1)]:
        if s[h+i][w+j] == '#':
          count += 1
          continue
      if count == 0:
        print("No")
        exit()
    else:
      pass

print("Yes")

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

int SumDigit(int x){
  int sum = 0;
  
  while(x > 0){
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  
  for(int i = 1; i <= N; i++){
    int sum_digit = SumDigit(i);
    if(A <= sum_digit && sum_digit <= B)
      total += i;
  }
  
  cout << total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   
 
 
int main(){
  ll i,j,k;
  ll result = -INF;
  ll buf = 0;
  ll buf2 = 0;
  ll buf3 = 0;
  bool judge = true;
  ll n; cin >> n;
  ll f[n][10];
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      cin>>f[i][j];
    }
  }
  ll p[n][11];
  for(i=0;i<n;i++){
    for(j=0;j<=10;j++){
      cin>>p[i][j];
    }
  }
  vector<ll> a(10);
  for(i=0,buf=1;i<10;i++)buf*=2;
  for(i=1;i<buf;i++){
    k=i;
    for(j=0;j<10;k/=2,j++)
      a[j]=k%2;  
    buf2=0;
    for(j=0;j<n;j++){
      buf3=0;
      for(k=0;k<10;k++){
        if(a[k]==1&&f[j][k]==1){
          buf3++;
        }
      }
      buf2+=p[j][buf3];
    }
    chmax(result,buf2);
  }
  cout<<result<<endl;
    
      
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
void print(ll n)
{ if(n>0)	{
		n--;
		print(n/26);
  cout<<(char)(n%26+97);
		
	} }
int main(){
  ll x; 
  cin>>x; 
  print(x);
  }
	




Measured memory_bytes: 3648
import java.io.*;
import java.util.*;


class Main {
    static final long MOD=1000000007;
    static long f(long[]a){
        int n=a.length;
        long ans=0;
        for(int i=0;i<n;++i){
            a[i]%=MOD;
            if(a[i]<0)a[i]+=MOD;
            long f=(2*i-n+1+MOD)%MOD;
            ans=(ans+f*a[i])%MOD;
        }
        return ans;
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        long[]x=new long[n],y=new long[m];
        for(int i=0;i<n;++i)x[i]=sc.nextLong();
        for(int i=0;i<m;++i)y[i]=sc.nextLong();
        out.println(f(x)*f(y)%MOD);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            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: 43456
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y=0,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1=INT_MAX;
    cin>>n;
   ll neg_counts=0;
   rep(i,0,n)
   {
       cin>>x;
       if(x<0)
        neg_counts++;
       sum+=abs(x);
       res1=min(res1,abs(x));
   }
   if(neg_counts%2==1)
    sum-=(2*res1);
   cout<<sum;
}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vector<int> rev(N);
    for(int i=0;i<N;i++) rev[A[i]-1] = i+1;    
    for(int i=0; i<N;i++)cout << rev[i] << endl;
}

Measured memory_bytes: 1664
fn main() {
  
  let n = read::<usize>()[0];
  let (mut px, mut py, mut pt) = (0, 0, 0);
  for _ in 0..n {
    let txy = read::<i64>();
    let (t, x, y) = (txy[0], txy[1], txy[2]);
    let dx = (px - x).abs() + (py - y).abs();
    let dt = t - pt;
    if dt < dx || (dt - dx) % 2 != 0 {
      println!("No");
      return;
    };
    px = x;
    py = y;
    pt = t;
  };
  println!("Yes");
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


Measured memory_bytes: 2116
using System;
using System.Collections.Generic;

namespace abc179_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var D = CIn.ReadIntArray(N * 2);

      for (int i = 0; i < N - 2; i++)
      {
        if (D[i * 2] == D[i * 2 + 1] && D[i * 2 + 2] == D[i * 2 + 3] && D[i * 2 + 4] == D[i * 2 + 5])
        {
          Console.WriteLine("Yes");
          return;
        }
      }

      Console.WriteLine("No");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27856
n=int(input())
a=input().split()

for i in range(len(a)):
    a[i]=int(a[i])

b=[0 for i in range(len(a))]

if(n%2==0):
    for i in range(int(n/2)):
        b[i]=a[n-2*i-1]
    
    for i in range(int(n/2)):
        b[i+int(n/2)]=a[1+2*i-1]
else:
    for i in range(int((n+1)/2)):
        b[i]=a[n-2*i-1]
    for i in range(int((n-1)/2)):
        b[i+int((n+1)/2)]=a[2+2*i-1]
        
for i in range(n):
    print(b[i],end=" ")

Measured memory_bytes: 21524
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x)
{
  Q[tail]=x;
  tail=(tail+1)%(LEN+1);

}

P dequeue()
{
  P x=Q[head];
  head=(head+1)%(LEN+1);
  return x;
}

int min(int a,int b){return a<b ? a:b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail)
    {
      u=dequeue();
      if(q<u.t)
	{
	  c=q;
	}
      else c=u.t;
      
      u.t-=c;
      elaps+=c;

      if(u.t>0) enqueue(u);
      else
	{
	  printf("%s %d\n",u.name,elaps);
	}
    }
  return 0;
}
  



Measured memory_bytes: 11920
def finish():
    print('NO')
    exit()

N = int(input())
cnt = 0
vec = -1
for i in range(N):
    w = input()
    if  w == 'A':
        #if vec == -1 and cnt != 0:
        #    finish()
        cnt += 1
        vec = 1
    else:
        if cnt == 0:
            finish()

        cnt -= 1
        vec = -1
if cnt != 0:
    finish()
print('YES')



Measured memory_bytes: 5596
#include <iostream>


using namespace std;
int main() {

    int a,b,c,d,x,y;

    cin>>a>>b>>c>>d;

    x=a*b;
    y=c*d;

    if(x>y){
        cout<<x<<endl;
    }
    else{
        cout<<y<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        string a,b,c;
        cin>>a;
        if(a == "0")break;
        cin>>b>>c;
        int n=a.size();
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        reverse(c.begin(),c.end());
        int dp[54][2];
        for(int i=0;i<n+1;i++)for(int j=0;j<2;j++)dp[i][j]=0;
        dp[0][0]=1;
        for(int i=0;i<n;i++){
            for(int j=0;j<10;j++){
                if(a[i]!='?'){
                    if(j)break;
                    j=a[i]-'0';
                }
                if(i==n-1&&!j)continue;
                for(int k=0;k<10;k++){
                if(b[i]!='?'){
                    if(k)break;
                    k=b[i]-'0';
                }
                if(i==n-1&&!k)continue;
                for(int l=0;l<10;l++){
                if(c[i]!='?'){
                    if(l)break;
                    l=c[i]-'0';
                }
                if(i==n-1&&!l)continue;
                if((j+k)%10==l){
                    dp[i+1][(j+k)/10]+=dp[i][0];
                }
                if((j+k+1)%10==l){
                    dp[i+1][(j+k+1)/10]+=dp[i][1];
                }
                dp[i+1][0]%=mod;
                dp[i+1][1]%=mod;
                }
            }
        }
      }
      cout<<dp[n][0]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<pair<int,int>> v(n);
  rep(i, n) {
    cin >> v[i].first;
    v[i].second = i+1;
  }
  sort(v.begin(), v.end());
  rep(i, n) {
    cout << v[i].second << " ";
  }
  return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#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(){
    long long int w,h,x,y;
    cin >> w >> h >> x >> y;
    if(x*2==w && y*2==h)
        cout << w*h/2.0 << " " << 1 << endl;
    else
        cout << w*h/2.0 << " " << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 1; i < n-1; i++) {
            if(a[i] != Math.min(a[i-1], Math.min(a[i], a[i+1]))
                    && a[i] != Math.max(a[i-1], Math.max(a[i], a[i+1]))){
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


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

int main()
{
	int N = 0, ans = 0, tmp;
	cin >> N;
	int V[20];

	for (int i = 0; i < N; i++) {
		cin >> V[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		ans += V[i] - tmp > 0 ? V[i] - tmp : 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, a = 0, b;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b;
		if (b % 2)a++;
	}
	if (a % 2)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define PII             pair<int, int>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
using namespace std;
int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod =1e9+7;
const int N = 1e5+5;
//if(x<0 || x>=r || y<0 || y>=c)

inline ll read()
{
	ll x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}
ll gcd(ll m, ll n)
{
	return n == 0 ? m : gcd(n, m % n);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
bool prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}
ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}      

int main()
{
    int n,k;
    cin >> n>>k;
    vector<int> a(n + 1);
    rep(i, 1, n)
        cin >> a[i];
    vector<int> dp(n + 1,inf);
    a[0] = a[1];
    dp[0] = 0;
    rep(i, 1, n)
    {
        rep(j, 1, k)
        {
            if(i-j>=0)
                dp[i] = min(dp[i],dp[i-j] + abs(a[i] - a[i - j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}



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

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

  string ans = "";

  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '0') ans += '0';
    if (S.at(i) == '1') ans += '1';
    if (S.at(i) == 'B' && ans != "") ans.pop_back();
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int> L(2 * N);
    cin >> L;

    SORT(L);
    int ans = 0;
    REP(i, N) {
        ans += L[i * 2];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])
	if temp!=1:
		arr.append([temp, 1])
	if arr==[]:
		arr.append([n, 1])
	return arr

a = factorization(n)
c = 0
for i in a:
	k = 1
	x = i[1]
	while x >= 0:
		x -= k
		if x < 0:
			break
		c += 1
		k += 1
if n == 1:
	print (0)
else:
	print (c)


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

using namespace std;
#define ll long long
const int mxN=2e5;

int main() {
//#ifndef ONLINE_JUGDE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    map<pair<int,int>,int> cnt;
    for(int i=0;i<n;i++){
    	double num;
    	cin>>num;
    	ll x=llround(num*1e9);
    	int two=0,five=0;
    	while(x%2==0){
    		two++;
    		x/=2;
		}
		while(x%5==0){
			five++;
			x/=5;
		}
		cnt[{two,five}]++;
	}
    ll ans=0;
    for(auto i:cnt){
    	for(auto j:cnt){
    		if(i.first.first+j.first.first>17&&i.first.second+j.first.second>17){
    			if(i<j)
    				ans+=(ll)i.second*j.second;
    			else if(i==j)
    				ans+=(ll)i.second*(j.second-1)/2;
			}
		}
	}
	cout<<ans;
    return 0;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k--;
  cout << a[k] << endl;
  return 0;
}

Measured memory_bytes: 256
#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 <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N, M;
        cin >> N >> M;
        set<int> kiken;
        rep(i, 0, M) {
            int tmp;
            cin >> tmp;
            kiken.insert(tmp);
        }

        vector<ll> dp(N + 2);
        dp[0] = 1;

        for (int i = 0; i < N; ++i) {
            if (!kiken.count(i)) {
                dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
                dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
            }
        }

        ll ans = dp[N];
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;

    int u=0, d=0, l=0, r=0;

    for( auto ch: s ){
        if( 'A'<= ch and ch <= 'M' ){
            u++;
        }else if( 'N' <= ch and ch <= 'Z'){
            d++;
        }else if( 'a' <= ch and ch <= 'm' ){
            r++;
        }else if( 'n' <= ch and ch <= 'z' ){
            l++;
        }else{
            exit(1);
        }            
    }


    string ans = "";
    if( l>r ){
        for( int i=0; i<l-r; ++i ){
            ans += 'n';
        }
    }else{
        for( int i=0; i<r-l; ++i ){
            ans += 'a';
        }
    }
    
    if( u>d ){
        for( int i=0; i<u-d; ++i ){
            ans += 'A';
        }
    }else{
        for( int i=0; i<d-u; ++i ){
            ans += 'N';
        }
    }
    cout << ans.size() << endl;
    cout << ans << endl;
    
}


Measured memory_bytes: 3336
#include <iostream>
#include <string>
#include <map>
#include <queue>

using namespace std;

void sche(queue<pair<string, int> > &q, int qtime){
    int time = 0;
    while(q.size() > 0){
        pair<string, int> task = q.front();
        int t = qtime > task.second ? task.second : qtime;
        time += t;
        task.second -= t;
        q.pop();
        if(task.second > 0)
            q.push(task);
        else
            cout << task.first << " " << time << endl;
    }
}

int main(){
    int n, qtime;
    cin >> n >> qtime;
    queue<pair<string, int> > q;
    for(int i=0; i < n; i++){
        string name;
        int t;
        cin >> name >> t;
        q.push(make_pair(name, t));
    }
    sche(q, qtime);
    return 0;
}

Measured memory_bytes: 4404
(defun coin-sum (a b c)
  (+ (* a 500) (* b 100) (* c 50)))

(defun main (a b c m)
  (let ((ans 0))
  (dotimes (x (+ 1 a))
    (dotimes (y (+ 1 b))
      (dotimes (z (+ 1 c))
        (if (= m (coin-sum x y z))
            (setq ans (+ 1 ans))
            nil))))
    (format t "~a~%" ans)))

(main (read) (read) (read) (read))

Measured memory_bytes: 4576
#include <stdio.h>
#include <stdlib.h>
int cp(const int*a,const int*b){return *a-*b;}
int main(void){
int n,k,h[101000],i,j,s;
scanf("%d %d",&n,&k);
for(i=0;i<n;i++) scanf("%d",&h[i]);
qsort(h,n,sizeof(int),cp);
s=h[k-1]-h[0];
for(i=k;i<n;i++)if(s>h[i]-h[i-k+1])s=h[i]-h[i-k+1];
printf("%d",s);
return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        String firstRound = getShortestPathToGo(sx, sy, tx, ty);
        String secondRound = getShortestPathToBack(sx, sy, tx, ty);
        String thirdRound = "D" + getShortestPathToGo(sx, sy-1, tx+1, ty) + "L";
        String fourthRound = "U" + getShortestPathToBack(sx-1, sy, tx, ty+1) + "R";
        System.out.println(firstRound + secondRound + thirdRound + fourthRound);
    }

    public static String getShortestPathToGo(int sx, int sy, int tx, int ty) {
        String path = "";
        for(int i = 0; i < tx - sx; i++) {
            path += "R";
        }
        for(int j = 0; j < ty - sy; j++) {
            path += "U";
        }
        return path;
    }

    public static String getShortestPathToBack(int sx, int sy, int tx, int ty) {
        String path = "";
        for(int i = 0; i < tx - sx; i++) {
            path += "L";
        }
        for(int j = 0; j < ty - sy; j++) {
            path += "D";
        }
        return path;
    }
}

Measured memory_bytes: 71748
a,b=map(int,input().split())
count=0

if a==1:
    count+=300000
if a==2:
    count+=200000
if a==3:
    count+=100000
if b==1:
    count+=300000
if b==2:
    count+=200000
if b==3:
    count+=100000
if a==1 and b==1:
    count+=400000

print (count)

Measured memory_bytes: 3064
// Problem : C - Marks
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll       long long int
#define ull      unsigned long long int
#define pb       push_back
#define vi       vector<int>
#define vb       vector<bool>
#define vll      vector<long long int>
#define pi       pair<int,int>
#define all(x)   (x).begin(), (x).end()

const int MOD = 1000000007;




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t=1;
	//cin>>t;
	
	while(t--)
	{
		ull n,k,x=1;
		cin>>n>>k;
		vector<ull>v(n+5);
		vector<ull>dp(n+5);
		
		for(int i=0;i<n;i++)cin>>v[i];
		
		for(int i=k;i<n;i++)
		{
			if(v[i-k]>=v[i])cout<<"No\n";
			else	cout<<"Yes\n";
		}
		
		
	}
	
   	return 0;
}



Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    using pii = pair<int,int>;
    vector<vector<int>>edge(N);
    vector<pii>input;
    for(int i = 0; i < N - 1; ++i){
        int a,b; cin >> a >> b;
        --a,--b;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
        input.emplace_back(minmax(a,b));
    }
    int max_v = -1;
    int K = -1;
    for(int i = 0; i < N; ++i){
        if((int)edge[i].size() > K){
            max_v = i;
            K = (int)edge[i].size();
        }
    }
    
    map<pii,int>color;
    vector<bool>visit(N,false);
    visit[max_v] = true;
    function<void(int,int)> f = [&](int v, int p_clr){
        visit[v] = true;
        int clr = (p_clr == 1 ? 2 : 1);
        for(int i = 0; i < edge[v].size(); ++i){
            int nv = edge[v][i];
            if(visit[nv]) continue;
            color[minmax(nv,v)] = clr;
            f(nv,clr);
            ++clr;
            if(clr == p_clr) clr++;
        }
        return;
    };
    for(int i = 0; i < edge[max_v].size(); ++i){
        color[minmax(edge[max_v][i],max_v)] = i + 1;
        visit[edge[max_v][i]] = true;
        f(edge[max_v][i],i + 1);
    }
    cout << K << endl;
    for(auto p : input)
        cout << color[p] << endl;
}


Measured memory_bytes: 14968
#include<iostream>

using namespace std;

int main () {

    int x, y;

    while (1) {

        cin >> x >> y;

        if (x == 0 && y == 0) {

            break;

        }

        if (x < y) {

            cout << x << " " << y << endl;

        } else {

            cout << y << " " << x << endl;

        }

    }

    return 0;

}

Measured memory_bytes: 2976
/**
 * CODE
 * BY
 * VIKAS VERMA
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n; i++)

#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef long long ll;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6 + 13;
//=======================
vi g[N];
int a[N];
//=======================
bool triangle(int a, int b, int c)
{
  if (a == b || a == c || b == c)
    return false;
  if (a + b <= c || a + c <= b || b + c <= a)
    return false;
  else
    return true;
}
void solve()
{
  int n;
  cin >> n;
  fo(i, n)
          cin >>
      a[i];

  int count = 0;
  fo(i, n)
  {
    for (int j = i + 1; j < n; j++)
    {
      for (int k = j + 1; k < n; k++)
      {
        count += triangle(a[i], a[j], a[k]);
      }
    }
  }
  cout << count << endl;
  ;
}

int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int t = 1;

  // cin >> t;

  while (t--)
  {
    solve();
  }

  return 0;
}

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

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


using namespace std;

int main(){

    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> ok(n, true);
    rep(i,n) cin>>h[i];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        if(h[a]<=h[b])ok[a]=false;
        if(h[b]<=h[a])ok[b]=false;
    }
    int ans = 0;
    rep(i,n) if(ok[i]) ans++;
    cout << ans << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  
  vector<int> ans;
  int flag = -1;
  for (int i = 0; i < n; i ++) {
    flag = false;
    for (int j = 0; j < a.size(); j ++) {
      if (a[j] > j + 1) {
        cout << "-1" << endl;
        return 0;
      }
      if (a[j] == j + 1) flag = j;
    }
    if (flag == -1) {
      cout << "-1" << endl;
      return 0;
    }
    ans.push_back(flag + 1);
    a.erase(a.begin() + flag);
  }

  reverse(ans.begin(), ans.end());
  for (int i : ans) cout << i << endl;

}

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

void solve(std::string a, std::string b, std::string c) {
  char curr = 'a';
  int aIdx = 0;
  int bIdx = 0;
  int cIdx = 0;
  while (true) {
    if (curr == 'a') {
      if (aIdx == a.size()) {
        cout << "A" << endl;
        return;
      }
      curr = a[aIdx];
      aIdx++;
    }
    if (curr == 'b') {
      if (bIdx == b.size()) {
        cout << "B" << endl;
        return;
      }
      curr = b[bIdx];
      bIdx++;
    }
    if (curr == 'c') {
      if (cIdx == c.size()) {
        cout << "C" << endl;
        return;
      }
      curr = c[cIdx];
      cIdx++;
    }
  }
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S_A;
  std::cin >> S_A;
  std::string S_B;
  std::cin >> S_B;
  std::string S_C;
  std::cin >> S_C;
  solve(S_A, S_B, S_C);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
arr = list(map(int,input().split()))
ans = [arr[0]*2]*N
for i in range(1,N):
    ans[0] += arr[i]*2 if i % 2 == 0 else - arr[i]*2
ans[0] //= 2
for i in range(1,N):
    ans[i] = arr[i-1]*2 - ans[i-1]
print(*ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = INF;
    REP(i, std::max(X + 1, Y + 1)) {
        ans = std::min(ans, 2LL * i * C + std::max(0LL, X - i) * A + std::max(0LL, Y - i) * B);

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

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define rep(n, i) for(int i = 0; i < n; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

void cango(int m, int p, int*a, int*b, int*flags){
    flags[p] = 1;
    rep(m, i) {
        if (a[i] == p && !flags[b[i]]) cango(m, b[i], a, b, flags);
        else if (b[i] == p && !flags[a[i]]) cango(m, a[i], a, b, flags);
    }
}

void solve(void){
    int n, m;
    scanf("%d %d\n", &n, &m);
    int a[m], b[m];
    rep(m, i) {
        scanf("%d %d\n", &a[i], &b[i]);
        a[i]--; b[i]--;
    }

    int ans = 0;
    rep(m, j){
        int al[m-1], bl[m-1];       //橋を落とす
        int c = 0;                  //index管理
        for(int k = 0; k < m-1; k++) {
            if (k == j) c = 1;
            al[k] = a[k+c];
            bl[k] = b[k+c];
        }
        int flag = 0;
        int flags[n];
        rep(n, i) flags[i] = 0;

        cango(m-1, 0, al, bl, flags);
        rep(n, i) if (!flags[i]) flag = 1;
        if (flag) ans++;
    }
  printf("%d\n", ans);
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 128
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

vector<int> v;

int check(int n)
{
    int sum = 0;
    REP(i,v.size())
    {
        sum += (v[i] - n) * (v[i] - n);
    }
    return sum;
}

int run()
{
    int min = INT_MAX;
    
    FOR(i , -100 , 101)
    {
        int temp = check(i);
        if(min>temp){
            min = temp;
        }
    }
    
    return min;
}

int main()
{
	fastIOS();

	int n; cin >> n;
    
    REP(i,n)
    {
        int temp;
        cin >> temp;
        v.push_back(temp);
    }
    
    cout << run() << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,now;
vector<int>pos[1000005];

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n=998244353) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

int calc(vector<int>vec){
	if(!vec.size())return 0;
	int sum=0;
	for(int i=0;i<vec.size();i++){
		sum+=vec[i];
	}
	sum%=998244353;
	int ret=sum*sum%998244353;
	for(int i=0;i<vec.size();i++){
		int sub=vec[i]*vec[i]%998244353;
		ret-=sub;if(ret<0)ret+=998244353;
	}
	return ret;
}

vector<pair<int,int> >factor;

void dfs(int p,int cur){
	if(p==factor.size()){
		pos[cur].push_back(now);
		return;
	}
	int Mul=1;
	for(int i=0;i<=factor[p].second;i++){
		dfs(p+1,cur*Mul);
		Mul*=factor[p].first;
	}
}

void init(int v){
	factor.clear();now=v;
	for(int i=2;i*i<=v;i++){
		if(v%i==0){
			pair<int,int>ins(i,0);
			while(v%i==0){
				v/=i;ins.second++;
			}
			factor.push_back(ins);
		}
	}
	if(v!=1)factor.push_back(make_pair(v,1)); 
	dfs(0,1);
}

int ans[1000005];

void solve(){
	for(int Gcd=1000000;Gcd>=1;Gcd--){
		ans[Gcd]=calc(pos[Gcd])%998244353;
		for(int Mul=Gcd+Gcd;Mul<=1000000;Mul+=Gcd){
			ans[Gcd]-=ans[Mul];
		}
		ans[Gcd]%=998244353;if(ans[Gcd]<0)ans[Gcd]+=998244353;
	}
	int fuck=0;
	for(int i=1;i<=1000000;i++){
		fuck+=ans[i]*inv(i);
		fuck%=998244353;
	}
	cout<<fuck*inv(2)%998244353<<endl;
}

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

Measured memory_bytes: 111224
# 解説

n,k,c = map(int, input().split())
s = input()

l = [0 for i in range(n)]
r = [-1 for i in range(n)]

a = 1
b = -1
for i in range(n):
    if s[i]=='o' and b<i:
        l[i]=a
        a+=1
        b=i+c
        if a>k:
            break

a = k
b = n
for i in range(n):
    if s[-i-1]=='o' and b>n-i-1:
        r[-i-1]=a
        a-=1
        b=n-i-1-c
        if a<1:
            break

for i in range(n):
    if l[i]==r[i]:
        print(i+1)


Measured memory_bytes: 57464
import std.stdio, std.conv, std.array;

void main()
{
    int N;
    readf("%d", &N);
  if(N == 25){
  	writeln("Christmas");
  }
 if(N == 24){
  	writeln("Christmas Eve");
  }
    if(N == 23){
  	writeln("Christmas Eve Eve");
  }
    if(N == 22){
  	writeln("Christmas Eve Eve Eve");
  }
    
  
  
}

Measured memory_bytes: 256