akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final long MOD = 1_000_000_007;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final List<Long> list = IntStream.range(0, n)
            .mapToObj(i -> scanner.nextLong())
            .collect(Collectors.toList());
        final long[] sums = new long[n + 1];
        for (int i = n; i > 0; i--) {
            sums[i - 1] = (list.get(i - 1) + sums[i]) % MOD;
        }

        IntStream.range(0, n - 1)
            .mapToLong(i -> list.get(i) * sums[i + 1] % MOD)
            .reduce((a, b) -> (a + b) % MOD)
            .ifPresent(System.out::println);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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


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

int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i=0;i<k-1;i++){
        cout << s[i];
    }
    switch (s[k-1])
    {
    case 'A':
        cout << 'a';
        break;
    case 'B':
        cout << 'b';
        break;
    case 'C':
        cout << 'c';
        break;
    
    default:
        break;
    }
    for(int j=k;j<n;j++){
        cout << s[j];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c,temp,k;
	while(~scanf("%d%d%d%d",&a,&b,&c,&k))
	{
		if(a>b)
		{
			if(a<c)
			{
				temp=a;
				a=c;
				c=temp;
			}
		}
		else
		{
			if(b>c)
			{
				temp=b;
				b=a;
				a=temp;
			}
			else
			{
				temp=a;
				a=c;
				c=temp;
			}
		}
		for(int i=0;i<k;i++)
		a=a*2;
		printf("%d\n",a+b+c);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    cin >> n;
    int m = 0;
    int l = 0;
    for(int i = 1; i <= n; i += 2){
        for(int j = 1; j <= i; j++){
            if(i % j == 0){
                m++;
            }
        }
        if(m == 8){
            l++;
        }
        m = 0;
    }
    cout << l << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int N;
	string S;
	cin >> N;
	cin >> S;
	
	int x = 0;
	int ans = 0;
	int len = S.size();

	for (int i = 0; i < len; i++)
	{
		if (S[i] == 'I') x++;
		else x--;

		if (x > ans) ans = x;
		else continue;
	}

	printf("%d\n", ans);
}

Measured memory_bytes: 256
N, M = map(int, input().split())

L = []
R = []
for _ in range(M):
  l, r = map(int, input().split())
  L.append(l)
  R.append(r)
  
max_L   = max(L)
min_R = min(R)
print(len(range(max_L, min_R+1)))

Measured memory_bytes: 11124
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??????????????????????????¢

???????????????????????????????????????????????????????????????????????¢??§??¬???????????????
????????????????????°???????????????????§?????????¨????????§????????????????????????
????????§??????????????? n ?¬???????????????? 
x={x1,x2,...,xn}x={x1,x2,...,xn} ??¨ 
y={y1,y2,...,yn}y={y1,y2,...,yn} ????????¢????¨????????????????????????????

Dxy=(???i=1~n|x(i)???y(i)|^p)1/p

p=??? ?????¨??? 
Dxy=max(ni=1)(|xi???yi|)

??¨???????????????????????§????????§????????¢??¨?????°????????????

????????? n?¬???????????????????????????????????????§???p??????????????? 1???2???3?????????
??????????????????????????¢????±???????????????°????????????????????????????????????
"""
import math

def Mink(x,y,n,p):
    """
    p????????????????????????????????????????????¢
    """
    D = 0
    for i in range(n):
        j = abs(x[i] - y[i])
        b = j ** p
        D += b
    return D ** (1 / p)

def Chebyshev(x,y,n):
    """
    ?????§????????§????????¢
    """
    D = 0
    for i in range(n):
        j = abs(x[i] - y[i])
        if D < j:
            D = j
    return D


n = int(input().strip())
x = list(map(float,input().strip().split()))
y = list(map(float,input().strip().split()))

print(Mink(x,y,n,1))
print(Mink(x,y,n,2))
print(Mink(x,y,n,3))
print(Chebyshev(x,y,n))

Measured memory_bytes: 7936
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  string s;
  cin >> s;
  cout << (s[0] - '0') + (s[1] - '0') + (s[2] - '0') << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    vector<vector<int>> a(3, vector<int>(3));
    vector<vector<bool>> t(3, vector<bool>(3));
    REP(i, 3) REP(j, 3) {
        cin >> a[i][j];
        t[i][j] = 0;
    }
    int n;
    cin >> n;
    vector<int> b(n);
    REP(i, n) {
        cin >> b[i];
        REP(j, 3) REP(k, 3) {
            if (b[i] == a[j][k]) t[j][k] = 1;
        }
    }

    bool ok = 0;
    REP(i, 3) {
        if (t[i][0] && t[i][1] && t[i][2]) ok = true;
    }
    REP(i, 3) {
        if (t[0][i] && t[1][i] && t[2][i]) ok = true;
    }
    if(t[0][0] && t[1][1] && t[2][2]) ok = true;
    if(t[0][2] && t[1][1] && t[2][0]) ok = true;

    cout << (ok ? "Yes" : "No") << endl;


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

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

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

using namespace std;

int main(){
	int a,b; cin>>a>>b;
	if(a<=0 && 0<=b) cout<<"Zero"<<endl;
	else if(a>0 || (b-a)%2==1) cout<<"Positive"<<endl;
	else cout<<"Negative"<<endl;

	return 0;
}


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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

char str[105];

int main(){
    scanf("%s",str+1);
    int len=strlen(str+1);
    for(int i=1;i<=len;i++){
        if(i&1){
            if(str[i]=='L')
                return puts("No"),0;
        }
        else{
            if(str[i]=='R')
                return puts("No"),0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 256
# A[i], A[i-1] = "C", "A"になるiの場所で累積和。探索はB[i]-B[i-1]

n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp.chars
arr = 0.upto(n).to_a.map{0}
(1...n).to_a.each do |i|
  if s[i-1] == "A" && s[i] == "C"
    arr[i]+=1
  end
end
(1...n).to_a.each do |i|
  arr[i]+=arr[i-1]
end
q.times do
  a, b = gets.chomp.split.map(&:to_i)
  puts arr[b-1] - arr[a-1]
end


Measured memory_bytes: 13356
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        Dictionary<int, int> dic = new Dictionary<int, int>();
        for (int i = 0; i < 3; i++)
        {
            dic[cin.nextInt()] = 1;
        }
        Console.WriteLine(dic.Count);
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
import java.util.*;
import java.lang.*;

public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] surface = new int[6];
        for (int i = 0; i < 6; i++) {
            surface[i] = sc.nextInt();
        }
        String s = sc.next();
        
        Dice dice = new Dice(s, surface);
    
        System.out.println(dice.step());

    }
}

class Dice {
    int[] oldsurf = new int[6];
    int[] newsurf = new int[6];
    String commands;
    
    Dice(String s, int[] surface) {
        commands = s;
        for (int i = 0; i < 6; i++) {
            oldsurf[i] = surface[i];
        }
    }
    
    int step() {
        for (int i = 0; i < commands.length(); i++) {
            char command = commands.charAt(i);
            if (command == 'N') {
                newsurf[0] = oldsurf[1];
                newsurf[1] = oldsurf[5];
                newsurf[2] = oldsurf[2];
                newsurf[3] = oldsurf[3];
                newsurf[4] = oldsurf[0];
                newsurf[5] = oldsurf[4];
            } else if (command == 'S') {
                newsurf[0] = oldsurf[4];
                newsurf[1] = oldsurf[0];
                newsurf[2] = oldsurf[2];
                newsurf[3] = oldsurf[3];
                newsurf[4] = oldsurf[5];
                newsurf[5] = oldsurf[1];
                
            } else if (command == 'E') {
                newsurf[0] = oldsurf[3];
                newsurf[1] = oldsurf[1];
                newsurf[2] = oldsurf[0];
                newsurf[3] = oldsurf[5];
                newsurf[4] = oldsurf[4];
                newsurf[5] = oldsurf[2];
                
            } else if (command == 'W') {
                newsurf[0] = oldsurf[2];
                newsurf[1] = oldsurf[1];
                newsurf[2] = oldsurf[5];
                newsurf[3] = oldsurf[0];
                newsurf[4] = oldsurf[4];
                newsurf[5] = oldsurf[3];
                
            }
            for (int j = 0; j < 6; j++) {
                oldsurf[j] = newsurf[j];
            }
        }
        return newsurf[0];
    }
}


Measured memory_bytes: 26252
n = int(input())
s = input()
mod = 1000000007

if n == 1:
    ans = 3
else:
    i = 1
    if s[0] == s[1]:
        ans = 6
        c = 2
        i += 1
    else:
        c = 1
        ans = 3

    while i < n-1:
        if c == 1:
            if s[i] == s[i+1]:
                c = 2
                i += 1
                ans *= 2
                ans %= mod
            else:
                c = 1
                ans *= 2
                ans %= mod
        elif c == 2:
            if s[i] == s[i+1]:
                c = 2
                i += 1
                ans *= 3
                ans %= mod
            else:
                c = 1
        else:
            if s[i] == s[i+1]:
                c = 2
                i += 1
            else:
                c = 1
        i += 1
    if s[-1] != s[-2]:
        if n >= 3:
            if s[-2] != s[-3]:
                ans *= 2
                ans %= mod
        else:
            ans *= 2
            ans %= mod
print(ans%mod)

Measured memory_bytes: 9268
#include<iostream>
#include<cstdio>
#include<set>
#include<string>
using namespace std;
std::set<string> s;
string t;
int k;
int main() {
    cin>>t>>k;
    for(int i=1;i<=k;i++) for(int j=0;j+i<=t.length();j++) s.insert(t.substr(j,i));
    while(k--) t=*s.begin(),s.erase(s.begin());
    cout<<t;
    return 0;
}


Measured memory_bytes: 1664
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   string s;
   cin >> n >> s;
   int cR = count(all(s),'R');
   int cW = n-cR;
   int ans = min(cR,cW);
   debug(ans);
   int curR = 0, curW = 0;
   f(i,0,n){
      curW += (s[i] == 'W');
      curR += (s[i] == 'R');
      int req = i+1-curR;
      int rem = cR-curR;
      if(req <= rem){
         ans = min(ans,rem);
      }else{
         ans = min(ans,rem+i+1-req);
      }
   }
   cout << ans << '\n';
   return 0;
} 


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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int step = 0;
  for(int i = 0; i < n; i++){
    if(i != 0 && d[i] == d[i - 1]){ 
      continue;
    }
    step++;
  }
  cout << step << endl;
}

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

int main()
{
    int n, m, i, sum=0;
    cin >> n >> m;
    int a[m];

    for(i=0; i<m; i++)
    {
        cin >> a[i];
        sum=sum+a[i];
    }

    if(sum>n) cout << -1 << endl;
    else if(sum<=n) cout << n-sum << endl;

    return 0;
}



Measured memory_bytes: 3636
S = str(input())
sub = S[2:-1]
cnt = 0
if S[0] != "A":
    print("WA")
    exit()
for i in range(len(sub)):
    if sub[i] == "C":
        cnt += 1
        if cnt >= 2:
            print("WA")
            exit()
if cnt == 0:
    print("WA")
    exit()
ans = S.replace("A","").replace("C","")
if not ans.islower():
    print("WA")
    exit()
print("AC")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int C[110000];

int main(){
    int N;
    cin>>N;
    int count=0;
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        C[i]=a;
        if(C[a]==i) count++;
    }
    cout<<count<<endl;
}



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

using namespace std;

long long int  n,s, m,k,ans,b,d,f,s1,s2,s3,w,a,c,z2,z1,z3,ans1;
string  j,t,g,k2,k3;
bool ww=false,wwr=false;
set <int> ss;

//vector <pair<long long int,long long int >> a1;
char e1,e2;

int main() {
  cin>>n>>m;
cout<<n-m+1;
	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000001
 
int a[N],b[N],c[N];
 
int main(){
  int i,j,n,k=0;
    
  scanf("%d",&n);
 
  for(i = 1; i < n+1 ; i++){
    scanf("%d",&a[i]);
    if(a[i] > k){
      k = a[i];
    }
  }
  for(i = 0; i < k+1; i++){
    c[i] = 0;
  }

  for(j = 1; j < n+1; j++){
    c[a[j]]++;
  }
 
  for(i = 1; i <= k; i++){
    c[i] = c[i-1] + c[i];
  }
  
  for(j = n; j > 0; j--){
    b[c[a[j]]] = a[j];
    c[a[j]]--;
  }
 
  for(i = 1; i < n; i++){
    printf("%d ",b[i]);
  }

  printf("%d\n",b[n]);
 
  return 0;
}
 

Measured memory_bytes: 17892
loop do
  n = gets.to_i
  break if n == 0
  go = [0]*(n+1)
  last_clr = gets.to_i
  go[0] = 1

  (2..n).each do |i|
    put = gets.to_i
    if put == last_clr
      j = go.index(0) - 1
      go[j] += 1
    else
      # put != last_clr
      if i.odd?
        j = go.index(0)
        go[j] = 1
      else
        # 連続する石の色を変える
        j = go.index(0) - 1
        if j > 0
          go[j-1] += go[j] + 1
          go[j] = 0
        else
          go[0] += 1
        end
      end
    end
    last_clr = put
  end

  # 石を数える
  cnt_w = 0
  last_i = go.index(0) - 1
  if last_clr == 0
    last_i.step(0, -2) do |i|
      cnt_w += go[i]
    end
  else
    (last_i - 1).step(0, -2) do |i|
      cnt_w += go[i]
    end
  end

  puts cnt_w
end

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

using namespace std;

int main()
{
    int n;
    int a[200];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n;
string s;
set<string> t;
int main(){
	n=read();
	while(n--){
		cin >> s;
		t.insert(s);
	}
	cout << t.size();
	return 0;
}

Measured memory_bytes: 19120
/*
AizuOnline A2503
Title Project Management
@kankichi573
*/
#include <stdio.h>
#include <string.h>
//Global data section
int n,m;
int jikan[800][800];
//
int solve()
{
        int flag,sum;
        int i,j;

        
        do
        {
                flag=0;
                for(i=1;i<n;i++)
                {
                        if(jikan[0][i]==0)
                                continue;
                        //printf("I=%d \n",i);
                        for(j=1;j<n;j++)
                        {
                                if(i==j)
                                        continue;
                                if(jikan[i][j]==0)
                                        continue;
                                sum=jikan[0][i]+jikan[i][j];
                                if(sum > jikan[0][j])
                                {
                                        //printf("0~%d %d\n",j,sum);
                                        jikan[0][j]=sum;
                                        flag=1;
                                }
                        }
                }
        }while(flag);

        return(jikan[0][n-1]);
}
main()
{
        int i,p,q,r,ret;

        memset(jikan,0,800*800*sizeof(int));
        scanf("%d %d",&n,&m);
        for(i=0;i<m;i++)
        {
                scanf("%d %d %d",&p,&q,&r);
                jikan[p][q]=r;
        }
        ret=solve();
        printf("%d\n",ret);
        return(0);
}

Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	set<char>baket;
	char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
	for (int i = 0; s[i] != NULL; i++) {
		baket.insert(s[i]);
	}
	auto itr = baket.begin();
	for (int i = 0; i < 26; i++) {
		//cout <<"*itr"<< *itr<<endl;
		if (*itr != alpha[i]) {
			cout << alpha[i];
			return 0;
		}
		else if (*itr == NULL) {
			break;
		}
		itr++;
	}
	cout << "None";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define MAX 200005
                int main()
                {
                      string s;
                      int arr[500] = {0};
                      cin>>s;
                      int l = s.size();

                      for(int i = 0 ; i < l ; i++)
                      {
                            arr[s[i]]++;
                      }
                      for(int i = 'a' ; i <= 'z' ; i++)
                      {
                            if(arr[i] % 2)
                            {
                                printf("No\n");
                                return 0;
                            }
                      }
                      printf("Yes\n");
                }


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    rep(0, i, N)
    {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D * D)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
N, X, M = map(int, input().split())

lim = 10**5*2+1

f = [0]*(lim)
a = [0]*(lim)

x = X
f[x] = 1
a[1] = x

ans = x

i = 1
l = N
while i < l:
    i += 1

    x **= 2
    x %= M
    if not x:
        break

    if f[x]:
        lp_len = (i-f[x])
        z = (l-i+1)//lp_len
        if z:
            ls = ans - a[f[x]-1]
            ans += ls * z
            i += z*lp_len

    if i <= l:
        ans += x
    
    f[x] = i
    if i < lim:
        a[i] = ans

print(ans)

Measured memory_bytes: 16868
#include <stdio.h>

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

  scanf("%d %d %d", &a,&b,&c );

  if (( (a==b || a==c) && (b!=c) ) || ( (b==c || b==a) && (a!=c) ) ){
    printf("Yes\n");
  } else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#include <cctype>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
vector<vector<pair<int,int>>> z(100010);


int main()
{
    string S;
    cin >> S;
    
    int U,D,i,y;
    y=stoi(S);
    U=y/100;
    D=y%100;
    if(D<13&&D>0){
        if(U<13&&U>0){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "YYMM" << endl;   
        }
    }else{
       if(U<13&&U>0){
            cout << "MMYY" << endl;
        }else{
            cout << "NA" << endl;   
        } 
    }
        
    return 0;
}

Measured memory_bytes: 2560
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const ll mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18;
const int inf = 2e9;
const int nmax = 5e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

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

    int n;
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];
    bool hoise = false;
    for(int i=2; i<n; i++){
        if(a[i]==b[i] and a[i-1]==b[i-1] and a[i-2]==b[i-2]) hoise = true;
    }
    if(hoise) cout<<"Yes\n";
    else cout<<"No\n";

}
/*
*/


Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int p[n],i,j,min,sum=0,temp;
    for(i=0;i<n;i++)
    {
      scanf("%d",&p[i]);
    }


    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
         if(p[i]>p[j])
         {
             temp=p[j];
             p[j]=p[i];
             p[i]=temp;

         }

        }
    }
     for(i=0;i<k;i++)
     {
      sum=sum+p[i];
     }

    printf("%d\n",sum);

    return 0;
}


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

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

	int res = 0;
	for(int i = A; i <= B; ++i) {
		if(res < K || res >= B - A - K + 1) {
			cout << i << endl;
		}
		res++;
	}
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
if N<3:
    print(0)
    exit()
a=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            if L[j]==L[k]:
                continue
            if L[i]+L[j]>L[k]:
                a+=1
print(a)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		switch (str) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
//#define DEBUG
using namespace std;

bool check_one(char c){
    if(c == '1'){
        return true;
    }
    return false;
}

int main(){
    string S;
    cin >> S;
    
    // 初期値は大きい値
    int ans = S.length();

    // iは最初に使う色(0 or 1)
    for(int i = 0; i < 2; i++){

        // iを最初に使った時に変えなければならないタイルの数
        int cnt = 0;

        for(int j = 0; j < S.length(); j++){

            // char(0 + '0') -> '0'
            // char(1 + '1') -> '1'
            if(j % 2 == 0 && S.at(j) != (char)(i+'0')) cnt++;
            if(j % 2 == 1 && S.at(j) == (char)(i+'0')) cnt++;
        }
        ans = min(ans, cnt);
    }

    
    cout << ans << endl;
}

Measured memory_bytes: 512
'''
Created on 2020/09/14

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  mod=10**9+7
  if N==1:
    print(0)
  elif N==2:
    print(2)
  else:
    ans1=1 #全体
    ans0=1  #0がないor9がない
    ans2=1 #0と9がない
    for i in range(N):
      ans1=(ans1*10)%mod 
      ans0=(ans0*9)%mod 
      ans2=(ans2*8)%mod 
    ans=(ans1-2*ans0+ans2)%mod
    print(ans)
  return
main()

Measured memory_bytes: 63188
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	int n,m;
	cin>>n>>m;
	vi co(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		co[a-1]++;
		co[b-1]++;
	}
	bool h=true;
	rep(i,n)if(co[i]%2)h=false;
	if(h)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}












Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

long long msum(long long x){
  if(x<1) return 0;
  else return x*(x+1)/2;
}

int main() {
  long long n;
  cin>>n;
  int nf=n/3,nb=n/5,nfb=n/15;
  long long ans=msum(n)-3*msum(nf)-5*msum(nb)+15*msum(nfb);
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll A,B,C;
    cin >> A >> B >> C;
    string out1 = "Yes";
    string out2 = "No";
    if(A==B && C != B){
        cout << out1 << endl;
    }else if(A==C && B != A){
        cout << out1 << endl;

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

    }else{
        cout << out2 << endl;

    }


}

int main(){
    Main();
}

Measured memory_bytes: 3044
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {  
  string s;
  cin >> s;
  
  long long int count = 0;
  long long int na = 0;
  
  string t;
  for (int i = 0; i < (int)s.size() - 1; i++) {
    if (s[i] == 'B' && s[i+1] == 'C') {
      t.push_back('D');
      i++;
    }
    else
      t.push_back(s[i]);
  }

  for (int i = 0; i <= (int)t.size() - 1; i++) {    
    if (t[i] == 'A') {
      na++;
    }
    else if (t[i] == 'D') {
      count += na;
    }
    else {
      na = 0;
    }
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  string s;
  cin >> s;
  int ans = 0, l = 0;
  REP(i, s.size()) {
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
      l++;
    else
      l = 0;
    ans = max(ans, l);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    ll sum=0;
    int n;
    in(n);
    vector<ll> vec(n);
    rep(i,n){
        scanf("%lld",&vec[i]);
        sum+=vec[i];
    }
    sort(all(vec));
    out(vec[0],vec[n-1],sum);
}


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

typedef long long ll;
using namespace std;

vector<vector<int> > tree(200001);
vector<int> counter(200001);
vector<int> res(200001);

void dfs(int x, int p = -1) {
    if (p != -1) res[x] += counter[x] + res[p];
    else res[x] += counter[x];

    for (const int element : tree[x]) {
        if (element == p) continue;
        dfs(element, x);
    }
}

int main() {
    // 木を表現するときは vector<vector<int>> tree(n); で必ず表現する。
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        // 木の設定
        // 双方向に設定して、DFSの引数に前の要素（親）の情報を持たせる
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        --p;
        counter[p] += x;
    }

    dfs(0);

    for (int i = 0; i < n; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 24320
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
// #define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

#define MAX_N 301
#define INF 10000000000001
bool d[MAX_N][MAX_N];


// void warshall_floyd() {
// 	for (int k = 0; k < N; k++) 
// 		for (int i = 0; i < N; i++) 
// 			for (int j = 0; j < N; j++) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
// }


int main(){	
	ll N;
	cin >> N;
	vector< vector<ll> > A(N, vector<ll>(N));
	rep(i, N) {
		rep(j, N) {
			cin >> A[i][j];
		}
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				if (i == j || i == k || j == k) continue;
				if (A[i][j] > A[i][k]+A[k][j]) {
					// cout << i << " " << j << " " << k << endl;
					// cout << A[i][j] << " " << A[i][k] << " " << A[k][j] << endl;
					cout << "-1" << endl;
					return 0;
				} else if (A[i][j] == A[i][k]+A[k][j]) {
					d[i][j] = true;
					d[j][i] = true;
				}
			}
		}
	}
	ll res = 0;
	rep(i, N) {
		rep(j, N) {
			if (!d[i][j]) res += A[i][j];
		}
	}
	cout << res/2 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  int n,m;
  cin >> n>>m;
  vector<tuple<int,int,int>>a;
  
  rep(i,n){
    int s,t,c;
    cin>>s>>t>>c;
    a.push_back(tuple<int,int,int>(s,t,c));
  }
  sort(a.begin(),a.end());
  vector<bool>e(n,true);
  int ans=0;
  int co=0;
  while(co<n){
    ans++;
    int f=0;
    int g=0;
    int h=0;
  rep(i,n){
    if(e.at(i)){
      int s,t,c;
      tie(s,t,c)=a.at(i);
      if((g<s&&h!=c)||(g<=s&&h==c)){
        f=s;
        g=t;
        h=c;
        e.at(i)=false;
        co++;
      }
    }
  }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const ll maxn=3e6+5;
const double pi=3.14159265358979323846;
ll f[maxn];
ll C[30][30];
void table_C(){
    memset(C,0,sizeof(C));
    C[0][0]=1;
    for(int i=1;i<=28;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++) C[i][j]=C[i-1][j]+C[i-1][j-1];
    }
}
void table()
{
    f[0]=1;
    for(ll i=1;i<maxn;i++) f[i]=f[i-1]*i%mod;
}
 
void exgcd( ll a,ll b, ll &x,ll &y,ll &d )
{
    if(!b){ x=1;y=0;d=a; }
    else
    {
        exgcd(b,a%b,x,y,d);
        int t=x;
        x=y;
        y=t-(a/b)*y;
    }
}
ll solve(ll a,ll b) // 求a mod b 下的逆元如ax ≡ 1 mod p 求x 则 solve(a,p)
{
    ll x,y,d;
    exgcd(a,b,x,y,d);
    ll t=b/d;
     x=(x%t+t)%t;//最小正整数解
    return x;
}
ll CC( ll n,ll m,ll p )
{
    if(n<m) return 0;
    return f[n]*(solve(f[m]*f[n-m]%p,p)%p)%p;
}

ll ktl( ll n ) //卡特兰数 
{
	return ( CC(n*2,n,mod)-CC(2*n,n+1,mod)+mod )%mod; 
}

ll h( ll n,ll m ,ll t=1) // n个数中选择 m 个至少相邻 t 个的数，
{
	return CC(n-t*(m-1),m,mod);
} 
int fm[maxn];

int main()
{
	table();
	ll n,m,k;
	cin>>n>>m>>k;
	fm[1]=m;
	for( int i=2;i<=n;i++ ) fm[i]=fm[i-1]*(m-1)%mod;
	ll ans=0;
	
	for( int i=0;i<=k;i++ )
	{
		ans=(ans+CC(n-1,i,mod)*fm[n-i]%mod )%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 27812
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    ll N;
    cin >> N;

    reple(h, 1, 3500)
    {
        reple(n, 1, 3500)
        {
            ll y = 4 * h * n - N * h - N * n;

            if (y == 0) continue;

            ll x = N * h * n;

            if (x % y == 0 && x / y > 0)
            {
                cout << h << " " << n << " " << x / y << endl;
                return 0;
            }
            
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,i;
    int *a;
    scanf("%d",&n);
    a = (int*)malloc(sizeof(int)*n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        printf("node %d: ",i+1);
        printf("key = %d, ",a[i]);
        if(i!=0){
            printf("parent key = %d, ",a[(i-1)/2]);
        }
        if(i*2+1<n){
            printf("left key = %d, ",a[i*2+1]);
        }
        if(i*2+2<n){
            printf("right key = %d, ",a[i*2+2]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2024
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int h, w;
char s[400][401];
int dx[] = { -1, 1, 0, 0 }, dy[] = { 0, 0, -1, 1 };
void dfs(int x, int y, ll& black, ll& white) {
	(s[x][y] == '#' ? black : white)++;
	char cur = s[x][y];
	s[x][y] = 0;
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w &&
			s[nx][ny] != 0 && cur != s[nx][ny])
			dfs(nx, ny, black, white);
	}
}
int main() {
	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++)
		scanf("%s", s[i]);
	ll total = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			ll b = 0, w = 0;
			if (s[i][j] != 0) {
				dfs(i, j, b, w);
				total += b * w;
			}
		}
	printf("%lld\n", total);
}

Measured memory_bytes: 10368
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 19, 2020 6:05 PM
 *    Problem Name  : B - Go to Jail
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc179/tasks/abc179_b
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    int n,cnt=0;
    cin >> n;

    while(n--){
        if(cnt >= 3) {
            break;
        }
        int u,v;
        cin >> u >> v;
        
        if(u == v) cnt++;
        else cnt=0;
    }

    //cout << cnt << endl;

    if(cnt >=3) cout << "Yes" << endl;
    else cout << "No" << endl;



    return 0 ;
}


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

using namespace std;
typedef long long ll;
const ll mod = 998244353;
ll qpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
int main()
{
	ll n,x;
	ll ans = 1;
	ll s[100100],num[100100];
	memset(num,0,sizeof(num));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		if(!i&&x) ans=0;
		else if(i&&!x) ans=0;
		num[x]++;
	}
	if(ans)
	{
		for(int i=2;i<n;i++)
		{
			if(num[i]&&num[i-1])
				ans=ans*qpow(num[i-1],num[i])%mod;
			else if(num[i]&&!num[i-1]) ans = 0;
		}
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 1024
import sys

S = input()
if len(S) == 1:
    print(int(S))
    sys.exit()

ls = []
for i in range(1<<(len(S)-1)):
    ans = 0
    num = format(i, 'b').zfill(len(S)-1)
    start = 0
    for (j, x) in enumerate(num):
        if x == '1':
            ans += int(S[start:j+1])
            start = j + 1
    ans += int(S[start:len(S)])
    ls.append(ans)
print(sum(ls))

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

using namespace std;

int main()
{
    int A, B;
    int max = 0;

    cin >> A >> B;

    for(int i=0; i<2; i++){
        if(A>=B){
            max += A;
            A--;
        }
        else{
            max += B;
            B--;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    void solve(){
        LL n;
        vector<LL> v(4);
        for(int i=0; i<4; ++i){
            cin >> v[i];
        }
        v[0]*=4;
        v[1]*=2;
        cin >>  n;
        int x=0;
        x=min_element(v.begin(),v.begin()+3)-v.begin();
        if(v[x]*2<v[3]){
            cout << n*v[x] <<"\n";
        }else{
            cout << (n/2)*v[3]+(n%2)*v[x] <<"\n";
        }
    }
};

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



Measured memory_bytes: 256
s = int(input())
a = [s]
i = 0
while True:
    i = i+1
    if a[i-1] % 2 == 0:
        n = a[i-1]//2
    else:
        n = 3*a[i-1]+1
    if n in a:
        print(i+1)
        break
    a.append(n)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	bool good=false;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			for(int l=0;l<=k;l++){
			if(i+j+l>k) continue;
				long long x=a*(1<<i);
				long long y=b*(1<<j);
				long long z=c*(1<<l);
				if(x<y && y<z){
					//cout<<x<<" "<<y<<" "<<z;
					good=true;
				}
			}
		}
	}
	if(good) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3648
N,M=map(int, input().split())
H=list(map(int, input().split()))
AB=[tuple(map(int, input().split()))for _ in range(M)]
X=[True]*N
for a,b in AB:
    a-=1
    b-=1
    if H[a]>H[b]:
        X[b]=False
    elif H[a]<H[b]:
        X[a]=False
    else:
        X[a]=False
        X[b]=False
print(sum(X))

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

int main(){
    int x[5],y[5];
    cin >> x[1] >> y[1] >> x[2] >> y[2];

    x[3]=x[2]+y[1]-y[2];
    y[3]=y[2]+x[2]-x[1];
    x[4]=x[3]+x[1]-x[2];
    y[4]=y[3]+y[1]-y[2];

    cout << x[3] << ' ' << y[3] << ' ' << x[4] << ' ' << y[4] << endl;

}

Measured memory_bytes: 3596
def orchestra(n, move_count, current, flag):
    for i in range(move_count):
        n_lis.append(multiple_lis[current+i])
        if flag == n:
            if calculate():
                return True
            del n_lis[-1]
        else:
            if orchestra(n, move_count, current+i+1, flag+1):
                return True
            move_count -= 1
            del n_lis[-1]
    
def calculate():
    if sum(n_lis) == _num:
        result_lis = [str(2*n) for n in n_lis]
        if num % 2 != 0:
            result_lis.insert(0, '1')
        print ' '.join(result_lis)
        return True
    
multiple_lis = [1, 2, 4, 8, 16, 32, 64, 128, 256]
while True:
    try:   
        num = int(raw_input())
        n_lis = []
        _num = num / 2
        for i in range(8, -1, -1):
            n = i
            move_count = 9-i
            current = 0
            flag = 0
            if orchestra(n, move_count, current, flag):
                break
        else:
            print 1
    except EOFError:
        break

Measured memory_bytes: 4320
import java.util.Scanner;

public class Main {
 public static void main(String[] args){
 Scanner sc = new Scanner(System.in);
 int A = sc.nextInt();
 int B = sc.nextInt();
 int x = A+A+B+B;
 int xx = A * B;
 System.out.println(xx + " " + x);
 }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int N = s.size();
    string ss;
    rep(i, N) {
        if (i != N - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            ss += 'D';
            i++;
        } else {
            ss += s[i];
        }
    }

    ll ans = 0;
    ll cnt = 0;
    rep(i, ss.size()) {
        if (ss[i] == 'D') {
            ans += cnt;
        } else if (ss[i] == 'A') {
            cnt++;
        } else {
            cnt = 0;
        }
    }

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define LINF (1ll<<60)
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'

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

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

    if (a > 9 || b > 9) cout << -1 << endl;
    else cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 256