akhauriyash/Code-Regression huggingface dataset:
import sys

S = input()
for b_op in range(2):
    for c_op in range(2):
        for d_op in range(2):
            ans = S[0]
            total = int(S[0])
            if bool(b_op):
                total += int(S[1])
                ans += "+" + S[1]
            else:
                total -= int(S[1])
                ans += "-" + S[1]

            if bool(c_op):
                total += int(S[2])
                ans += "+" + S[2]
            else:
                total -= int(S[2])
                ans += "-" + S[2]

            if bool(d_op):
                total += int(S[3])
                ans += "+" + S[3]
            else:
                total -= int(S[3])
                ans += "-" + S[3]

            if total == 7:
                print(ans + "=7")
                sys.exit()


Measured memory_bytes: 38256
#include <vector>
#include <cstdio>
using namespace std;

typedef struct{
	double x;
	double y;
	double z;
	double r;
	long long l;
}_object;

int main(){
	int N,Q;
	scanf("%d%d",&N,&Q);
	vector<_object> object(N);
	for(int i=0;i<N;i++)scanf("%lf%lf%lf%lf%lld",&object[i].x,&object[i].y,&object[i].z,&object[i].r,&object[i].l);
	for(int i=0;i<Q;i++){
		// http://www.infra.kochi-tech.ac.jp/takagi/Survey2/7Parameter.pdf
		double xa,ya,za,xx,yx,zx;
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&za,&xx,&yx,&zx);
		double vx=xx-xa,vy=yx-ya,vz=zx-za;
		long long R=0;
		for(auto &e:object){
			double t=(vx*(e.x-xa)+vy*(e.y-ya)+vz*(e.z-za))/(vx*vx+vy*vy+vz*vz);
			if(t<0)t=0;
			if(t>1)t=1;
			double xt=xa+vx*t,yt=ya+vy*t,zt=za+vz*t;
			double r=(e.x-xt)*(e.x-xt)+(e.y-yt)*(e.y-yt)+(e.z-zt)*(e.z-zt);
			if(r<e.r*e.r+1e-9)R+=e.l;
		}
		printf("%lld\n",R);
	}
}

Measured memory_bytes: 1052
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N;


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

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mx = 200001;
vector<int> g[mx];
vector<int> vis(mx);
int cnt=0;
void dfs(int u){
    
    vis[u]=1;
    cnt++;
    for(auto v:g[u]){
        if(!vis[v]){
            dfs(v);
        }
    }
}
int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	
	int n,m;
	cin>>n>>m;
	int ans=0;

	for(int i=1;i<=m;i++){
	    int u,v;
	    cin>>u>>v;
	    
	        
	        g[u].pb(v);
	        g[v].pb(u);
	        
	    
	}
	
	for(int i=1;i<=n;i++){
	    cnt=0;
	    if(vis[i]==0){
	        dfs(i);
	        ans=max(ans,cnt);
	    }
	    
	}
	cout<<ans;
	
}

Measured memory_bytes: 21860
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=0,ans=0;
  for(int i=0;i<n;i++)
  {
      if(s[i]=='I')
        x++;
      else
        x--;
      ans=max(ans,x);
  }
  cout<<ans;

}


Measured memory_bytes: 3588
#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
//a power n mod p
long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int 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); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
   // cin>>t;
    lld n,i,j,ans,x3,x5,x15;
    cin>>n;
    ans = n*(n+1)/2;
    x3 = n/3;
    ans-= 3*(x3)*(x3+1)/2;
    x5=n/5;
    ans-=5*(x5)*(x5+1)/2;
    x15=n/15;
    ans+=15*(x15)*(x15+1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


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



    int n,k;
    cin >> n >> k;

    if(n <= abs(n-k))
    {
      cout << n;
    }
    else
    {
      cout << min(abs(n%k),abs(k-n%k));
    }
    
    


    return 0; 
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
  	
	string ans = "Yay!";
  
  	if(e-a > k) ans = ":(";
  
	cout << ans << endl;
}

Measured memory_bytes: 256
// import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import java.io._;
import java.util.ArrayDeque

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = Integer.parseInt(in.readLine)

  case class edge(v:Int, d:Int)
  val tree = Array.fill(n)(mu.ListBuffer.empty[edge])

  Iterator.continually(in.readLine)
    .take(n-1)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      new edge(e(1)-1, e(2)) +=: tree(e(0)-1)
      new edge(e(0)-1, e(2)) +=: tree(e(1)-1)
    }

  val colors = Array.ofDim[Int](n)
  val visit = Array.ofDim[Boolean](n)

  def dfs(v:Int, d:Int):Unit = {
    // val stk = mu.Stack.empty[edge]
    val stk = new ArrayDeque[edge]
    stk.push(new edge(v, d))

    while(!stk.isEmpty) {
      val v = stk.pop
      if(!visit(v.v)) {
        visit(v.v) = true
        colors(v.v) = v.d
        for(nv <- tree(v.v) if !visit(nv.v)){
          val d = (v.d + nv.d) % 2
          stk.push(new edge(nv.v, d))
        }
      }
    }
  }

  dfs(0,0)
  val out = new java.io.PrintWriter(System.out)
  colors.foreach(out.println)
  out.flush
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n;cin >> n;
  vi a(n); REP(i, n) cin >> a[i];

  map<int, int> m;
  int fr = 0;
  REP(i, n) {
    if(a[i] / 400 > 7) fr++;
    else m[a[i]/400]++;
  }

  int k = m.size();

  cout << ((k==0) ? 1 : k) << " " << k + fr << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


void MAIN() {
    int H1, M1, H2, M2, K;
    scanf("%d%d%d%d%d", &H1, &M1, &H2, &M2, &K);

    int x = (H2 * 60 + M2) - (H1 * 60 + M1);
    printf("%d\n", x-K);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3828
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())

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

def solve(N):
    for a in range(1, 3501):
        N1 = 4*a - N
        N2 = N * a
        if N1 < 0: continue
        for b in range(1, 3501):
            N3 = b * N1 - N2
            N4 = b * N2
            if N4 > 0 and N3 > 0 and N4 % N3 == 0:
                print(a, b, N4//N3)
                return
    
solve(N)



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  int ans = 0;
  rep(i, n) {
    if (i % 2 == 0 && a[i] % 2 == 1) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
var
	n,a,x,y,z:Longint;
begin
	read(n,a);
	a:=a div 1000;
	for y:=0 to 8 do begin
		x:=(a-n-4*y)div 9;
		z:=n-y-x;
		if(x>=0)and(y>=0)and(z>=0)and(x*10+y*5+z=a)then begin
			writeln(x,' ',y,' ',z);
			exit;
		end;
	end;
	writeln('-1 -1 -1');
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t a, b; cin >> a >> b;
	cout << a * b / __gcd(a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from functools import reduce

MOD = 1000000007

def power_func(a, b, mod):
    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

def nCr(n, r, mod):

    min_r = min(r, n-r)

    if min_r == 1: return n


    bunsi = reduce(lambda x, y: (x * y) % mod, range(n, n-r, -1))
    bunbo = reduce(lambda x, y: (x * y) % mod, range(r, 1, -1))

    return bunsi * power_func(bunbo, mod - 2, mod) % mod


n, a, b = [int(i) for i in input().split()]

print(((power_func(2, n, MOD) -1) - nCr(n, a, MOD)- nCr(n, b, MOD)) % MOD)


Measured memory_bytes: 3572
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, a, n)  for(int i=0; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define pb  push_back
#define eb  emplace_back

const int INF = 1<<28;
const int MOD = 1000000007;

int main(){
  string s; cin >> s;
  ull ans = 0;
  REP(i, (1 << SZ(s)-1)){
    ull sum = 0, cur = 0;
    REP(j, SZ(s)){
      if(j>0 and (i & (1 << (j-1)))){
        sum += cur;
        cur = 0;
      }
      cur = cur * 10 + (s[j] - '0');
    }
    sum += cur;
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <ios>
#include <iostream>
#include <vector>

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

int lcm(int a, int b) { return (a / gcd(a, b)) * b; }

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

  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];

  int m = 1;
  for (int i = 0; i < n; ++i)
    m = lcm(m, a[i]);

  int c = 0;
  for (int i = 0; i < n; ++i)
    c += m / a[i];

  std::cout << std::fixed << double(m) / c << std::endl;
}


Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define pb push_back
#define ri(x) scanf("%d",&x)
#define rii(x,y) ri(x),ri(y)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define ms2(obj,val,sz) memset(obj,val,sizeof(obj[0])*sz)
#define FOR(i,f,t) for(int i=f;i<(int)t;i++)
#define FORR(i,f,t) for(int i=f;i>(int)t;i--)

typedef long long ll;
typedef vector<int> vi;

const int MOD=1e9+7;

int n,m;
ll ans=1;

int main() {
	rii(n,m);
	FOR(i,1,n+1) ans=(ans*i)%MOD;
	FOR(i,1,m+1) ans=(ans*i)%MOD;
	if(abs(n-m)>1) printf("0\n");
	else if(n==m) printf("%lld\n",ans*2%MOD);
	else printf("%lld\n",ans);
}


Measured memory_bytes: 256
N,C = map(int,input().split())
num = 100009*2
channel = [[0]*num for _ in range(C)]
time = [0]*num

max_num = 0
for i in range(N):
  s,t,c = map(int,input().split())
  s,t,c = 2*s-1,2*t,c-1
  if(channel[c][s-1] == 1): channel[c][s-1] = 0
  else: channel[c][s] = 1 
  channel[c][t] = 1
  max_num = max(max_num,t)

tmp = 0
for i in range(C):
 for j in range(max_num+15):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    time[a] += 1
    time[b+1] -= 1

ans = 0    
for i in range(max_num+15):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)                         

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int k, n;
    cin >> k >> n;
    vi a(n);
    for (auto& x : a)
        cin >> x;

    int ans = k - (a[0] + k - a[n - 1]);
    for (int i = 1; i < n; ++i) {
        ans = min(ans, k - (a[i] - a[i - 1]));
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 1024
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

k = INT()
a = LIST()
mn = 2
mx = 2
for i in reversed(range(k)):
    mn = (mn + a[i] - 1) // a[i] * a[i]
    mx = mx // a[i] * a[i] + a[i] - 1
    if mn > mx:
        print(-1)
        exit()
print(mn, mx)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i=i+2){
      cout<<s.at(i);
    }
    cout<<endl;


return 0;

}


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

int main() {
  int cnt=1, N, C, K, s=0;
  bool flg = true;
  cin >> N >> C >> K;
  vector<int> T(N,0);
  for (int i = 0; i<N; i++) cin >> T[i];
  sort(T.begin(),T.end());
  for (int i = 1; i<N; i++) {
    if(T[i]>T[s]+K || i==s+C) {
      cnt++;
      s=i;
    }
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 640
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1-i):
        if (Y - 10000*i - 5000*j) / 1000 == N-i-j:
            print(i,j,N-i-j)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
# # -*- coding: utf-8 -*-
import collections
N = int(input())
A = list(map(int, input().split(' ')))

a_frq_dict = collections.Counter(A)
A = sorted(a_frq_dict.keys())

bads = set()
max_a = max(A)
n = len(A)
for i in range(n):
    if A[i] in bads:
        pass

    elif a_frq_dict[A[i]] > 1:
        bads.add(A[i])
        for a in range(A[i]*2, max_a+1, A[i]):
            if a in a_frq_dict:
                bads.add(a)

    else:
        for a in range(A[i]*2, max_a+1, A[i]):
            if a in a_frq_dict:
                bads.add(a)

answer = set(A) - bads
# print(answer)
print(len(answer))




Measured memory_bytes: 139940
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int x, y, z;  cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
int h,w;
string s[30][30];
signed main(){
    cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=="snuke"){
                char c='A'+j;
                cout<<c<<i+1<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;

// ll factorial(ll x){
//     if(x==0||x==1) return 1;
//     return x*factorial(x-1);
// }


// int main(){
//     int64_t n,k;
//     cin >> n >> k;
//     int64_t  ans=k;
//     for(int i=1;i<n;++n) ans *= (k-1);

//     cout<<ans<<endl;
//     return 0;
// }

int main()
{
	ll n, k;
	cin >> n >> k;
	ll j = k;
	for (int i = 1; i < n; i++)
		j *= (k - 1);
	cout << j << endl;
	return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	String ans = "No";
      	int num = 0;
		for(int i=1; i<10; i++){
			for(int j=1; j<10; j++){
              num = i*j;
              if(num==n) ans = "Yes";
            }
		}
      	System.out.println(ans);
	}
}


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

unsigned long long knapsack(vector<unsigned long long>&weight,vector<unsigned long long>&value,int n,int W)
{   vector<vector<unsigned long long > >dp(n+1,vector<unsigned long long>(W+1,0));
    for(int i=1;i<=n;i++)
    {
      for(unsigned long long w = 1;w<=W;w++)
      {   if(w>=weight[i-1])
        dp[i][w] = max(value[i-1]+dp[i-1][w-weight[i-1]],dp[i-1][w]);
          else dp[i][w] = dp[i-1][w];
      }
         
    }
    return dp[weight.size()][W];
}
int main()
{
     int n,W;
  cin>>n>>W;
  vector<unsigned long long>weight(n),value(n);
  for(int i =0;i<n;i++)
  {
    cin>>weight[i]>>value[i];
  }
  cout<<knapsack(weight,value,n,W)<<endl;
	
}

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

int main(){
	int n;
	cin >> n;
	ll h[100010];
	ll dp[100010];

	rep(i, n) cin >> h[i];
	rep(i, n) dp[i] = INF;
	dp[0] = 0;

	rep(i, n){
		chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
		if(i > 1) chmin(dp[i],dp[i-2]+ abs(h[i] - h[i-2]));
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define  F  first
#define  S  second
#define  pb push_back
#define  mp make_pair
typedef long long int ll;
const int N = 1e6+6;

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


    int n;cin>>n;
    map<string,int>M;
    bool F = 1;
    string prv = "";
    while(n--)
    {
        string s;cin>>s;
        if( M[s] )F = 0;
        else
        {
            if(prv.size()&&s[0]!=prv[ prv.size()-1 ])F = 0;
        }
        prv = s;
        M[s]++;
    }
    if(F)cout<< "Yes\n";
    else cout<< "No\n";











    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>

#define PI 3.1415926535898

using namespace std;
int main(void)
{
	double x = 0,y = 0;
	double hosu,kakudo;
	double kakudos = 90;
	while(scanf("%lf,%lf",&hosu,&kakudo))
	{
		if(hosu == 0 && kakudo == 0) break; 
		x += cos(kakudos * PI / 180) * hosu;
		y += sin(kakudos * PI / 180) * hosu;
		kakudos -= kakudo;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c;
	if(a>=c) cout<<a-c<<" "<<b<<endl;
	else 
	{
		if(b+a>=c)cout<<0<<" "<<b+a-c;
		else cout<<"0 0";
	}
	return 0;
}

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

int main(){
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=0){
    if(d>=0){
      cout<<b*d<<endl;
    }
    else{
      cout<<a*d<<endl;
    }
  }
  else if(a<0&&b>=0){
    if(c<0&&d>=0){
      if(a*c>b*d){
        cout<<a*c<<endl;
      }
      else{
        cout<<b*d<<endl;
      }
    }
    else if(c>0){
      cout<<b*d<<endl;
    }
    else if(d<0){
      cout<<a*c<<endl;
    }
  }
  if(b<0){
    if(c>=0){
      cout<<b*c<<endl;
    }
    else{
      cout<<a*c<<endl;
    }
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string.h>

using namespace std;
#define maxn 100000
#define ll long long
int main()
{
   int n;
   cin>>n;
   ll a[n+1];
   ll b[n+1];
   for(int i=1;i<=n+1;i++)
   {
       scanf("%lld",&a[i]);
   }
   for(int i=1;i<=n;i++)
    scanf("%lld",&b[i]);
   ll re=0;
   for(int i=1;i<=n;i++)
   {
       if(a[i]<=b[i])
       {
           re+=a[i];
           b[i]-=a[i];
       }
       else
       {
           re+=b[i];
           b[i]=0;
       }
       if(a[i+1]<=b[i])
       {
           re+=a[i+1];
           a[i+1]=0;
       }
       else
       {
           re+=b[i];
           a[i+1]-=b[i];
       }
   }
   cout<<re<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>

bool judge(const std::string& s)
{
    if (s[0] != s[1])
    {
        return true;
    }

    if (s[1] != s[2])
    {
        return true;
    }

    return false;
}

int main()
{
    std::string s;
    std::cin >> s;

    std::cout << (judge(s) ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn find(s: &[char], a: u8, b: u8, c: u8) -> bool {
    let mut i = 0;
    let mut ok = false;
    for x in i..s.len() {
        i = x + 1;
        if s[x] == ('0' as u8 + a) as char {
            break;
        }
    }
    for x in i..s.len() {
        i = x + 1;
        if s[x] == ('0' as u8 + b) as char {
            break;
        }
    }
    for x in i..s.len() {
        if s[x] == ('0' as u8 + c) as char {
            ok = true;
            break;
        }
    }
    ok
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let _n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                if find(&s, i, j, k) {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    int N;
    long long int HP;
    cin >> N >> HP;
    vector<long long int> a(N), b(N);
    for(int i=0; i<N; i++) cin >> a[i] >> b[i];
    
    auto it = max_element(a.begin(), a.end());
    auto max_a_index = distance(a.begin(), it);
    long long int max_a = a[max_a_index];
    
    sort(b.begin(), b.end(), greater<long long int>());
    long long int sum = 0;
    int i;
    for(i=0; i<N; i++) {
        if(b[i] <= max_a) {
            break;
        }
        sum += b[i];
        if(sum >= HP) {
            cout << i+1 << endl;
            return 0;
        }
    }
    long long int rest = HP-sum;
    cout << std::setprecision(12)<< i + ceil((double)rest/max_a) << endl;
    return 0;
}


Measured memory_bytes: 1792
INF = float("inf")

N, Ma, Mb, *ABC = map(int, open(0).read().split())

M = 160010

dp = [0] + [INF] * M
for a, b, c in zip(*[iter(ABC)] * 3):
    T = dp[:]
    p = 401 * a + b
    for i, dpi in enumerate(dp):
        j = p + i
        if j > M:
            break
        if T[j] > dpi + c:
            T[j] = dpi + c
    dp = T

ans = INF
for i in range(1, M):
    a, b = divmod(i, 401)
    if Ma * b == Mb * a and ans > dp[i]:
        ans = dp[i]

print(-1 if ans == INF else ans)

Measured memory_bytes: 12308
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

int main(void){

    string s,t;
int n;
cin>>n;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);

    while (1) {
        int w,h;
        cin >> w >> h; 
        if (w==0 && h==0) break;
        vector<vector<int>> d(w*h,vector<int>(w*h));
        rep(i,2*h-1) {
            if (i%2==0) {
                rep(j,w-1) {
                    int k;
                    cin >> k;
                    if (k==1) {
                        d[w*(i/2)+j][w*(i/2)+j+1]=1;
                        d[w*(i/2)+j+1][w*(i/2)+j]=1;
                    }
                }
            } else {
                rep(j,w) {
                    int k;
                    cin >> k;
                    if (k==1) {
                        d[w*(i/2)+j][w*(i/2)+j+w]=1;
                        d[w*(i/2)+j+w][w*(i/2)+j]=1;
                    }
                } 
            }
        }
        queue<int> q;
        q.push(0);
        vector<int> di={-1,0,0,1},dj={0,-1,1,0};
        vector<int> cost(w*h);
        cost[0]=1;
        while (!q.empty()) {
            int now=q.front();
            q.pop();
            rep(i,4) {
                int ni=now/w+di[i],nj=now%w+dj[i];
                if (ni>=0 && ni<h && nj>=0 && nj<w) {
                    int next=ni*w+nj;
                    if (cost[next]==0 && d[now][next]==0) {
                        cost[next]=cost[now]+1;
                        q.push(next);
                    }
                }
            }
        }
        cout << cost[w*h-1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5900
// Problem : C - 755
// Contest : AtCoder - AtCoder Beginner Contest 114
// URL : https://atcoder.jp/contests/abc114/tasks/abc114_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
 ll mod_pow(ll x,ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x, n / 2);
	if (n & 1) res = res * x;
	return res;
}
inline bool okay(ll S)
{
	set<int> s;
	while(S!=0)
	{
		s.ins(S%10);
		S/=10;
	}
	if(sz(s)==3)
		return true;
	return false;
}
ll N;
ll answer=0;
void calc(ll S)
{
	if(S>N)
		return;
	if(okay(S))
		answer++;
	calc(S*10+3);
	calc(S*10+5);
	calc(S*10+7);
}
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>N;
	calc(0);
	cout<< answer;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m),c(m);
  rep(i,m) cin >> a[i] >> b[i] >> c[i], --a[i], --b[i];
  vector<vector<int>> d(n,vector<int>(n,1e9));
  rep(i,n) d[i][i] = 0;
  rep(i,m) d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
  int ans = 0;
  rep(i,m) if(d[a[i]][b[i]]<c[i]) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <bitset>
#include <limits.h>
#include <stack>
#include <ctime>
#include <fstream>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define de cout<<1
#define FOR(NAME,FIRST,END) for(int NAME=FIRST;NAME<=END;NAME++)
#define openi(s) freopen(s,"r",stdin)
#define openo(s) freopen(s,"w",stdout)
const bool debug=false;
const bool INJUDGE=false;
int n;
bool f[105][15];
int p[105][15];
bool ope[105];
int res=INT_MIN;
void bt(int x){
	if(x==11){
		bool all0=true;
		for(int i=1;i<=10;i++)if(ope[i])all0=false;
		if(all0)return;
		int ss=0;
		for(int i=1;i<=n;i++){
			int s=0;
			for(int j=1;j<=10;j++){
				if(f[i][j]&&ope[j])s++;
			}
			ss+=p[i][s];
		}
	//	for(int i=1;i<=10;i++)cout<<ope[i]<<' ';
	//	cout<<ss;
	//	puts("");
		res=max(res,ss);
		return;
	}
	ope[x]=true;
	bt(x+1);
	ope[x]=false;
	bt(x+1);
} 
int main(){
	cin>>n;
	FOR(i,1,n){
		FOR(j,1,10){
			int x;
			cin>>x;
			f[i][j]=x;
		}
	}
	FOR(i,1,n){
		FOR(j,0,10){
			int x;
			cin>>x;
			p[i][j]=x;
		}
	}
	bt(1);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

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

Measured memory_bytes: 3564
def main():
    import sys
    buf = sys.stdin.buffer

    class UnionFind:
        def __init__(self, size):
            self.parent = [-1] * size
            self.rank = [1] * size

        def get_root(self, node):
            parent = self.parent[node]
            if parent == -1:
                root = node
            else:
                root = self.get_root(parent)
                self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
            return root

        def in_same_group(self, node1, node2):
            root1 = self.get_root(node1)
            root2 = self.get_root(node2)
            return root1 == root2

        def unite(self, node1, node2):
            if self.in_same_group(node1, node2):
                return
            main_root = self.get_root(node1)
            sub_root = self.get_root(node2)
            if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
                main_root, sub_root = sub_root, main_root

            self.parent[sub_root] = main_root
            self.rank[main_root] += self.rank[sub_root]

    n, m, k = map(int, buf.readline().split())
    uf = UnionFind(n)
    minus_count = [1] * n

    def gen():
        for num in buf.read().split():
            yield int(num)

    generator = gen()
    for _ in range(m):
        a, b = generator.__next__(), generator.__next__()
        uf.unite(a-1, b-1)
        minus_count[a-1] += 1
        minus_count[b-1] += 1

    for i in range(k):
        a, b = generator.__next__(), generator.__next__()
        if uf.in_same_group(a-1, b-1):
            minus_count[a-1] += 1
            minus_count[b-1] += 1

    result = []
    for i in range(n):
        parent = uf.get_root(i)
        count = uf.rank[parent]
        ans = count - minus_count[i]
        result.append(ans)

    print(*result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34240
from collections import *
import itertools
import sys
sys.setrecursionlimit(10**5)
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()

X = sorted(enumerate(A), key=lambda x: x[1], reverse=True)
p = [x for x, _ in X]
sc = [x for _, x in X]

DP = [[-1]*N for _ in range(N)]
def opt(l, i):
    r = N - i + l - 1
    if i == N: return 0
    if DP[i][l] != -1: return DP[i][l]
    v1 = abs(p[i]- l)*sc[i] + opt(l+1, i+1)
    v2 = abs(p[i] - r)*sc[i] + opt(l, i+1)
    DP[i][l] = max(v1, v2)
    return DP[i][l]

print(opt(0, 0))


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

int main() {
  int a,b;
  cin>>a>>b;

  if (a == 2 || b == 2) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<int> p(N);

    rep(i, N) cin >> p[i];

    int s = 0;

    rep(i, N) s += p[i];

    int M = 0;

    rep(i, N) M = max(M, p[i]);

    cout << s - M / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

int N;
int a[2][101];

int main(){

	cin >> N;

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

	int result = 0;
	for (int n = 0; n < N; n++){
		int sum = 0;
		for (int i1 = 0; i1 <= n; i1++) sum += a[0][i1];
		for (int i2 = n; i2 <= N; i2++) sum += a[1][i2];

		if (sum>result) result = sum;

	}

	cout << result << endl;



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){
  // property
  map<string, int> wordlist;
  int N, MaxCount;
  string w;
  //init
  cin >> N;
  MaxCount = 0;
  // solve
  for(int i= 0; i < N;i++){
    cin >> w;
    wordlist[w]++;
    MaxCount = max(wordlist[w], MaxCount);
  }
  for(auto itr = wordlist.begin(); itr != wordlist.end(); itr++){
    if(itr->second == MaxCount){
      cout << itr->first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 26112