akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}

const double PI=acos(-1.0);

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double rad;
    if(s >= a * b / 2) {
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    } else {
        double w = s * 2 / b;
        rad = atan2(b, w);
    }

    double deg = rad / (2 * PI) * 360;

    printf("%.10f\n", deg); 

    return 0;
}

Measured memory_bytes: 384
K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * N
k = 0
for i in A:
  k += 1
  if k != N:
    B[k-1]=A[k]-A[k-1]
  else:
    B[N-1] = A[0] + K - A[N-1]

print(K-max(B))


Measured memory_bytes: 26060
import sys


def solve(k, ax, bx, cx):
    ab = []
    for a in ax:
        for b in bx:
            ab.append(a+b)

    ab.sort(reverse=True)
    abk = ab[:k]

    ans = []
    for c in cx:
        for abi in abk:
            ans.append(c+abi)

    return sorted(ans, reverse=True)[:k]


if __name__ == '__main__':
    _, _, _, k = map(int, input().split())
    ax = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    bx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)
    cx = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

    ans = solve(k, ax, bx, cx)

    print(*ans, sep="\n")


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

int main(){
  int n, m, Taro[100], Hanako[100];
  while(1){
    cin>>n>>m;
    if(!(n + m)) return 0;
    int sum_T = 0, sum_H = 0;
    for(int i=0;i<n;i++){
      cin>>Taro[i];
      sum_T += Taro[i];
    }
    for(int i=0;i<m;i++){
      cin>>Hanako[i];
      sum_H += Hanako[i];
    }
    int diff;
    diff = sum_T - sum_H;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	if((Taro[i] - Hanako[j]) * 2 == diff){
	  cout<<Taro[i]<<" "<<Hanako[j]<<endl;
	  i = n;
	  j = m;
	}
	if(i == n-1 && j == m-1){
	  cout<<-1<<endl;
	}
      }
    }
  }
}



Measured memory_bytes: 2960
import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    x = I()

    a = 100
    i = 0
    while True:
        a = int(a * 1.01)
        i += 1
        if a >= x:
            print(i)
            exit()


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
LL INF = 1e17;
double EPS=1.0e-9;
double PI=atan2(0,-1);

int main()
{
    string s;
    int k;
    cin>>s>>k;
    
    REP(i,s.size())
    {
        if(s[i]=='a')continue;
        if('z'-s[i]+1 <= k)
        {
            k-='z'-s[i]+1;
            s[i]='a';
        }
    }
    
    s[s.size()-1]+=k%26;
    if(s[s.size()-1]>'z')s[s.size()-1]-=26;
    
    cout<<s<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

bool chk[1100000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N; cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];

	sort(v.begin(), v.end());
	for (int i = 0; i < N - 1; i++) if (v[i] == v[i + 1]) {
		for (int j = v[i]; j <= v[N - 1]; j += v[i]) chk[j] = 1;
	}

	for (int i = 0; i < N; i++) 
		if (!chk[v[i]])
			for (int j = 2 * v[i]; j <= v[N - 1]; j += v[i]) chk[j] = 1;
	
	int cnt = 0;
	for (int i = 0; i < N; i++) if (!chk[v[i]]) cnt++;
	cout << cnt << '\n';

	return 0;
}

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

int main(){
  int n; cin>>n;
  int rest=n%100,p=n/100;
  int check=0;
  for(int i=5;i>=1;i--){
    check+=(rest/i);
    rest-=(rest/i)*i;
  }if(check<=p){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
data = [
    '{0} {1}'.format(s, r)
    for s in ('S', 'H', 'C', 'D')
    for r in range(1, 13 + 1)
    ]

count = int(input())
for c in range(count):
    card = input()
    data.remove(card)

for c in data:
 print(c)

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

int main(){
    int n,i,j,vmax1=0,vmax2=-1;
    cin>>n;
    vector<int> v(n);
    for(i=0; i<n; i++){
        cin>>v[i];
        vmax1=max(v[i],vmax1);
    }

    for(i=0; i<n; i++){
        if(v[i]!=vmax1){
            cout<<vmax1<<endl;
        }else if(vmax2==-1){
            for(j=0; j<n; j++){
                if(j==i){ continue; }
                vmax2=max(vmax2,v[j]);
            }
            cout<<vmax2<<endl;
        }else{
            cout<<vmax2<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for(int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 0x3b9aca07;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll n; cin >> n;
	ll ans = 0;
	rep(i, 1, n + 1) {
		rep(j, 2, 11) {
			ll x = pow(((ll)i), (ll)j);
			if (x <= n) ans = max(ans, x);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
# -*- coding: utf-8 -*-

"""
参考：https://betrue12.hateblo.jp/entry/2018/08/18/224408
・二次元累積和
・こっちの方針のが分かりやすいかも。
"""

N, M, Q = map(int, input().split())
LR = [[0] * (N) for i in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    # 左端=L、右端=Rの表
    LR[l-1][r-1] += 1

# 二次元の縦横両方について累積和を出す
# 縦方向の足し方を逆からにすることで、今回の条件と合致できる
for i in range(N):
    for j in range(1, N):
        # 左端=L、右端<=Rになる
        LR[i][j] += LR[i][j-1]
for i in range(N):
    for j in range(N-2, -1, -1):
        # 左端>=L、右端<=Rになる
        LR[j][i] += LR[j+1][i]

for i in range(Q):
    p, q = map(int, input().split())
    # ここでは添字指定だけで加減不要
    ans = LR[p-1][q-1]
    print(ans)


Measured memory_bytes: 9332
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple{
    private long x;
    void Solve(){
        //input
        x = io.Long;
        //cal
        var cnt = Math.DivRem(x, 11L, out x) * 2;
        if(x > 6) cnt += 2;
        else if(x > 0) cnt += 1;
        //ret
        Console.WriteLine(cnt);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream(){
        Solve();
        io.writeFlush();
    }
}
class SimpleIO{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[]{' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    public SimpleIO(){
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next(){
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 main(){
	set<int> s;
	for(int i=0;i<3;i++){
		int a;
		cin>>a;
		s.insert(a);
	}
	if(s.size()==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()

int main(void)
{
    li n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? 0 : 1) << endl;

    return 0;
}

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


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
    //  static int dx[]={1,-1,0,0};
    //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
    int n = sc.nextInt();
    int m = sc.nextInt();
    int d[]= new int[n]; 
    for( int i=0; i<m; i++ ){
        int x=sc.nextInt();
        int y=sc.nextInt();
        x--;y--;
        d[x]++;d[y]++;
    }
    String ans="YES";
    for( int i=0; i<n; i++ ){
        if(d[i]%2==1){ans="NO"; break;}
    }

    out.println(ans);
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 41424
#include <bits/stdc++.h>
#include <cstdio>
#include <chrono>
#include <random>
using namespace std;

#define DRACARYS ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, -1, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define PI 3.14159265
const long long int MAXN = 1e5+10;
const long long int MINN = 1e5+10;
const long long int inf = 1e9+7;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi; 
typedef stack<int> st;
ll n,w,wt[110],val[110],dp[105][MAXN],sum;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    DRACARYS
    cin>>n>>w;
    repA(i,1,n) cin>>wt[i]>>val[i],sum+=val[i];
    repA(i,1,sum) dp[0][i]=1e15;
    dp[0][0]=0;
    repA(i,1,n){
        repA(j,0,sum){
            if(val[i]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=min(dp[i-1][j-val[i]]+wt[i],dp[i-1][j]);
        }
    }        
    ll ans=-1;
    repA(i,1,n) repD(j,sum,0) if(dp[i][j]<=w){
        ans=max(ans,(ll)j);
        break;
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 80128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int coun(int x){
	int temp = 0;
	for (int i = 1; i <= x; i++){
		if (!(x%i)) temp++;
	}
	return temp;
}


int main(){
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i+=2){
		if (coun(i) == 8) ans++;
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
fun main(args : Array<String>){
    val (W, a, b) = readLine()!!.split(' ').map{it.toInt()}
    val (left, right) = listOf(a, b).sorted()

    when(right){
        in left + 0..W -> println(0)
        else -> println(right - left - W)
    }
}

Measured memory_bytes: 30280
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define x first
#define y second

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

template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}

vector<vector<pll>> E;

vector<pll> solve(int u, ll T) {
    if (E[u].empty()) {
        return {{0LL,0LL}};
    } else {
        auto A = solve(E[u][0].x, T);
        auto B = solve(E[u][1].x, T);
        for (auto &a: A) { a.x += E[u][0].y; a.y += E[u][0].y; }
        for (auto &b: B) { b.x += E[u][1].y; b.y += E[u][1].y; }
        vector<pll> Ans;
        for (int t = 0; t < 4; ++t) {
            int i = 0;
            for (pll a: A) {
                while (i < B.size() && B[i].y + a.x > T) ++i;
                if (i != B.size()) Ans.emplace_back(min(a.y,B[i].x),max(a.y,B[i].x));
            }
            
            if (t == 1) {
                for (pll&a:A) swap(a.x, a.y);
                reverse(A.begin(),A.end());
            } else {
                for (pll&b:B) swap(b.x, b.y);
                reverse(B.begin(),B.end());
            }
        }

        sort(Ans.begin(),Ans.end());
        vector<pll> F;
        for (pll ans: Ans) if (F.empty() || F.back().y > ans.y) F.push_back(ans);
        return F;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    E.resize(N);
    for (int i = 1; i < N; ++i) {
        int p, c; cin >> p >> c;
        --p;
        E[p].push_back({i,c});
    }

    cout << bsl(0LL, 18000000000LL, [](ll v) {
        auto s = solve(0, v);
        return !s.empty();
    }) << endl;
}


Measured memory_bytes: 22784
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int judge(string s){
	for(int i=0;i<s.length();i++){
		if(s[i]!=s[s.length()-1-i]){
			return 0;
		}
	}
	return 1;
}
int main() {
	string s;
	cin>>s;
	int f1=0,f2=0,f3=0;
	int n = s.length();
	string s1 = s.substr(0,(n-1)/2);
	string s2 = s.substr((n+3)/2-1,(n-(n+3)/2)+1);
	if(judge(s)&&judge(s1)&&judge(s2)){
		cout<<"Yes\n";
	}
	else {
		cout<<"No\n";
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int s{}; cin >> s;
  std::unordered_set<int> res{};

  ui ans{1};
  int n{s};
  while(!res.count(n))
  {
    res.emplace(n);
    s = n;
    n = s % 2 ? 3*s + 1 : s / 2;
    ++ans;
  }


  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  long long N, A, B;
  cin >> N >> A >> B;
  vector<long long> h(N);
  rep(i, N)
  {
    long long hp;
    cin >> hp;
    h[i] = hp;
  }

  int l = 0;
  int r = 1e9;

  while (r - l != 1)
  {
    long long c = (l + r) / 2;
    long long cnt = 0;
    rep(i, N)
    {
      long long offset_damage = B * c;
      long long hp = h[i] - offset_damage;
      if (hp > 0)
        cnt += (hp + A - B - 1) / (A - B);
    }
    if (cnt <= c)
      r = c;
    else
      l = c;
  }
  int ans = r;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
s = input()
n = len(s) - 1
res = 0
for i in range(1 << n):
    num_str = s[0]
    for j in range(n):
        if i >> j & 1 == 0:
            num_str += s[j + 1]
        else:
            res += int(num_str)
            num_str = s[j + 1]
    res += int(num_str)

print(res)


Measured memory_bytes: 9172
import java.util.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] d=new int[n];
		Arrays.fill(d,-1);
		for(int m=s.nextInt();m>0;--m){
			int e=s.nextInt()-1;
			int c=s.nextInt();
			if(n>1&&e+c==0||d[e]>0&&d[e]!=c){
				System.out.println(-1);
				return;
			}
			d[e]=c;
		}
		for(int i=0;i<n;++i)
			if(d[i]<0)
				d[i]=i<1&&n>1?1:0;
		System.out.println(Arrays.toString(d).replaceAll("\\D",""));
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

#define REPI(i, a, n)	for(ll (i)=(a);(i)<(int)(n);(i++))
#define REP(i,n) REPI(i,0,n)
#define REP1(i,n) for(ll (i)=1;(i)<=(n);(i++))
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
 
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;
 
	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
 
/*template<class T>
void VecUniqErs(vector<T> *v) {
	std::sort(ALL(v));
	&v.erase(unique(ALL(&v)), &v.end());
}*/

template<class T, class S>
bool contains(std::vector<T> vec, S number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll fact(ll n) {
	ll m;
	if (n == 0) {
		return 1;
	}
	m = fact(n - 1);
	return n * m;
}
 
ll Combination(unsigned long long n, unsigned long long r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
 
struct vec {
	ll x, y;
 
	bool operator == (const vec &v) const{
		return x == v.x && y == v.y;
	}
 
};
 
namespace std {
	template<>
	class hash<vec> {
	public:
		size_t operator () (const vec& p) const { return p.x%SIZE_MAX; }
	};
}

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

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

int main() {
	ll N;
	ll v[100010][3];

	cin>>N;
	REP(i,N){
		cin >> v[i][0] >> v[i][1] >> v[i][2];
	}
	ll dp[100010][3];
	REP(i,100010){
		REP(j,3){
			dp[i][j] = 0;
		}
	}

	REP1(i,N){
		REP(j,3){
			REP(k,3){
				if(j==k) continue;
				chmax(dp[i][j], dp[i - 1][k] + v[i - 1][j]);
			}
		}
	}
	ll res = 0;
	REP(i, 3) chmax(res,dp[N][i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>

using namespace std;

int main(){
  int outHigh[3],inHigh[10];
  int where;
  outHigh[0]=0;
  outHigh[1]=0;
  outHigh[2]=0;

  for(int i = 0; i < 10; i++){
    cin>>inHigh[i];
  }
  
  for(int j = 0; j < 3; j++){
    for(int i = 0; i < 10; i++){
      if(outHigh[j] < inHigh[i]){
	outHigh[j] = inHigh[i];
	where = i;
      }	
    }
    inHigh[where] = 0;
  }
  for(int i = 0; i < 3; i++){
    cout << outHigh[i]<<endl;
  }
  
}

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

// clang-format off
#define rep(i, n) for(int i=0; i< (n); i++)
#define reps(i, a, n) for(int i=a; i < (n); i++)

const int INF{1001001001};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

int main(){
    int a,b;
    cin >> a >> b;
    
    if(a > 8 || b > 8)cout << ":(";
    else cout << "Yay!";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    int A[n][m];
    int B[m][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>B[i][j];
        }
    }
    long C[n][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            C[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout<<C[i][j];
            if(j!=l-1) cout<<' ';
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;

#define pb push_back

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

    ll t,s;
    ll lim=1000000000;
    cin>>s;
    ll r=(lim-s%lim)%lim;
    ll k=(r+s)/lim;
    cout<<0<<" "<<0<<" "<<lim<<" "<<1<<" "<<r<<" "<<k;


    return 0;
}



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

int main(){
  string s;
  cin >> s;
  int ansa =0, ans =0;
  sort(s.begin(),s.end());
  for(int i=1;i<4;i++){
    if(s.at(0)==s.at(i)){
      ans++;
    }
  }
  for(int i=2;i>-1;i--){
    if(s.at(3)==s.at(i)){
      ansa++;
    }
  }
  if(ans==1&&ansa==1){
    cout << "Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}
int fp(int a,int b){
	if(b==0) return 1;
	int x=fp(a,b/2);
	x=(x*x)%mod;
	if(b&1) x=(x*a)%mod;
	return x;
}
 
signed main()
{
    crap;
    int n,m;
    cin>>n>>m;
    int a[n],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n,greater<int>());
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=((1.0/(4*m))*sum))
        c++;
    }
    if(c>=m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

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

using ll = long long;

int N, M;
vector<int> a(100001);

ll lcm(ll a, ll b){
    return a * b / __gcd<ll>(a, b);
}

void solve(){
    for(int i = 1; i <= N; ++i){
        a[i] /= 2;
    }

    ll cm = lcm(a[1], a[1]);
    for(int i = 2; i <= N; ++i){
        cm = lcm(cm, a[i]);
    }

    bool has_odd = false;
    bool has_even = false;
    for(int i = 1; i <= N; ++i){
        if((cm / a[i]) % 2 == 1) has_odd = true;
        else has_even = true;
    }
    if(has_even) { cout << 0; return; }
    else cout <<  (M / cm + 1) / 2;
}
int main(){
    cin >> N >> M;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }
    solve();
    return 0;
}

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

using int64 = long long;

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

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

    // a_0を正の数にする
    int64 sum1 = 0;
    int64 ans1 = 0;
    for (int i = 0; i < n; i++) {
        sum1 += a[i];
        if (i % 2 == 0) {   // 正の数
            ans1 += max(0LL, -sum1 + 1);
            sum1 = max(1LL, sum1);
        } else {    // 負の数
            ans1 += max(0LL, sum1 + 1);
            sum1 = min(-1LL, sum1);
        }
    }

    // a_0を負の数にする
    int64 sum2 = 0;
    int64 ans2 = 0;
    for (int i = 0; i < n; i++) {
        sum2 += a[i];
        if (i % 2 == 1) {
            ans2 += max(0LL, -sum2 + 1);
            sum2 = max(1LL, sum2);
        } else {
            ans2 += max(0LL, sum2 + 1);
            sum2 = min(-1LL, sum2);
        }
    }

    cout << min(ans1, ans2) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int a, b;
  cin >> a >> b;

  int c = stoi(to_string(a) + to_string(b));

  for (int i = 0; i * i <= c; i++)
  {
    if (i * i == c)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

using namespace std;

vector<int> edge[10];
int dp[1024][10];

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dp[1][0] = 1;
    for (int mask = 2; mask < (1 << n); mask++){
        for (int u = 0; u < n; u++){
            if (mask & (1 << u)){
                for (auto v: edge[u]){
                    if (mask & (1 << v)){
                        dp[mask][u] += dp[mask ^ (1 << u)][v];
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans += dp[(1 << n) - 1][i];
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rrep(i,n) for(int i=1; i<n; i++)
using vi = vector<int>;

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    if (a % k == 0)cout << "OK" << '\n';
    else if (b % k == 0)cout << "OK" << '\n';
    else if(a / k != b / k)cout << "OK" << '\n';
    else cout << "NG" << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

vector<vector<int>> to;
int n;
int m;

bool bfs(int i, int j) {
	vector<int> v(n);
	queue<int> q;
	q.push(i);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		if (v[p]) continue;
		v[p] = 1;
		for (int t: to[p]) {
			if ((p == i && t == j) || (p == j && t == i)) continue;
			q.push(t);
		}
	}
	bool b = false;
	rep(i,n) if (!v[i]) b = true;
	return b;
}

void solve() {
	cin >> n >> m;
	to.resize(n);
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	int ans = 0;
	rep(i,n) {
			for (int j: to[i]) {
				if (bfs(i, j)) ans++;
			}
	}
	cout << ans / 2 << endl;
}

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

Measured memory_bytes: 3596
n = int(input())

ans = False
for i in range(n // 4 + 1):
    if ans:
        break
    for j in range(n // 7 + 1):
        if 4 * i + 7 * j == n:
            ans = True
            break
    
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n,k;
  cin >> n >> k;
  map<int,int> mp;
  rep(i,n){
    int a; cin>>a;
    mp[a]++;
  }
  if(mp.size()<=k){cout << 0 << endl; return 0;}
  int cnt=mp.size()-k;
  vector<int> t;
  for(auto it:mp){
    t.emplace_back(it.S);
  }
  sort(t.begin(),t.end());
  int ans=0;
  rep(i,cnt){
    ans += t[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10748
n = int(input())

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

ans = sum([dams[x]*(-1)**x for x in range(n)])
out = str(ans)

ansList = [0 for x in range(n)]

ansList[0] = ans

for i in range(1, n):
  ans = -1 * ans + 2 * dams[i - 1]
  ansList[i] = ans
  
print(*ansList)
  


Measured memory_bytes: 66276
import sys
from collections import deque
import itertools

def input(): return sys.stdin.readline().strip()

icase=0
if icase==0:
    h,w=map(int,input().split())
    ch,cw=map(int,input().split())
    ch-=1
    cw-=1
    dh,dw=map(int,input().split())
    dh-=1
    dw-=1
    s=[[] for i in range(h)]
    for i in range(h):
        s[i]=input()
        
ij=[(1,0),(-1,0),(0,1),(0,-1)]
wpij=[(1,1),(-1,-1),(-1,1),(1,-1),
      (2,-2),(2,-1),(2,0),(2,1),(2,2),
      (-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),
      (1,2),(0,2),(-1,2),(1,-2),(0,-2),(-1,-2)]

hh=[i for i in range(h)]
ww=[i for i in range(w)]

g=[[[] for i in range(w)] for i in range(h)]
gg=[[[] for i in range(w)] for i in range(h)]
wpg2=[[0]*w for i in range(h)]
wpg=[]

hhww=[(i,j) for i,j in itertools.product(hh,ww) if s[i][j]=="."]
                
for i,j in hhww:
    g[i][j]=[(i+ii,j+jj) for ii,jj in ij if (0<=(i+ii)<h and 0<=(j+jj)<w and s[i+ii][j+jj]==".")] 
    if i+1<h and s[i+1][j]=="#": wpg2[i][j]=1
    elif 0<=i-1 and s[i-1][j]=="#": wpg2[i][j]=1
    elif j+1<w and s[i][j+1]=="#": wpg2[i][j]=1
    elif 0<=j-1 and s[i][j-1]=="#": wpg2[i][j]=1

wpg=[(i,j) for i,j in hhww if wpg2[i][j]>=1 ]
                
for i,j in wpg:
    gg[i][j]=[(i+ii,j+jj) for ii,jj in wpij if (0<=i+ii and i+ii<h and 0<=j+jj and j+jj<w and s[i+ii][j+jj]==".")]

q=deque([(ch,cw)])
qq=deque()
parent=[[-1]*w for i in range(h)]
parent[ch][cw]=0
dist=[[-1]*w for i in range(h)]
dist[ch][cw]=0
while True:
    while q:
#        print("q1:",q)
        hi,wi = q.popleft()
        if len(gg[hi][wi])>0:
            qq.append((hi,wi))
        for hj,wj in g[hi][wi]:
            if parent[hj][wj] !=-1:
                continue
            else:
                parent[hj][wj]=(hi,wi)
                dist[hj][wj]=dist[hi][wi]+1
                q.append((hj,wj))
                if hj==dh and wj==dw:
                    print(dist[dh][dw]//(10**7))   
                    sys.exit()

    while qq:
        hi,wi = qq.popleft()
        for hj,wj in gg[hi][wi]:
            if parent[hj][wj]!=-1:
                continue
            parent[hj][wj]=(hi,wi)
            dist[hj][wj]=dist[hi][wi]+10**7
            q.append((hj,wj))
            if hj==dh and wj==dw:
                print(dist[dh][dw]//(10**7))   
                sys.exit()

    if len(q)==0:
        break
print(-1)   


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL N;
LL ans[99];

int main(){
	cin >> N;
	ans[0] = 2; ans[1] = 1;
	repp(i,1,N) ans[i+1] = ans[i] + ans[i-1];
	cout << ans[N] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		if(N%2==0){
			if(K<=N/2)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
		else
			if(K<=(N/2)+1)
				System.out.println("YES");
			else
				System.out.println("NO");
	}
}


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

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

  ll a[100005];
  bool zero=false;
  for (int i=0; i<n; i++) {
    cin>>a[i];
    if (a[i]==0) {
      zero=true;
    }
  }
  ll sum=0;
  if (zero) {
    for (int i=0; i<n; i++) {
      sum+=abs(a[i]);
    }
  }
  else {
    for (int i=0; i<n; i++) {
      sum+=abs(a[i]);
    }
    int cnt_m=0;
    for (int i=0; i<n; i++) {
      if (a[i]<0) cnt_m++;
    }
    if (cnt_m%2==1) {
      ll e=1e18;
      for (int i=0; i<n; i++) {
	e=min(e,abs(a[i]));
      }
      sum-=e*2;
    } 
  }
  
  cout<<sum<<endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	sort(a.begin(), a.end());

	unordered_map<ll, ll> mp;
	for (int i = 0; i < N; ++i) {
		mp[a[i]] += 1;
	}

	ll res = 0;
	for (int t = 35; t >= 0; --t) {
		ll x = pow(2, t);
		if (a[N - 1] + a[N - 2] < x) { continue; }
		for (int i = N - 1; i >= 0; --i) {
			if (mp[a[i]] == 0) { continue; }
			if (a[i] > x) { continue; }

			ll y = x - a[i];
			if (y == a[i]) {
				if (mp[y] >= 2) {
					mp[y] -= 2;
					++res;
				}
			} else if (mp[y] > 0) {
				mp[a[i]] -= 1;
				mp[y] -= 1;
				++res;
			}
		}
		if (N - res*2 < 2) { break; }
	}

	cout << res << endl;

	return 0;
}


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

#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;



void solve()
{
	int n;
	cin >> n;
	ld ans = 0;
	for (int k = 1; k <= n; k++)
	{
		ans += ((ld)k / 2) * (n / k) * (1 + (n / k));
	}

	cout << (ull)ans;
}

int main()
{

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

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

	int t = 1;
	// cin >> t;

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

	return 0;
}




Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>

int a[101000], b[101000]; int n; 

long long check(int type)
{
	long long sum = 0;
	for(int i = 1, j = n - 2; i <= j; i++, j--)
	{
		if(type == 0)
		{
			sum += b[j] - b[i];
			if(i + 1 <= j) sum += b[j] - b[i + 1];
		}
		if(type == 1)
		{
			sum += b[j] - b[i];
			if(i <= j - 1) sum += b[j - 1] - b[i];
		}
	}
	return sum;
}
int main()
{
	long long sum = 0, sum2 = 0; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + 1);
	if(n == 2) return 0 * printf("%d\n", a[2] - a[1]);
	if(n & 1)
	{
		int u = a[n / 2 + 1], v = a[n / 2 + 2];
		for(int i = 1; i < n / 2 + 1; i++) b[i] = a[i];
		for(int i = n / 2 + 3; i <= n; i++) b[i - 2] = a[i];
		sum = check(0) + u - a[1] + v - a[n / 2];
		u = a[n / 2], v = a[n / 2 + 1];
		for(int i = 1; i < n / 2; i++) b[i] = a[i];
		for(int i = n / 2 + 2; i <= n; i++) b[i - 2] = a[i];
		sum2 = check(1) + a[n] - u + a[n / 2 + 2] - v;
		printf("%lld\n", std::max(sum, sum2));
	}
	else
	{
		int u = a[n / 2], v = a[n / 2 + 1];
		for(int i = 1; i < n / 2; i++) b[i] = a[i];
		for(int i = n / 2 + 2; i <= n; i++) b[i - 2] = a[i];
		sum = check(0) + v - a[1] + a[n / 2 + 2] - u;
		sum2 = check(1) + a[n] - u + a[n / 2 - 1] - v;
		printf("%lld\n", std::max(sum, sum2));
	}
	return 0;
}

Measured memory_bytes: 896
A = [
    list(map(int, input().split())),
    list(map(int, input().split())),
    list(map(int, input().split()))
]
N = int(input())
B = [int(input()) for i in range(N)]
if ((A[0][0] in B and A[0][1] in B and A[0][2] in B)
    or (A[1][0] in B and A[1][1] in B and A[1][2] in B)
    or (A[2][0] in B and A[2][1] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][0] in B and A[2][0] in B)
    or (A[0][1] in B and A[1][1] in B and A[2][1] in B)
    or (A[0][2] in B and A[1][2] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
    or (A[0][2] in B and A[1][1] in B and A[2][0] in B)):
    print("Yes")
else:
    print("No")

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

int n, m;
int arr[510][510]; 

#define pii pair <int, int>
vector <pii> v;
queue <pii> q;

void DFS(int x, int y) 
{
	if (x > n) return;  
//	printf("%d %d\n", x, y);
	if (arr[x][y])
	{
		while (!q.empty()) v.push_back(q.front()), q.pop();
		arr[x][y] = 0;
		return;
	}
	int nx, ny;
	if (x & 1)  
	{
		if (y == m)
		{
			nx = x + 1;
			ny = y;
		}
		else
		{
			nx = x;
			ny = y + 1;
		}
	}
	else
	{
		if (y == 1)
		{
			nx = x + 1;
			ny = y;
		}
		else
		{
			nx = x;
			ny = y - 1;
		}
	}
	q.emplace((x - 1) * m + y - 1, (nx - 1) * m + ny - 1);
	DFS(nx, ny);
}

int main()
{
	while (scanf("%d%d", &n, &m) != EOF)
	{
		v.clear();
		while (!q.empty()) q.pop();
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= m; ++j)
			{
				scanf("%d", &arr[i][j]);
				arr[i][j] &= 1;
				
			}
		for (int i = 1; i <= n; ++i) for (int j = (i & 1) ? 1 : m; (i & 1) ? j <= m : j >= 1; (i & 1) ? ++j : --j) if (arr[i][j]) 
		{
			arr[i][j] = 0;
			while (!q.empty()) q.pop();
			DFS(i, j);
		}
		printf("%d\n", (int)v.size());
		for (int i = 0, len = v.size(); i < len; ++i)
		{
			int fi = v[i].first, se = v[i].second;
			printf("%d %d %d %d\n", (fi / m) + 1, fi % m + 1, (se / m) + 1, se % m + 1); 
		}
	}
	return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll b = K + 1; b <= N; ++b){
        ans += (b - K) * ((N + 1) / b) + max((N + 1) % b - K, 0LL);
        if(K == 0) --ans;
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
N=int(input())
MOD=10**9 + 7
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
t=1
l=[]
x=dict()
ans=1
for i in range(1,N+1):
    t=t*i
    a=make_divisors(i)
    for j in range(len(a)):
        if a[j] in x:
            x[a[j]]=0
        else:
            x[a[j]]=0
for idx in x:
    a=make_divisors(idx)
    if len(a)==2:
        l.append(idx)


for i in range(1,N+1):
    n=i
    for j in range(len(l)):
        count=0
        while(1):
            if n%l[j]==0:
                n=n//l[j]
                count+=1
            else:
                break
        x[l[j]]+=count
for idx in x:
    if x[idx]!=0:
        ans=ans*(x[idx]+1)

ans=ans%MOD
print(ans)

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

using namespace std;

int main(void) {
    long n;
    cin >> n;

    auto tail = [&](long a) {
        return (a%10);
    };
    auto head = [&](long a) {
        long r = a;
        while(r / 10) r /= 10;
        return r;
    };

    vector<vector<long>> d(10, vector<long>(10));

    for(long a=1; a<=n; a++) {
        long h = head(a);
        long t = tail(a);
        d[h][t]++;
    }

    long r = 0;
    for(long a=1; a<=n; a++) {
        long h = head(a);
        long t = tail(a);
        r += d[t][h];
    }

    cout << r<< endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{

    int n,s=0,k,i,h=0;
    cin>>k>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    s=a[n-1]-a[0];
    for(i=1;i<n;i++)
    {
        h=a[i]+(k-a[(i+1)%n]);
        if(h<s)
            s=h;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    string S;
    int count = 0;
    int maxCount = 0;
    cin >> S;
    for (int i = 0; i < 3; i++){
        if(S[i] == 'R'){
            count++;
        }else{
            maxCount = max(maxCount, count);
            count = 0;
        }
    }
    maxCount = max(maxCount, count);
    cout << maxCount << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int n;
  cin >> n;
  if(n<1000){
	cout << "ABC" << endl;
  }
  else{
	cout << "ABD" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

long long n;
int ans;

int dfs(bool f1, bool f2, bool f3, long long num){

    if(num > n) return 0;
    else if(f1 && f2 && f3) ans++;

    num = num * 10;
    dfs(true, f2, f3, num + 7);
    dfs(f1, true, f3, num + 5);
    dfs(f1, f2, true, num + 3);

}

int main(){
    cin >> n;
    dfs(false, false, false, 0);
    cout << ans << endl;
}

Measured memory_bytes: 256
h1,m1,h2,m2,k=input().split()
h1=int(h1)
h2=int(h2)
m1=int(m1)
m2=int(m2)
k=int(k)
#print(h1,end=":")
#print(m1)
#print(h2,end=":")
#print(m2)
#print(k)
h3=0
m3=0
m3=m2-m1
h3=h2-h1


#print(h3*60,end="+")
#print(m3*60)
print(h3*60+m3-k)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
string str,s1,s2;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>str;
	int q,s=0,tot1=0,tot2=0;
	cin>>q;
	while(q--){
		int op;
		cin>>op;
		if(op==1)s=(s+1)%2;
		else{
			int a;
			char t;
			cin>>a>>t;
			if(s==1){
				if(a==1)a=2;
				else a=1;
			}
			if(a==1)s1=s1+t;
			else s2+=t;
		}
	}
	for(int i=0;i<s1.size()/2;i++)
	swap(s1[i],s1[s1.size()-i-1]);
	str=s1+str+s2;
	if(s==1){
		for(int i=str.size()-1;i>=0;i--)
		cout<<str[i];
		cout<<"\n";
	}
	else cout<<str<<"\n";
	return 0;
}


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

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= b && a <= c){
    if(b <= c){
      cout << b - a + c - b << endl;
    }else{
      cout << c - a + b - c << endl; 
    }
  }else
  if(b <= a && b <= c){
    if(a <= c){
      cout << a - b + c - a << endl;
    }else{
      cout << c - b + a - c << endl;
    }
  }else
  if(c <= a && c <= b){
    if(a <= b){
      cout << a - c + b - a << endl;
    }else{
      cout << b - c + a - b << endl;
    }
  }
}

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

int main()
{
    int N, A, B;
    int cnt = 0, bcnt = 0;
    string S;

    cin >> N >> A >> B;
    cin >> S;

    for(int i = 0; i < N; i++) {
        if(S[i] != 'c' && cnt < A + B) {
            if(S[i] == 'a') {
                cnt++;
                cout << "Yes" << endl;
            } else if(bcnt < B) {
                cnt++, bcnt++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }

    return (0);
}


Measured memory_bytes: 896