akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    x = list(int(_) for _ in input().split())
    ans = INF
    for i in range(N-K+1):
        l = i
        r = i + K-1
        ans_l = abs(x[l]) + abs(x[l]-x[r])
        ans_r = abs(x[r]) + abs(x[l]-x[r])
        ans = min(ans_l,ans_r,ans)
        
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14608
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100

using Weight = int;
struct Edge {
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s, int d, int w) : s(s), d(d), w(w) {};
};
using Edges = vector<Edge>;
//???????????\???
//g[u].push_back(Edge(u, v, c));
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };

//???????§????????????? (Dijkstra)
//?????????: ??????????????§????????¢
vector<Weight> dijkstra(Graph g, int s) {
	typedef pair<Weight, int> State; //?§?????????????????°?????????? ??????id
	priority_queue<State, vector<State>, greater<State> >PQ;
	vector<int> color(g.size(), WHITE);
	vector<Weight> dist(g.size(), INF); //distance
	dist[s] = 0; PQ.push(State(0, s)); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v;
		tie(d, v) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????	
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		for (auto e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.push(State(dist[e.d], e.d));
				color[e.d] = GRAY;
			}
		}
	}
	return dist;
}

int main() {
	int n; cin >> n;
	Graph g(n);
	for (int i = 0; i < n; i++) {
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c; cin >> v >> c;
			g[u].push_back(Edge(u, v, c));
		}
	}
	vector<Weight> ans = dijkstra(g, 0);
	for (int i = 0; i < n; i++) {
		cout << i << " " << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e9+7;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<pair<ll,ll>>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    while (n % 2 == 0)  
    {  
        mp[2]++;
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            mp[i]++;
            n = n/i;  
        }  
    }  
    if (n > 2){ 
        mp[n]++; 
    } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n;
        cin>>n;
        long double p[n];
        for(ll x=0; x<n; x++){
            cin>>p[x];
        }
        long double dp[n+1][n+1];
        //memset(dp,0,sizeof(dp));
        for(ll x=0; x<=n; x++){
            for(ll y=0; y<=n; y++){
                dp[x][y]=0.00000000;
                if(x==0){
                    dp[x][y]=0;
                }
                else if(y==0){
                    dp[x][y]=p[x-1]*dp[x-1][y];
                }
                else if(x>=y){
                    dp[x][y]=dp[x-1][y]*p[x-1]+dp[x-1][y-1]*(1.0000-p[x-1]);
                }
                else{
                    continue;
                }
                dp[1][0]=p[0];
                dp[1][1]=1.000000000-p[0];
                //cout<<dp[x][y]<<" ";
            }
            //cout<<"\n";
        }
        long double ans=0;
        for(ll x=0; x<=n/2; x++){
            ans+=dp[n][x];
        }
        cout<<setprecision(10);
        cout<<fixed<<ans<<"\n";
        //printf("%0.10llf\n",ans);
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 140928
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

bool solve(const vector<int>& as)
{
    int n = as.size();

    if (abs(as[n - 1] - as[0]) >= 2) {
        return false;
    }

    int a = 1;
    for (int i = 1; i < n; i++) {
        if (as[i] == as[0]) {
            a++;
        }
    }
    int b = n - a;

    if (b == 0) {
        if (as[0] == n - 1)
            return true;
        if (n >= 2 * as[0])
            return true;
        return false;
    }

    if (b == 1) {
        return false;
    }

    int max_col = a + b / 2;
    int min_col = a + 1;
    return min_col <= as[n - 1] && as[n - 1] <= max_col;
}

int main()
{
    cin.tie(0);
    int n;
    cin >> n;

    vector<int> as(n);
    for (auto& a : as)
        cin >> a;

    sort(as.begin(), as.end());

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

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX = 1000000000;

int main()
{
    string s;
    cin >> s;if(s == "ABC"){
        cout << "ARC";
    }
    else{
        cout << "ABC";
    }
} 


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

int main() {
    string s;
    cin >> s;
    int count=0;
    for(int i=0;  i<3; i++){
        if(s.at(i)=='o'){
            count++;
        }
    }
    cout << 700 + count*100 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K,ans=0;
    int h[100005];
    scanf("%d%d",&N,&K);
    for(int i=1;i<=N;i++){
        scanf("%d",&h[i]);
    }
    for(int i=1;i<=N;i++){
         if(h[i]>=K)ans++;
    }
    printf("%d",ans);
}


Measured memory_bytes: 768
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


inline li gcd(li a,li b) // a>b;
{
    if(b==0) return a;
    a%=b;
    return gcd(b,a); 
}

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((c%gcd(max(a,b),min(a,b))==0)?"YES":"NO")<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    int M = 1e6 + 5;
    vector<int> cnt(M,0);

    for(int x : a){
        if(cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for(int i=x; i<M; i+=x) cnt[i]++;
    }

    int ans = 0;
    for(int x : a){
        if(cnt[x] == 1) ans++;
    }
    cout(ans);

    return 0;
}

Measured memory_bytes: 8796
#include <iostream>
#include <string>
using namespace std ;
int main()
{
	string s , t, u ;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==s)
		a-=1;
	else if (u==t)
		b-=1;
	cout<<a<<"\n"<<b<<"\n";
return 0 ;
}

Measured memory_bytes: 256
import sys
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

n, X, *x = map(int, sys.stdin.read().split())

def main():
    x.append(X)
    for i in range(n):
        x[i] -= x[i+1]
    x[-1] -= X
    
    return reduce(gcd, x)

if __name__ == '__main__':
    ans = main()
    print(ans)

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

const int maxn = 1<<18;
const int mod = 998244353;
int x[maxn],p[maxn],b[maxn];
const int inv2 = mod/2+1;
int add(int a,int b)
{
    a+=b;
    if(a>=mod)  return a-mod;
    return a;
}
int sub(int a,int b)
{
    a-=b;
    if(a<0) return a+mod;
    return a;
}
int mul(int a,int b)
{
    long long t=1ll*a*b;
    return t-t/mod*mod;
}
int qp(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans=mul(ans,a);
        a=mul(a,a);
        b>>=1;
    }
    return ans;
}
int inv(int a)
{
    return qp(a,mod-2);
}
void fwt(int x[],int n,int opt=1)
{
    for(int i=1;i<n;i<<=1)
        for(int p=i<<1,j=0;j<n;j+=p)
            for(int k=0,a,b;k<i;++k)
            {
                a=x[j+k],b=x[i+j+k];
                x[j+k]=add(a,b);    if(opt==-1) x[j+k]=mul(x[j+k],inv2);
                x[j+k+i]=sub(a,b);  if(opt==-1) x[j+k+i]=mul(x[j+k+i],inv2);
            }
}
int main()
{
    int n;
    int s=0;
    ios::sync_with_stdio(false);
    cin>>n; n=1<<n;
    for(int i=0;i<n;++i)
        cin>>p[i];
    for(int i=0;i<n;++i)
        s+=p[i];
    s=inv(s);
    for(int i=0;i<n;++i)
        p[i]=mul(p[i],s);
    p[0]=sub(p[0],1);
    for(int i=1;i<n;++i)
        b[i]=sub(0,1);
    b[0]=sub(n,1);
    fwt(p,n);
    fwt(b,n);
    x[0]=s;
    for(int i=1;i<n;++i)
        x[i]=mul(b[i],inv(p[i]));
    fwt(x,n,-1);
    for(int i=n-1;i>=0;--i)
        x[i]=sub(x[i],x[0]);
    for(int i=0;i<n;++i)
        cout<<x[i]<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

vector<lint> A(3);

int main()
{
    cin >> A;
    for (auto v : A) if (v % 2 == 0)
    {
        puts("0");
        return 0;
    }
    sort(A.begin(), A.end());
    cout << A[0] * A[1] << endl;
}


Measured memory_bytes: 256
void main()
{
    long n, k;
    rdVals(n, k);

    long[] list = new long[k+1];
    long result;
    foreach_reverse (i; 1 .. k+1)
    {
        list[i] = (list[i] + modPow(k/i, n)) % mod;
        result = (result + list[i] * i % mod) % mod;
        foreach (d; divisors(i))
        {
            if (d == i) continue;
            list[d] = (list[d] - list[i] + mod) % mod;
        }
    }

    result.writeln;
}

long modPow(long x, long y)
{
    long result = 1;
    while (y > 0)
    {
        if (y & 1) result = result * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return result;
}

long[] divisors(long x)
{
    long[] result;
    for (long i = 1; i * i <= x; ++i)
    {
        if (x % i == 0)
        {
            result ~= i;
            if (i != x / i) result ~= x / i;
        }
    }

    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 4472
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>

using std::min;
using std::cin;
using std::cout;
using std::endl;
const int N = 2010;
int _w;

int n, k, ans;

namespace Tree {
	int head[N], nxt[N*2], to[N*2], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
		to[eid] = u, nxt[eid] = head[v], head[v] = eid++;
	}
}

int f[N], g[N], fk, gk, sz[N];

void dfs( int u, int fa, int d ) {
	using namespace Tree;
	sz[u] = 1;
	f[u] = d <= fk;
	g[u] = d <= gk;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		if( v == fa ) continue;
		dfs(v, u, d+1);
		sz[u] += sz[v];
		f[u] += f[v];
		g[u] += g[v];
	}
}

int solve( int u ) {
	using namespace Tree;
	memset(f, 0, sizeof f);
	memset(g, 0, sizeof g);
	fk = gk = k/2, gk += k&1;
	int fs = 0;
	for( int i = head[u]; ~i; i = nxt[i] ) {
		int v = to[i];
		dfs(v, u, 1);
		f[v] = sz[v] - f[v];
		g[v] = sz[v] - g[v];
		fs += f[v];
	}
	int ans = fs;
	if( k & 1 )
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			ans = min( ans, fs - f[v] + g[v] );
		}
	return ans;
}

int main() {
	cin >> n >> k, ans = n;
	Tree::init();
	for( int i = 0; i < n-1; ++i ) {
		int u, v;
		cin >> u >> v;
		Tree::link(u, v);
	}
	for( int i = 1; i <= n; ++i )
		ans = min( ans, solve(i) );
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 384
sx, sy, tx, ty = map(int, input().split())
 
dx = abs(tx - sx)
dy = abs(ty - sy)

s = ["L"]+["U"]*(dy+1)+["R"]*(dx+1)+["D"] + ["R"]+["D"]*(dy+1)+["L"]*(dx+1)+["U"] + ["U"]*dy+["R"]*dx + ["D"]*dy+["L"]*dx
print("".join(s))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	int maxn=0;
	map<string,int> sn;
	map<int,vector<string> > ns;
	while(n--){
		cin>>s;
		sn[s]++;
		if(maxn<=sn[s]){
		    maxn = sn[s];
			ns[sn[s]].push_back(s);
		}
	}
	int nn = ns[maxn].size();
	sort(ns[maxn].begin(),ns[maxn].end());
	for(int i=0;i<nn;i++){
		cout<<ns[maxn][i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    
    ll N, K; cin >> N >> K;
    vector<ll> p(N);
    rep(i,N) cin >> p[i];
    vector<ll> cum(N+1);
    rep(i,N){
        cum[i+1] = cum[i] + (p[i]+1);
    }
    ll mx = 0;
    rep(i,N){
        if (i+K > N) break;
        mx = max(mx, (cum[i+K] - cum[i]));
    }
    double ans = mx/2.0;
    //ans /= 2;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 6400
import sys
n, a, b, c, d = map(int, input().split())
s = input()
snuke, fnuke, gnuke = 0, 0, 0
s_max, f_max, g_max = 0, 0, 0
for i in range(a-1, c):
	if s[i] == "#":
		snuke += 1
		s_max = max(s_max, snuke)
	else:
		snuke = 0
for i in range(b-1, d):
	if s[i] == "#":
		fnuke += 1
		f_max = max(f_max, fnuke)
	else:
		fnuke = 0
if c>d:
	for i in range(b-2, d+1):
		if s[i] == ".":
			gnuke += 1
			g_max = max(g_max, gnuke)
		else:
			gnuke = 0

if s_max > 1 or f_max > 1:
	print("No")
elif c < d:
	print("Yes")
else:
	if g_max >= 3:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int memo=0;
  int ans=0;
  int sum=0;
  int Xor=0;
  for(memo;memo<N;memo++){
      sum+=A[memo];
      Xor^=A[memo];
      if(sum!=Xor){
        sum-=A[memo];
        Xor^=A[memo];
        break;
      }
    }
  ans=memo;
  rep(i,1,N){
    sum-=A[i-1];
    Xor^=A[i-1];
    for(memo;memo<N;memo++){
      sum+=A[memo];
      Xor^=A[memo];
      if(sum!=Xor){
        sum-=A[memo];
        Xor^=A[memo];
        break;
      }
    }
    ans+=memo-i;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 1920
nums=gets.strip.split(" ").map do |i|
  i.to_i
end
n=nums[0]
k=nums[1]
s=nums=gets.strip.split(" ").map do |i|
  i.to_i
end
now=1
tele_num=0
a = Array.new(n,nil)
a[0] = 0
flag=false
#puts "tele_num #{tele_num} now #{now}"
while tele_num < k
  next_pos = s[now-1]
  tele_num+=1
  #puts "tele_num #{tele_num} next_pos #{next_pos}"
  if a[next_pos].nil? || flag
    a[next_pos] = tele_num
  else
    #puts "tele_numff #{tele_num}"
    #puts "next_pos #{a[next_pos]}"
    loop_num = tele_num - a[next_pos]
    #puts "loop_num #{loop_num}"
    t=((k - tele_num) / loop_num).to_i 

    tele_num += (t*loop_num)
    flag=true
  end
  now = next_pos
end
puts now

Measured memory_bytes: 30172
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int k;
    cin>>k;
    int sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                sum += __gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3628
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]

dp = [[0] * 3 for _ in range(n)]
dp[0] = abc[0]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + abc[i][j])
print(max(dp[n - 1]))

Measured memory_bytes: 74712
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

#define INF 1e+9

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<int, int>;

int N;
vector<edge> G[2005];
int d[2005];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + N, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> N >> X >> Y;
    REP(i, N) {
        edge e = {i + 1, 1};
        G[i].push_back(e);
    }
    REP(i, N) {
        edge e = {i, 1};
        G[i + 1].push_back(e);
    }
    G[X - 1].push_back({Y - 1, 1});
    G[Y - 1].push_back({X - 1, 1});

    map<ll, ll> m;
    REP(j, N) {
        dijkstra(j);
        for (int i = 0; i < N; ++i) {
            if (d[i] != INF) {
                m[d[i]]++;
            }
        }
    }
    FOR(i, 1, N) { cout << m[i] / 2 << endl; }
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int X, Y;
ll DP[1000001]; // n回動かした時に、たどり着くか

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll kaizyo(ll a, int c) {
  ll b = 1;
  rep(i, c) {
    b *= a;
    b%=MOD;
    a--;
  }
  return b;
}

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

  cin >> X >> Y;
  if ((X+Y)%3!=0) {
    cout << 0 << "\n";
    return 0;
  }
  int cnt = (X+Y)/3;
  int p1 = X-cnt;
  int p2 = Y-cnt;
  if (p1<0 || p2<0) {
    cout << 0 << "\n";
    return 0;
  }
  assert(p1==cnt-p2);
  ll bunshi = kaizyo(cnt, p1);
  ll bunbo = kaizyo(p1, p1);
  
  cout << bunshi%MOD*modinv(bunbo, MOD)%MOD << "\n";
  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> m;
    ll a=0, b1=0, b2=0, c1=0, c2=0, d1=0, d2=0;
    frep(i, 2, n) {
        ll tmp = i;
        frep(j, 2, tmp) {
            if((tmp%j) == 0) {
                while((tmp%j) == 0) {
                    if(m.count(j)) m[j]++;
                    else m[j] = 1;
                    tmp /= j;
                }
            }
        }
    }
    for(auto p: m) {
        auto v = p.second;
        if(v >= 74) a++;

        if(2 <= v && v <= 23) b1++;
        else if(24 <= v) b2++;

        if(4 <= v && v <= 13) c1++;
        else if(14 <= v) c2++;

        if(2 <= v && v <= 3) d1++;
        else if(4 <= v) d2++;
    }
    ans += (a + b1*b2 + b2*(b2-1) + c1*c2 + c2*(c2-1) + \
            d1*d2*(d2-1)/2 + d2*(d2-1)*(d2-2)/2);
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string number;
	cin >> number;
	int answer = 0;
	for(int i=0; i<(int)number.length(); i++) {
		answer += number[i] - '0';
	}
	answer % 9 == 0 ? puts("Yes") : puts("No");
	return 0;
}


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

#define F first
#define S second

using namespace std;

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

const int N = 510, M = 35, INF = 0x3f3f3f3f;

int n, m;
int c[M][M], g[N][N];
vector<LL> sum;
vector<pair<LL, int> > a[3];

void get(int u)
{
	for (int t = 1; t <= m; t ++ )
	{
		LL sum = 0;
		for (int i = 1; i <= n; i ++ )
			for (int j = 1; j <= n; j ++ )
				if ((i + j) % 3 == u)
				{
					int p = g[i][j];
					sum += c[p][t];
				}
		a[u].push_back({sum, t});
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i ++ )
		for (int j = 1; j <= m; j ++ )
			cin >> c[i][j];
	for (int i = 1; i <= n; i ++ )
		for (int j = 1; j <= n; j ++ )
			cin >> g[i][j];
			
	for (int i = 0; i < 3; i ++ )
	{
		get(i);
		sort(a[i].begin(), a[i].end());
	}
	
	for (int i = 0; i < 3; i ++ )
		for (int j = 0; j < 3; j ++ )
			for (int k = 0; k < 3; k ++ )
				if (a[0][i].S != a[1][j].S && a[1][j].S != a[2][k].S && a[0][i].S != a[2][k].S)
					sum.push_back(a[0][i].F + a[1][j].F + a[2][k].F);
				
	LL res = INF;
	for (auto u : sum) res = min(res, u);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1280
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):

        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv


def main():
    N,K = map(int,input().split())
    A = [int(x) for x in input().split()]
    A = sorted(A,reverse=True)
    comb = Combination(10**5)
    ans = 0
    for i in range(0,N-K+1):
        ans += A[i]*comb((N-1)-i,K-1)
        ans %= 10**9+7
    for i in range(K-1,N):
        ans -= A[i]*comb(i,K-1)
        ans %= 10**9+7

    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 72488
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int main(){
	ios::sync_with_stdio(false);
	string a,b;cin>>a>>b;
	a=a+b;
	int t=0;
	for(int i=0;i<a.length();i++){
		t=t*10+a[i]-'0';
	}
	for(int i=1;i*i<=t;i++){
		if(i*i==t){
			cout<<"Yes"<<endl;return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
use utf8;
use warnings;
use strict;
use List::Util qw/sum/;

chomp(my $n = <STDIN>);
my @arr = ();
for my $i (<STDIN>){
    chomp($i);
    push(@arr, $i)
}
@arr = sort {$a <=> $b} @arr;
my $tot = sum @arr;
$tot%10 == 0? print del_minimum_number_not_divided_by_ten(\@arr) : print $tot;

sub del_minimum_number_not_divided_by_ten {
    my $arr = shift;
    for my $i (0..scalar(@$arr)-1) {
        if ($arr[$i]%10 == 0) {
            next
        } else {
            $arr[$i] = 0;
            if (sum(@$arr)%10 == 0) {
                return del_minimum_number_not_divided_by_ten($arr);
            } else {
                return sum(@$arr);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {};
    vector<int> b = {0};
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    reverse(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        if (a[i] >= b.back()) b.push_back(a[i]);
        else *upper_bound(b.begin(), b.end(), a[i]) = a[i];
    }
    cout << (int)b.size() - 1;
}


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

int main(){
    int H, N;
    cin >> H >> N;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        H -= a;
    }
    cout << (H<=0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    int n, dig;
    int ans = 0;
    scanf("%d", &n);

    while (n)
    {
        dig = n % 10;
        if (dig == 7)
        {
            puts("Yes");
            return 0;
        }
        n = n / 10;
    }

    puts("No");
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    long long rez = 0;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') c++;
        else rez += c;
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 640
import * as fs from 'fs';

const input: string = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const nextNumbers: number[][] = [];
for (let i = 0; i < 10; i++) {
  const tmp: number[] =
    [i + 9, i, i + 1]
      .map(x => x % 10)
      .filter(x => Math.abs(i - x) <= 1)
      .sort((x, y) => x - y);
  nextNumbers.push(tmp);
}

function getLunlun(n: number): number {
  let tmp = n - 1;
  let a: number[][] = [];
  for (let i = 1; i <= 9; i++) a.push([i]);
  if (tmp < a.length) return getNum(a[tmp])

  while (tmp >= a.length) {
    tmp -= a.length;
    let tmpArray: number[][] = [];
    a.forEach(array => {
      const nexts: number[] = nextNumbers[array[array.length - 1]];
      nexts.forEach(x => {
        const array2: number[] = [...array, x];
        tmpArray.push(array2);
      })
    });
    a = tmpArray;
  }
  return getNum(a[tmp])
}

function getNum(ns: number[]): number {
  return ns.reduce((x, y) => 10 * x + y)
}

const k = parseInt(args[0][0]);
console.log(getLunlun(k));

Measured memory_bytes: 58188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int R,r,N;
  string X;
  cin>>N>>X;
  R=0;
  r=0;
  for(int i=0; i<N; i++){
    if(X.at(i)=='R'){
    R++;
    }
  }
  for(int i=0;i<R; i++){
  if(X.at(i)=='R'){
  r++;
  }
  }
  cout<<R-r<<endl;
}

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

struct TXY{
    int t;
    int x;
    int y;
};

int distance(const struct TXY& lhs, const struct TXY& rhs){
    int dx = abs(lhs.x - rhs.x);
    int dy = abs(lhs.y - rhs.y);
    return dx + dy;
}

int main(){
    int N; cin >> N; N++;
    
    struct TXY txy_prev={0,0,0};
    for(int i=1; i<N; ++i){
        struct TXY txy_now;
        cin >> txy_now.t;
        cin >> txy_now.x;
        cin >> txy_now.y;
        
        int t = txy_now.t - txy_prev.t;
        int d = distance(txy_now, txy_prev);
//        if(t%d!=0){
        if((t+d)&1 || t<d){
            cout << "No";
            return 0;
        }
        txy_prev = txy_now;
    }
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(360*i%n==0)

        {
            cout<<((360*i)/n);
            return;
        }
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
       cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int a,b;
	cin >> a >>b;
	if (a ==1) {
		if (a == b) cout << "Draw" << endl;
		else cout << "Alice" << endl;
	return 0;
	}
	if (b ==1) {
		cout << "Bob" << endl;
	return 0;
	}
	if (a == b) cout << "Draw" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int N,a=0,b=0;

int poker[100];

int max() {
  int i, mx = -1, pos;
  for(i=0;i<N;i++) {
    if(mx < poker[i]) {
      mx = poker[i];
      pos = i;
    }
  }
  poker[pos] = -1;
  return mx;
}

int main() {
  scanf("%d",&N);
  int i;
  for(i = 0; i < N; i++) {
    scanf("%d", &poker[i]);
  }
  for(i = 0; i < N; i++) {
    if(i % 2 == 0) {
      a = a + max();
    }
    else {
      b = b + max();
    }
  }
  int ans = a - b;
  if(ans < 0) ans = -ans;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

const int NIL = -1;
const int MAX = 2147483647;
clock_t START, END;

bool debug = false;
int Tree[500010];
int n;

void update(int x)
{
	x = x / 2;
	while (x > 0) {
		Tree[x] = min(Tree[2 * x], Tree[2 * x + 1]);
		x = x / 2;
	}
}

int find(int x, int y, int k, int height, int N)
{
	int l, r;
	l = k * (1 << height) - N;
	r = l + (1 << height) - 1;
	if (x > r || y < l)
		return MAX;
	if (l > n)
		return MAX;
	if (l >= x && r <= y || height == 0)
		return Tree[k];
	if (y < (l + r) / 2 + 1)
		return find(x, y, 2 * k, height - 1, N);
	else if (x > (l + r) / 2)
		return find(x, y, 2 * k + 1, height - 1, N);
	else
		return min(find(x, y, 2 * k, height - 1, N), find(x, y, 2 * k + 1, height - 1, N));
}
int main(void)
{
	int t;
	if (debug) {
		START = clock();
		freopen("in12.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int q, com, x, y, N = 1, height = 0;
	scanf("%d%d", &n, &q);
	while (N < n) {
		N *= 2;
		height++;
	}
	for (int i = 0; i < 2 * N; i++)
		Tree[i] = MAX;
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &com, &x, &y);
		if (com) {
			t = find(x, y, 1, height, N);
			printf("%d\n", t);
		}
		else {
			Tree[N + x] = y;
			update(N + x);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 4236
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
using namespace std;

int state[51][51];
int temp[51][51];

int main(void){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      char c;
      cin >> c;
      state[j][i] = (c=='.')?0:1;
    }
  }
  for(int i = 0; i < M; i++){
    for(int j = 0; j < M; j++){
      char c;
      cin >> c;
      temp[j][i] = (c=='.')?0:1;
    }
  }

  bool isOK = false;
  for(int i = 0; i <= N - M; i++){
    for(int j = 0; j <= N - M; j++){
      bool flag = true;

      for(int k = 0; k < M; k++){
        for(int l = 0; l < M; l++){
          int nx = j+l;
          int ny = i+k;
          if(state[nx][ny] == temp[l][k])flag = true;
          else{
            flag = false;
            break;
          }
        }
        if(flag == false)break;
      }
      if(flag == true)isOK = true;
      if(isOK == true)break;
    }
    if(isOK == true)break;
  }
  cout << ((isOK)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<ll,ll>> drink(n);
  rep(i,n){
    cin >> drink[i].fi >> drink[i].se;
  }

  sort(rng(drink));

  ll ans = 0;
  ll cnt = 0;
  rep(i,n){
    ll c = min(m-cnt,drink[i].se);
    cnt+=c;
    ans+=c*drink[i].fi;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4784
import sys
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import deque
input = sys.stdin.readline

def main():
    N = int(input())
    link = [[0 if c == "0" else 1 for c in list(input().strip())] for i in range(N)]
    # print(link)
    check = [False] * N
    colors = [True] * N

    q = deque()
    q.append((0, True, 1))
    ok = True
    check[0] = True
    while len(q) > 0:
        i, color, step = q.popleft()
        # print(i, color, step)
        for nex, c in enumerate(link[i]):
            if c == 1:
                if check[nex]:
                    if colors[nex] == color:
                        ok = False
                        break
                else:
                    check[nex] = True
                    colors[nex] = not(color)
                    q.append((nex, not(color), step+1))
        if not ok:
            break
    
    if ok:
        ans = 0
        link = wf(link)
        for i in range(N):
            ans = max(ans, int(max(link[i])))
        print(ans + 1)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18316
#include <bits/stdc++.h>
using namespace std;
         
int main(){
	int N, i;
	cin >> N;
	vector<int> V(N), C(N);
  
  for (i=0; i<N; i++){
    cin >> V[i];
  }
  
  for (i=0; i<N; i++){
  	cin >> C[i];
  }
  
  int ans = 0;
  
  for (i=0; i<N; i++){
  	if(V[i] > C[i]){
      	ans += (V[i]-C[i]);
    }
  }
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 40;
const int MAX_AB = 10;
const int INF = 1e8;
int dp[MAX_N + 1][MAX_N * MAX_AB + 1][MAX_N * MAX_AB + 1];
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for (int j = 0; j <= N * MAX_AB; j++) {
        for (int k = 0; k <= N * MAX_AB; k++) {
            dp[0][j][k] = INF;
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N * MAX_AB; j++) {
            for (int k = 0; k <= N * MAX_AB; k++) {
                if(j >= a[i] && k >= b[i]) {
                    dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
                } else {
                    dp[i + 1][j][k] = dp[i][j][k];
                }
            }
        }
    }
    int ans = INF;
    for (int n = 1; n * max(A, B) <= N * MAX_AB; n++) {
        ans = min(ans, dp[N][A * n][B * n]);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 25984
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n-1)]
PX=[list(map(int,input().split())) for _ in range(q)]

es=[[] for _ in range(n)]
for a,b in AB:
  a,b=a-1,b-1
  es[a].append(b)
  es[b].append(a)
  
cnt=[0]*n
for p,x in PX:
  cnt[p-1]+=x

ans=[0]*n
ans[0]=cnt[0]
visited=[0]*n
stack=[0]
while stack:
  v=stack.pop()
  visited[v]=1
  for to in es[v]:
    if visited[to]: continue
    stack.append(to)
    ans[to]=ans[v]+cnt[to]
print(*ans)

Measured memory_bytes: 150656
import sys

test = False
N = 100

def check(n):
    if test:
        if n<=N and str(n)<=str(N) or n>N and str(n)>str(N):
            return "Y"
        else:
            return "N"
    else:
        print "?", n
        sys.stdout.flush()
        return raw_input()

for d in range(11):
    if check(10**d)=="N":
        d -= 1
        break
if d==10:
    for i in range(1,11):
        if check(10**i-1)=="Y":
            print "!", 10**(i-1)
            break
else:
    l = 10**d
    r = 10**(d+1)
    while r-l>1:
        m = (l+r)/2
        if check(m*10)=="Y":
            r = m
        else:
            l = m
    print "!", r
sys.stdout.flush()


Measured memory_bytes: 3036