akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		long long int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
		if (!a)break;
		long long int na, nb, nc; cin >> na >> nb >> nc;
		long long int ans;
		if (nc >= d) {
			ans = a*na + b*nb + e*nc;
		}
		else {
			if (nc + nb >= d) {
				ans = a*na + b*(nc + nb - d) + e*d;
			}
			else if (na + nb + nc >= d) {
				ans = a*(nc + nb + na - d) + e*d;
			}
			else {
				ans = e*d;
			}
			ans = min(ans, a*na + b*nb + c*nc);
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

    public static void main(final String... args) {
        final String mode = "a";

        if (mode.equals("a")) {
            A.solve();
        } else if (mode.equals("b")) {
            B.solve();
        } else if (mode.contentEquals("c")) {
            C.solve();
        }
    }
}

class A {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final String s = sc.nextLine();
        final String res = calc(s);
        System.out.println(res);
    }

    static String calc(final String s) {
        switch (s) {
        case "Sunny":
            return "Cloudy";
        case "Cloudy":
            return "Rainy";
        case "Rainy":
            return "Sunny";
        }
        return null;
    }
}

class B {
    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final String str = sc.nextLine();
        final char[] s = str.toCharArray();
        final boolean res = calc(s);
        if (res) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static boolean calc(final char[] s) {
        if (cond1(s) && cond2(s)) {
            return true;
        }
        return false;
    }

    private static boolean cond1(final char[] s) {
        for (int i = 0; i < s.length; i += 2) {
            if (s[i] == 'L') {
                return false;
            }
        }
        return true;
    }

    private static boolean cond2(final char[] s) {
        for (int i = 1; i < s.length; i += 2) {
            if (s[i] == 'R') {
                return false;
            }
        }
        return true;
    }
}

class C {

    static void solve() {
        final Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        final int k = sc.nextInt();
        final int q = sc.nextInt();
        final int[] a = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt();
        }
        final int[] res = calc(n, k, q, a);
        for (final int p : res) {
            if (q - p < k) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    static int[] calc(final int n, final int k, final int q, final int[] correctors) {
        final int[] points = new int[n];
        for (final int col : correctors) {
            points[col - 1]++;
        }
        return points;
    }
}


Measured memory_bytes: 23508
N,M = map(int,input().split())

if N == 1:
  ans = ["0"]
  default = "0"
else:
  ans = ["1"] + ["0"] * (N - 1)
  default = "1" + "0" * (N - 1)

for i in range(M):
  s,c = input().split()
  s = int(s) - 1
  if N > 1 and s == 0 and c == "0":
    print(-1)
    exit(0)
  if ans[s] == default[s] or ans[s] == c:
    ans[s] = c
  else:
    print(-1)
    exit(0)
     
print("".join(ans))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;template<typename TypeInt>TypeInt G_C_D(TypeInt a, TypeInt b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename TypeInt>
TypeInt G_C_D(const std::vector<TypeInt> &list){TypeInt a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename TypeInt>TypeInt L_C_M(TypeInt a, TypeInt b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename TypeInt>TypeInt L_C_M(const std::vector<TypeInt> &list){TypeInt a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	int N;
	cin>>N;
	vector<string> S(N);
	vector<char> c(N);
	FDS(i,N){
		cin>>S[i];
		string s;
		s=S[i];
		c[i]=s[0];
	}
	ll M=0,A=0,R=0,C=0,H=0;
	ll ans=0;
	FDS(i,N){
		if(c[i]=='M'){
			M++;
		}
		if(c[i]=='A'){
			A++;
		}
		if(c[i]=='R'){
			R++;
		}
		if(c[i]=='C'){
			C++;
		}
		if(c[i]=='H'){
			H++;
		}
	}
	ans+=M*A*(R+C+H)+M*R*(C+H)+M*C*H+A*R*(C+H)+A*C*H+R*C*H;
	cout<<ans<<endl;
}

Measured memory_bytes: 6272
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        String s=nln();
        char x=s.charAt(0);
        pn((char)((int)(x+1)));     
    }
 
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj =true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }
 
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
 
    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    ll ans = 0, s = 0;
    rep(i, 0, n){
        ll a; cin >> a;
        if(!a){
            ans += s/2;
            s = 0;
        }
        s += a;
    }
    ans += s/2;

    co(ans);

    return 0;
}
 
 


Measured memory_bytes: 3580
S=input()
T=input()

d = {}
d2 = {}
for i in range(len(S)):
  if not d.get(S[i]):
    d[S[i]] = T[i]
  elif d[S[i]] != T[i]:
    print('No')
    exit()
  if not d2.get(T[i]):
    d2[T[i]] = S[i]
  elif d2[T[i]] != S[i]:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 9440
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);



int main(){
  FAST_IO  
  
  int M; cin >> M;
  cout << 48 - M << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N;
int A[103];

int RATING[9] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200};

signed main() {
    cin >> N;
    REP(i, N) cin >> A[i];

    set<int> rset;
    int maxr = 0;
    REP(i, N) {
        int a = A[i];
        REV(k, 8) {
            int r = RATING[k];
            if (a >= r) {
                if (r == 3200)
                    ++maxr;
                else
                    rset.insert(r);
                break;
                DUMP(r)
            }
        }
    }

    int minans = rset.size();
    if (maxr > 0 && rset.size() == 0) minans += 1;
    int maxans = rset.size() + maxr;
    cout << minans << " " << maxans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, ma = 0;

int main() {
	cin >> n;
	vector<ll> s(n);
	REP(i, n)cin >> s[i];
	s.push_back(INF);
	ll ans = 0;
	REP(i, n) {
		if (s[i] >= s[i + 1])ans++;
		else ans = 0;
		ma = max(ma, ans);
	}
	cout << ma << endl;
}

	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    dump(e - a > k ? ":(" : "Yay!");
    return 0;
}

Measured memory_bytes: 764
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:] for _ in range(m)]
p=list(map(int,input().split()))
ans=0

for i in range(2**n):
    tmp=[]
    cnt=[0]*n
    for j in range(n):
        if (i>>j)&1:
            tmp.append(j+1)
    for k in range(m):
        if len(set(tmp)&set(s[k]))%2!=p[k]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 9176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn =1e4+100;
int n,m,res;

int a[maxn];
int mx=0;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=mx) mx=a[i],res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
def koubai(a,b):
    if b == 0:
        return a
    else:
        return koubai(b,a%b)

a,b = map(int,input().split())
if a < b :
    a,b = b,a  
s = koubai(a,b)
print( int ( (a*b) /s ) )

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k,ans;
signed main(){
	cin>>n>>k;
	if (k&1){
		cout<<(n/k)*(n/k)*(n/k);
		return 0;
	}
	else{
		int p=k,i=1,kk,j;
		for (i=1,j=p; j<=n; j+=p,++i);
		for (kk=1,j=k>>1; j<=n; j+=p,++kk);
		cout<<(i-1)*(i-1)*(i-1)+(kk-1)*(kk-1)*(kk-1);
	}
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc068/tasks/abc068_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;

  cin >> n;

  cout << pow(2, floor(log2(n))) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];

  int cnt = 0;
  for (int i = 0; i < N - 2; i++)
  {
    for (int j = i + 1; j < N - 1; j++)
    {
      for (int k = j + 1; k < N; k++)
      {
        if (L[i] != L[j] && L[j] != L[k] && L[i] != L[k])
        {
          int sum = L[i] + L[j] + L[k];
          int mx = std::max({L[i], L[j], L[k]});
          if (sum - mx <= mx)
            continue;

          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

int main() {
	int n, m;
	int C[MMAX + 1];
	int T[NMAX + 1];
	
	cin >> n >> m;

	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}

	for (int i = 0; i <= NMAX; i++) T[i] = INFTY;
	T[0] = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j + C[i] <= n; j++) {
			T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
		}
	}
	cout << T[n] << endl;

	return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define mod 1000000007

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string ans;
    while(n){
        ll temp=n%26;
        if(temp==0){
            ans+="z";
            n--;
            n/=26;
            continue;
        }
        ans+=char(temp+96);
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int []a=new int [n+1];
    for(int i=0;i<=n;i++)
      a[i]=sc.nextInt();
    long ans=0;
    for(int i=0;i<n;i++){
      int x=sc.nextInt();
      long min=Math.min(x, a[i]);
      ans += min;
      x-=min;
      min=Math.min(x, a[i+1]);
      a[i+1] -= min;
      ans += min;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 64784
H, W = map(int, input().split())
a = []
y = 0
while True:
    if y >= H:
        break
    x = 0
    A = list(input())
    cnt = 0
    while True:
        if x >= W:
            break
        if A[x] == ".":
            cnt += 1
        x += 1
    if cnt == W:
        H -= 1
    else:
        a.append(A)
        y += 1
x = 0
while True:
    if x >= W:
        break
    y = 0
    cnt = 0
    while True:
        if y >= H:
            break
        if a[y][x] == ".":
            cnt += 1
        y += 1
    if cnt == H:
        for i in range(H):
            del a[i][x]
        W -= 1
    else:
        x += 1

for i in range(H):
    for j in range(W):
        print(a[i][j], end = "")
    print()


Measured memory_bytes: 4596
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = n % 10;
		if(x == 3)
		    System.out.println("bon");
		else if(x == 1 || x == 0 || x == 6 || x == 8)
		    System.out.println("pon");
		else
		    System.out.println("hon");
	}
}


Measured memory_bytes: 35756
#include <stdio.h>

int main(void) {
    int a;int b;
    scanf("%d %d",&a,&b);
    int wa =a+b;
    int seki =a*b;
    int sa=a-b;
    if(wa<=seki&&sa<=seki){
        printf("%d",seki);
    }else if(seki<=wa&&sa<=wa){
        printf("%d",wa);
    }else if(wa<=sa&&seki<=sa){
        printf("%d",sa);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
 
const int MAX_N = 100000;
 
int main() {
  int N, ansj;
  string s;
  int r[MAX_N], ans[4][MAX_N];
  bool flag;
  cin >> N >> s;
  for (int i=0; i<N; i++) {
    r[i] = (s[i] == 'o' ? 0 : 1);
  }
  ans[0][0] = ans[1][0] = 0;
  ans[2][0] = ans[3][0] = 1;
  if (r[0] == 0) {
    ans[0][1] = ans[0][N-1] = 0;
    ans[1][1] = ans[1][N-1] = 1;
    ans[2][1] = 0; ans[2][N-1] = 1;
    ans[3][1] = 1; ans[3][N-1] = 0;
  } else {
    ans[0][1] = 0; ans[0][N-1] = 1;
    ans[1][1] = 1; ans[1][N-1] = 0;
    ans[2][1] = ans[2][N-1] = 0;
    ans[3][1] = ans[3][N-1] = 1;
  }
  flag = false;
  for (int j=0; j<4; j++) {
    for (int i=1; i<N-2; i++) {
      ans[j][i+1] = (ans[j][i] ^ ans[j][i-1] ^ r[i]);
    }
    if (ans[j][N-2] == (ans[j][N-1] ^ ans[j][0] ^ r[N-1])
        && ans[j][N-1] == (ans[j][N-3] ^ ans[j][N-2] ^ r[N-2])) {
      ansj = j;
      flag = true;
      break;
    }
  }
  if (flag) {
    for (int i=0; i<N; i++) {
      cout << (ans[ansj][i] == 0 ? 'S' : 'W');
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
 
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

set<int> v;
int a,b,k;

int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
	cin>>a>>b>>k;
	for(int i=a;i<=min(a+k-1,b);i++)
		v.insert(i);
	for(int i=max(b-k+1,a);i<=b;i++)
		v.insert(i);
	for(auto it:v)
		cout<<it<<" ";
}
	

Measured memory_bytes: 3664
/*input
1 100
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	int ans=1;
	for(int i=1;i*i<=m;i++) if(m%i==0){
		if(m/i>=n){
			ans=max(ans,i);
		}
		if(i>=n) ans=max(ans,m/i);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int N = 100;
const long double EPS = 1e-9;

using namespace std;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}


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

	long long n, m, x;
	set<long long> S;
	cin >> n >> m;
	
	x = n = n % m;
	S.insert(n);
	if (n == 0) {
		cout << n << '\n';
		return 0;
	}


	while (true) {
		n = abs(n - m);
		if (S.find(n) != S.end())
			break;
		x = min(x, n);
	}
	
	cout << x << '\n';
}

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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
  ll n,x;
  cin>>n>>x;
  Vi v;
  ll t;
  rep(i,n){
    cin>>t;
    v.pb(t);
  }
  ll ans=0;
  sort(all(v));
  for(int i=0;i<n;i++){
    if(x-v[i]>=0){
      ans++;
      x -= v[i];
    }else{
      x -= v[i];
    }
  }
  if(x>0)ans-=1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func solve(s string) int {
	n := len(s)
	if n == 1 {
		return 1
	}

	dp := make([]int, n+1)
	dp[1] = 1
	if s[0] == s[1] {
		dp[2] = 1
	} else {
		dp[2] = 2
	}
	if n == 2 {
		return dp[n]
	}

	for i := 3; i <= n; i++ {
		if s[i-1] == s[i-2] {
			dp[i] = dp[i-3] + 2
		} else {
			dp[i] = dp[i-1] + 1
		}
	}

	return dp[n]
}

func main() {
	s := input()
	fmt.Println(solve(s))
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    size_t n, m, l;
    cin >> n >> m >> l;

    vector<vector<uint64_t>> a(n, vector<uint64_t>(m));
    vector<vector<uint64_t>> b(m, vector<uint64_t>(l));
    vector<vector<uint64_t>> c(n, vector<uint64_t>(l, 0));

    for (auto&& i : a) {
        for (auto&& j : i) {
            cin >> j;
        }
    }

    for (auto&& i : b) {
        for (auto&& j : i) {
            cin >> j;
        }
    }

    for (size_t i = 0; i < n; i++) {
        for (size_t j = 0; j < m; j++) {
            for (size_t k = 0; k < l; k++) {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }

    for (size_t i = 0; i < n; i++) {
        for (size_t j = 0; j < l - 1; j++) {
            cout << c[i][j] << " ";
        }
        cout << c[i][l - 1] << "\n";
    }
}



Measured memory_bytes: 3280
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int ans,a;
	while(1){
		cin>>ans;
		if(ans==0)
		break;
		for(int i=0;i<9;i++){
		cin>>a;
		ans-=a;
		}
		cout<<ans<<endl;
	}
return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    string ans = "No";
    for(int i = 0; i <= n / 7; i++){
        if((n - (7 * i)) % 4 == 0){
          ans = "Yes";
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))

ll difmax=0;
ll dcnt=0;

int main(){
	int n;
	int t;
	scanf("%d%*d%d",&n,&t);
	n--;
	ll low=t;
	while(n--){
		scanf("%d",&t);
		if(t-low>difmax){
			difmax=t-low;
			dcnt=1;
		}else if(t-low==difmax){
			dcnt++;
		}
		low=min(low,t);
	}
	printf("%lld\n",dcnt);
	return 0;
}

Measured memory_bytes: 128
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x = readline().decode('utf8').rstrip()
print('Yes' if x == x[::-1] else 'No')


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
int n, m;
int main(void) {
    cin >> n >> m;
    vector<vector<bool>> vec(n, vector<bool>(m, false));
    rep(i, n) {
        int k; cin >> k;
        rep(j, k) {
            int a; cin >> a; a--;
            vec[i][a] = true;
        }
    }
    int count = 0;
    rep(i, m) {
        bool flag = true;
        rep(j, n) {
            if (!vec[j][i]) {
                flag = false;
                break;
            }
        }
        if (flag) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
using namespace std ; 
int main ()
{
int a , b ;
cin>>a>>b ;  
if ( b%2==0)
{
if ( a>=13 )
cout <<b ;
else if ( a>=6 && a <=13 ) 
{
b/=2 ; 
cout << b ;
}
else 
cout << "0\n";
}
return 0 ;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	char n;
	for(int i=0;i<a;i++)
	{
		cin>>n;
		if(n>'9'||n<'0')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cin>>n;
	if(n!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=a+1;i<a+b;i++)
	{
		cin>>n;
		if(n>'9'||n<'0')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
  int A,B,C,D,E,k;
  cin>>A>>B>>C>>D>>E>>k;
  if(E-A >k){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
}


Measured memory_bytes: 256
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "c");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    string n, k;
    scan(n, k);
    auto d = aryread();
    auto useSet = iota(10).filter!(x => !d.includes(x)).array();
    auto numSet = new long[](0);

    void dfs(long t)
    {
        if (t >= n.to!(long))
            return;

        foreach (e; useSet)
        {
            if (t == 0 && e == 0)
                continue;

            numSet ~= t * 10 + e;
            dfs(t * 10 + e);
        }

        return;
    }

    dfs(0);
    numSet.sort();
    // numSet.writeln();
    long ok = numSet.length + 1, ng = -1;
    while (abs(ok - ng) > 1)
    {
        auto mid = (ok + ng) / 2;
        if (numSet[mid] >= n.to!long)
            ok = mid;
        else
            ng = mid;
    }

    numSet[ok].writeln();
}

bool includes(T)(T[] ary, T value)
{
    return ary.filter!(x => x == value).array.length > 0;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4132
#include<iostream>

using namespace std;

int main() {
	long long n, m;

	cin >> n >> m;

	int a[10000];
	long long i, res = n;

	for (i = 0; i < m; i++) {
		cin >> a[i];
		res -= a[i];
	}

	if (res >= 0)cout << res;
	else cout << "-1";
	return 0;
}

Measured memory_bytes: 3660
N,M=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(M)]
p=list(map(int,input().split()))

allbit = []
for i in range(2**N):
  bit = [0] * N
  for j in range(N):
    if (i >> j) & 1:
      bit[j] = 1
  allbit.append(bit)


j=0
for onof in allbit:
    l=0
    for m in range(M):
        s=ks[m][1:]
        i=0
        for st in s:
            i+=onof[st-1]
        if(i%2==p[m]):
            l+=1
    if(l==M):
        j+=1
        
print(j)

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

typedef pair<int, int> pii;

int N, M;
pii P[402];
vector<pii> adj[402];
int vis[402];
int ans;

bool dfs(int u, int fe) {
    if(vis[u]) return false;
    vis[u] = 1;

    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i].first;
        int e = adj[u][i].second;
        if(e >= fe) continue;
        if(vis[v]) return false;
        if(!dfs(v, e)) return false;
    }
    return true;
}

int main() {
    scanf("%d %d", &N, &M);

    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            memset(vis, 0, sizeof(vis));
            if(!dfs(i, 1e9)) continue;
            if(!dfs(j, 1e9)) continue;
            ans++;
        }
    }
    printf("%d", ans);
}


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

int main() {
	int w;
	int n;
	cin >> w >> n;
	int* tate = new int[w];
	for (int i = 0; i < w; i++) {
		tate[i] = i + 1;
	}
	int* yoko_a = new int[n];
	int* yoko_b = new int[n];
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &yoko_a[i], &yoko_b[i]);
	}
	for (int i = 0; i < n; i++) {
		swap(tate[yoko_a[i]-1], tate[yoko_b[i]-1]);
	}
	for (int i = 0; i < w; i++) {
		cout << tate[i] << endl;
	}
}

Measured memory_bytes: 3036
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]


# print(-1*(-1*Line[2] // Line[1]))
# print(-1*(-1*Line[0] // Line[3]))

if -1*(-1*Line[2] // Line[1]) <= -1*(-1*Line[0] // Line[3]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include<stdio.h>
#include<math.h>

int main(void){
	int a,b=0;
	double c,p,s,l,h=0;
	
	scanf("%d %d %lf",&a,&b,&c);
	
	p=acos(-1);
	c=(c/180)*p;
	
	s=0.5*a*b*sin(c);
	l=a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c));
	h=b*sin(c);
	
	printf("%lf\n%lf\n%lf\n",s,l,h);
	
	return 0;
}


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


int main(){
    int n;
    cin >> n;
    if(n%10==9){
        cout << "Yes" << endl;
        return 0;
    }
    n/=10;
    if(n==9){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    a = tuple(geta(int))
    s = sum(a)

    cur = 1
    ans = 0

    for ai in a:
        if cur < ai:
            print(-1)
            exit()
        else:
            ans += min(cur, s)
            cur = 2 * (min(cur, s) - ai)
            s -= ai

    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    if(n/10 == 9 || n%10 == 9)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(m, n):
    if m < n:
        m, n = n, m

    while True:
        r = m % n
        if r == 0:
            return n
        else:
            m, n = n, r

def lcm(m, n):
    return m*n // gcd(m, n)

n = int(input())
l = []

ans = 1

for i in range(n):
    t = int(input())
    ans = lcm(ans, t)

print(ans)


Measured memory_bytes: 9152
/*

- ÂeÂWÂÂÂÂÂÂÂÃÂ{ÂÃ°ÂÂ½ÂÃ»ÂÂÂÃ©ÂÂ©ÂÃ°ÂÂÂÃÂÃÂÃ¢ÂÃªÂÃÂÂ¢ÂÂ¢

- ÂÂ ÂÃ©ÂWÂÂÂÂÂÂÂÃÂ{ÂÃ°xÂ{ÂÂÂÃ©ÂÃÂÂ·ÂÃ©ÂÃÂAÂÂ±ÂÃÂÃÂÂ«ÂÃÂÃÂÃ¥ÂÂÂÃ£ÂlÂÃÂÃÂPÂÃÂÂÂÃÂÃ©ÂB
-- Â~ÂÂsortÂÂµÂÃÂAÂÃ¥ÂÂ«ÂÂ¢ÂÃ»ÂÂ©ÂÃ§ÂÃ¦ÂÃÂÃÂÂ¢ÂÂ¯ÂÃÂÂ¢ÂÂ¢ÂÂ©ÂÃ§

- ÂÂ±ÂÂ¤ÂÂ¢ÂÂ¤DPÂÂ·ÂÃªÂÃÂÂ¢ÂÂ¢ÂÃÂÂ¨ÂÃ ÂÂ¤
-- dp[ ÂWÂÂÂÂÂÂÂÃÂÂ (ÂÃÂÃ¥10) ][ ÂÂÂÃÂÂ½ÂÃ»ÂÂ (ÂÃÂÃ¥2000) ]
-- [i][j]ÂÂ©ÂÃ§ÂÃÂAÂWÂÂÂÂÂÂiÂÃ°ÂÂÂÃ©ÂÃ»ÂÂkÂÃ°ÂÂÂÃÂÃÂA[i+1][j+k]ÂÃÂÂªÂÃ²ÂÂ³ÂÂ¹ÂÃ©

- ÂvÂZÂÃÂÃ
-- DPÂzÂÃ±ÂÃÂÃ¥ÂÂ«ÂÂ³(10 * 2000) * ÂÂÂÃ©ÂÃ»ÂÂÂÃ°ÂÂÂÃÂÃ©ÂÃÂÂ«ÂÃÂÂÂ[ÂvÂÃ(2000)
-- O(4000ÂÂ)
-- ÂÃ¥ÂÃ¤ÂvÂÃÂvÂZÂÃ
-- ÂÃÂÃÂÃÂÃÂAÂÂÂÃ©ÂÃ»ÂÂÂÃ°ÂÂÂÃÂÃ©ÂÂÂ[ÂvÂÂªÂÂ­ÂÃÂÂ­ÂÃÂÃ©ÂÃÂvÂÃ­ÂÃªÂÃ©ÂÃÂÃÂAÂÃ ÂÂ¤ÂÂ­ÂÂµÂvÂZÂÃÂÃÂÂ¬ÂÂ³ÂÂ¢

 */
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int dp[12][2002];

int main(){
  int n, m;

  while(cin >> n >> m){
    vector<int> t[12];

    for(int i = 0; i < n; i++){
      int price, x;
      cin >> price >> x;
      t[x - 1].push_back(price);
    }

    for(int i = 0; i < 10; i++){
      sort(t[i].rbegin(), t[i].rend());
      for(int j = 1; j < t[i].size(); j++) t[i][j] += t[i][j - 1];
      for(int j = 1; j < t[i].size(); j++) t[i][j] += (j + 1) * j;
    }

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    for(int i = 0; i < 10; i++){
      for(int j = 0; j <= m; j++){
        if(dp[i][j] == -1) continue;

        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

        for(int k = 1; j + k <= m && k <= t[i].size(); k++){
          dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + t[i][k - 1]);
        }
      }
    }

    cout << dp[10][m] << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(void){
    int A,B,K; cin >> A >> B >> K;
    
    vector<int> res(min(A,B));
    
    for(int i = 1; i <= min(A,B); i++){
        if (A % i == 0 && B % i == 0){
            res.push_back(i);
        }
    }
    
    int index = res.size() - K;
    cout << res.at(index) << endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int best = 1;
    for(int i = 1; i * i <= m; i++){
        if(m % i == 0){
            if(i <= m / n) best = max(i, best);
            if(m / i <= m / n) best = max(m / i, best);
        }
    }
    cout << best << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())


if a <= c and c <= b:
    print(a, c, b)
elif b <= a and a <= c:
    print(b, a, c)
elif b <= c and c <= a:
    print(b, c, a)
elif c <= a and a <= b:
    print(c, a, b)
elif c <= b and b <= a:
    print(c, b, a)
else:
    print(a, b, c)


Measured memory_bytes: 5596
n, q = map(int, input().split())
p = [-1]*n

def root(x):
    if p[x]==-1:
        return x
    
    p[x] = root(p[x])
    return p[x]

def unite(a, b):
    if root(a)!=root(b):
        if a>b:
            a,b = b,a
        p[root(b)] = root(a)
        
def same(a, b):
    if root(a)==root(b):
        return True
    else:
        return False
    
for i in range(q):
    c, a, b = map(int, input().split())
    if c==0:
        unite(a, b)
       # print(p)
    if c==1:
        if same(a, b):
            print(1)
        else:
            print(0)


Measured memory_bytes: 5772
/*
  AOJ 2190
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
char stairs[50001][3];
char music[50001][3];
int m,n;
char oct[]="C C#D D# E F F#G G#A A#B ";

int t2n(char tt[3])
{
        int num;
	char t[3];
	memcpy(t,tt,3);
 
        if(t[1]=='\0')
        {       t[1]=' ';
                t[2]='\0';
        }
        num=(strstr(oct,t)-oct)/2;
        return(num);
} 
int diff(char t1[],char t2[])
{
  int ret=t2n(t2)-t2n(t1);
  //printf("diff %c%c %c%c\n",t1[0],t1[1],t2[0],t2[1]);
  if(ret<0)
    ret+=12;
  return(ret);
}
solve(int st,int mu,int lv)
{
  int i;
#ifdef DEBUG
  for(i=0;i<lv;i++)printf(">");
  printf("st,mu=%d %d \n",st,mu);
#endif
  if(st>=m-1 && mu==n)
    return(1);
  if(mu==n)
    return(0);
  if(diff(&stairs[st+1][0],&music[mu+1][0])==0)
    if(solve(st+1,mu+1,lv+1))
      return(1);
  if(st < n-1 && diff(&stairs[st+2][0],&music[mu+1][0])==1)
    if(solve(st+2,mu+1,lv+1))
      return(1);
  if(st > 1 && diff(&stairs[st-1][0],&music[mu+1][0])==11)
    return(solve(st-1,mu+1,lv+1));
  return(0);
}
void dump()
{
  int i;
  for(i=1;i<=m;i++)
    printf("%2s|",&stairs[i][0]);
  printf("\n");
  for(i=1;i<=n;i++)
    printf("%2s|",&music[i][0]);
  printf("\n");
  printf("----------------\n");
}
int check_last()
{
  int diff1,diff2;

  diff1=diff(&stairs[m][0],&music[n][0]);
  diff2=diff(&stairs[m-1][0],&music[n][0]);
  return ((diff1==0||diff1==1||diff1==11) || (diff2==0||diff2==1||diff2==11));
}
main()
{
  int d,i,j,ret;
  scanf("%d",&d);
  for(i=0;i<d;i++)
    {
      scanf("%d %d",&m,&n);
      for(j=1;j<=m;j++)
	scanf("%s ",&stairs[j][0]);
      for(j=1;j<=n;j++)
	scanf("%s ",&music[j][0]);
#ifdef DEBUG
      dump();
#endif
      ret=(  check_last() && solve(0,0,0));
      printf("%s\n",ret?"Yes":"No");
    }
  return(0);
}

Measured memory_bytes: 2644
#include<stdio.h>

int main(){
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		bool d[10];
		for(int i=0;i<10;i++)d[i]=false;
		d[a-1]=true;
		d[b-1]=true;
		d[c-1]=true;
		int time=0;
		for(int i=0;i<10;i++){
			if(!d[i]){
				if(a+b+i+1<=20)time++;
			}
		}
		if(time>3)printf("YES\n");
		else printf("NO\n");
	}
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

string atos(int N){
	stringstream res;
	string s;
	while(N > 0){
		s += (char)(N % 2 + '0');
		N /= 2;
	}
	reverse(all(s));
	res << setw(22) << setfill('0') << s;
	return res.str();
}

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<string> S(N);
	rep(i,N)cin >> A[i];
	rep(i,N){
		S[i] = atos(A[i]);
	}
	ll ans = 0;
	int right = 0;
	vector<int> digsum(22,0);
	rep(left, N){
		while(right < N){
			rep(k,22)if(S[right][k] == '1') ++digsum[k];
			bool ok = true;
			rep(k,22)if(digsum[k] >= 2)ok = false;
			if(ok){
				++right;
			}else{
				rep(k,22)if(S[right][k] == '1') --digsum[k];
				break;
			}
		}
		ans += right - left;		
		if(right == left) ++right;
		else{
			rep(k,22)if(S[left][k] == '1') --digsum[k];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 19640
s = input()

before = 0
before_2 = 1

for i in range(2, len(s)):
    if s[before] == s[before_2]:
        print(before + 1, before_2 + 1)
        exit()
    if s[before] == s[i] and s[before] != s[before_2]:
        print(before + 1, i + 1)
        exit()
    before = before_2
    before_2 = i
if s[-1] == s[-2]:
    print(len(s) - 1, len(s))

else:
    print(-1, -1)


Measured memory_bytes: 3188
k=int(input())
a=list(map(int,input().split()))
if a[-1]!=2:
  print(-1)
  exit()
l,r=2,2
for i in range(k):
  ai=a[-1-i]
  # l以上r以下のaiの倍数を探す。なければ-1
  if r<ai or (l//ai==r//ai and l%ai!=0):
    print(-1)
    exit()
  l=ai*((l+ai-1)//ai)
  r=ai*(r//ai)+(ai-1)
print(l,r)



Measured memory_bytes: 20500
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
class BIT {
  vector<T> tree_;

 public:
  BIT(int n) : tree_(n, 0) {}
  void Add(int i, T x) {
    for (i++; i <= tree_.size(); i += i & -i) {
      tree_[i - 1] += x;
    }
  }

  T Sum(int s) {
    T ans = 0;
    for (s++; s > 0; s -= s & -s) {
      ans += tree_[s - 1];
    }

    return ans;
  }

  T Sum(int l, int r) { return Sum(r) - Sum(l - 1); }
};

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n;
  cin >> n;
  vector<vector<int>> vs(n);
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    vs[c - 1].push_back(i);
  }

  vector<vector<int>> tree(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }

  int k = 0;
  vector<int> in(n), out(n);
  function<void(int, int)> dfs;
  dfs = [&](int v, int p) {
    in[v] = k++;
    for (int u : tree[v]) {
      if (u != p) {
        dfs(u, v);
      }
    }

    out[v] = k - 1;
  };

  dfs(0, -1);

  auto c2 = [](ll n) { return n * (n + 1) / 2; };
  BIT<ll> d(n);
  for (int i = 0; i < n; i++) {
    d.Add(i, 1);
  }

  ll tot = c2(n);
  for (int i = 0; i < n; i++) {
    ll ans = tot;
    vector<int> &nvs = vs[i];
    sort(nvs.begin(), nvs.end(), [&](int a, int b) { return in[a] > in[b]; });
    vector<pair<int, int>> history;
    for (int v : nvs) {
      int cnt = 1;
      for (int u : tree[v]) {
        if (in[u] > in[v]) {
          int num = d.Sum(in[u], out[u]);
          ans -= c2(num);
          cnt += num;
        }
      }

      d.Add(in[v], -cnt);
      history.emplace_back(in[v], cnt);
    }

    ans -= c2(d.Sum(n - 1));
    for (auto p : history) {
      d.Add(p.first, p.second);
    }

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

  return 0;
}

Measured memory_bytes: 40992
n,a,b = tuple(map(int,input().split()))

s = list(input())
rank = 0
brank = 0
for s_i in s:
  if s_i=='a':
    if rank==a+b:
      print("No")
      continue
    rank+=1
    print("Yes")
  elif s_i=='b':
    if rank==a+b:
      print("No")
      continue
    if brank==b:
      print("No")
      continue
    rank+=1
    brank+=1
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 4712