akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int convertRandL(char c);

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

    std::vector<int>  result(S.size());

    char child;
    int place;
    int even;
    int odd;

    //R
    //一文字ずつ検証
    for (int i = 0; i < S.size(); ++i) {
        //移動させていく
        child = S[i];
        if ( child != 'R') continue;
        place = i;
        int moveCount=0;
        odd = 0;
        even = 0;
        while(true){

            if (moveCount % 2 == 0 ){
                even++;
            } else {
                odd++;
            }

            //移動先が今と違うか
            if (child != S[place+convertRandL(child)]) {

                result[place] += even;
                result[place+convertRandL(child)] += odd;
                i += moveCount;
                break;
            }
            //移動           
            place += convertRandL(child);
            moveCount++;
        }
    }

    //L
    //一文字ずつ検証
    for (int i = S.size()-1; i >= 0; --i) {
        //移動させていく
        child = S[i];
        if ( child != 'L') continue;
        place = i;
        int moveCount=0;
        odd = 0;
        even = 0;
        while(true){

            if (moveCount % 2 == 0 ){
                even++;
            } else {
                odd++;
            }

            //移動先が今と違うか
            if (child != S[place+convertRandL(child)]) {

                result[place] += even;
                result[place+convertRandL(child)] += odd;
                i -= moveCount;
                break;
            }
            //移動           
            place += convertRandL(child);
            moveCount++;
        }
    }


    for (int i = 0; i < S.size(); ++i){
         cout << result[i] << ' ';
    }
    
    return 0;
}

int convertRandL(char c) {

    if (c == 'R'){
        return 1;
    } else {
        return -1;
    }
}


Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		if(N % 2 ==0){
		// 出力
			System.out.println(N);
		} else {
			System.out.println(N * 2);
		}
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

class Main{
    public static void main(String[] args){
         Scanner stdIn = new Scanner(System.in);
         int a = stdIn.nextInt();
         int b = stdIn.nextInt();
         int c = stdIn.nextInt();
         
         if(a<=b){
             if(b<=c) System.out.println(a+ " " +b+ " " +c);
             else if(a<=c) System.out.println(a+ " " +c+ " " +b);
             else System.out.println(c+ " " +a+ " " +b);
         }else{ //b<a
             if(c<=b) System.out.println(c+ " " +b+ " " +a);
             else if(c<=a) System.out.println(b+ " " +c+ " " +a);
             else System.out.println(b+ " " +a+ " " +c);
         }
    }
}

Measured memory_bytes: 26040
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cassert>
#include <deque>
#include <map>
#include <queue>
#include <climits>
#include <set>
#include <stack>

using namespace std;

#define ll long long
#define MAX 100000
#define MAX1 10000
#define MAX2 100000
#define inf 1000000000
#define eps 1e-12
#define MOD 1000000007

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n, m, k, i, j, a, b, c, ans = 0;
    string s[6];
    cin >> n >> m >> k;
    for (i = 0; i < n; ++i) {
        cin >> s[i];
    }
    bool vis[6][6];
    for (i = 0; i < (1 << n); ++i) {
        for (j = 0; j < (1 << m); ++j) {
            c = 0;
            for (a = 0; a < n; ++a) {
                for (b = 0; b < m; ++b) {
                    vis[a][b] = s[a][b] == '#';
                    if (((1 << a) & i) || ((1 << b) & j)) {
                        vis[a][b] = false;
                    }
                    c += vis[a][b];
                }
            }
            ans += c == k;
        }
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> as(N);
    std::vector<int> bs(N);
    std::vector<int> cs(N);
    for (int i = 0; i < N; i++) {
        std::cin >> as.at(i) >> bs.at(i) >> cs.at(i);
    }
    std::vector<std::array<int, 3>> costs(N);
    costs.at(0).at(0) = as.at(0);
    costs.at(0).at(1) = bs.at(0);
    costs.at(0).at(2) = cs.at(0);
    for (int i = 1; i < N; i++) {
        costs.at(i).at(0) = std::max<int>(costs.at(i - 1).at(1), costs.at(i - 1).at(2)) + as.at(i);
        costs.at(i).at(1) = std::max<int>(costs.at(i - 1).at(2), costs.at(i - 1).at(0)) + bs.at(i);
        costs.at(i).at(2) = std::max<int>(costs.at(i - 1).at(0), costs.at(i - 1).at(1)) + cs.at(i);
    }
    std::cout << *std::max_element(costs.at(N - 1).begin(), costs.at(N - 1).end()) << std::endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  
  if(S<0){
    printf("error\n");
  }else if(S>86400){
    printf("error\n");
  }
  h=S/3600;
  m=(S%3600)/60;
  s=(S%3600)%60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++){
        cin>>hoge.at(i);
    }
    vector<int> fuga=hoge;
    sort(hoge.begin(),hoge.end());
    int left=hoge.at(n/2-1);
    int right=hoge.at(n/2);
    
    for(int i=0;i<n;i++){
        if(fuga.at(i)<=left) cout<<right<<endl;
        else cout<<left<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3712
import sys
readline = sys.stdin.readline

# 残った数の中で最大の数とペアになれる（可能性のある）数は一意に決まる。
# 15に15以下の数を足して作れる2べきは16だけ、32は作れない。
# 8 * 2 < 15 * 2 < 16 * 2だから。
# 大きいほうから見ていって、ペアになれる数を特定出来たらペアにする。
# 以下を別々で持つ
# ・大きい順の管理
# ・探している数へのO(1)での到達と、残数管理（同じ数が複数回出てくる可能性があるため）

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

from collections import defaultdict

balls_count = defaultdict(int) # 個数の管理

import heapq as hq
balls_q = [] # ボールを大きい順に入れていく

for a in A:
  balls_count[a] += 1
  hq.heappush(balls_q, -a)

def get_pair_num(x): # xとペアになれる数を探す
  tar = 2
  while tar < x:
    tar *= 2
  if tar == x:
    return tar
  return tar - x

ans = 0
while balls_q:
  ball = -(hq.heappop(balls_q))
  if balls_count[ball] == 0: # すでに使用済みのボールである
    continue
  # 取り出した時点で、このあとペアにするか破棄するかのどちらかである。
  # 同じボールを取り出すことのないよう、この時点で1引いておく
  balls_count[ball] -= 1
  pair = get_pair_num(ball)
  if balls_count[pair] > 0:
    ans += 1
    balls_count[pair] -= 1
  # pushしないからheapqでなくてよかったな・・・

print(ans)

Measured memory_bytes: 56488
#include<stdio.h>
#include<stdlib.h>
 
typedef struct vector2 {
  int x, y;
}vector2;
 
int main(void) {
  int h, w, m;
  scanf("%d%d%d", &h, &w, &m);
  int row[h+1], column[w+1];
  vector2 v[m+1];
  for(int i = 0;i < h;i++) {
    row[i] = 0;
  }
  for(int i = 0;i < w;i++) {
    column[i] = 0;
  }
  int maxr = 0, maxc = 0;
  for(int i = 0;i < m;i++) {
    int x, y;
    scanf("%d%d", &y, &x);
    x--, y--;
    row[y]++, column[x]++;
    v[i] = (vector2){ x, y };
    if(maxr < row[y]) maxr = row[y];
    if(maxc < column[x]) maxc = column[x];
  }
  int rc = 0, cc = 0;
  for(int i = 0;i < h;i++) {
    if(maxr == row[i]) {
      rc++;
    }
  }
  for(int i = 0;i < w;i++) {
    if(maxc == column[i]) {
      cc++;
    }
  }
 
  int count = rc * cc;
  for(int i = 0;i < m;i++) {
    int x = v[i].x, y = v[i].y;
    if(row[y] == maxr && column[x] == maxc) {
      count--;
    }
 
  }
 
  if(count == 0) {
    printf("%d\n", maxr + maxc - 1);
  } else {
    printf("%d\n", maxr + maxc);
  }
  return 0;
}

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

int main(){
  int a, b;
  
  cin >> a >> b;
  
  if(a>=10 || b>=10){
    cout << -1 << endl;
  }
  else if(a<0 || b<0){
    cout << -1 <<endl;
  }
  else{
    cout << a*b << endl;
  }
}

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

using namespace std;
using ll = long long;

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

	int ans = 0;
	if (N % 1000 > 0) {
		ans = 1000 - (N % 1000);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3616
def main():
    from collections import Counter
    from heapq import heapify,heappop,heappush
    H,W = map(int,input().split())
    A = ''
    for i in range(H):
        A += input()
    A = list(A)
    num_chars = list(map(lambda x: -x, Counter(A).values()))
    heapify(num_chars)
    # H == 1 or W == 1

    for i in range((H//2)*(W//2)):
        num = heappop(num_chars)
        
        if -4 < num:
            print('No')
            return
        else:
            heappush(num_chars,num+4)

    if H & 1:
        for i in range(W//2):
            num = heappop(num_chars)
            if -2 < num:
                print('No')
                return
            else:
                heappush(num_chars,num+2)

    if W & 1:
        for i in range(H//2):
            num = heappop(num_chars)
            if -2 < num:
                print('No')
                return
            else:
                heappush(num_chars,num+2)

    print('Yes')
    return
    






main()

Measured memory_bytes: 75076
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  char c;
  cin >> c;
  cout << (char)(c + 1);
}
#endif


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N, M, X; std::cin >> N >> M >> X;
    std::vector<int> C(N);
    std::vector<std::vector<int>> A(N, std::vector<int>(M));
    for(int i(0); i < N; ++i){
        std::cin >> C[i];
        for(int j(0); j < M; ++j){
            std::cin >> A[i][j];
        }
    }
    int ans(INF), cst(0);
    for(int i(0), i_len(1 << N); i < i_len; ++i){
        cst = 0;
        std::vector<int> undstnd(M, 0);
        for(int ii(0); ii < N; ++ii){
            if((i >> ii) & 1){
                for(int j(0); j < M; ++j){
                    undstnd[j] += A[ii][j];
                }
                cst += C[ii];
            }
        }
        bool okay(true);
        for(int j(0); j < M; ++j){
            if(undstnd[j] < X){
                okay = false;
                break;
            }
        }
        if(okay) chmin(ans, cst);
    }
    std::cout << ((ans != INF) ? ans : -1) << std::endl;
    return 0;
}


Measured memory_bytes: 3636
#Some sums
N,A,B = map(int,input().split())
S = 0
for i in range(N+1):
    L = list(str(i))
    S1 = 0
    for j in range(len(L)):
        S1 += int(L[j])
    if A <= S1 <= B:
        S += i
print(S)

Measured memory_bytes: 2940
N=int(input())
a=[[0 for j in range(N-1)] for i in range(N)]
for i in range(N):
  line=list(map(int,input().split()))
  for j in range(N-1):
    a[i][j]=line[j]-1
  a[i]=a[i][::-1]
    
q=[]

#seen=[[False for j in range(N)] for i in range(N)]

# 選手nが試合できるならqueに入れる
def check(i):
  if len(a[i])==0:
    return False
  j=a[i][-1]
  if a[j][-1]==i:
    q.append([i,j])
  
for i in range(N):
  check(i)
  
from collections import defaultdict

day=0
while q:
  day+=1
 # q=sorted(q)
  prevQ=q.copy()
  q=[]
  matched=defaultdict(list)
  for p in prevQ:
    i=p[0]
    j=p[1]
    if i>j:
      i,j=j,i
    if matched[i]:
      continue
    a[i].pop()
    a[j].pop()
    check(i)
    check(j)
    matched[i].append(j)
    
for i in range(N):
  if len(a[i])!=0:
    print(-1)
    break
else:
  print(day)


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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;



int main() {
const ll INF = 1001001001;
const ld PI = 3.14159265358979323846;
int N,count=0;
string S;
cin>>N>>S;
rep(i,N-2){
    if(S.substr(i,3)=="ABC"){
        count++;
    }

}
cout<<count<<endl;
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
    int n, x, arr[110], i, j,w,temp, sum=0,e;
    scanf("%d %d", &n, &x);
    for(i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
        sum+=arr[i];
    }
    if(sum==x)
        printf("%d\n", n);
    else
    {
        w = x -sum;
        for(i=0; i<n-1; i++)
        {
            for(j=0; j<n-i-1; j++)
            {
                if(arr[j]>arr[j+1])
                {
                    temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }
        e = w/arr[0];
        printf("%d\n", n+e);
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
ans = 0

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

for i in range(n):
    ans += b[i]*(b[i] - 1)//2

for i in range(n):
    print(ans - b[a[i] - 1] + 1)

Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
typedef long double ld;
typedef vector<vector<int> > matrix;
typedef vector<int> arr;
typedef vector<string> vs;
typedef vector<pair<int,int> > pv;
#define test() int t;cin>>t;while(t--)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};
//=================================================================//


#undef int
int main(){
#define int long long 
    fast;
    int n;
    cin>>n;
    int arr[n];
    FOR(i,0,n-1) cin>>arr[i];
    int cnt = 0;
    ROF(i,n-1,1) {
        if(arr[i]>=arr[i-1]) {
            cnt++;
            continue;
        } else if(arr[i-1]-arr[i]==1) {
            arr[i-1]--;
            cnt++;
        } else cout<<"No", exit(0);
    }
    cout<<"Yes";   
    return 0;
}

Measured memory_bytes: 1024
s = str(input())
alp = list('abcdefghijklmnopqrstuvwxyz')
lst = []

for i in range(len(s)):
    if s[i] in alp:
        alp.remove(s[i])

if alp==[]:
    print('None')
else:
    alp.sort()
    print(alp[0])

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-
import sys
from math import *
if __name__ =="__main__":
    str_in = input()
    num = [int(n) for n in str_in.split()]
    A,B,C,D=num
    LEFT=A+B
    RIGHT=C+D
    if LEFT>RIGHT:
        print("Left")
    elif RIGHT>LEFT:
        print("Right")
    else:
        print("Balanced")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

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

  if (x == 3 || x == 5 || x == 7) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
dat = {}
n = gets.to_i
n.times do
  tmp = gets.chomp
  if dat[tmp] == nil
    dat[tmp] = 1
  else
    dat[tmp] += 1
  end
end
m = gets.to_i
m.times do
  tmp = gets.chomp
  if dat[tmp] == nil
    dat[tmp] = -1
  else
    dat[tmp] -= 1
  end
end
print [dat.max {|x, y| x[1] <=> y[1]}[1], 0].max


Measured memory_bytes: 1788
#include <stdio.h>

int main(){
    int a[2],n,x,z = 0,an = 0;
    scanf("%d %d",&n,&a[0]);

    for(x=1;x<n;x++){
        scanf("%d",&a[1]);
        if(a[0] == a[1] && z == 0){
            an++;
            z++;
            a[0] = a[1];
            continue;
        }
        a[0] = a[1];
        z = 0;
    }

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


}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

ll n, m, q;
ll a[50], b[50], c[50], d[50];
ll x[11];
ll ans = 0;

void dfs( ll r, ll num )
{
	if ( r > n ) {
		ll tmp = 0;
		rep( i, q ) {
			if ( x[b[i]] - x[a[i]] == c[i] ) {
				tmp += d[i];
			}
		}
		ans = max(ans, tmp);
		return;
	}

	for ( int i = num; i <= m; i++ ) {
		x[r] = i;
		dfs(r + 1, i);
	}
}


int main( void )
{
	cin >> n >> m >> q;

	rep( i, q ) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	dfs( 1, 1 );

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
import numpy as np

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append(e)
        b, e = b + 1, 0
    if n > 1:
        fct.append(1)
    return np.asarray(fct)

last_val = int(raw_input().replace("\n", ""))
count = 1 if last_val >= 105 else 0
for val in xrange(107, last_val+1, 2):
    ret = factorize(val)
    yaku_num = np.prod(ret + 1)
    if yaku_num == 8:
        count += 1

print count

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  uint64_t ans = 0;
  int l = 0, r = 1;
  int status = a[0];
  while (l < n) {
    while (r < n && (status & a[r]) == 0) {
      status |= a[r++];
    }
    status ^= a[l++];
    if (l == r)
      status = 0, r = l;
    ans += r - l + 1;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 1024
a,b,c = input().split()
d,e,f = input().split()
g,h,i = input().split()
N = int(input())

A = []
B = [a,b,c,d,e,f,g,h,i]
F =[]
q = 0
E = True

for X in range(N):
    A.append(input())
    
for Y in range(N):
    V = A[q] in B
    if V == E:
        F.append(B.index(A[q]))
        q += 1
    else:
        q += 1
W = sorted(F)
if B.index(a) in W and B.index(b) in W and B.index(c) in W:
    print('Yes')
elif B.index(d) in W and B.index(e) in W and B.index(f) in W:
    print('Yes')
elif B.index(g) in W and B.index(h) in W and B.index(i) in W:
    print('Yes')
elif B.index(a) in W and B.index(d) in W and B.index(g) in W:
    print('Yes')
elif B.index(b) in W and B.index(e) in W and B.index(h) in W:
    print('Yes')
elif B.index(c) in W and B.index(f) in W and B.index(i) in W:
    print('Yes')
elif B.index(a) in W and B.index(e) in W and B.index(i) in W:
    print('Yes')
elif B.index(c) in W and B.index(e) in W and B.index(g) in W:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');
            int[] v = new int[n];
            for (int i=0; i<n; i++) v[i] = int.Parse(s1[i]);
            string[] s2 = Console.ReadLine().Split(' ');
            int[] c = new int[n];
            int ans = 0;
            for (int i=0; i<n; i++)
            {
                c[i] = int.Parse(s2[i]);
                int point = v[i] - c[i];
                if (point > 0) ans += point;
            }
            Console.WriteLine(ans);

            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13268
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int h = cin.Int();
			int n = cin.Int();
			long[] a = cin.ArrayLong(n);

			long sum = a.Sum();
			if (sum >= h) {
				Console.WriteLine("Yes");
			} else {
				Console.WriteLine("No");
			}
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 17376
#!/usr/bin/perl

# 引数取り込み
my $a = <>;
my $b = substr( $a, 0, 1 );
my $c = substr( $a, 1, 1 );
my $d = substr( $a, 2, 1 );

# 処理開始
if ( $b == 7 or $c == 7 or $d == 7 ) {
    print "Yes";
}
else {
    print "No";
}

1;

Measured memory_bytes: 4716
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld a,b,c;
    cin>>a>>b>>c;
    ld d=2.000*sqrt(a*b);
    if(a+b+d<c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


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

struct Unir {
    struct Unir * ant;
    int encontrado;
    char valor;
    bool selecionado;
} typedef tUnir;

void printUnir(tUnir * Unir) {
    if (Unir->ant != NULL) {
        printUnir(Unir->ant);
    }

    if (Unir->selecionado) {
        printf("%c", Unir->valor);
    }
}

void printLSB(char * s, char * t, int n, int m) {
    int i, j;
    tUnir iguais[n][m];

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            iguais[i][j].encontrado = 0;
            iguais[i][j].ant = NULL;
            iguais[i][j].valor = '\0';
            iguais[i][j].selecionado = false;
        }
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            iguais[i][j].valor = s[i];

            if (iguais[i][j].valor == t[j]) {
                iguais[i][j].encontrado = 1;
                iguais[i][j].selecionado = true;
            } else {
                iguais[i][j].encontrado = 0;
                iguais[i][j].selecionado = false;
            }

            if (i > 0 && j > 0) {
                iguais[i][j].ant = &iguais[i - 1][j - 1];
                iguais[i][j].encontrado += iguais[i][j].ant->encontrado;
            }

            if (i > 0) {
                if (iguais[i - 1][j].encontrado > iguais[i][j].encontrado) {
                    iguais[i][j].ant = &iguais[i - 1][j];
                    iguais[i][j].encontrado = iguais[i - 1][j].encontrado;
                    iguais[i][j].selecionado = false;
                }
            }

            if (j > 0) {
                if (iguais[i][j - 1].encontrado > iguais[i][j].encontrado) {
                    iguais[i][j].ant = &iguais[i][j - 1];
                    iguais[i][j].encontrado = iguais[i][j - 1].encontrado;
                    iguais[i][j].selecionado = false;
                }
            }
        }
    }
    printUnir(&iguais[n - 1][m - 1]);
    printf("\n");
}

int main() {
    char s[3000], t[3000];

    scanf("%s", s);
    scanf("%s", t);

    int n = strlen(s);
    int m = strlen(t);

    if (n < m) {
        printLSB(s, t, n, m);
    } else {
        printLSB(t, s, m, n);
    }
	return 0;
}

Measured memory_bytes: 140928
def IsPalindrome(S):
	l = len(S)
	for i in range(l >> 1):
		if S[i] != S[-(i + 1)]:
			return False
	return True

S = input()

m = len(S) >> 1
L, R = [""] * (m), [""] * (m)
for i in range(m):
	L[i] = S[i]
	R[i] = S[i + m + 1]

if not (IsPalindrome(L) and IsPalindrome(S) and IsPalindrome(R)):
	print("No")
else:
	print("Yes")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int r,D,x;
    cin >> r >> D >> x;
    for(int i=0; i<10; i++){
        cout << r*x-D << endl;
        x=r*x-D;
    }

}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

visited = [0 for _ in range(n)]
i = 0
while visited[i] == 0:
    visited[i] = 1
    i = a[i]

cnt = 0
goal = i
i = goal
while not (i == goal and cnt > 0):
    i = a[i]
    cnt += 1

i = 0

if True:
    while i != goal and k > 0:
        k -= 1
        i = a[i]
    if k != 0:

        k = k % cnt
        i = goal

        for cnt in range(k):
            i = a[i]

print(i+1)

Measured memory_bytes: 32308
x, y = map(int, input().split())

if (0 <= x <= y) or (x <= y <= 0):
    print(y - x)
elif (0 <= y <= x) or (y <= x <= 0):
    if x == 0 or y == 0:
        print(x - y + 1)
    else:
        print(x - y + 2)
else:
    absX, absY = abs(x), abs(y)
    if absX <= absY:
        print(absY - absX + 1)
    else:
        print(absX - absY + 1)


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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll N; cin >> N;
	ll T[100];
	ll sum_t = 0;
	rep(i, 0, N) {
		cin >> T[i];
		sum_t += T[i];
	}
	ll M; cin >> M;
	ll p[100];
	ll x[100];
	rep(i, 0, M) {
		cin >> p[i] >> x[i];
	}
	rep(i, 0, M) {
		cout << sum_t - T[p[i] - 1] + x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 1000000007;
using ld = long double;
const ld pi = atan2l(0, -1);

ld T[3010], ct[3010], st[3010], ctr[3010], str[3010];
complex<ld> C[3010];

int main() {
	ll N;
	cin >> N;
	ld L;
	cin >> L;
	
	for (int i = 0;i < N;i++) {
		cin >> T[i];
		T[i] *= 2 * pi;
		T[i] /= L;
		ct[i] = cosl(T[i] / 2);
		st[i] = sinl(T[i] / 2);
		C[i] = { cosl(T[i]),sinl(T[i]) };
	}

	ctr[0] = 0, str[0] = 0;
	for (int i = 0;i < N;i++) {
		ctr[i + 1] = ctr[i] + ct[i];
		str[i + 1] = str[i] + st[i];
	}

	complex<ld> Z, A, X = { 0,0 };
	ld ssm, csm, ang, r, cp, sp;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N - 1;j++) {
			//j+1からNまで
			ang = (T[i] + T[j]) / 2;
			Z = { cosl(ang),sinl(ang) };
			r = abs(Z - C[i]);
			cp = cosl(ang / 2);
			sp = sinl(ang / 2);
			ssm = str[N] - str[j + 1];
			csm = ctr[N] - ctr[j + 1];
			A = { (ld)(N - j - 1) - r * cp * ssm + r * sp * csm,r * cp * csm + r * sp * ssm };
			X += A * Z;
		}
	}
	ll alp = N * (N - 1) * (N - 2) / 6;
	X /= alp;
	printf("%.12Lf ", X.real());
	printf("%.12Lf\n", X.imag());
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    for(int i=1;i<n;i++){
        int v = a[i];
        int j= i-1;
        while(j>=0 && a[j]>v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(int k=0;k<n-1;k++){
            cout << a[k] << " " ;
        }
        cout << a[n-1] << endl;
    }
}

Measured memory_bytes: 1160
n = int(input())
*A, = map(int, input().split())

def partition(A,p,r):
	x = A[r]
	i = p
	for j in range(p,r):
		if A[j] <= x:
			A[i], A[j] = A[j], A[i]
			i = i+1
	A[i], A[r] = A[r], A[i]

	return i

j = partition(A,0,n-1)
print(*(str(x) if i != j else "[%d]" % x for i, x in enumerate(A)))



Measured memory_bytes: 16388
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int h = scanner.nextInt();
		int w = scanner.nextInt();
		for (int  i  = 0 ; i < h ; i++) {
			String c = scanner.next();
			System.out.println(c);
			System.out.println(c);
		}
	}
} 

Measured memory_bytes: 22612
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    string s1,s2;
    cin>>s1>>s2;
    x=0;
    Ff(i,0,s1.size())
    {
      if(s1[i]==s2[i])
      x++;
    }
    cout<<x;
    
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int>H(N);
    for (int i = 0; i < N; ++i) {
      cin >> H[i];
    }
    int ans = 0;
    int t = 0;
    for (int i = 0; i < N-1; ++i) {
        if(H[i] >= H[i+1]){
            t++;
            ans = max(ans, t);
        } else{
            t = 0;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int total = 0;
		int ans = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					total = 500*i + 100*j + 50*k;
					if(total == x) {
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(T x, T y){
        cout << x << "," << y << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

std::vector<std::vector<long long> > comb(int n, int r) {
  std::vector<std::vector<long long> > v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
  
    //--------------//

    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    ll r = 0;
    ll l = 0;
    COMinit();

    rep(i, n-k+1){
        l += a[i] * COM(n-1-i, k-1) % MOD;
    }
    reverse(ALL(a));
    rep(i, n-k+1){
        r += a[i] * COM(n-1-i, k-1) % MOD;
    }
    //print(l, r);
    ll ans = r - l;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define range(i, a, b, s) for (int i = (a); i < (b); i += (s))
#define down(i, a, b, s) for (int i = (a); (b) < i; i -= (s))

string s;

int main(int argc, char const *argv[]) {
  // freopen("B.txt", "r", stdin);

  while (cin >> s) {
    int cnt = 15;
    int len = s.length();
    range(i, 0, len, 1) {
      if (s[i] == 'x') cnt -= 1;
    }
    if (cnt >= 8)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
int h,w;
int sx,sy,gx,gy;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
char m[50][50];
int hm[50][50];
int ok[50][50];
void dfs(int x,int y){
    if(x<0||x>=w||y<0||y>=h||m[y][x]=='#')return;
    if(ok[y][x]==1)return;
    ok[y][x]=1;
    dfs(x+1,y);
    dfs(x-1,y);
    dfs(x,y+1);
    dfs(x,y-1);
}
void deps(int x,int y){
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx>=0&&nx<w&&ny>=0&&ny<h&&m[ny][nx]=='.'){
			if(hm[ny][nx]>hm[y][x]+1){
				hm[ny][nx]=hm[y][x]+1;
				if(nx==gx&&ny==gy){return;}
				deps(nx,ny);
			}
		}
	}
}
int main() {
	for(int i=0;i<50;i++){
		for(int j=0;j<50;j++){
			hm[i][j]=9999;
		}
	}
	cin>>h>>w;
	sy=0;sx=0;gy=h-1;gx=w-1;
    int buf=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>m[i][j];
            if(m[i][j]=='#')buf++;
		}
	}
	hm[sy][sx]=0;
    dfs(0,0);
    if(ok[gy][gx]!=1){
        cout<<"-1"<<endl;
        return 0;
    }
	deps(sx,sy);
    if(hm[gy][gx]+buf+1)
	cout<<(h*w-hm[gy][gx]-buf-1)<<endl;
}


Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=list(map(int,input().split()))
    l.sort(reverse=True)
    cnt=0
    if l[0]>l[1]:
        cnt+=l[0]-l[1]
        l[2] = l[2] + cnt
        l[1]=l[1]+cnt

    if (l[1]-l[2])%2==0:
        cnt+=(l[1]-l[2])//2
    elif (l[1]-l[2])%2==1:
        cnt+=(l[1]-l[2])//2+2
    print(cnt)

resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001
#define INF         INT_MAX

int32_t main(){

	int n;cin>>n;
	string str[n];

	unordered_map<string,int> mp;
	for(int i=0;i<n;i++){
		cin>>str[i];
		mp[str[i]]++;
	}
	cout<<mp.size()<<endl;
	
	return 0;
}

Measured memory_bytes: 23928
#include <bits/stdc++.h>
#define fi first
#define se second
#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)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  int ans = 0;
  rep(i,n) {
    int l,r;
    scanf("%d%d",&l,&r);
    ans += r-l+1;
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split()))[1:] for i in range(n)]
food = {}
for i in a:
    for j in i:
        if j in food:
            food[j] += 1
        else:
            food[j] = 1
ans = 0
for i in food.values():
    if i == n:
        ans += 1
print(ans)

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s;
    cin >> s;
    ll ans1 = 0;
    for(int bit=0;bit<(1<<s.size()-1);++bit){
        ll ans2 = 0;
        string res = "";
        res += s[0];
        for(int i=0;i<s.size()-1;i++){
            if(bit&(1<<i)){
                ans2 += stoll(res);
                res = "";
                res += s[i+1];
            }
            else res += s[i+1];
        }
        if(res!=""){
            ans2 += stoll(res);
        }
        ans1 += ans2;
    }
    cout << ans1 << endl;
    return 0;
}  


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Factorial(N int) (F, Finv, Inv []int) {
  F = make([]int, N + 1)
  Finv = make([]int, N + 1)
  Inv = make([]int, N + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < N + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, N, a int) (ret int) {
  ret = (*F)[N] * ((*Finv)[a] * (*Finv)[N - a] % p) % p
  return
}

const p = 1000000007

func main() {
  NK := NextIntVec()
  N, K := NK[0], NK[1]
  A := NextIntVec()
  sort.Ints(A)
  F, Finv, _ := Factorial(N)
  E := 0
  for i := 0; i < N; i++ {
    if K <= N - i {
      E += p - A[i] * Comb(&F, &Finv, N - 1 - i, K - 1) % p
      E %= p
    }
    if K - 2 < i {
      E += A[i] * Comb(&F, &Finv, i, K - 1) % p
      E %= p
    }
  }
  Write(E)
  Output()
}


Measured memory_bytes: 8576
import sys,os,math
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat
import Queue



# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())


def main():
    n, m = map(int, raw_input().split())
    G = [[] for i in range(n+1)]
    ss = set()
    for i in range(m):
        a, b = map(int, raw_input().split())
        G[a].append(b)
    s, t = map(int, raw_input().split())
    t = t<<2
    q = deque()
    q.append((s<<2, 0))
    ss.add(s<<2)
    while q:
        st, step = q.popleft()
        point, mod = st>>2, st&3
        # print point, step, mod
        if st == t:
            print step/3
            return

        for adj in G[point]:
            new_st = (adj<<2) + (mod+1)%3
            if new_st not in ss:
                ss.add(new_st)
                q.append((new_st, step+1))
    print -1

main()


Measured memory_bytes: 92824
#include <iostream>
#include <vector>
#define DEBUG 0
typedef long long LL;

int main() {
  int N; std::cin >> N;
  std::vector<LL> h(N);

  for (int i = 0; i < N; ++i) std::cin >> h[i];

  LL cnt = 0;
  LL next = 0;
  for (int i = 0; i < N; ++i) {
    int j = i;
    while(j<N) {
      if (h[j]>h[j+1]) break;
      ++j;
    }
    int k = j;
    while(k<N) {
      if (h[k]<h[k+1]) break;
      ++k;
    }

    if (j >= N) j = N-1;
    if (k >= N) k = N-1;
#if DEBUG
    std::cout << i << ", " << j << ", " << k
              << "(" << h[i] << ", " << h[j] << ", " << h[k] << ")"
              << " - " << next
              << std::endl;
#endif
    cnt = cnt + h[j] - next;
    next = h[k];
    i = k;
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n, ans=0;
  cin >> n;
  string s[n];
  rep(i, n){
    cin >> s[i];
  }
  int m;
  cin >> m;
  string t[m];
  rep(i, m){
    cin >> t[i];
  }
  rep(i, n){
    int cnt=0;
    rep(j, n){
        if(s[i] == s[j])
          cnt++;
    }
    rep(k, m){
      if(s[i] == t[k])
        cnt--;
    }
    ans = max(ans, cnt);
  }
 cout << ans << endl;
}


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

int main(void){
    char c[6];
    for (size_t i = 0; i < 6; i++)
    {
        cin >> c[i];
    }
    for (size_t i = 0; i < 3; i++)
    {
        if (c[i]!=c[5-i])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256