akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  string str;
  char c, field[3][3];

  while(cin >> str) {
    int i = 0;
    c = 'd';
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
	field[j][k] = str[i];
	i++;
      }
    }

    for(i = 0; i < 3; i++) {
      if(field[i][0] != 's' && field[i][0] == field[i][1] && field[i][0] == field[i][2]) c = field[i][0];
      else if(field[0][i] != 's' && field[0][i] == field[1][i] && field[0][i] == field[2][i]) c = field[0][i]; 
    }
 
    if(field[1][1] != 's' && field[0][0] == field[1][1] && field[0][0] == field[2][2]) c = field[0][0];
    else if(field[1][1] != 's' && field[0][2] == field[1][1] && field[0][2] == field[2][0]) c = field[0][2];

    cout << c << endl;
  }
}

Measured memory_bytes: 1172
package main


import (
    "fmt"
    "strings"
    "strconv"
    "os"
)

func main() {
    var H,W int
    var y,x int
    var A string
    var minenumber int

// define 8 direction 
//     536              ^
//     1@2     <-dx->  dy
//     748              v

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

    
    fmt.Scan(&H,&W)

    S := make([][]string,H)
    for i:=0; i<H; i++ {
      S[i] = make([]string,W)
    }

    for i := 0; i < H; i++ {
      fmt.Scan(&A)
      slice := strings.Split(A,"")
      if len(slice) != W {
        fmt.Println("error")
        os.Exit(1)
      }
      S[i]   = slice
    }

    //fmt.Println(S)

    for i:=0; i < H; i++{
      for j:=0; j < W; j++ {

        if S[i][j] == "." {
          minenumber = 0
          for k:=0; k < 8 ; k++{
            y = i+dy[k]
            x = j+dx[k]
            if y >=0 && y < H {
              if x >=0 && x < W {
                if S[y][x] == "#" {
                  minenumber++
                }
              }
            }
          }
          S[i][j] = strconv.Itoa(minenumber)
        }
      }
    }

    for i:=0; i<H; i++ {
      fmt.Println(strings.Join(S[i],""))
    }

}




Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<queue>
#define ll long long
ll read()
{
	ll tmp=0;char c=getchar(),f=1;
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-48;c=getchar();}
	return tmp*f;
}
using namespace std;
int f[100100];
int n;
int main()
{
	int i;
	n=read();
	for(i=1;i<=n;i++)f[read()]++,f[read()+1]--;
	int tot=0,cnt=0;
	for(i=1;i<=100010;i++){
		cnt+=f[i];
		if(cnt>0)tot++;
	}
	printf("%d",tot);
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef pair<ll,ll> Q;
typedef pair<Q,ll> R;

int n,m;
bool ex[777][777];
vector<int>edge[777];
int cnt[2][777],col[777];

int par[777],ran[777];
void init(){ for(int i=0;i<777;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
void dfs(int v,int c){
	col[v] = c;
	rep(i,edge[v].size()){
		int to = edge[v][i];
		if(col[to] == -1) dfs(to,c^1);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b; scanf("%d%d",&a,&b);
		ex[a][b] = ex[b][a] = 1;
	}
	init();
	repn(i,n) repn(j,n) if(ex[i][j] == false && i != j){
		edge[i].pb(j);
		unite(i,j);
	}
	memset(col,-1,sizeof(col));
	repn(i,n){
		if(find(i) != i) continue;
		dfs(i,0);
	}
	repn(i,n)rep(j,edge[i].size()){
		if(col[i] == col[edge[i][j]]){
			puts("-1"); return 0;
		}
	}
	repn(i,n) cnt[col[i]][find(i)]++;
	
	bitset<777>B; B.reset(); B[0] = 1;
	repn(i,n){
	    //cout<<cnt[0][i]<<cnt[1][i]<<endl;
		B = (B<<cnt[0][i]) | (B<<cnt[1][i]);
	}
	int ans = INF;
	rep(i,777){
		if(B[i]){
			ans = min(ans,i*(i-1)/2 + (n-i)*(n-i-1)/2);
		}
	}
	cout << ans << endl;
}

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


int main(){
  while(true){
    int n,m,now = 0,x = 0;
    cin >> n >> m;
    if(n == 0 &&m == 0){
      break;
    }
    int sn[n],sm[m];
    for(int i = 0;i < n;i++){
      cin >> sn[i];
    }
    for(int j = 0;j < m;j++){
      cin >> sm[j];
    }
    for(int k = 0;k < m;k++){
      now = now + sm[k];
      x = x + 1;
    if(n <= now){
      break;
    }
    now = now + sn[now];
    if(n <= now){
      break;
    }
  }
  cout << x << endl;
    now=0;
    x=0;
  } 
    return 0;
}

Measured memory_bytes: 1168
use itertools_num::ItertoolsNum;
use proconio::input;
use std::iter::once;

fn main() {
    input!(n: usize, m: usize, k: u64, a: [u64; n], b: [u64; m]);
    let a: Vec<u64> = once(0).chain(a.into_iter()).cumsum().collect();
    let b: Vec<u64> = once(0).chain(b.into_iter()).cumsum().collect();
    let mut j = m;
    println!(
        "{}",
        a.into_iter()
            .take_while(|&x| x <= k)
            .enumerate()
            .map(|(i, x)| {
                while 0 < j && k < x + b[j] {
                    j -= 1;
                }
                i + j
            })
            .max()
            .unwrap()
    );
}


Measured memory_bytes: 10884
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int K,T; cin>>K>>T;
    vector<int> A(T);
    rep(t,0,T) cin>>A.at(t);

    sort(ToEnd(A));
    int64_t sum=accumulate(ToEnd(A),0),ans=0;
    if(A.back()>sum-A.back()) ans=A.back()-(sum-A.back())-1;

    cout<<ans<<endl;
}

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

int solve(int n){
  if(n%10==0)return 10;
  int res=0;
  while(n){
    res+=n%10;
    n/=10;
  }
  return res;
}

main(){
  int n;
  cin>>n;
  cout<<solve(n)<<endl;
}


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

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

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(int i = x-1 ; i >= 0 ; i --)
#define pb push_back
#define sor(vec) sort(vec.begin(),vec.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define fr first
#define sc second

const ll M = 1000000007;

int main(){
	int h,w;
	int a[202][202];
	scanf("%d%d",&h,&w);
	rep1(i,h)rep1(j,w){
		scanf("%d",&a[i][j]);
	}
	
	static int dp[202][202][202] = {};
	dp[1][1][1] = a[1][1];
	for(int i = 2 ; i <= w ; i ++)dp[1][1][i] = dp[1][1][i-1] + a[1][i];
	for(int i = 2 ; i <= h ; i ++){
		for(int k = w ; k >= 2 ; k --){
			for(int j = 1 ; j < k ; j ++){
				dp[i][j][k] = max ( dp[i][j][k] , dp[i-1][j][k]+a[i][j]+a[i][k] );
				dp[i][j][k] = max ( dp[i][j][k] , dp[i][j-1][k]+a[i][j] );
				for(int K = k+1 ; K <= w ; K ++){
					dp[i][j][K] = max ( dp[i][j][K] , dp[i][j][K-1]+a[i][K] );
				}
			}
		}
	}
	int ret = 0;
	for(int i = 1 ; i <= w ; i ++){
		ret = max ( ret , dp[h][i][w] );
	}
	cout << ret << endl;
}
				


Measured memory_bytes: 32128
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iterator>
#include <typeinfo>
using namespace std;


// define list


namespace  math{
    const double PI = 3.14;
    const int INF = 1000000007;
    int GCM(int a,int b); //最大公約数
    int LCM(int a,int b); //最小公倍数
    int Pemu(int n,int r); //順列
    int Comb(int n,int m); //組み合わせ
    int Digit(int N); //桁和
    
    int GCM(int a,int b){
        if(a<b){
            swap(a,b);
        }
        int r = a%b;
        while (r!=0)
        {
            a=b;
            b=r;
            r=a%b;
        }
        return b;
    }

    int LCM(int a,int b){
        return a*(b/GCM(a,b));
    }

    int Pemu(int n,int r){
        int ans = n;
        for(int i=1;i<r;i++){
            ans*=(ans-i);
        }
        return ans;
    }

    int Comb(int n,int m){
        int a=n,b=m;
        for(int i=1;i<m;i++){
            a *= (a-i);
        }
        for(int i=1;i<m;i++){
            b *= (b-i);
        }
        
        return a/b;
    }

    int Digit(int N){
        if(N<10){
            return N;
        }
        int r = 0;
        while (N>=10)
        {
            r += (N%10);
            N /= 10;
        }
        r += N;
        return r;
    }
}

namespace SubLib{
    #define int long long
    #define double long double
    #define incin(n) int (n); cin >> (n);
    #define incin2(a,b) int a,b; cin >> a >> b; 
    #define rap(n,i) for(int (i) = 0;i<(n);(i)++)
    #define input(n,v) (v) = SubLib::Input((n),(v))
    #define all(v) (v).begin(),(v).end()
    using intv = vector<int>;
    using strv = vector<string>;
    using charv = vector<char>;
    template <class T1>
    using pvec = vector<pair<T1,T1>>;
    template <typename T> vector<T> Input(int n,vector<T> v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
        return v;
    }
}

using namespace math;
using namespace SubLib;

signed main(){
    incin(n);
    incin2(t,a);
    double log_dif = 10000000000000.0;
    int point;
    int x;
    rap(n,i){   
        cin >> x;
        if(abs(t-(x * 0.006)-a) < log_dif){
            log_dif = abs(t-(x * 0.006)-a);
            point = i + 1;
        }
    }
    cout << point << endl;
    return 0;
}

Measured memory_bytes: 256
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=2e5+5;
ll n , ans[maxN];
ll solve(ll x , ll y , ll z){
	return x*x+y*y+z*z+x*y+y*z+z*x;
}
ll solve(ll N){
	ll ans=0;
	for(ll x=1;x*x<=N ; x++){
		for(ll y=1;y*y<=N ; y++){
			ll l=1 , r=N ;
			while(l<=r){
				ll z= (l+r)/2;
				ll ps=solve(x , y , z);
				if(ps==N){
					ans++;
					break;
				}
				else if(ps<N)l=z+1;
				else r=z-1;
			}
		}
	}
	return ans ;
}
void solve(){
	cin>> n ;
	for(ll i=1;i<=n ; i++){
		ans[i]=solve(i);
	}
	for(ll i=1;i<=n ;i++)cout<<ans[i]<<endl;

}

int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ; 
	while(t--)solve();
	cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

Measured memory_bytes: 3884
#include <stdio.h>

int main(){
    
    int S;
    int h;
    int m;
    int s;
    
    scanf("%d" , &S);
    
    h = S / 3600;
    S = S - h * 3600;
    m = S / 60;
    S = S - m * 60;
    s = S;
    
    printf("%d:%d:%d\n" , h , m , s);
    
    return 0;
}

Measured memory_bytes: 592
n=int(input())
h=list(map(int,input().split()))
l=[]
l.append(abs(h[1]-h[0]))
if n>2:
  l.append(min(abs(h[2]-h[0]),l[-1]+abs(h[2]-h[1])))
if n>3:
  for i in range(3,n):
    l.append(min(l[-1]+abs(h[i]-h[i-1]),l[-2]+abs(h[i]-h[i-2])))
print(l[-1])

Measured memory_bytes: 13928
#include <stdio.h>

int rectangle(int a, int b, int c)
{
	if (a*a + b*b == c*c) return 1;
	return 0;
}

int lozenge(int a, int b)
{
	if (a == b) return 1;
	return 0;
}
int main(void)
{
	int a, b, c;
	int rectangleN = 0, lozengeN = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
		if (rectangle(a, b, c)) rectangleN++;
		if (lozenge(a, b)) lozengeN++;
	}
	printf("%d\n%d\n", rectangleN, lozengeN);
	return 0;
}

Measured memory_bytes: 0
h,w = map(int,input().split())


map_input = [list(map(str,list(input()))) for i in range(h)]

map_list = [['.']*(w+2)]
for m in map_input:
    map_list.append(['.']+m+['.'])
map_list.append(['.']*(w+2))

for i in range(h+2):
    for j in range(w+2):
        if map_list[i][j]=='#':
            if map_list[i+1][j]=='#':
                continue
            elif map_list[i-1][j]=='#':
                continue
            elif map_list[i][j+1]=='#':
                continue
            elif map_list[i][j-1]=='#':
                continue
            else:
                print('No');exit()

print('Yes')


Measured memory_bytes: 3064
def main():
    K = int(input())
    N = 50

    a = [N - 1] * N
    q, r = divmod(K, N)
    for i in range(N):
        cnt_add = q + int(i < r)
        a[i] += N * cnt_add
        a[i] -= K - cnt_add

    print(N)
    print(*a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = Integer.parseInt(String.valueOf(a) + String.valueOf(b));
        boolean bre = false;
        for (int i = 0; i < c / 2; i++) {
            if (i * i == c) {
                bre = true;
                break;
            }
        }
        if (bre) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    double sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    double ave=sum/n;
    double diff=INF;
    int ans;
    for(int i=0;i<n;i++){
        if(abs(n*a[i]-n*ave)<diff){
            ans=i;
            diff=abs(n*a[i]-n*ave);
        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(n,0);
  rep(i,m){
    int x,y;
    cin>>x>>y;
    y--,x--;
    a[x]++,a[y]++;
  }
  rep(i,n){
    if(a[i]%2){
      cout<<"NO";
      return 0;
    }
  }
  cout<<"YES";
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

int main() {
	int a, b, k[105];
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i];
	}
	int count = 1;
go:
	for (int i = 0; i < a - 1; ++i) {
		if (k[i] % count > k[i + 1] % count) {
			swap(k[i], k[i + 1]);
		}
	}
	count++;
	if (count - 1 != b) goto go;
	for (int i = 0; i < a; ++i) {
		cout << k[i] << endl;
	}
}


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

    long long n,ans=0,i,j,k;
    cin>>n;
    long long a[n+1][n+1];
    bool p[n+1][n+1];
    memset(p,0,sizeof(p));
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cin>>a[i][j];
    for(k=1;k<=n;k++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                if(k!=j&&k!=i&&i!=j)
                {
                    if(a[i][j]==a[i][k]+a[k][j])
                        p[i][j]=1;
                    if(a[i][j]>a[i][k]+a[k][j])
                    {
                        cout<<"-1"<<endl;
                        return 0;
                    }
                }//distrika最短路
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(p[i][j]==0)
                ans+=a[i][j];
    cout<<ans/2<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    string s; cin >> s;
    vi c(26, 0);
    rep(i, 0, 4){
        c[s[i] - 'A']++;
    }
    int cnt = 0;
    rep(i, 0, 26){
        if(c[i] == 2) cnt++;
    }
    if(cnt == 2) cout << "Yes";
    else cout << "No";
    cout << endl;
        
    return 0;
}




Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n;
    vector<int> v(15001, 0);
    cin >> n;
    v[0] = 1;
    int p = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = p; j >= 0; --j) {
            if(v[j]) v[j+k]++;
        }
        p += k;
    }
    for (int i = p; i >= 0; --i) {
        if(v[i]>0 && i%10 != 0){
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	t, a := sc.nextInt(), sc.nextInt()
	for i := 1; i < N; i++ {
		nt, na := sc.nextInt(), sc.nextInt()
		nt1, na1 := nt, na
		nt2, na2 := nt, na
		m := mul(t, nt)
		na1 *= m
		nt1 *= m
		m = mul(a, na1)
		na1 *= m
		nt1 *= m

		m = mul(a, na2)
		na2 *= m
		nt2 *= m
		m = mul(t, nt2)
		na2 *= m
		nt2 *= m
		if nt1+na1 < nt2+na2 {
			t = nt1
			a = na1
		} else {
			t = nt2
			a = na2
		}
	}

	fmt.Fprintln(wtr, t+a)
	wtr.Flush()
}

func mul(before, n int) int {
	m := 1
	if n < before {
		if before%n == 0 {
			m = before / n
		} else {
			m = before/n + 1
		}
	}
	return m
}


Measured memory_bytes: 640
#include<cstdio>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;

const int N = 5e5 + 5;

int T,n,m,x,y;
int fi[N],to[N * 2],nt[N * 2],tot,bz[N];
int fa[N],ans[N],siz[N];

void link(int x,int y){
	nt[++tot] = fi[x],to[tot] = y,fi[x] = tot;
}

void cl(){
	fo(i,1,n)	bz[i] = fi[i] = ans[i] = siz[i] = 0;
	tot = 1;
}

void dg(int x,int la){
	bz[x] = 1;
	for(int i = fi[x]; i; i = nt[i]) if(!bz[to[i]]){
		ans[i / 2] = (i & 1);
		siz[to[i]] ^= 1;
		dg(to[i],i);
		siz[x] ^= siz[to[i]];
	} else if(i != (la ^ 1)){
		ans[i / 2] = !(i & 1);
		siz[to[i]] ^= 1;
	}
	if(siz[x]) ans[la / 2] ^= 1;
}

#include <vector>
using namespace std;

int main(){
	//for(scanf("%d",&T); T; T--){
		cl();
		scanf("%d %d",&n,&m);
		vector<pair<int,int>>ed;
		fo(i,1,m){
			scanf("%d %d",&x,&y);
			ed.push_back({x,y});
			link(x,y); link(y,x);
		}
		if(m & 1){
			printf("-1\n"); return 0;
		}
		dg(1,0);
		fo(i,1,m){
			printf("%d %d\n",(ans[i]?ed[i-1].first:ed[i-1].second),
				(ans[i]?ed[i-1].second:ed[i-1].first));
		}
	//}
}

//sub-EOF


Measured memory_bytes: 21748
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  long long L[N], R[N];
  for (int i = 0; i < N; i++) cin >> L[i] >> R[i];
  int idx[N];
  iota(idx, idx + N, 0);
  // debugArray(idx, N);
  auto step = [&]() {
    long long leftl[N + 1], leftr[N + 1], rightl[N + 1], rightr[N + 1];
    leftl[0] = 0, leftr[0] = INT_MAX;
    for (int i = 0; i < N; i++) {
      int j = idx[i];
      leftl[i + 1] = max(leftl[i], L[j]);
      leftr[i + 1] = min(leftr[i], R[j]);
    }
    rightl[N] = 0, rightr[N] = INT_MAX;
    for (int i = N - 1; i >= 0; i--) {
      int j = idx[i];
      rightl[i] = max(rightl[i + 1], L[j]);
      rightr[i] = min(rightr[i + 1], R[j]);
    }
    // debugArray(leftl, N + 1);
    // debugArray(leftr, N + 1);
    // debugArray(rightl, N + 1);
    // debugArray(rightr, N + 1);
    long long ret = 0;
    for (int i = 0; i < N - 1; i++) {
      ret = max(ret, max(0ll, leftr[i + 1] - leftl[i + 1] + 1)
                         + max(0ll, rightr[i + 1] - rightl[i + 1] + 1));
    }
    for (int i = 0; i < N; i++) {
      int j = idx[i];
      int ll = max(leftl[i], rightl[i + 1]);
      int rr = min(leftr[i], rightr[i + 1]);
      ret = max(ret, max(0, rr - ll + 1) + R[j] - L[j] + 1);
    }
    return ret;
  };
  long long ans = 0;
  sort(idx, idx + N,
       [&](int l, int r) { return L[l] == L[r] ? R[l] > R[r] : L[l] < L[r]; });
  ans = max(ans, step());
  sort(idx, idx + N,
       [&](int l, int r) { return R[l] == R[r] ? L[l] > L[r] : R[l] < R[r]; });
  ans = max(ans, step());
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8716
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    ll N;
    cin>>N;
    vector<ll> three(60, 0);
    three[0] = 1;
    rep(i,59){
        three[i + 1] = three[i] * 3 % mod;
    }
    string S="";
    ll now = N;
    while (now>0){
        S += to_string(now % 2);
        now /= 2;
    }
    ll L = S.size();
    //cout << S << endl;
    map<ll, ll> dp;
    map<ll, ll> dp0;
    map<ll,ll> dp1;
    dp1[0] = 1;
    if (S[0]=='0'){
        dp[0] = 1;
    }
    else{
        dp[0] = 2;
    }
    dp1[1] = 3;
    dp[-1] = 1;
    repf(i,1,L){
        //cout << dp1[i - 1] << endl;
        //cout << dp[i - 1] << endl;
        if (S[i-1]=='1'){
            dp1[i] = (dp1[i - 1] + 2 * three[i - 1] % mod) % mod;
        }
        else{
            dp1[i] = ((dp[i - 2] + dp1[i - 1]) % mod + three[i - 1]) % mod;
        }
        if (S[i]=='0'){
            dp[i] = dp[i - 1];
        }
        else{
            dp[i] = (dp[i - 1] + dp1[i]) % mod;
            }
        }
        //cout << dp1[L - 1] << endl;
        cout << dp[L - 1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef struct Words
{
    char	word[31];
    int		page[100];
} WORDS;

WORDS	wordArray[100];

void printMinWord(WORDS*);
void printMinPage(WORDS*);

int main()
{
    char	tempWord[31];
    int		tempPage;
    int		wordCnt;
    int		pageCnt;
    int		inputCnt = 0;
	
    while (scanf("%s %d", &tempWord, &tempPage) != EOF)
    {
        wordCnt = 0;
        /*sort page to each words*/
        while(1)
        {
            if(!strcmp(tempWord, wordArray[wordCnt].word))
            {
                for(pageCnt = 1; pageCnt < 100; pageCnt++)
                {
                    if(!(wordArray[wordCnt].page[pageCnt]))
                    {
                        break;
                    }
                }
                wordArray[wordCnt].page[pageCnt] = tempPage;
                break;
            }
            else if(!strcmp("", wordArray[wordCnt].word))
            {
                strcpy(wordArray[wordCnt].word, tempWord);
                wordArray[wordCnt].page[0] = tempPage;
                break;
            }
            wordCnt++;
        }
    }
	
    printMinWord(wordArray);

	return 0;
} 

void printMinWord(WORDS* word_array)
{
	int		word_cnt;
	char	min_word[31]	= "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	int		min_word_index	= -1;
	
	/*find min word and its index*/
	for(word_cnt = 0; word_cnt < 100; word_cnt++)
	{
		if(!strcmp(word_array[word_cnt].word, ""))
		{
			continue;
		}
		if(strcmp(word_array[word_cnt].word, min_word) <= 0)
		{
			strcpy(min_word, word_array[word_cnt].word);
			min_word_index = word_cnt;
		}
	}
	
	/*no recursion if no word content*/
	if(min_word_index != -1)
	{
		printf("%s\n", word_array[min_word_index].word);
		printMinPage(&word_array[min_word_index]);
		strcpy(word_array[min_word_index].word, "");
		printMinWord(word_array);
	}
}

void printMinPage(WORDS* word_array)
{
	int		page_cnt;
	int		min_page = 1001;
	int		min_page_index	= -1;
		
	/*find min page and its index*/
	
	
	for(page_cnt = 0; page_cnt < 100; page_cnt++)
	{
		if(word_array->page[page_cnt] == 0)
		{
			continue;
		}
		if(word_array->page[page_cnt] < min_page)
		{
			min_page = word_array->page[page_cnt];
			min_page_index = page_cnt;
		}
	}
	
	/*no recursion if no page content*/
	if(min_page_index == -1)
	{
		printf("\n");
		return word_array;
	}
	else{
		printf("%d", word_array->page[min_page_index]);
		word_array->page[min_page_index] = 0;
		
		for(page_cnt = 0; page_cnt < 100; page_cnt++)
		{
			if(word_array->page[page_cnt] == 0)
			{
				continue;
			}
			printf(" ");
			return printMinPage(word_array);
		}
		
		return printMinPage(word_array);
	}
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

a.sort()
# print(a)
b = [0 for _ in range(n)]
b[n//2] = a[0]
left = 1
right = n-1
for i in range(n//2):
    if i%2==0:
        b[n//2-(i+1)] = a[right]
        right -= 1
        if n//2+(i+1)<n:
            b[n//2+(i+1)] = a[right]
            right -= 1
    else:
        b[n//2-(i+1)] = a[left]
        left += 1
        if n//2+(i+1)<n:
            b[n//2+(i+1)] = a[left]
            left += 1
ans1 = 0
for i in range(n-1):
    ans1 += abs(b[i]-b[i+1])




b = [0 for _ in range(n)]
b[n//2] = a[n-1]
left = 0
right = n-2
for i in range(n//2):
    if i%2==1:
        b[n//2-(i+1)] = a[right]
        right -= 1
        if n//2+(i+1)<n:
            b[n//2+(i+1)] = a[right]
            right -= 1
    else:
        b[n//2-(i+1)] = a[left]
        left += 1
        if n//2+(i+1)<n:
            b[n//2+(i+1)] = a[left]
            left += 1
ans2 = 0
for i in range(n-1):
    ans2 += abs(b[i]-b[i+1])

print(max(ans1,ans2))


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;


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

	int n;
	string s;
	cin >>n >> s;
	auto os =s;
	
	for(bool nxt=true; nxt;){
		nxt = false;
		int ps=-1;
		while(ps = s.rfind("()"), ps !=-1){ s.erase(ps, 2); nxt=true;}
	}
	
	int bf=0, af=0;
	for(auto x: s) if(x==')') bf++; else af++;
	cout << string(bf, '(') + os + string(af, ')')<<"\n";
	return 0;
}




Measured memory_bytes: 256
from collections import deque
H,W = map(int,input().split())
A = [input().strip() for _ in range(H)]
B = [[0 for _ in range(W)] for _ in range(H)]
que = deque([])
for i in range(H):
    for j in range(W):
        if A[i][j]=="#":
            que.append((i,j,0))
            B[i][j] = 1
dmax = 0
while que:
    i,j,d = que.popleft()
    if j+1<W and B[i][j+1]==0:
        B[i][j+1]=d+1
        dmax = max(dmax,d+1)
        que.append((i,j+1,d+1))
    if i-1>=0 and B[i-1][j]==0:
        B[i-1][j]=d+1
        dmax = max(dmax,d+1)
        que.append((i-1,j,d+1))
    if j-1>=0 and B[i][j-1]==0:
        B[i][j-1]=d+1
        dmax = max(dmax,d+1)
        que.append((i,j-1,d+1))
    if i+1<H and B[i+1][j]==0:
        B[i+1][j]=d+1
        dmax = max(dmax,d+1)
        que.append((i+1,j,d+1))
print(dmax)

Measured memory_bytes: 182580
stopper = 1
x,y = [],[]
while stopper == 1:
	a,b = map(int,input().split())
	if a == 0 and b == 0:
		stopper = 0
	else:
		x.append(min(a,b))
		y.append(max(a,b))
for i in range(len(x)):
	print(x[i],y[i])


Measured memory_bytes: 6128
<?php
$input = explode(' ', trim(fgets(STDIN)));
$m1 = (int)$input[0];
$d1 = (int)$input[1];

$input = explode(' ', trim(fgets(STDIN)));
$m2 = (int)$input[0];
$d2 = (int)$input[1];

if ($m1 !== $m2) {
	echo '1';
}else{
	echo '0';
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;


vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}
lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}
int dx[4]={-1,0,0,1}, dy[4]={0,1,-1,0};

// ---- コーディングはここから！ ('-')7



void solve(){
	int n; cin>>n;
	vvl v(n,vl(n)); fore(i,0,n)fore(j,0,n)cin>>v[i][j];
	vl mask(1<<n,0);
	fore(i,0,1<<n)fore(j,0,n)if(i & (1<<j))fore(k,j+1,n)if(i & (1<<k))mask[i]+=v[j][k];
	vl dp(1<<n,-INF);
	dp[0]=0;
	fore(i,1,1<<n)for(int j=i;j; j=((j-1)&i))dp[i]=max(dp[i],dp[i^j]+mask[j]);
	cout<<dp[(1<<n)-1]<<ENDL;


}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int const maxn=1e6+5;
ll num[maxn];
int main(){
	int n;
	ll res=0;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int cnt=sqrt(i);
		for(int j=1;j<=cnt;j++) if(i%j==0) num[i]++; 
		res+=num[i]<<1;
		if(cnt*cnt==i) res--;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 11592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

bool IsSquare(Int a) {
    Int i = 1;
    while(i <= a) {
        if (i*i == a) return true;
        ++i;
    }
    return false;
}

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

    Int N, D; cin >> N >> D;
    vector<vector<Int>> X(N, vector<Int>(D));
    rep(i, 0, N) {
        rep(j, 0, D) cin >> X[i][j];
    }

    Int res = 0;
    rep(i, 0, N-1) {
        rep(j, i+1, N) {
            Int d = 0;
            rep(k, 0, D) {
                d += abs(X[i][k]-X[j][k]) * abs(X[i][k]-X[j][k]);
            }
            if (IsSquare(d)) ++res;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}

double cal(int a){
  int b=a,c=0;
  while(b)c+=b%10,b/=10;
  return 1.0*a/c;
}

signed main(){
  int k;
  cin>>k;
  int a=1,b=1;
  for(int i=0;i<k;i++){
    if(cal(a)>cal(a+b))a-=b,b*=10,i--;
    else cout<<a<<endl;
    a+=b;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main(){
 string str;
   cin >> str;
   int sum = 0;
   for (int i = 0;i < 3;i++){
     if (str.at(i) == '1'){
       sum++;
     }
     else {
     }
   }
   cout << sum << endl;
 }


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

bitset<4000111>now;
int n,a[2333];
int main()
{
	get1(n);
	now.set(0);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		get1(a[i]);
		now|=now<<a[i];
		sum+=a[i];
	}
	for(int i=(sum+1)/2;i<=sum;i++)if(now.test(i))
	{
		printf("%d\n",i);
		return 0;
	}
	return 0;
}

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

using namespace std;

int main()
{

int a[100];

for(int i = 0 ; i < 5 ; i++) cin >> a[i];

sort(a,a+5);

int ans = 1e9;
do
{
int time = 0;
for(int i = 0 ; i < 5 ; i++) 
   {
    if(time%10 == 0) time+=a[i];
    else 
       {
        time += (10 - (time % 10));
        time+=a[i];
       }
   }

 ans = min(ans , time);
}while(next_permutation(a,a+5));

cout << ans ;
}

Measured memory_bytes: 256
import math

def main():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    a = min([A,B,C,D,E])
    ans = math.ceil(N/a) + 4
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9156
import heapq

N, M = [int(n) for n in input().split()]
A = [-int(n) for n in input().split()]
heapq.heapify(A)

while M > 0:
    M -= 1
    Amax = -heapq.heappop(A) // 2
    heapq.heappush(A, -Amax)

print(-sum(A))

Measured memory_bytes: 14188
using System;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        var N = scan.NextInt();
        var A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.NextInt();
        }
        var sb = new StringBuilder();
        var max = A.Max();
        var foundMaximums = false;
        for (int i = 0; i < N; i++) {
            if (A[i] != max || foundMaximums) {
                sb.Append(max).AppendLine();
                continue;
            }
            if (A[..i].Concat(A[(i + 1)..]).Max() == max) foundMaximums = true;
            sb.Append(A[..i].Concat(A[(i + 1)..]).Max()).AppendLine();
        }
        return sb.ToString();
    }
}

class Scanner
{
    string[] s;
    int i;

    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
    public long NextLong() => long.Parse(Next());
    public double NextDouble() => double.Parse(Next());
    public int[] ArrayInt(int N, int add = 0) {
        var Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = NextInt() + add;
        }
        return Array;
    }
    public long[] ArrayLong(int N, long add = 0) {
        var Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = NextLong() + add;
        }
        return Array;
    }
    public double[] ArrayDouble(int N, double add = 0) {
        var Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 50228
import java.util.Scanner;
class Main {
	public static void main(String[] args){
    	Scanner stdIn = new Scanner(System.in);
    	
        String a = stdIn.next();
      	if(a.equals("ABC"))
      		System.out.println("ARC");
      	if(a.equals("ARC"))
      		System.out.println("ABC");
    }
}

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

int main() {
  int n;
  cin >> n;
  int f = 0, t = n;
  while (t > 0) {
    f += t % 10;
    t /= 10;
  }
  if (n % f == 0) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,dif,sum=0;

    cin>>n>>k;

    dif= n-k;

    if(n<=k){

    cout<<"0"<<endl;

    }

    else if(k==1)
    {
        cout<<"0"<<endl;
    }

    else{

        cout<<dif<<endl;
    }

}


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

ll n,m,k,a,b;
string s,t;
ll h[100005]; 
bool ok[100005];

int main() {
  cin >> n ;
  double ans=2*n*M_PI;
  printf("%.10f\n",ans);
}

Measured memory_bytes: 3760
N = int(input())
applist = list(map(int, input().split()))

newlist = []
for i in applist:
  if i % 2 == 0:
    newlist.append(i)

flag = 0
for j in newlist:
  if j % 3 == 0 or j % 5 == 0:
    flag = 0
  else:
    flag = 1
    break

if flag == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int INF = 1000000007;
 
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  int H, W, K;
  cin >> H >> W >> K;
  char S[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> S[i][j];
    }
  }
  int T[H][W] = {};

  int count = 0;
  bool ans1 = false;
  for(int i=0;i<H;i++){
    bool ans = false;
    for(int j=0;j<W;j++){
      if(S[i][j] == '#'){
        ans = true;
        ans1 = true;
        count++;
        T[i][j] = count;
        if(j != 0){
          for(int k = j-1;k>=0;k--){
            if(T[i][k] == 0){
              T[i][k] = count;
            }
            else break;
          }
        }
      }

      if(j == W-1){
        if(ans){
          for(int k = j;k>=0;k--){
            if(T[i][k] == 0){
              T[i][k] = count;
            }
            else break;
          }
        }
      }
    }
    if(ans == false){
      if(ans1){
        for(int l=0;l<W;l++){
          T[i][l] = T[i-1][l];
        }
      }
    }
  }

  for(int i=H-1;i>=0;i--){
    for(int j=W-1;j>=0;j--){
      if(T[i][j] != 0) continue;
      else{
        T[i][j] = T[i+1][j];
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j != W-1){
        cout << T[i][j] << ' ';
      }
      else{
        cout << T[i][j] << endl;
      }
    }
  }
}

Measured memory_bytes: 1280
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a <= 5) {
			System.out.println(0);
		} else if (a <= 12) {
			System.out.println(b / 2);
		} else {
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 21844
li=[list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b=int(input())
    for i in range(3):
        li[i] = [0 if j == b else j for j in li[i]]
for i in range(3):
    if li[i][0]==0 and li[i][1]==0 and li[i][2]==0:
        print("Yes")
        exit(0)
for i in range(3):
    if li[0][i]==0 and li[1][i]==0 and li[2][i]==0:
        print("Yes")
        exit(0)
if li[0][0]==0 and li[1][1]==0 and li[2][2]==0:
    print("Yes")
    exit(0)
if li[2][0]==0 and li[1][1]==0 and li[0][2]==0:
    print("Yes")
    exit(0)
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
string s;
int32_t main(){
CODE_START;
cin>>n>>s;
ll val=s.size();
for(ll i=0;i<min(val,n);i++)
{
    cout<<s[i];
}
if(s.size()>n){
    cout<<"...";
}
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define LL long long
using namespace std;

const int MAXN = 1e5 + 3;

int n;
LL prefix[MAXN], arr[MAXN];

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + n + 1);
  for(int i = 1; i <= n; i++) {
    prefix[i] = prefix[i-1] + arr[i];
  }
  int res = 1;
  for(int i = n - 1; i > 0; i--) {
    if(2*prefix[i] < arr[i+1]) {
      break;
    } else {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(unsigned int i=0;i<s.length();i++){
        sum+= s[i]-'0';
    }
    //cout<<sum<<"\n";
    if(sum%9==0){
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3728