akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 100001
class DisjointSet{
    public:
    vector<int> rank,p;

    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++) makeSet(i);
    }
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }
    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }
    void link(int x,int y){
        if(rank[x]>rank[y]) p[y]=x;
        else{
            p[x]=y;
            if(rank[x]==rank[y]) rank[y]++;
        }
    }
    int findSet(int x){
        if(x!=p[x]) p[x]=findSet(p[x]);
        return p[x];
    }
};
int n,q,com,a,b;
int main(){
    cin>>n>>q;
    DisjointSet ds=DisjointSet(n);
    for(int i=0;i<q;i++){
        cin>>com>>a>>b;
        if(com==0) ds.unite(a,b);
        else{
            if(ds.same(a,b))cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        int n;
        int A[3][3];
        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j)
                cin >> A[i][j];
        cin >> n;
        for (int i = 0; i < n; ++i) {
            int t;
            cin >> t;
            for (int j = 0; j < 3; ++j) {
                for (int jj = 0; jj < 3; ++jj) {
                    if (t == A[j][jj]) {
                        A[j][jj] = 0;
                    }
                }
            }
        }
        if (!A[0][0] && !A[0][1] && !A[0][2]) {

        } else if (!A[1][0] && !A[1][1] && !A[1][2]) {

        } else if (!A[2][0] && !A[2][1] && !A[2][2]) {

        } else if (!A[0][0] && !A[1][0] && !A[2][0]) {

        } else if (!A[0][1] && !A[1][1] && !A[2][1]) {

        } else if (!A[0][2] && !A[1][2] && !A[2][2]) {

        } else if (!A[0][0] && !A[1][1] && !A[2][2]) {

        } else if (!A[2][0] && !A[1][1] && !A[0][2]) {

        } else {
            cout << "No\n";
            return;
        }
        cout << "Yes\n";
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    //入力
    Scanner scanner = new Scanner(System.in);
    
    int N = scanner.nextInt();
    
    int[] arrayH = new int[N];
    for(int i = 0; i < N; i++){
      arrayH[i] = scanner.nextInt();
    }
    
    //処理
    String result = "Yes";
    int max = 0;
    
    for(int i = 0; i < N; i++){
      if(max - arrayH[i] >= 2){
        result = "No";
      }
      
      if(arrayH[i] > max){
        max = arrayH[i];
      }
    }
    
    System.out.println(result);
  }
}


Measured memory_bytes: 50888
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        sc.close();
    }
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

  for (Real a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f, cin; ) {

    Real det = a * e - b * d;
    Real x = e * c - b * f;
    Real y = - d * c + a * f;
    x /= det;
    y /= det;
    if (x == -0.0) x = 0.0;
    if (y == -0.0) y = 0.0;
    printf("%0.3f %0.3f\n", x, y);

  }

  return 0;
}

Measured memory_bytes: 1228
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",if b%a==0{a+b}else{b-a})
}

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

vector<ll> to[200010];
vector<ll> ans;
vector<bool> seen;

void dfs(int v) {
    seen[v] = 1; 

    for (auto next_v : to[v]) { 
        if (seen[next_v]) continue;
        ans[next_v]+=ans[v];
        dfs(next_v); 
    }
}

int main(){
    ll N,Q;cin>>N>>Q;
    rep(i,0,N-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(N);
    rep(i,0,Q){
        ll p,x;
        cin>>p>>x;
        p--;
        ans.at(p)+=x;
    }
    seen.assign(N,0);
    dfs(0);
    rep(i,0,N)cout<<ans[i]<<endl;
}







Measured memory_bytes: 25856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    cout << s.substr(0, 4) << " " << s.substr(4, 12) << endl;

    return 0;
}


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

using namespace std;

int N, K;
vector<int> a;
bitset<5001> dp;

//is m necessary?
bool sub(int m) {
	if(K <= a[m]) return true;
	dp.reset();
	dp.set(0);
	for(int i = 0; i < N; ++i) {
		if(i != m) dp |= (dp << a[i]);
	}
	for(int b = K - a[m]; b < K; ++b) {
		if(dp[b]) return true;
	}
	return false;
}

int main(void) {
	cin >> N >> K;
	long long s = 0;
	for(int i = 0; i < N; ++i) {
		int t;
		cin >> t;
		a.push_back(t);
		s += t;
	}
	sort(a.begin(), a.end());
	if(s < K) {
		cout << N << '\n';
		return 0;
	}

	if(sub(0)) {
		cout << "0\n";
		return 0;
	}
	int L = 0, R = N;
	while(1 < R - L) {
		int m = (L + R) / 2;
		(sub(m) ? R : L) = m;
	}
	cout << R << '\n';
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

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

            while (N != 0)
            {
                var rem = N % 2;
                if (rem < 0) rem += 2;

                N = (N - rem) / -2;
                s += rem;
            }

            s = new string(s.Reverse().ToArray());

            Console.WriteLine(s == "" ? "0" : s);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#define rep(i,n)for(int i=0;i<n;i++)
#define l int64_t
using namespace std;l q,x,y,f[99]={0,1},m=1e9+7;main(){cin>>q;rep(i,97)f[i+2]=f[i]+f[i+1];rep(i,q){cin>>x>>y;if(x>y)swap(x,y);if(y<=2){printf("1 %d ",y==1?1:x==1?2:4);continue;}rep(j,99){if(x<f[j]|y<f[j+1]){l a=x==1?2:1;rep(k,j-2){l n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];if(n<=x&m<=y)a+=(y-m)/n+1;}if(f[j]<=x){a++;rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);}cout<<j-2<<" "<<a%m<<" ";j=99;}}}}

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

int main(){
   char picture[100][100];
   short h,w;

   cin >> h,cin >>w;

   //picture = new char[h][w];
   for(short i = 0;i < h;i++){
      for(short j = 0;j < w;j++) cin >> picture[i][j];
   }

   for(short j = 0;j < w + 2; j++) cout << '#';
   cout <<"\n";
   for(short i = 0;i < h;i++){
      cout << '#';
      for(short j = 0;j < w;j++) cout << picture[i][j];
      cout << "#\n";
   }
   for(short j = 0;j < w + 2; j++) cout << '#';
   cout <<"\n";

   return 0;
}

Measured memory_bytes: 256
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//  cout <<  s.at(1)-'0'-49  <<endl;
int main() {
  int a,b,k;
  cin >> a >> b >> k;
  if( b-a+1 <= 2*k){
    for(int i=a; i<=b; i++){
      cout << i << endl;
    }
  }
  else{
    for(int i=a;i<a+k;i++){
      cout << i << endl;
    }
    for(int i=b-k+1;i<b+1;i++){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[105],n;
bool esta(int k){
    bool b=true;
    for(int i=0;i<n;i++){
        if(k==a[i]) b=false;
    }
    if(b) return true;
    else return false;
}

int main() {
    int x;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int t1=1e5,t2=1e5;
    for(int i=0;i<=200;i++){
        if(esta(i)){
            if(x>i) t1=min(t1,x-i);
            else t2=min(t2,i-x);
        }
    }
    if(t1>t2) cout<<x+t2<<"\n";
    else cout<<x-t1<<"\n";
    
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            int tmp_a;
            cin >> tmp_a;
            a[i][j] = tmp_a;
        }
    }
    int ans = 1e8;
    rep(i, 1<<n) {
        int cost = 0;
        vector<int> s(m, 0);
        rep(j, n) {
            if ( (i>>j) & 1 ) {
                cost += c[j];
                rep(k, m) {
                    s[k] += a[j][k];
                }
            }
        }
//        cout << cost << endl;
        bool ok = true;
        rep(j, m) {
            if (s[j] < x) {
                ok = false;
                break;
            } 
        }
        if ( ok ) {
            ans = min(ans, cost);
        }
    }
    if ( ans == 1e8 ) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}


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

int main() {
  int n;
  string s;
  ll ans=0,r=0,g=0,b=0;
  cin >> n >> s;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }
  ans = r*g*b;
  for(int i=1;2*i<n;i++){
    for(int j=0;j+2*i<n;j++){
      if(s[j] != s[j+i] && s[j+i] != s[j+2*i] && s[j+2*i] != s[j]) ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2, degrees
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
total_xor = 0
for i in range(n):
    total_xor ^= A[i]


for i in range(n):
    A[i] &= ~total_xor


r = 0
for i in range(60, -1, -1):
    for j in range(r, n):
        if (A[j] >> i) & 1:
            A[r], A[j] = A[j], A[r]
            break
    else:
        continue
    for j in range(n):
        if j == r:
            continue
        if (A[j] >> i) & 1:
            A[j] ^= A[r]
    r += 1


ret = 0
for i in range(n):
    ret ^= A[i]


print(ret * 2 + total_xor)







Measured memory_bytes: 69488
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);
	
	REP(i, N) {
		A[i] = A[i] - 1;
		A[i] %= K;
		A[i] = (A[i] + K) % K;
	}
	
	vector<int> sum(N + 1);
	sum[0] = 0;
	REP(i, N) sum[i + 1] = (sum[i] + A[i]) % K;
	
	ll ans = 0;
	map<int, int> mm;
	FOR(i, 1, N + 1) {
		if (sum[i] == 0) ans++;
		if (i >= K) mm[sum[i - K]]--;
		ans += mm[sum[i]];
		mm[sum[i]]++;
	}
	
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
vector<pii>l_list[100005];
int check[100005];
int d[100005];
int DFS(int x,int ct){
	check[x]=ct==MOD?1:2;
	d[x]=ct;
	for(auto &p:l_list[x]){
		if(check[p.F]==1)continue;
		else if(check[p.F]==2){
			if(d[x]==MOD){
				d[x]=d[p.F]-p.S;
				check[x]=2;
			}
			else{
				if(d[x]!=d[p.F]-p.S)return -MOD;
			}
		}
		else{
			if(check[x]<2){
				int t=DFS(p.F,MOD);
				if(t==-MOD)return -MOD;
				if(d[x]==MOD){
					d[x]=t-p.S;
					check[x]=2;
				}
				else{
					if(d[x]!=t-p.S)return -MOD;
				}
			}
			else{
				int t=DFS(p.F,d[x]+p.S);
				if(t==-MOD)return -MOD;
			}
		}
	}
	if(d[x]==MOD)d[x]=0,check[x]=2;
	return d[x];
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		int t1,t2,t;
		scanf("%d%d%d",&t1,&t2,&t);
		l_list[t1].pb({t2,t});
		l_list[t2].pb({t1,-t});
	}
	for(int i=1;i<=n;i++){
		if(!check[i]){
			if(DFS(i,MOD)==-MOD)ex("No");
		}
	}
	printf("Yes");
}

Measured memory_bytes: 11392
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
ans = [1] * len(h)

for i in range(m):
    a[i], b[i] = map(int, input().split())

for i in range(m):
    if h[a[i]-1] > h[b[i]-1]:
        ans[b[i]-1] = 0
    elif h[a[i]-1] < h[b[i]-1]:
        ans[a[i]-1] = 0
    else:
        ans[b[i]-1] = 0
        ans[a[i]-1] = 0

print(sum(ans))

Measured memory_bytes: 21856
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, A, B;
	cin >> N >> A >> B;

	cout << min(N * A, B);

	return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    ll SUM=0;

    rep(i,s.size()){
        SUM+=s[i]-'0';
    }

    if(SUM%9==0)cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1400

int dp[MAX][MAX], G[MAX][MAX];

int getLargestSquare(int H, int W) {
  int maxWidth = 0;
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      dp[i][j] = (G[i][j] + 1) % 2;
      maxWidth |= dp[i][j];
    }
  }
  
  for ( int i = 1; i < H; i++ ) {
    for ( int j = 1; j < W; j++ ) {
      if ( G[i][j] ) {
	dp[i][j] = 0;
      } else {
	dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
	maxWidth = max(maxWidth, dp[i][j]);
      }
    }
  }
  
  return maxWidth * maxWidth;
}

int main(void) {
  int H, W;
  scanf("%d %d", &H, &W);
  
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) scanf("%d", &G[i][j]);
  }
  
  printf("%d\n", getLargestSquare(H, W));
  
  return 0;
}

Measured memory_bytes: 17988
#include<iostream>
using namespace std;
int main(){
	int a,b;
  	int x;
  	cin >> a >> b;
  	x=a+b;
  	if(a-b>x)
        x=a-b;
  	if(a*b>x)
        x=a*b;
  	cout << x;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll X,Y; cin>>X>>Y;
  rep(i,X+1)
  {
    ll t=X-i;
    if(2*i+4*t==Y)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3632
from math import sqrt
n = int(input())
X = []
Y = []
s = 0
for i in range(n):
    x,y = input().split()
    X.append(int(x))
    Y.append(int(y))

for i in range(n):
    for j in range(n):
        a = X[i] - X[j]
        b = Y[i] - Y[j]
        s += sqrt(a*a + b*b)
print(s/n)

Measured memory_bytes: 3064
// Nihesh Anderson - knandy

#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;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int n, m;
	cin >> n >> m;
	if(n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

a = []
b = []

for i in range(n):
    aa, bb = map(int, input().split(' '))
    a.append(aa)
    b.append(bb)

order = sorted(range(len(b)), key=lambda k: b[k])

available = False


margin = [0 for i in range(n)]
now_time = 0
for i in range(n):
    j = order[i]
    margin[j] = b[j] - (now_time + a[j])
    now_time += a[j]

if min(margin) >= 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 33204
N = int(input())
A = list(map(int, input().split()))
for a in A:
    if a % 2 == 0:
        if (a % 3 == 0) or (a % 5 == 0):
            continue
        else:
            print("DENIED")
            exit()
    else:
        continue
print("APPROVED")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
    int i;
    int N, V[30], C[30];
    scanf("%d",&N);
    for(i = 0; i < N; i++)
        scanf("%d",&V[i]);
    for(i = 0; i < N; i++)
        scanf("%d",&C[i]);

    int sum = 0;
    for(i = 0; i < N; i++)
    {
        /* code */
        if(V[i] > C[i]) {
            sum = sum + (V[i] - C[i]);
        }      
    }
    printf("%d\n",sum);


return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

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

vector<ll> newton_interpol(ll D, const vector<ll>& X, const vector<ll>& Y, ll mod){
  vector<ll> res(D, 0), C(D);
  vector<vector<ll>> dp(D + 1, vector<ll>(D + 1, 0));

  // construct C array
  for(ll i = 0; i < D; i++) {
    ll sum = 0, crt = 1;
    for(ll j = 0; j < i; j++) {
      sum += crt * C[j] % mod;
      sum %= mod;
      crt *= (X[i] - X[j] + mod) % mod;
      crt %= mod;
    }
    C[i] = (Y[i] - sum + mod) % mod;
    C[i] *= mod_pow(crt, mod - 2, mod);
    C[i] %= mod;
  }

  // calc polynomial (dp)
  dp[0][0] = 1;
  for(ll i = 0; i < D; i++) {
    for(ll j = 0; j <= i; j++) {
      res[j] += C[i] * dp[i][j] % mod;
      res[j] %= mod;
    }
    if(i == D - 1) break;
    for(ll j = 0; j <= i; j++) {
      (dp[i + 1][j] += dp[i][j] * (D - i)) %= mod;
      (dp[i + 1][j + 1] += dp[i][j]) %= mod;
    }
  }

  return res;
}

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

  ll p;
  vector<ll> X,Y;

  cin>>p;
  X.resize(p); Y.resize(p);

  rep(i,p){
    X[i]=i;
    cin>>Y[i];
  }

  vector<ll> b=newton_interpol(p,X,Y,p);

  rep(i,p)cout<<b[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<string>> m(20);
void dfs(string s, char t)
{
    if (s.size() == 11)
    {
        m[s.size() - 1].push_back(s);
        return;
    }
    s = s + t;

    m[s.size() - 1].push_back(s);
    for (ll i = -1; i <= 1; i++)
    {
        if (i == -1 && s[s.size() - 1] == '0' || i == 1 && s[s.size() - 1] == '9')
        {
            continue;
        }
        ll l = (ll)s[s.size() - 1] + i;
        dfs(s, (char)l);
    }
}
int main()
{
    ll k;
    cin >> k;
    for (ll i = 1; i < 10; i++)
    {
        ll al = 48;
        char ak = al + i;
        dfs("", ak);
    }
    
    ll cnt = 0;
    for (ll i = 0; i < m.size(); i++)
    {
        for (ll j = 0; j < m[i].size(); j++)
        {
            if (cnt == k - 1)
            {
                cout << m[i][j] << endl;
                return 0;
            }
            cnt++;
        }
    }
}

Measured memory_bytes: 103524
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    string s;
    cin >> s;
    sort(all(s));
    if(s == "abc") cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
import qualified Data.IntMap as M
import Data.List
 
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  let dict = mkDict as
  print $ solve k dict
 
mkDict :: [Int] -> M.IntMap Int
mkDict [] = M.empty
mkDict (x:xs) = M.insertWith (+) x 1 $ mkDict xs
 
solve :: Int -> M.IntMap Int -> Int
solve k dict = sum . drop k . sortOn negate $ M.elems dict

Measured memory_bytes: 41980
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    ld l = m / 60.0 * 360.0 * acos(-1) / 180;
    ld x = b * sin(l);
    ld y = b * cos(l);
    // cout << x << "/" << y << endl;
    ld l2 = ((h * 60.0 + m) / (60.0 * 12.0)) * 360 * acos(-1) / 180;
    ld x2 = a * sin(l2);
    ld y2 = a * cos(l2);
    // cout << x2 << "/" << y2 << endl;
    cout << sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)) << endl;
}


Measured memory_bytes: 4184
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
 
n = int(input())
numlist = factorization(n)
result = 0
for i in numlist:
    k = 0
    for j in range(n):
        if(k*(k+1)/2 > i[1]):
            k-=1
            break
        else:
            k+=1
    result+=k
if(n == 1 ):
    result = 0
print(result)

Measured memory_bytes: 63400
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <cstdint>
#include <boost/range/irange.hpp>
using namespace std;
using namespace boost;

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

    int N,M,R;
    cin >> N >> M >> R;

    vector<vector<int>> D(N, vector<int>(N, 1e9));
    
    for( int i : irange(0, N) )
    {
        D[i][i] = 0;
    }

    vector<int> rs(R);
    for( int& r : rs )
    {
        cin >> r;
        r--;
    }
    sort(rs.begin(), rs.end());

    for( int i : irange(0, M) )
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        D[a][b] = c;
        D[b][a] = c;
    }

    for( int i : irange(0, N) )
    {
        for( int j : irange(0, N) )
        {
            for( int k : irange(0, N) )
            {
                D[j][k] = min(D[j][k], D[j][i] + D[i][k]);
            }
        }
    }

    int mini = 1e9;
    do{
        int s, cost = 0;
        for( int i : irange(0, R) )
        {
            if(i)
            {
                cost += D[s][rs[i]];
                s = rs[i];
            }
            else s = rs[i];
        }
        mini = min(mini, cost);
    }while(next_permutation(rs.begin(), rs.end()));

    cout << mini << endl;

    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int getPeace(string s, int& pos)
{
	int c = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s.substr(i, 1) == "1")
		{
			if (c == 0)
			{
				pos = i;
			}
			c++;
		}
	}
	return c;
}

int main()
{
	string s;
	string out = "";
	int p0 = -1;
	int pos0 = -1;
	for (int i = 0; cin >> s; )
	{
		int pos = -1;
		int p = getPeace(s, pos);

		if (out == "")
		{
			if (p == 4)
			{
				out = "C";
			}
			else if (p == 2)
			{
				if (p0 == 2)
				{
					if (pos == pos0)
					{
						out = "A";
					}
					else if (pos > pos0)
					{
						out = "E";
					}
					else
					{
						out = "G";
					}
				}
				else if (p0 == 1)
				{
					if (pos < pos0)
					{
						out = "D";
					}
					else if (pos == pos0)
					{
						out = "F";
					}
				}
			}
			else if (p == 1)
			{
				if (p0 == 1)
				{
					out = "B";
				}
			}
		}

		p0 = p;
		pos0 = pos;

		i++;
		if (i == 8)
		{
			i = 0;
			cout << out << endl;
			out = "";
			p0 = -1;
			pos0 = -1;
		}
	}

}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1<<27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

ll func(ll a, ll x){
    if (a == -1) return 0;
    return (a / x) + 1;
}

int main(){
    ll a, b, x; cin >> a >> b >> x;
    pt(func(b, x) - func(a - 1, x));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}



ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*(i%mod);
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
	ll x,y,ans = 0;

	cin >> x >> y;
	if ((x + y) % 3 !=0){
		ans = 0;
	}
	else{
		ll n = (2*y - x)/3;
		ll m = (2*x - y)/3;
		if (n < 0 || m < 0){
			ans = 0;
		}
		else{
			COMinit();
			ans = COM(n+m,n);	
		}
	}
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <cmath>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

int m;
double dp[1001][1001];

//ifstream ifs("input.txt");
//#define cin ifs

double dfs(int pos,int mem){
	if(mem<0)return 0;
	else if(pos>=m)return 0;
	else if(m-pos<=mem)return 0;
	else if(dp[pos][mem]>=-0.5)return dp[pos][mem];
	double res=0;
	double per1=1.0*mem/(m-pos);
	// êÚªÌÉ¶Ý
	if(!EQ(per1,0))
		res+=per1*(dfs(pos+1,mem-1));
	if(!EQ(per1,1)){
		double per2=(1.0)/(m-pos-1);
		// êÚÈOÆ}b`
		double per3=((double)mem)/(m-pos-1);
		// êÚÆ}b`
		if(!EQ(per2,0))
			res+=(1-per1)*(per2*(dfs(pos+2,mem)));
		// êÚÈOÌÌàÌÆ}b`
		if(!EQ(per3,0))
			res+=(1-per1)*(per3*(dfs(pos+2,mem)+1));
		// }b`¹¸
		if(!EQ(1-per2-per3,0))
			res+=(1-per1)*(1-per2-per3)*(dfs(pos+2,mem+2)+1);
	}
	return dp[pos][mem]=res;
}

int main(){

	while(cin>>m&&m!=0){
		for(int i=0;i<1001;i++)
			for(int j=0;j<1001;j++)dp[i][j]=-1;
		double res=dfs(0,0);
		printf("%.8f\n",res);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<iomanip>
using namespace std;

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

    vector<double> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<double> inv(N);
    for (int i = 0; i < N; i++)
        inv[i] = 1.0 / A[i];

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

    double ans = 0.0;
    for (int i = 0; i < N; i++)
        ans += inv[i];

    ans = 1.0 / ans;

    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	while(1){
		int n, d;//n country  d limit
		cin >> n >> d;
		if(n == 0 && d == 0) return 0;

		vector<pair<int, int> > inf(n);//fi ???????????????????????????????¨????se????¬?????????????????????¨?????§???????????????????????????
		rep(i, n) inf[i].fi = 0;//?????????
		rep(i, n) inf[i].se = 0;//?????????
		vector<vector<int> > misairu(n);//misairu[i][]??????i???????????????????????\???

		rep(i, n){
			int m; scanf("%d", &m);
			misairu[i].resize(m);
			for (int j = m - 1; j >= 0 ; --j){//?????????????????????????????????????????????????????§??????????????\??????
				int c; scanf("%d", &c);
				misairu[i][j] = c;
				inf[i].fi += c;//??????????????????????????\????????????
			}
		}

		//??¨??¢?´¢
		while(1){
			bool endflag = false;
			int cntflag = 0;
			rep(j, n){
				int size = misairu[j].size() - inf[j].se;//j???????????¨?????????????????????????????£????????????
				//printf("misairusaize %lu\n", misairu[j].size());
				//printf("j %d size %d\n", j, size);

				if(size <= 0) continue;
				int now = inf[j].se;//???????¶?????????¨?????§???????????????????????????
				int tikara = misairu[j][now];//????????¨??????????????¨????????????????????????????¨????
				int tmp = inf[j].fi;//????¨?????????????????????????
				inf[j].fi -= tikara;//??????????????????????????????????¨???????????¨????
				//?????§?????¨????°?????????¢???
				int dai = -1, syou = 10000000;
				rep(k, n){
					dai = max(dai, inf[k].fi);
					syou = min(syou, inf[k].fi);
				}
				//rep(k, n) printf("inffi %d\n", inf[k].fi);
				//printf("dai %d   syopu%d\n", dai, syou);

				if(dai - syou > d){//??????????¨?????????§???????????¨?°????????????????????????????d????¶???????????????????????????§??????
					//printf("??????\n");
					inf[j].fi = tmp;//?????????????????????
					cntflag++;
					//printf("NOOOOOOOOO %d %d\n", j, cntflag);
					if(j == n - 1 && cntflag == n){
						printf("No\n");
						endflag = true;
						break;
					}  
				}else{
					//printf("yeahs\n");
					//printf("ok\n");
					inf[j].se++;
					//flag = true;//?????????????????????????????¨?????§???????????¨?????????
				}
				//?????????????????????????????????????????????????¨????????¨????
				int sum = 0;
				rep(j, n) sum += inf[j].fi;
				if(sum == 0){
					printf("Yes\n");
					endflag = true;
					break;
				}
				/*
				//??????????????????????????????????????????????????¨?????§???????????£??????
				if(j == n - 1 && cntflag  == n - 1){
					printf("NO\n");
					endflag = true;
					break;
				}
				*/
			}
			if(endflag == true) break;
		}
	}
	return 0;
}

Measured memory_bytes: 3164
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        t: chars,
    }

    let mut used = vec![true; n];
    let mut ans = 0;
    for (i, &ti) in t.iter().enumerate() {
        if i >= k && t[i] == t[i - k] && used[i - k] {
            used[i] = false;
            continue;
        }
        ans += if ti == 'r' {
            p
        } else if ti == 's' {
            r
        } else {
            s
        };
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
num_books,m,min_understanding=list(map(int,input().split()))
info=[]
for _ in range(num_books):
    arr=list(map(int,input().split()))
    info.append(arr)
#print(info)
from itertools import combinations
l=[i for i in range(1,num_books+1)]
new=[]
for i in range(1,num_books+1):
    new.append(list(combinations(l,i)))
#print(new)
def add(l1,l2):
    faltu=[0 for i in range(len(l1))]
    #print(len(l1),len(l2),"fds")
    #print(l1,l2,"daa")
    for i in range(len(l1)):
        faltu[i]=l1[i]+l2[i]
    return faltu
def check(temp):
    #print(temp,len(temp))
    ans=[0 for i in range(m+1)]
    for i in range(len(temp)):
        ans=add(ans,info[temp[i]-1])
    for i in range(1,len(ans)):
        if ans[i]>=min_understanding:
            continue
        else:
            return 999999999
    return ans[0]
tempo=[]
for i in new:
    for j in i:
        tempo.append(check(j))
if min(tempo)==999999999:
    print(-1)
else:
    print(min(tempo))#arr[0] would be the price of that book

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

using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};
//const int INF = (1 << 29);

int main(){

  int k;
  cin >> k;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << a[k-1];

  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, M; cin >> N >> M;
  map<int, int> m;
  rep(i, M) {
    int a, b; cin >> a >> b;
    m[a]++;
    m[b]++;
  }
  for (auto e: m) {
    if (e.second % 2) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

string S; cin >> S;
int64_t sum = 0ll;
int Slen = S.size();

rep(bit, 0, (1<<Slen)) { // bit全探索, 0 ≦ bit < 0b1000... （0がSlen個ならぶ)
    int64_t sub = 0;
    rep(i, 0, Slen){ // Sの位置 
        if (bit & (1<<i)){
            sum += sub;
            sub = 0;
        }
        else sub = 10 * sub + (S[i] - '0');
    }
    sum += sub;
}

cout << sum << "\n";

return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()
ks = nan(m)
p = na()

ans = 0
for i in range(2 ** n):
    on = dict()
    for j in range(n):
        if (i >> j) & 1:
            on[j + 1] = True
    l = 0
    for j in range(m):
        k, s = ks[j][0], ks[j][1:]
        sum_on = 0
        for a in range(k):
            if on.get(s[a], False):
                sum_on += 1
        if sum_on % 2 == p[j]:
            l += 1
    if l == m:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
map<int,int>m;
map<int,int>m2;
int main(){
	cin>>N;
	REP(i,N){
		int a;
		cin>>a;
		if(i%2==0){
			m[a]++;
		}else{
			m2[a]++;
		}
	}
	int a1=0,a2=0;
	int b1=0,b2=0;
	int c1=0,c2=0;
	int d1=0,d2=0;
	for(auto it: m){
		if(it.second>b1){
			a2=a1;
			b2=b1;
			a1=it.first;
			b1=it.second;
		}else if(it.second>b2){
			a2=it.first;
			b2=it.second;
		}
	}
	for(auto it: m2){
		if(it.second>d1){
			c2=c1;
			d2=d1;
			c1=it.first;
			d1=it.second;
		}else if(it.second>d2){
			c2=it.first;
			d2=it.second;
		}
	}
	if(a1!=c1){
		cout<<N-(b1+d1)<<endl;
	}else{
		cout<<N-max(b1+d2,b2+d1)<<endl;
	}
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
int main(void){
int n,t;
int maxcost=999999;
int c[105],tt[105];
scanf("%d %d",&n,&t);

for(int count=0;count<n;count++){
scanf("%d %d",&c[count],&tt[count]);
}

for(int count=0;count<n;count++){
if(tt[count]<=t&&maxcost>=c[count]){maxcost=c[count];}
}
if(maxcost==999999){printf("TLE");}
else{
printf("%d",maxcost);
}

}

Measured memory_bytes: 128