akhauriyash/Code-Regression huggingface dataset:
n,k = list(map(int,input().split()))

pList = list(map(int,input().split()))

cList = list(map(int,input().split()))

cSum = sum(cList)
p = dict()
c = dict()

for i in range(n):
    p[i] = pList[i]
    c[i] = cList[i]

highScore = min(cList)
for i in range(n):
    count = 0
    zahyou = i
    score = 0
    zumi =zahyou
    loop = False
    while count < k:
        if not(loop):
            if zahyou == zumi and count != 0:
                loop = True
                if score > 0:
                    score += score * ((k // count) - 2)
                    count += ((k // count) - 2) * count
                else:
                    break
        zahyou = p[zahyou] - 1
        score += c[zahyou]
        count += 1
        if highScore < score:
            highScore = score

print(highScore)

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

int main(){
  int K,S;
  cin >> K >> S;
  int count = 0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if((S-(i+j))>=0 && (S-(i+j))<=K){
        count++;
      }
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;

    int sum=1;
    for(int i=0;i<N;++i){
        if(i==0){
            sum++;
            continue;
        }
        else if(sum*2<sum+K){
            sum=sum*2;
        }
        else sum+=K;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> s(H + 2, vector<int>(W + 2));
	bool flag_paint = true;
	string S;

	REP(h, H + 2) {
		REP(w, W + 2) {
			s[h][w] = 0;
		}
	}

	REP(h, H) {
		cin >> S;
		REP(w, W) {
			if (S[w] == '#') {
				s[h + 1][w + 1] = 1;
			}
			else {
				s[h + 1][w + 1] = 0;
			}
		}
	}

	for (int h = 1; h < H + 1; h++) {
		for (int w = 1; w < W + 1; w++) {
			if (s[h][w] == 1
				&& s[h - 1][w] == 0
				&& s[h + 1][w] == 0
				&& s[h][w - 1] == 0
				&& s[h][w + 1] == 0) {
					//cout << "No" << endl;
					flag_paint = false;
				}
		}
	}

	if (flag_paint) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	//cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    
    polls_set = set()
    for key, value in polls_dict.items():
        if value == max_poll:
            polls_set.add(key)

    polls_set = sorted(polls_set)
    for poll in polls_set:
        print(poll)
    
    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 42460
n,k= map(int,input().split())
td=[]
for _ in range(n):
    td.append(list(map(int,input().split())))
td.sort(key=lambda x:x[1],reverse=True)
NEW=[1]*(n+1)
x=0
y=0
TOP=[]
SUB=[]
A=[]
for tdi in td[:k]:
    if NEW[tdi[0]]==1:
        NEW[tdi[0]]=0
        TOP.append(tdi[1])
        y+=1
    else:
        A.append(tdi[1])
    x+=tdi[1]
    
for tdi in td[k:]:
    if NEW[tdi[0]]==1:
        SUB.append(tdi[1])
        NEW[tdi[0]]=0
ans=x+y**2
for i in range(min(k-1,len(A),len(SUB))):
    x -= A.pop()
    x += SUB[i]
    y += 1
    ans = max(ans,x+y**2)
print(ans)

Measured memory_bytes: 30212
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    REP(i,H) cin >> S[i+1];
    S[0] = string(W+2,'.');
    S[H+1] = string(W+2,'.');
    REP(i,H) S[i+1] = '.' + S[i+1] + '.';
    vector<string> ans(H);
    REP(i,H) ans[i] = "";
    REP(i,H){
        REP(j,W){
            if (S[i+1][j+1] =='.'){
                int cnt = 0;
                for (int k = i-1 ; k <= i+1; k++){
                    for (int l = j-1 ; l <= j+1; ++l){
                        if (S[k+1][l+1] == '#') cnt+=1;
                    } 
                }
                ans[i] += to_string(cnt);
            }
            else{
                ans[i] += '#';
            }
        }
    }
    REP(i,H) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
e = Enumerator.new do |y|
  i = 1
  loop do
    y << case
         when (i % 15).zero? then "FizzBuzz"
         when (i %  3).zero? then "Fizz"
         when (i %  5).zero? then "Buzz"
         else i.to_s
         end
    i += 1
  end
end

until (given = gets.chomp) == "0 0"
  m, n = given.split.map(&:to_i)
  data = n.times.map {gets.chomp}
  table = (1..m).map(&:itself)
  pointer = 0
  
  data.each do |said|
    if said != e.next
      table.delete_at(pointer)
      break if table.size == 1
    else
      pointer += 1
    end
    pointer = 0 if pointer >= table.size
  end
  
  puts table.join(" ")
  e.rewind
end



Measured memory_bytes: 8560
using System;
using System.IO;
using System.Text;

class Solver {
  public Istream cin = new Istream(Console.OpenStandardInput());
  public void solve() {
    int n = cin.readInt();
    int[,] a = new int[2, n];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        a[i, j] = cin.readInt();
      }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int cur = 0;
      for (int j = 0; j < n; j++) {
        if (j <= i) cur += a[0, j];
        if (i <= j) cur += a[1, j];
      }
      ans = Math.Max(ans, cur);
    }
    Console.Out.WriteLine(ans);
  }
}


#region Istream
class Istream {
  public Istream(Stream _ins) { ins = _ins;}

  const int BUF_SZ = 1024;
  private Stream ins;
  private byte[] buf = new byte[BUF_SZ];
  private int len, ptr;

  private byte readByte() {
    if (ptr >= len) {
      ptr = 0;
      len = ins.Read(buf, 0, BUF_SZ);
      if (len == 0) return 0;
    }
    return buf[ptr++];
  }
  public char nextChar() {
    byte b;
    do b = readByte(); while (b < 33 && 126 < b);
    return (char)b;
  }
  public string read() {
    var sb = new StringBuilder();
    for (char c = nextChar(); (33 <= c && c <= 126); c = (char)readByte()) sb.Append(c);
    return sb.ToString();
  }
  public string readLine() {
    var sb = new StringBuilder();
    for (char c = nextChar(); (c != '\n' && c != 0); c = (char)readByte()) sb.Append(c);
    return sb.ToString();
  }
  public long readLong() { return long.Parse(read()); }
  public int readInt() { return int.Parse(read()); }
  public double readDouble() { return double.Parse(read()); }
}
#endregion


#region Main
class ReSha {
  static void Main() {
    new Solver().solve();
  }
}
#endregion

Measured memory_bytes: 13140
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i, n) for (int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int         // 10^18
#define INF 1000000001           // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
//---------------------------
bool isUnbalanced(string a) {
    // aの長さは3
    if(a[0]==a[1] || a[1]==a[2] || a[0]==a[2])return true;
    return false;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    
    string s;cin>>s;
    // アンバランスな部分文字列が存在→その長さは3以下
    if(s.size()==2){
        if(s[0] ==s[1]){
            P("1 2");
        }else{
            P("-1 -1");
        }
    }else{
        for(int i=0;i<s.size()-3;i++){
            if(isUnbalanced(s.substr(i, 3))) {
                cout<<i+1<<" "<<i+3<<endl;
                return 0;
            }
        }
        P("-1 -1");
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    cin>>N;

    cout<<N*N*N<<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 num1 = sc.nextInt();
      int num2 = sc.nextInt();
      int num3 = sc.nextInt();
      if(num1 == (num2 + num3)){
            System.out.println("Yes");
      }
      else if(num2 == (num1 + num3)){
            System.out.println("Yes");
      }
      else if(num3 == (num1 + num2)){
            System.out.println("Yes");      
      }
      else{
            System.out.println("No");
      }
  }
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(void){

	int N, M;
	int i, j;
	scanf("%d%d", &N, &M);
	int n = N;
	int m = M;
	int a[50][50];
	for(i = 0; i < 50; i++) for(j = 0; j < 50; j++) a[i][j] = 0;

	for(i = 0; i < N; i++){
		int k;
		scanf("%d", &k);
		for(j = 0; j < k; j++){
			int A;
			scanf("%d", &A);
			// i 番目の人はA 番目の料理がすき
			a[i][A - 1] = 1;
		}
	}

	
	int ans = 0;
	for(j = 0; j < m; j++){
		int flag = 1;
		for(i = 0; i < n; i++){
			if(a[i][j] == 0){
				flag = 0;
				break;
			}
		}

		if(flag == 1) ans++;
	}

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



	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), k = sc.nextInt();
        long count = 0L;
        if (k == 0) {
            count = ((long) n * n);
        } else {
            for (int b = k + 1; b <= n; b++) {
                long rep = n / b;
                long repK = rep * Math.max(b - k, 0);
                long mod = n % b;
                long modK = Math.max(mod - k + 1, 0);
                count += repK + modK;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int N, i;
	cin >> N >> i;
	cout << N - i + 1;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef complex<double> Point;
#define X real()
#define Y imag()
const double EPS = 1e-9;

double dot(Point a, Point b) {
	return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
	return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

int main(void){
	int q;
	cin>>q;
	rep(i,q){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
		cout<<isecSS({x0,y0},{x1,y1},{x2,y2},{x3,y3})<<endl;
	}
	return 0;
}

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

class Main{
    public static void main(String args[]){
	int i,n=0,fn;
	try{
	    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
	    String str = buffer.readLine();
	    n = Integer.parseInt(str);
	}catch(Exception e){
	    System.out.println("error");
	}
	fn = fib(n);
	System.out.println(fn);
    }

    static int fib(int n){
	int f1,f2,f3,i;
	if(n==0 || n==1){
	    return 1;
	}
	else{
	    f1=1;
	    f2=1;
	    for(i=2;i<=n;i++){
		f3 = f2;
		f2 = f1;
		f1 = f2+f3;
	    }
	    return f1;
	}
    }
}



Measured memory_bytes: 24340
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
long long p  = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define end_s(a) cout <<a<<endl;return 0
int sol(int val, vel &a) {
	int m = a.size();
	vel b(m + 2);
	b[0] = a[0]; b[m + 1] = a[m - 1];
	rep(i, m) { b[i + 1] = a[i]; }
	m += 2;
	rep(i,m){
		if (b[i] <= val) { b[i] = 0; }
		else { b[i] = 1; }
	}
	int n = m / 2;
	if (b[n - 1] == b[n] || b[n + 1] == b[n]) { return b[n]; }
	pin lef;
	rep(i, n) {
		if (b[i] == b[i + 1]) { lef = mkp(i, b[i]); }
	}
	pin ri;
	for (int i = m - 1; i > n; i--) {
		if (b[i] == b[i - 1]) { ri = mkp(i, b[i]); }
	}
	if (lef.first + ri.first >= 2 * n) { return lef.second; }
	else { return ri.second; }
}
signed main(){
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n+1) {
		bool fl = true;
		rep(j, n - i) {
			if (t[j] != s[i + j]) { fl = false; }
		}
		if (fl) { cout << n + i << endl; return 0; }
	}
	return 0;
}

Measured memory_bytes: 1408
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main () {
    int a, b, c, k;
    int ans = 0;
    cin >> a >> b >> c >> k;
    if(k-a <= 0) ans = k;
    else if(k - a - b <= 0)  ans = a;
    else ans = 2*a + b - k;
    cout << ans <<endl;
    return 0;
}





Measured memory_bytes: 3628
W, H, x, y, r = map(int, input().split())
if x - r < 0:
 #left
 print("No")
elif x + r > W:
 #right
 print("No")
elif y - r < 0:
 print("No")
elif y + r > H:
 print("No")
else:
 print("Yes")

Measured memory_bytes: 7640
#include<map>
#include<set>
#include<string>
#include<iostream>

using namespace std;

int main()
{
	string key;
	int page;
	map< string, set<int> > dic;

	while (cin >> key >> page)
	{
		dic[key].insert(page);
	}

	for (map< string, set<int> >::iterator it_dic = dic.begin(); it_dic != dic.end(); ++it_dic)
	{
		cout << it_dic->first << endl;
		for (set<int>::iterator it = it_dic->second.begin(); it != it_dic->second.end(); ++it)
		{
			if (it != it_dic->second.begin())
			{
				cout << " ";
			}
			cout << *it;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int n, m, k;

int main()
{
    cin >> m >> k;
    n = (1 << m) - 1;
    if (m == 1 && k == 0)
    {
        cout << "0 0 1 1";
        return 0;
    }
    if (k > n)
    {
        cout << -1;
        return 0;
    }
    int r = 0, t = 0;
    for (int i = 0; i <= n; i++)
    {
        if (i != k) r ^= i;
    }
    if (r != k)
    {
        cout << -1;
        return 0;
    }
    cout << k << " ";
    for (int i = 0; i <= n; i++) if (i != k) cout << i << " ";
    cout << k << " ";
    for (int i = n; i >= 0; i--) if (i != k) cout << i << " ";
}


Measured memory_bytes: 1792
x1, y1, x2, y2 = gets.chomp.split.map(&:to_f)

a = y2 - y1
b = x2 - x1
a2 = a * a
b2 = b * b
p = y1 - a / b * x1

gets.to_i.times{
    x, y = gets.chomp.split.map(&:to_f)

    if a == 0
        puts "#{x} #{y1}"
    elsif b == 0
        puts "#{x1} #{y}"
    else
        q = y + b / a * x
        cx = a * b * (q - p) / (a2 + b2) 
        cy = (a2 * q + b2 * p) / (a2 + b2)
        puts "#{cx} #{cy}"
    end
}


Measured memory_bytes: 6908
#include <stdio.h>
int main()
{
	int a,b; 
	scanf("%d %d",&a,&b);
	
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2600
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,k,x,y;
  cin >> n >> k >> x >> y;

  int a,b;

  a = k >= n ? n : k;

  b = k >= n ? 0 : n - k;

  int ans = a * x + b * y;

  cout  << ans;

  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define rint register int
#define rep(i,u,z) for(rint i=u;i<=z;++i)

using namespace std;
typedef long long ll;

int main(){
int n;
ll t;
scanf("%d%lld",&n,&t);
ll ans=inf;
rep(i,1,n){
ll a,b;
scanf("%lld%lld",&a,&b);
if(b<=t){
ans=min(ans,a);
}
}
if(ans==inf)puts("TLE");
else printf("%lld",ans);
return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s;cin >> s;
    int n = s.size();
    reverse(all(s));
    map<int,ll> mp;
    mp[0]++;
    ll t = 0;
    ll x = 1;
    rep(i,n){
        t = t + (s[i]-'0')*x;
        t %= 2019;
        mp[t]++;
        x = x*10%2019;
    }
    ll res = 0;
    for(auto m:mp){
        res += (m.second * (m.second -1)) / 2;
    }
    out(res);
}


Measured memory_bytes: 3740
def gcd(a,b):
    while (a % b != 0):
        c = a % b
        a = b
        b = c
    return b

k = int(input())
200
s = 0

for i in range(k):
    s += (i + 1)

if k == 1:
    print(s)
else:
    for i in range(1,k):
        for j in range(i + 1,k + 1):
            s += 6 * (gcd(j,i))
    if k == 2:
        print(s)
    else:
        for i in range(1,k-1):
            for j in range(i + 1,k):
                for k in range(j + 1,k + 1):
                    x = gcd(j,i)
                    y = gcd(k,x)
                    s += 6 * y
        print(s)


Measured memory_bytes: 9248
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f; }
int n,c,L[100],ps[100],Cnt,Ans; int F[310][40];
inline int solve() {
	memset(F,0,sizeof F); F[n*L[n-1]][0]=1;
	for(int i=0;i<n*c;i++) for(int j=i;j<=n*c;j++) for(int k=0;k<(1<<(n-1));k++) if(i%n&&!((k>>ps[i%n-1])&1)) F[min(c*n,max(j,i+n*L[ps[i%n-1]]))][k|(1<<ps[i%n-1])]+=F[j][k];
	return F[n*c][(1<<(n-1))-1];
}
signed main() {
	n=read(); c=read(); for(int i=0;i<n;i++) L[i]=read(),ps[i]=i; sort(L,L+n); while(1) { Cnt++; Ans+=solve(); if(!next_permutation(ps,ps+n-1)) break; }
	for(int i=1;i<n;i++) Cnt*=c; printf("%.12Lf",(long double)1.0*Ans/(Cnt*1.0)); puts("");
	return 0;
}

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

int main() {
  int nc;
  cin >> nc;
  for(int ic = 0; ic < nc; ++ic) {
    int n, k;
    cin >> n >> k;
    int first, last, lastnum;
    cin >> first;
    lastnum = first;
    vector<int> ds;
    for(int i = 1; i < n; ++i) {
      int num;
      cin >> num;
      ds.push_back(num - lastnum);
      lastnum = num;
    }
    int ans;
    last = lastnum;
    if(n > k) {
      sort(begin(ds), end(ds));
      ans = last - first;
      for(int i = n - k; i < ds.size(); ++i) {
        ans -= ds[i];
      }
    } else {
      ans = 0;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1864
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#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>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<int ,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define REP(i,n) for (int i = 1; i <= n; i++)

// mp::cpp_int



int solve( ){
    
int a,b,c;
cin>>a>>b>>c;
cout<<(a*b*c)/(2*max(a,max(b,c)));



return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
   
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  int ans = a - b * 2;
  if(ans > 0) OUT(ans);
  else OUT(0);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()-1) {
		if (s[i] != s[i + 1]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int N, K, x=1, plus=1, times=1, min;
	scanf("%d %d", &N, &K);
	
	for(int a=1; a<=N; a++){
		x=1; plus=1; times=1;
		
		while(times<=a){
			x*=2;
			times++;
		}
		
		while(plus<=N-a){
			x+=K;
			plus++;
		}
		
		if(a==1){
			min=x;
		}
		else if(x<min){
			min=x;
		}		
	
	}
	
		printf("%d\n", min);

	
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        List<Integer> heights = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            heights.add(sc.nextInt());
        }
        heights.sort((o1, o2) -> o2 - o1);
        System.out.println(heights.get(0));
        System.out.println(heights.get(1));
        System.out.println(heights.get(2));
    }
}


Measured memory_bytes: 32360
#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

#include <ccomplex>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll N = 1e6 + 100;
const ll M = 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void da()
{
	cout << "Yes";
	exit(0);
}

void $main()
{
	ll n, m; cin >> n >> m;

	for (ll i = 0; i <= n; ++i)
		if (i * 2 + (n - i) * 4 == m)
			da();

	cout << "No";
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}

Measured memory_bytes: 3652
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        mut x: isize,
        k: isize,
        d: isize,
    }
    x = x.abs();
    let l = x / d;
    let result = if l > k {
        x - d * k
    } else {
        if (k - l) % 2 == 0 {
            x - d * l
        } else {
            ((x - d * l) - d).abs()
        }
    };
    println!("{}", result);
}


Measured memory_bytes: 2176
//
//  main.cpp
//  ABC122
//
//  Created by hiroaki on 2019/03/24.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string b;
    cin>>b;
    string s;
    long l=b.size();
    for (int i=0; i<l; i++) {
        if (b[i]=='A') {
            s.push_back('T');
        }
        else if (b[i]=='C') {
            s.push_back('G');
        }
        else if (b[i]=='G') {
            s.push_back('C');
        }
        else if (b[i]=='T') {
            s.push_back('A');
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, d;

	cin>>n;

	if(n==0){
		cout<<0<<endl;
		return 0;
	}

	vll a, b;

	rep(i, 40){
		ll temp=pow(-2.0, (double)i);
		if(temp>0){
			a.push_back(temp);
		} else{
			b.push_back(temp);
		}
	}
	sort(all(a)); sort(all(b));
	reverse(all(b));

	vll asum(a.size()+1, 0), bsum(b.size()+1, 0);

	rep(i, a.size()){
		asum[i+1]=asum[i]+a[i];
		bsum[i+1]=bsum[i]+b[i];
		//cout<<bsum[i]<<endl;
	}

	rep(i, bsum.size()){
		bsum[i]*=(-1);
	}

	vll::iterator itr;
	if(n>0){
		itr=lower_bound(all(asum), n);
		d=(ll)(itr-asum.begin())*2-1;
	}else{
		itr=lower_bound(all(bsum), -n);
		d=(ll)(itr-bsum.begin())*2;
	}

	n-=pow(-2.0, (double)(d-1));

	vb ans(d, false);

	ans[d-1]=true;

	while(n!=0){
		if(n>0){
			itr=lower_bound(all(asum), n);
			d=(ll)(itr-asum.begin())*2-1;
		} else{
			itr=lower_bound(all(bsum), -n);
			d=(ll)(itr-bsum.begin())*2;
		}
		n-=pow(-2.0, (double)(d-1));
		//cout<<n<<","<<d<<endl;
		ans[d-1]=true;
	}
	reprev(i, ans.size()) cout<<ans[i];
	cout<<endl;
}


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

#define min(a,b) (((a)<(b))?(a):(b))

int main(void)
{
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if (A < 6)
        puts("0");
    else if (A < 13)
        printf("%d\n",B/2);
    else
        printf("%d\n",B);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ll INF = 9000000000000000;
    int n;
    cin >> n;
    ll a[n];
    rep(i,n)cin >> a[i];

    ll dp[n+1][n];
    ll cost[n+1][n];
    rep(i,n+1){
        rep(j,n){
            dp[i][j] = 0;
            cost[i][j] = 0;
        }
    }

    rep(i,n){
        dp[1][i] = a[i];
    }
    srep(i,2,n+1){
        rep(j,n){
            if(n<j+i)break;
            ll mi = INF;
            rep(k,i-1){
                ll tmp = dp[1+k][j] + dp[i-1-k][j+1+k];
                ll tmpcost = cost[1+k][j] + cost[i-1-k][j+1+k] + tmp;
                mi = min(mi,tmpcost);
            }
            dp[i][j] = dp[1][j] + dp[i-1][j+1];
            cost[i][j] = mi;
        }
    }
    /*
    rep(i,n+1){
        rep(j,n){
            cout << cost[i][j] << ' ';
        }
        cout << endl;
    }
    */

    cout << cost[n][0];
    return 0;
}
 
 


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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << "Line " << __LINE__ <<": " << x << nl
#define nl "\n"
#define sp " "

#define fastio() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)

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

const int N = 1e5+5;

int tc = 1;


int main(){

   	//file();

    fastio();

    //cin >> tc;

    while(tc--){

    	int x, y;

    	cin >> x >> y;

    	int ty = (y-2*x)/2;
    	int tx = (4*x-y)/2;

    	if(tx+ty == x and tx >= 0 and ty >= 0)
    		cout << "Yes" << nl;
    	else
    		cout << "No" << nl;
    	
    	
    }

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

#define N 999999

int set[999999];
int an[30];

int main(void)
{
	int i, j, num;
	int ans = 0;
	
	set[0] = 1;
	
	for (i = 2; i < N; i++){
		if (set[i - 1] == 0){
			for (j = 2; i * j <= N; j++){
				set[(i * j) - 1] = 1;
			}
		}
	}
	
	for (i = 0; i < 30 && scanf("%d", &num) != EOF; i++){
		for (j = 0; j < num; j++){
			if (set[j] == 0){
				ans += 1;
			}
		}
		an[i] = ans;
		ans = 0;
	}
	
	for (j = 0; j < i; j++){
		printf("%d\n", an[j]);
	}
	
	return (0);
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    cnt = 0
    first_done = False
    cont = True
    for c in s:
        if c == 'R' and cont:
            cnt += 1
            first_done = True
        else:
            if not first_done:
                continue
            else:
                cont = False
    print(cnt)


main()



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

# X以下のnの約数の個数
def g(n,X):
    m=X//n
    s=(m*(m+1)//2)*n
    return s

ans=0
for i in range(1,N+1):
    ans += g(i,N)
    # print(g(i,N))
print(ans)

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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int n;
    cin >> n;
    vi a(n);
    rep(i, n - 1) {
        int x;
        cin >> x;
        a[x - 1]++;
    }

    rep(i, n) cout << a[i] << '\n';

    return 0;
}


Measured memory_bytes: 3948
/**
 * @File   : atcoder.cpp
 * @Author : pasnger
 * @Date   : 30/8/2020, 4:52:41 pm
 */

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

#define INF 8e18
#define int long long
#define f(i, a, b) for (int i = (a); i < (b); (i)++)
#define fe(i, a, b) for (int i = (a); i <= (b); (i)++)
#define rf(i, a, b) for (int i = (a); i > (b); (i)--)
#define rfe(i, a, b) for (int i = (a); i >= (b); (i)--)
#define ff(ele, cont) for (auto(ele) : (cont))
#define pb push_back

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef set<int> si;
typedef multiset<int> msi;

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG(){
  cerr << "]\n";
}
template <typename T, typename... Args>
void DBG(T first, Args... args){
  cerr << first;
  if (sizeof...(args))
    cerr << ", ";
  DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////

void solve(){
  int n;
  cin>>n;
  int cnt = 0;
  f(i, 0, n){
    int a, b;
    cin>>a>>b;
    if(a==b) cnt++;
    else cnt = 0;
    if(cnt ==3){
      cout<<"Yes\n";
      return;
    }
  }
  cout<<"No\n";
}

int32_t main() {
  #ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    freopen("in.txt", "r", stdin);
  // freopen("in2.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    for (int tt = 1; tt <= t; tt++)
    {
      //cout << "Case #"<<tt<<": ";
      solve();
    }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> " << (double)(clock() - tStart) / CLOCKS_PER_SEC << " sec\n";
  #endif
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << A[0] << B[0] << C[0] << endl;;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 405
#define INF 5000
#define MAXN 100001
#define MAXM 1001
#define MAXP 1000001
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
ll X;
int main(){
    ll pos = 0;
    cin >> X;
    double t = (-1 + sqrt(1 + 8 * X)) / 2;
    ll ans;
    if(t > floor(t)) ans = floor(t) + 1;
    else ans = floor(t);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define   FOR(i,n) for(int i=0;i<n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {

   char a[3],b[3],c[3],out[4];

       cin>>a>>b>>c;
   out[0]=a[0];
   out[1]=b[1];
   out[2]=c[2] ;
    cout<<out[0]<<out[1]<<out[2];
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
char s[N];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int pd=0;
	if(s[1]!='A'){puts("WA");return 0;}
	for(int i=3;i<=len-1;i++){
		if(s[i]<'a'||s[i]>'z'){
			if(s[i]=='C'){
				if(!pd)pd=1;
				else return puts("WA"),0;
			}else {
				return puts("WA"),0;
			}
		}
	}
	if(!pd)return puts("WA"),0;
	if(s[len]>'z'||s[len]<'a')return puts("WA"),0;
	if(s[2]>'z'||s[2]<'a')return puts("WA"),0;
	printf("AC\n");
	return 0;
}

Measured memory_bytes: 128
def main():
    s = list(input())
    k = int(input())

    ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
    D = dict(zip(ascii_lowercase,list(range(0,len(ascii_lowercase)))))

    n = len(ascii_lowercase)

    for i in range(0,len(s)):
        j = D[s[i]]
        if j != 0 and 26 -j <= k:
            k -= (26-j)
            s[i] ='a'

    if k >0:
        j = (D[s[-1]] + k%26)%26
        s[-1] = ascii_lowercase[j]
    print(''.join(s))

main()

Measured memory_bytes: 10028
def read_input():
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    return [c1, c2, c3]

# i列目を取り出す
def get_v(c, i):
    result = [c[j][i] for j in range(3)]
    return result

# i行目を取り出す
def get_h(c, i):
    result = [c[i][j] for j in range(3)]
    return result

# aとbの要素差がすべて等しいかチェック
def check_diff(a, b):
    diff = [i - j for i,j in zip(a, b)]

    d = diff[0]
    for e in diff[1:]:
        if d != e:
            return False
    return True


def submit():
    c = read_input()

    checkee = [(0, 1), (1, 2), (0, 2)]
    result = []
    for check in checkee:
        result.append(check_diff(get_v(c, check[0]), get_v(c, check[1])))
        result.append(check_diff(get_h(c, check[0]), get_h(c, check[1])))

    if all(result):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    submit()


Measured memory_bytes: 38512
// Boxes and Candies
#include <iostream>
using namespace std;
typedef long long LL;

LL n;
LL a[100000],x,ans;

int main(){
    cin>>n>>x;
    for(LL i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>x){
            ans+=(a[i]-x);
            a[i]=x;
        }
    }
    for(LL i=1;i<n;i++){
        if(a[i-1]+a[i]>x){
            ans+=(a[i-1]+a[i]-x);
            a[i]=x-a[i-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

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

    int n,a,b;
    cin >> n >> a >> b;
    string s; cin >> s;
    int win = 0, foreign = 1;
    for(int i=0;i<n;i++){
        if(s[i]=='a' && win<a+b){
            cout << "Yes" << endl;
            win++;
        }
        else if(s[i]=='b' && win<a+b && foreign<=b){
            cout << "Yes" << endl;
            win++;
            foreign++;
        }
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 848
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL a[101][101];
LL b[101][101];
LL c[101][101];

int main()
{
	int n, m, l; cin >> n >> m >> l;

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

	for (int i = 0; i<m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					c[i][j] += a[i][k] * b[k][j];
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				cout << c[i][j];

				if (j == l - 1) {
					cout << endl;
				}
				else {
					cout << " ";
				}
			}
		}
	return 0;
}


Measured memory_bytes: 3328