akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


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

const ll mod=1000000007;

int main() {
 int x,y;
  cin >> x >> y;
  if((4*x-y)%2==0&&4*x-y>=0&&(y-2*x)%2==0&&y-2*x>=0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
X, N = map(int,input().split())
if(N != 0):
  p = list(map(int,input().split()))
  s = sorted(p)

if(N == 0): 
  print(X)
else:
  j = 0
  #min=X-(-1)
  min = abs(X)
  ans = 0
  for i in range(1,101):
    if(i != s[j]):
      if(abs(X-i) < min):
        min = abs(X-i)
        ans = i
    else:
      j += 1
    if(j >= len(s)):j=len(s)-1
      
  if(abs(X-101) < min):
    ans = 101
  print(ans)

Measured memory_bytes: 9228
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	public static void main(String args[]) throws Exception {
		int total = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> down = new ArrayDeque<Integer>();
		Deque<int[]> ike = new ArrayDeque<int[]>();

		String yama = br.readLine();
		for (int i = 0; i < yama.length(); i++) {
			if (yama.charAt(i) == '\\') {
				down.add(i);
			} else if (!down.isEmpty() && yama.charAt(i) == '/') {
				int a = i - down.getLast();
				total = total + a;
				while (!ike.isEmpty() && down.getLast() < ike.getLast()[0]) {
					a = a + ike.getLast()[1];
					ike.removeLast();
				}
				int[] data = { down.pollLast(), a };
				ike.add(data);
			}
		}
		System.out.println(total);
		System.out.print(ike.size());
		while (!ike.isEmpty()) {
			System.out.print(" " + ike.removeFirst()[1]);
		}
		System.out.println();
	}

}



Measured memory_bytes: 26388
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll K,N;
vector<vector<int>> al;
vector<int> now;
void dfs(){
	al.pb(now);
	if(now.size()==N) return;
	rep1(i,K){
		now.pb(i);
		dfs();
		now.pop_back();
	}
}
void brute(){
	dfs();
	int X = al.size();
	show(X/2);
	show(al[X/2]);
}
void prev(vector<int>& vs){
	for(int i=N-1;i>=0;i--){
		if(vs[i]!=0){
			vs[i]--;
			if(vs[i]==0) return;
			for(int j=i+1;j<N;j++) vs[j] = K;
			return;
		}
	}
}
int main(){
	cin>>K>>N;
//	brute();
	if(K%2==0){
		cout<<K/2<<" ";
		rep(i,N-1) cout<<K<<" ";
		puts("");
		return 0;
	}
	if(K==1){
		rep(i,(N+1)/2) cout<<1<<" ";
		puts("");
		return 0;
	}

	vector<int> vs(N,K/2+1);
	for(int t=0;t<N/2;t++){
		prev(vs);
//		show(vs);
	}
	while(vs.back()==0) vs.pop_back();
	for(int v:vs) cout<<v<<" ";
	puts("");
}


Measured memory_bytes: 3456
c=[0]
d=1
while c[-1]!="0 0":
    a=[int(x) for x in input().split()]
    a.sort()
    b=("%d %d"%(a[0],a[1]))
    c.append(b)
while c[d]!="0 0":
    print(c[d])
    d+=1


Measured memory_bytes: 5872
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int h, w, n;
    cin >> h >> w >> n;

    vector<vector<int>> d(w+1, vector<int>{0, h+1});
    rep(i, n){
        int x, y;
        cin >> x >> y;
        d[y].push_back(x);
    }

    int ans = h;
    int head = 0;
    int tail = h;
    for(int i = 1; i <= w; i++){
        sort(ALL(d[i]));
        head++;

        int begin = head;
        rep(j, SZ(d[i])){
            if(begin > d[i][j]){
                continue;
            }

            if(begin < d[i][j]){
                break;
            }
            begin++;
        }
        auto end = upper_bound(ALL(d[i]), begin);

        int diff = tail - begin;
        if(diff <= 0){
            break;
        }

        ans = min(ans, *end- 1);
        head = max(head, begin);
        tail = *end - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int N,A,B,C,D;
  string s;
  cin>>N>>A>>B>>C>>D>>s;
  bool ok1=true;
  for(int i=B-1;i<D;i++){
    if(s[i]=='#'&&s[i+1]=='#'){ok1=false;}
  }
  for(int i=A-1;i<C;i++){
    if(s[i]=='#'&&s[i+1]=='#'){ok1=false;}
  }
  if(!ok1){cout<<"No"<<endl;return 0;}
  bool ok2=false;
  for(int i=B-1;i<D;i++){
    if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){ok2=true;}
  }
  if(C>D){
    if(!ok2){cout<<"No"<<endl;return 0;}}
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3756
import math
a,b,h,m = map(int,input().split())
zi = h * 30 + m * 0.5
hun = m * 6
kaku = abs(zi-hun)
if kaku > 180:
    kaku = 360 - kaku
kaku = math.cos(math.radians(kaku))
ans2 = a**2 + b**2 - 2*a*b*kaku
print(math.sqrt(ans2))

Measured memory_bytes: 9404
#include<bits/stdc++.h>
using namespace std;
#define MAXN	2005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char mp[MAXN][MAXN];
int sum[MAXN][MAXN], sam[MAXN][MAXN], sbm[MAXN][MAXN];
int getsum(int x, int y, int a, int b) {
	return sum[a][b] - sum[x - 1][b] - sum[a][y - 1] + sum[x - 1][y - 1];
}
int getsam(int x, int y, int a, int b) {
	return sam[a][b] - sam[x][b] - sam[a][y - 1] + sam[x][y - 1];
}
int getsbm(int x, int y, int a, int b) {
	return sbm[a][b] - sbm[x - 1][b] - sbm[a][y] + sbm[x - 1][y];
}
int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("\n%s", mp[i] + 1);
		for (int j = 1; j <= m; j++) {
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
			sum[i][j] += mp[i][j] == '1';
			sam[i][j] = sam[i - 1][j] + sam[i][j - 1] - sam[i - 1][j - 1];
			sam[i][j] += mp[i][j] == '1' && mp[i - 1][j] == '1';
			sbm[i][j] = sbm[i - 1][j] + sbm[i][j - 1] - sbm[i - 1][j - 1];
			sbm[i][j] += mp[i][j] == '1' && mp[i][j - 1] == '1';
		}
	}
	for (int i = 1; i <= k; i++) {
		int x, y, a, b;
		read(x), read(y), read(a), read(b);
		printf("%d\n", getsum(x, y, a, b) - getsam(x, y, a, b) - getsbm(x, y, a, b));
	}
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 10005;
int N;
string S[MAX_N];

signed main()
{
  int N;
  int ans = 0;
  int RA = 0, LB = 0, BA = 0;
  cin >> N;
  REP(n,N) {
    cin >> S[n];
    REP(m,S[n].size()-1) {
      if(S[n][m] == 'A' && S[n][m+1] == 'B') ans++;
    }
    if(S[n][0] == 'B' && S[n][S[n].size()-1] == 'A') BA++;
    else if(S[n][0] == 'B') LB++;
    else if(S[n][S[n].size()-1] == 'A') RA++;
  }

  bool a = false;
  if(RA > 0) {
    RA--;
    a = true;
  }

  while(BA > 0) {
    BA--;
    if(a) ans++;
    a = true;
  }

  if(LB > 0 && a) {
    a = false;
    LB--;
    ans++;
  }

  ans += min(RA, LB);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


X = z()
if (400 <= X <= 599):
    print(8)
    exit()
elif(600 <= X <= 799):
    print(7)
    exit()
elif(800 <= X <= 999):
    print(6)
    exit()
elif(1000 <= X <= 1199):
    print(5)
    exit()
elif(1200 <= X <= 1399):
    print(4)
    exit()
elif(1400 <= X <= 1599):
    print(3)
    exit()
elif(1600 <= X <= 1799):
    print(2)
    exit()
elif(1800 <= X <= 1999):
    print(1)
    exit()


Measured memory_bytes: 42256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll INF = 1LL << 60;
int MOD = 1e9+7;
main(){
    ll N;
    ll C;
    cin >> N >> C;
    vector<ll>X(N),V(N);
    for(int i = 0;i < N;i++){
        cin >> X[i] >> V[i];
    }
    ll sum = V[0];
    vector<ll> R(N),L(N);//時計回り、反時計回りの累積

    R[0] = max(sum - X[0], 0LL);
    for(int i = 1;i < N;i++){
        sum += V[i];
        R[i] = max(sum - X[i], R[i-1]);
    }

    sum = V[N-1];
    L[N-1] = max(sum - (C - X[N-1]), 0LL);
    for(int i = N-2;i >= 0;i--){
        sum += V[i];
        L[i] = max(sum - (C - X[i]), L[i+1]);
    }

    ll maxi = max(L[0], R[N-1]);
    sum = 0;
    for(int i = 0;i < N-1;i++){
        sum += V[i];
        maxi = max(maxi, sum + L[i+1] - X[i]*2);
    }

    sum = 0;
    for(int i = N-1;i >= 1;i--){
        sum += V[i];
        maxi = max(maxi, sum + R[i-1] - (C - X[i])*2);
    }
    cout << maxi << endl;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public static class Program {
    private static Dictionary<int, List<int>> dic;
    private static int m = 0;
    public static void Main() {
        var sampleText = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n  = sampleText[0];
        m = sampleText[1];
        dic = new Dictionary<int, List<int>>();
        for(var i  = 0; i < n;i++)
        {
            dic.Add(i, new List<int>());
        }
        for(var i  = 0; i < m;i++)
        {
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var room1 = a[0]-1;
            var room2 = a[1]-1;
            dic[room1].Add(room2);
            dic[room2].Add(room1);
        }
      
        var nums = new int[n];
        var flags = new bool[n];
        var queue = new Queue<int>();
        queue.Enqueue(0);
        while(queue.Count > 0)
        {
            var num = queue.Dequeue();
            
            foreach(var a in dic[num])
            {
                if(flags[a] == true)
                {
                    continue;
                }
                flags[a] = true;
                nums[a] = num;
                queue.Enqueue(a);
            }  
        }
        
        if(flags.Contains(false))
        {
            Console.WriteLine("No");
            return;
        }
        for(var i = 0; i <n;i++)
        {
            if(i == 0)
            {
              Console.WriteLine("Yes");
              continue;
            }
            Console.WriteLine(nums[i]+1);
        }
    }
}

public class Room
{
    public int Current = 0;
    public int Target = 0;
}


Measured memory_bytes: 56200
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 
//int dp[333][2];	

void solve(){
	int n;
	cin>>n;
	int arr[n];
	FOR(i, 0, n){
		cin>>arr[i];
		if( arr[i]%2==0 && arr[i]%3!=0 && arr[i]%5!=0){
			cout<<"DENIED"<<endl;
			return;
		}
	}
	cout<<"APPROVED"<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Reservation System
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int[] reserve = new int[1001];

		line = br.readLine();

		int a, b;
		a = parseInt(line.substring(0, line.indexOf(' ')));
		b = parseInt(line.substring(line.indexOf(' ') + 1));

		int N = parseInt(br.readLine());

		for (int i = 0; i < N; i++) {
			line = br.readLine();
			int s, f;
			s = parseInt(line.substring(0, line.indexOf(' ')));
			f = parseInt(line.substring(line.indexOf(' ') + 1));
			reserve[s]++;
			reserve[f]--;
		}

		for (int i = 1; i <= 1000; i++) {
			reserve[i] += reserve[i - 1];
		}

		int ans = 0;

		for (int i = a; i < b; i++) {
			if (reserve[i] > 0) {
				ans = 1;
				break;
			}
		}

		System.out.println(ans);
	}
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n; cin>>n;

	vector<ll>a(n),b(n),c(n);

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

	sort(a.begin(),a.end());
	sort(c.begin(),c.end());

	ll ans=0;
	for(int i=0; i<b.size(); i++){
		ll aa = lower_bound(a.begin(),a.end(),b[i])-a.begin();
		ll cc = c.end()-upper_bound(c.begin(),c.end(),b[i]);

		ans +=aa*cc;
	}

	writeln(ans);


}




Measured memory_bytes: 2560
// https://atcoder.jp/contests/abc081/tasks/arc086_a
"use strict";
function Main(input) {
  const params = input.trim().split("\n");
  const [N, K] = params[0].trim().split(" ").map(Number);
  const A = params[1].trim().split(" ").map(Number);
  const counts = Array(N + 1).fill(0);

  for (let i = 0; i < N; i++) {
    counts[A[i]] = counts[A[i]] + 1;
  }
  const filterdCounts = counts.sort((a, b) => a - b).filter((a) => a);
  if (filterdCounts.length <= K) {
    console.log(0);
    return;
  }

  let rewriteCount = 0;
  let change = filterdCounts.length - K;
  for (let i = 0; i < change; i++) {
    rewriteCount += filterdCounts[i];
  }
  console.log(rewriteCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
  ll n, ans = 0;
  cin >> n;
  if (n >= 500)
  {
    
    ans += n/500 * 1000;
    n %= 500;
  }
  if(n>=5)ans += n / 5 * 5;
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll h,w;cin>>h>>w;
  ll a,b;cin>>a>>b;

  rep(i,0,h){
    if(i<b){
      rep(j,0,w){
        if(j<a)cout<<0;
        else cout<<1;
      }
      cout<<endl;
    }else{
      rep(j,0,w){
        if(j<a)cout<<1;
        else cout<<0;
      }
      cout<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
// const int N = ;

string s;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> s;
        if(s[s.size() - 1] == 's') cout << s << "es\n";
        else cout << s << "s\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3620
n,m= map(int,input().split())
a = [input().rstrip().split() for j in range(m)]

graph = [[False for i in range(n)] for j in range(n)]#どこが連結されているか
# graph
for i in range(0,m):
    x = int(a[i][0])-1
    y = int(a[i][1])-1
    graph[x][y]=graph[y][x]=True
# graph

def DFS(v,visited):
    visited[v]=True
    for i in range(0,n):
        if(graph[v][i]==False):
            continue
        if(visited[i]):
            continue
        DFS(i,visited)


cnt2 = 0
for i in range(0,m):
    x = int(a[i][0])-1
    y = int(a[i][1])-1
    graph[x][y]=graph[y][x]=False
    # print(graph)
    #始点が1とは限らない
    visited=[False]*n
    DFS(0,visited)
    # print(visited)
    if visited.count(False)!=0:
        cnt2 += 1
    graph[x][y]=graph[y][x]=True


print(cnt2)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

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

    int ans = 0;

    int prev_black_sum = 0;
    int now_white_sum = 0;
    int tmp_white_sum = 0;
    bool now_white;
    if(S.at(0) == '.') {
        now_white = true;
    } else {
        now_white = false;
    }

    for(int i=0; i < S.size(); i++) {

        // 白から黒に切り替わったタイミングで計算して変数なども初期化
        if (S.at(i) == '#' && now_white) {
            // 白を黒に変える場合は
            if (prev_black_sum - tmp_white_sum > now_white_sum) {
                ans += now_white_sum;
                tmp_white_sum += now_white_sum;
                now_white_sum = 0;
                // 黒のsumは更新しない
            } else {
                // 黒を白に変える
                ans = ans - tmp_white_sum  + prev_black_sum ;
                prev_black_sum = 0;
                now_white_sum = 0;
                tmp_white_sum = 0;
            }
        }
        // 黒が続いたら、黒の合計値を加算する
        if (S.at(i) == '#') {
            prev_black_sum++;
            now_white = false;
        }

        // 白が続いたら、白の合計値を加算する
        if (S.at(i) == '.') {
            now_white_sum++;
            now_white = true;
        }
    }

    // 最後が白で終わった場合
    if (S.at(N-1) == '.') {
        // 白を黒に変える場合は
        if (prev_black_sum - tmp_white_sum > now_white_sum) {
            ans += now_white_sum;
            tmp_white_sum += now_white_sum;
            now_white_sum = 0;
            // 黒のsumは更新しない
        } else {
            // 黒を白に変える
            ans = ans - tmp_white_sum - tmp_white_sum + prev_black_sum ;
            prev_black_sum = 0;
            now_white_sum = 0;
            tmp_white_sum = 0;
        }
    }

    cout << ans << endl;

    return 0;
}
// 9
// ....#...#
// ....#....
// ......#..
// .##.#...#
//

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    vector<int> s(101, -1);
    while(1){
        int a,b;
        scanf("%d,%d", &a,&b);
        if(a==0 && b==0) break;
        s[a] = b;
    }
    int n = s.size();
    vector<int> ord(n);
    for(int i=0; i<101; i++){
        if(s[i]==-1) continue;
        ord[i] = s[i];
    }
    sort(ord.begin(), ord.end(), greater<int>());
    ord.erase(unique(ord.begin(), ord.end()), ord.end());

    map<int, int> res;
    for(int i=0; i<(int)ord.size(); i++){
        res[ord[i]] = i+1;
    }

    int q;
    while(cin >> q){
        cout << res[s[q]] << endl;
    }
    
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	x=0;
	FORR(c,S) x+=c-'0';
	if(x%9==0) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long LL;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<int> c[50];
    for (int i = 0; i < n; i++) {
        c[i].resize('z' - 'a' + 1, 0);
        for (int j = 0; j < s[i].size(); j++) {
            c[i][s[i][j] - 'a']++;
        }
    }

    for (int i = 0; i < 'z' - 'a' + 1; i++) {
        int mn = 5000;
        for (int j = 0; j < n; j++) {
            mn = min(mn, c[j][i]);
        }

        for (int j = 0; j < mn; j++) {
            cout << (char)(i + 'a');
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = list([input() for i in range(N)])
M = int(input())
t = list([input() for i in range(M)])
union = list(set(s) | set(t))
l = [s.count(union[i])-t.count(union[i]) for i in range(len(union))]
if max(l) > 0:
  print(max(l))
else:
  print(0)

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

string solve(int N) {
	for (int i : range(100))for (int j : range(100))
		if (i * 4 + j * 7 == N)return "Yes";
	return "No";
}
int main() {
	int N;
	while (cin >> N) {
		cout << solve(N) << endl;
	}
	


	return 0;
}


Measured memory_bytes: 256
# N個のTrueの展望台リストを作り、隣り合うペアのうち標高が低いほうをFalseにしていく

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
H = list(map(int,readline().split()))

ans = [True] * N

for i in range(M):
  a,b = map(int,readline().split())
  if H[a-1] < H[b-1]:
    ans[a-1] = False
  elif H[a-1] > H[b-1]:
    ans[b-1] = False
  else:
    ans[a-1],ans[b-1] = False,False

print(sum(ans))

Measured memory_bytes: 20208
// #pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

const int oo=-10;//优化：定义常量oo小于-8，给有雷的格子标注，这样的话无论下面怎样加也不会大于0
int n,m,a[52][52];
char c;

int main()
{
    cin>>n>>m;//读入
    for(int i=1;i<=n;i++)//从1开始，有0行0列作围墙
        for(int j=1;j<=m;j++)
        {
            cin>>c;//一个一个读入矩阵的各个字符
            if(c=='#')//如果有雷
            {
                a[i][j]=oo;//标注出雷格
                a[i-1][j-1]++;//以下八行给雷格的周围的所有格子的雷数加一
                a[i-1][j]++;
                a[i-1][j+1]++;
                a[i][j-1]++;
                a[i][j+1]++;
                a[i+1][j-1]++;
                a[i+1][j]++;
                a[i+1][j+1]++;
            }
        }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            if(a[i][j]<0)cout<<"#";//标注的用处：如果小于0就是有雷的格子
            else cout<<a[i][j];//否则输出雷数
        cout<<endl;//省去了死亡换行的困扰
    }   /////////////////////////////////
}

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


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);


        int n = in.nextInt();
        int k = in.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        int [] dp = new int[n+1];
        for (int i = 0; i < n; i++) {
            dp[i + 1] = dp[i] + a[i];
        }

        int index = lower_Bound(dp,k);
        
        if(index == dp.length || dp[index] != k) {
            out.println(index);
        }
        else {
            out.println(index + 1);
        }
        out.flush();
    }
    static int lower_Bound(int [] a, int target) {
        int lo = 0;
        int hi = a.length - 1;
        while (lo<=hi) {
            int med = lo+(hi-lo)/2;
            if(target<=a[med]) {
                hi = med - 1;
            }
            else {
                lo = med + 1;
            }
        }
        return lo;
    }

}


class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

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

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}


Measured memory_bytes: 21460
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[30][30][30][30];
char str[30][30];
int calc(int a,int b,int c,int d){
    if(a>=b||c>=d)return 0;
    if(dp[a][b][c][d]!=-1)return dp[a][b][c][d];
    int val[64];
    for(int i=0;i<64;i++)val[i]=0;
    for(int i=a;i<b;i++)for(int j=c;j<d;j++){
        if(str[i][j]=='X')continue;
        int tmp=0;
        tmp^=calc(a,i,c,j);
        tmp^=calc(i+1,b,c,j);
        tmp^=calc(a,i,j+1,d);
        tmp^=calc(i+1,b,j+1,d);
        val[tmp]=1;
    }
    for(int i=0;i<64;i++)if(!val[i])return dp[a][b][c][d]=i;
}
int main(){
    int a,b;scanf("%d%d",&a,&b);
    for(int i=0;i<a;i++)scanf("%s",str[i]);
    for(int i=0;i<30;i++)for(int j=0;j<30;j++)for(int k=0;k<30;k++)for(int l=0;l<30;l++)
        dp[i][j][k][l]=-1;
    int ret=calc(0,a,0,b);
    if(ret)printf("First\n");
    else printf("Second\n");
}

Measured memory_bytes: 5844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string a,b,c; cin >> a >> b >> c;
    if (a.back() == b[0] && b.back() == c[0])
    {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    string s;
    cin>>s;
    ll n=s.length();
    ll x=n/2-1;
    ll ans=0;
    rep (i,0,x+1)
    {
        if (s[i]!=s[n-1-i])
        {
            ans++;
        }
    }
    cout<<ans<<"\n";
    
}


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

int main() {
	long n;
	cin>>n;
	string s;
	long a=0,t=0,w=0,r=0;
	for(long i=1;i<=n;++i) {
		cin>>s;
		if(s[0]=='A') ++a;
		else if(s[0]=='W') ++w;
		else if(s[0]=='T') ++t;
		else if(s[0]=='R') ++r;
	}
	printf("AC x %ld\nWA x %ld\nTLE x %ld\nRE x %ld",
	a,w,t,r);
	return 0;
}

Measured memory_bytes: 3716
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u64 = read();
    let ans: u64 = n * (n - 1) / 2;

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
int a, b, k, i, j, l;

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

for(l=0; l<k; l++){
 if((l+2)%2==0){
  if(a%2==1)
   a--;

 b+=a/2;
 a=a/2;
}
 else{
  if(b%2==1)
   b--;

 a+=b/2;
 b=b/2;
}
}
printf("%d %d\n", a, b);


return 0;
}


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

int gcd(int a, int b) {
  if ( a == 0 ) { return b; }
  if ( b == 0 ) { return a; }
  int tmp;
  while ( a%b != 0 ) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

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

  vector<int> left(n+1), right(n+1);
  left[0] = right[n] = 0;
  for ( int i = 0; i < n; i++ ) {
    left[i+1] = gcd(left[i], a[i]);
  }
  for ( int i = n-1; i >= 0; i-- ) {
    right[i] = gcd(right[i+1], a[i]);
  }

  int ans = 0;
  for ( int i = 0; i < n; i++ ) {
    int gcd_without_i = gcd(left[i], right[i+1]);
    if ( gcd_without_i > ans ) { ans = gcd_without_i; }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            if (s.Length % 2 == 0)
            {
                var s1 = "";
                for(int i = 0; i < s.Length / 2; i++)
                {
                    s1 += s[i];
                }

                var s2 = "";
                for(int i = s.Length / 2; i < s.Length; i++)
                {
                    s2 += s[i];
                }

                if (s1 == s2)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int res=0;
  for(int i=1; i<s.size(); i++){
    if (s.at(i-1) == s.at(i)){
      if (s.at(i) == '0') s.at(i) = '1';
      else s.at(i) = '0';
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int convet(int n)
{
	int ans=0;
	while(n)
	{
		ans+=n%10;
		n/=10;
	}
	return ans;
}
int main()
{
	int n,a,b,i,sum,ans=0;
	scanf("%d %d %d",&n,&a,&b);
	for(i=1;i<=n;i++)
	{
		sum=convet(i);
		if(sum>=a&&sum<=b)
			ans+=i;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
def solve():
    a, b, c, d = map(int, input().split())
    for i in range(1000):
        if i % 2 == 0:
            if a <= 0:
                print('No')
                return
            c -= b
        else:
            if c <= 0:
                print('Yes')
                return
            a -= d


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

char op(char x) {
    if (x == 'T') {
        return ('A');
    }
    if (x == 'A') {
        return ('T');
    }
    if (x == 'C') {
        return ('G');
    }
    if (x == 'G') {
        return ('C');
    }
    return 0;
}

int main() {
    long long a, b, c, ra, rb, rc, g;
    char s;
    cin >> s;
    cout << op(s) << endl;
}

Measured memory_bytes: 256
A,B,C,K = map(int,input().split())
ans = 0
if A <= K:
    ans += A
    K -= A
else:
    ans += K
    print(ans)
    quit()

if B <= K:
    K -= B
else:
    ans += K * 0
    print(ans)
    quit()
print(ans - K)


Measured memory_bytes: 9184
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int main()
{
	int n, m; cin>>n>>m;
	string s; cin>>s;
	const int INF=1e9;
	vector<P> v(n+1);
	for(int i=0; i<=n; i++) v[i]=P(INF, i);
	SegmentTree<P> seg(n+1, [](P a, P b){ return min(a, b);}, P(INF, INF), v);
	seg.update(n, P(0, n));
	int nx[100010];
	for(int i=n-1; i>=0; i--){
		if(s[i]=='1') continue;
		P p=seg.query(i+1, min(n+1, i+m+1));
		if(p.first>=INF/2){
			nx[i]=-1;
		}else{
			nx[i]=p.second;
			seg.update(i, P(p.first+1, i));
		}
	}
	if(nx[0]==-1){
		cout<<-1<<endl;
		return 0;
	}
	int k=0;
	while(k<n){
		cout<<nx[k]-k<<" ";
		k=nx[k];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 4096
#include <vector>
#include <iostream>
#include <stack>
using namespace std;
void dfs(vector<vector<int>> &g,vector<int> &visited,int v,stack<int> &s){
    visited[v]=1;
    int x = g[v].size();
    for(int i=0;i<x;i++){
        if(visited[g[v][i]]==0){
            dfs(g,visited,g[v][i],s);
        }
    }
    s.push(v);
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a-1].push_back(b-1);
    }
    stack<int> s;
    vector<int> visited(n,0);
    for(int i=0;i<n;i++){
        if(visited[i]==0) dfs(v,visited,i,s);
    }
    vector<int> dp(n,0);
    while(!s.empty()){
        int x = s.top();
        s.pop();
        int si = v[x].size();
        for(int i=0;i<si;i++){
            dp[v[x][i]]=max(dp[v[x][i]],1+dp[x]);
        }
    }
    int mx =0;
    for(int i=0;i<n;i++){
        mx = max(mx,dp[i]);
    }
    cout<<mx<<endl;

}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;



int main(void)
{
    int K, S, cnt = 0;

    cin >> K >> S;

    for(int i = 0; i <= K; i++)
    {
        for(int j = 0; j <= K; j++)
        {
            int k = S - i - j;
            if(k >= 0 && k <= K) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for i in range(n):
  ans+=b[a[i]-1]
  if(i>=1):
    if(a[i]-a[i-1]==1):
      ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::pair<std::int64_t, int>> child(N);
	for (auto i : boost::irange(N))
	{
		std::int64_t a;
		std::cin >> a;
		child[i] = std::make_pair(a, i);
	}
	boost::sort(child, std::greater<>());
	boost::multi_array<std::int64_t, 2> dp(boost::extents[N + 1][N + 1]);
	for (auto i : boost::irange(N))
	{
		auto [a, ind] = child[i];
		for (auto j : boost::irange(i + 1))
		{
			dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j] + a * std::abs((N - 1) - (i - j) - ind));
			dp[i + 1][j + 1] = std::max(dp[i + 1][j + 1], dp[i][j] + a * std::abs(j - ind));
		}
	}
	std::int64_t max = 0;
	for (auto i : boost::irange(N + 1))
	{
		max = std::max(max, dp[N][i]);
	}
	std::cout << max << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 34620
import sys
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = list(int(x) for x in sys.stdin.read().split())
if len(B) < 3:
  print('No')
  exit()
comb = []
for b in B:
  if b in A1:
    comb.append("1" + str(A1.index(b) + 1))
  elif b in A2:
    comb.append("2" + str(A2.index(b) + 1))
  elif b in A3:
    comb.append("3" + str(A3.index(b) + 1))
bingo_cond = ["111213", "212223", "313233", "112131", "112233", "132231", "132333"]
from itertools import combinations
for c in combinations(comb, 3):
  s = "".join(x for x in sorted(c))
  if s in bingo_cond:
    print('Yes')
    exit()
print('No')

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

using namespace std;

int main() {
    vector<int> v(5);
    int tmp;
    
    int annoy;
    int interval;
    int max_interval = -1;
    for(int i = 0; i < 5; i++) {
        cin >> v[i];
        interval = 10 - v[i] % 10;
        //cout << v[i] << endl;
        if ((interval != 10) && (interval > max_interval)) {
            annoy = i;
            max_interval = interval;
        }
    }
    int ans = 0;
    for(int i = 0; i < 5; i++) {
        if (i == annoy) continue;
        else {
            if (v[i] % 10 == 0) ans+= v[i];
            else {
                ans += ((v[i] / 10) + 1) * 10;
            }
        }
    }
    ans += v[annoy];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	int A, B, ans, x, y;
	cin >> A >> B;
	for (int i = 1; i <= 1000; i++) {
		ans = i;
		x = ans * 0.08;
		y = ans * 0.1;
		if (x == A && y == B)break;
		if (ans == 1000) {
			ans = -1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define inf (int)(1e8)

int main(){
	int H, W, h, w, i, j;
	scanf("%d%d%d%d", &H, &W, &h, &w);
	if(H % h == 0 && W % w == 0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
		for(i = 1; i <= H; i++){
			for(j = 1; j <= W; j++){
				if(i % h == 0 && j % w == 0){
					printf("%d ", - (1 + inf));
				}
				else if((h == 1 || i % h == 1) && (w == 1 || j % w == 1)){
					printf("%d ", inf);
				}
				else{
					printf("0 ");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2688
mod = 10**9 + 7


def comb(n, k):
    x, y = 1, 1
    k = min(k, n - k)
    for i in range(k):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod


def solve(string):
    n, m, k = map(int, string.split())
    base = n * m * (n + m) * (n * m - 1) // 6 % mod
    return str(base * comb(n * m - 2, k - 2) % mod)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int H, W;
cin>>H>>W;
if(H == 0 && W == 0) break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if((i + j) %2 == 0) cout<<"#";
else cout<<".";
}
cout<<endl;
}

cout<<endl;
}
return 0;
}


Measured memory_bytes: 3100
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])
t = np.array([int(input()) for x in range(D)])
last = np.zeros(26, dtype=np.int16)

score = 0
for d in range(1, D + 1):
    score += s[d - 1, t[d - 1] - 1]
    last[t[d - 1] - 1] = d
    score -= (c * (d - last)).sum()
    print(score)

Measured memory_bytes: 27176
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a!=b){
   if(a < b){ 
   puts("a < b");
   }   else{
    puts("a > b");
   }
  }  else{
   puts("a == b");
  }
 return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    ll ans=0;
    rep(i,n+1){
        if(i%3==0 || i%5==0) continue;
        ans += i;
    }
    cout << ans<< endl;
    return 0;
}





Measured memory_bytes: 3668
#!/usr/bin/env python3
import sys
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


# def kiriage(a, b):
#     return (a + b - 1) // b


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    i = A.index(1)

    # print(kiriage(i, K-1) + kiriage(N-i-1, K-1))
    l = i // (K-1)
    r = (N-i-1) // (K-1)

    rest_left = i - l*(K-1)
    rest_right = (N-i-1) - r*(K-1)
    rest = N - (l+r) * (K-1)


    if rest_left == 0 and rest_right == 0:
        print(l+r)
    elif rest_left == 0 or rest_right == 0:
        print(l+r+1)
    elif rest <= K:
        print(l + r + 1)
    else:
        print(l+r+2)


Measured memory_bytes: 52476
#include<stdio.h>

struct CELL
{
	int value;
	struct CELL *next;
};

int main()
{
	int n;
	struct CELL stu[1001];
	struct CELL header,*front,*back;
	int min,temp;

	while (1)
	{
		scanf("%d",&n);
		if (n == 0) break;
		header.next = NULL;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &stu[i].value);
			front = &header;
			back = header.next;
			while (back != NULL && stu[i].value > back->value)
			{
				front = back;
				back = back->next;
			}
			stu[i].next = back;
			front->next = &stu[i];
		}

		min = 1000001;
		front = header.next;
		back = front->next;
		for(int i=0;i<n-1;i++)
		{
			temp = back->value - front->value;
			if (temp < min)
				min = temp;
			front = back;
			back = back->next;
		}
		printf("%d\n",min);
	}
	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int lli;
typedef pair<int, int> P;

int main() {
    lli n, m;
    lli ans;
    cin >> n >> m;
    lli left = m - 2*n;
    if (left > 0) {
        ans = n + left/4;
    }
    else
        ans = m/2;

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>

#define MAXN 300005

using namespace std;


int main()
{
    //freopen("a.txt", "r", stdin);
    int a, b;
    while (cin >> a >> b) {
        if (a * b == 15)
            printf("*\n");
        else if (a + b == 15)
            printf("+\n");
        else
            printf("x\n");
    }
    return 0;
}

Measured memory_bytes: 256