akhauriyash/Code-Regression huggingface dataset:
//containing t test cases
#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define mkp make_pair
#define fi first
#define se second
#define ll long long
#define scan(n) ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(ll i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define pi 3.1415926535897932384626433832795028841971
#define mem(a,b) memset(a , b , sizeof a ) ;
//#define int long long
using namespace std;
//typedef vector<int>vi ;
typedef vector<ll>vi ;
typedef vector<vector<ll> >vvl ; 
typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll> > vpll;
//cout<<fixed<<setprecision(15);
/*vi adj[200005];
ll vis[200005];
ll parent[200005];
ll level[200005];
ll arr[200005];
ll size[200005];*/
//endl mut bhool!!
void solve()
{
	ll n;
	cin>>n;
	ll r;
	string s;
	while(n)
	{
		r=n%26;
		if(r==0)
		{
			s+='z';
			n/=26;
			n--;
		}
		else
		{
			s+=(r-1)+'a';
			n/=26;
		}
	}
	reverse(s.begin(),s.end());
	cout<<s;
}
int main()
{
	fast;
	ll test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	return 0;
}
/*
cout<<"YES"<<endl;
cout<<"NO"<<endl;
*/




Measured memory_bytes: 3652
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int _=1e2;
const int maxn=2e5+_;
const int maxm=1e6+_;
const int mod=998244353;
inline int ad(int x,int y){return x>=mod-y?x-mod+y:x+y;}
inline int re(int x,int y){return x<y?x-y+mod:x-y;}
inline int mu(int x,int y){return (LL)x*y%mod;}
inline int qp(int x,LL y){int r=1;while(y){if(y&1)r=mu(r,x);x=mu(x,x);y>>=1;}return r;}
inline int iv(int x){return qp(x,mod-2);}
inline int dv(int x,int y){return mu(x,qp(y,mod-2));}

int c[maxm],F[maxm];
int main()
{
	int n,m=0,ans=0,x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x),c[x]++;
		ans=re(ans,x);
		m=max(m,x);
	}
	
	for(int d=1;d<=m;d++)
	{
		F[d]=ad(F[d],iv(d));
		for(int i=2;i<=m/d;i++)
			F[i*d]=re(F[i*d],F[d]);
	}
		
	for(int i=1;i<=m;i++)
	{
		int cc=0;
		for(int j=i;j<=m;j+=i)
			cc=ad(cc,mu(c[j],j));
		ans=ad(ans,mu(F[i],mu(cc,cc)));
	}
	
	printf("%d\n",mu(ans,mod/2+1));
	
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string s, t;
  cin >> s >> t;

  for(int d = 0; d < s.length(); ++d)
  {
    if (s[0] != t[d]) continue;
    bool ok = true;
    for(int i = 0; i < s.length(); ++i)
    {
      ok &= (s[i] == t[(i + d) % s.length()]);
    }
    if (ok)
    {
      cout << "Yes";
      return;
    }
  }
  cout << "No";
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {

int N,M; cin>>N>>M;
  vector<int> a(M+1),b(M+1);
  map<int,int> A;
  for(int i=1;i<=M;i++){
    cin>>a.at(i)>>b.at(i);}
  
  for(int i=1; i<=M; i++){
    if(!A.count(a.at(i))){A[a.at(i)]=1;}
    else{A.at(a.at(i))++;}
    if(!A.count(b.at(i))){A[b.at(i)]=1;}
    else{A.at(b.at(i))++;}
  }
  for(int i=1;i<=N;i++){
    if(!A.count(i)){A[i]=0;}
    cout<<A.at(i)<<endl;}
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, k, i;
	scanf("%d %d", &n, &k);
	int odd = 0;
	for (i = 1; i <= n; i++)
	{
		if (i % 2 != 0)
			odd++;
	}

	if (odd >= k)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
w = input()
A = []
a1 = []
a2 = []

if len(w) % 2 == 0:
    for i in range(len(w)):
        A.append(w[i])

    A.sort()
    for i in range(len(w)):
        if i % 2 == 0:
            a1.append(A[i])
        else:
            a2.append(A[i])

    if a1 == a2:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <algorithm>
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	int n;
	cin >> n;
	int j=0,m;
	int arr[n];
	while(cin >> m)
		arr[j++] = m;
	sort(arr,arr+n);
	int min = 2e8;
	int ret = arr[0];
	for(int i = arr[0]; i < arr[n-1]; i++){
		int sum = 0;
		for(int j = 0; j < n; j++){
			int diff = arr[j] - i;
			diff *= diff;
			sum += diff;
		}
		if(sum < min)
			min = sum, ret = i;
	}
	if(min == 2e8)
		cout << 0;
	else
		cout << min;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int list[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};
    int K;
    cin >> K;
    cout << list[K - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
# dp[j][k][s]: x_1...x_jのうちk枚選んで和をsにする選び方
# dp[j-1][k][s](x_jを選ばない) + dp[j-1][k-1][s-x_j](x_jを選ぶ)
# ans = sum(dp[j][k][k*A] j:1->N k:1->j)

import sys
write = sys.stdout.write

N, A = map(int,input().split())
x = list(map(int,input().split()))
x.insert(0,0)
ssize = N*A+1
jsize = N+1
dp = [[[0 for s in range(ssize)] for k in range(jsize)] for j in range(jsize)]
for j in range(jsize):
    for k in range(jsize):
        for s in range(ssize):
            if j == 0 and k == 0 and s == 0:
                dp[j][k][s] = 1
            elif j >= 1 and s - x[j] < 0:
                dp[j][k][s] = dp[j-1][k][s]
            elif j >= 1 and k >= 1 and s - x[j] >= 0:
                dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
            else:
                dp[j][k][s] = 0
sum = 0
for k in range(1, N+1):
    sum += dp[N][k][k*A]
print(str(sum))

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    cout << (ab * bc) / 2;

    return 0;
}


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

// #include "../../template-proj/myMente.h"

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N; cin>>N;
	vector<ll> H(N);
	rp(i,N)cin>>H[i];
	// for(auto e:H){ot(e);ot(",");}ote("\n---");//

	ll ans = 0;
	ll count = 0;
	ll pre = H[0];
	up(i,1,N,1){
		ll now = H[i];
		if(pre>=now){
			++count;
		}
		else{
			count = 0;
		}
		ans = max(ans, count);
		pre = now;
	}
	ote(ans);
}


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

int main(){
  string s; cin>>s;
  if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
    cout<<3<<endl;
  else if(s[0]=='R'&&s[1]=='R')
    cout<<2<<endl;
  else if(s[1]=='R'&&s[2]=='R')
    cout<<2<<endl;
  else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
const std::string yes = "Yes";
const std::string no  = "No";

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

    int ans = 0;
    rep(i,n) ans += a[i] - 1;

    std::cout << ans << "\n";
    return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  int sum = 0;
  int mi = 1e9;
  for (int i = L, cnt = 0; cnt < N; i++, cnt++) {
    sum += i;
    if (abs(i) < abs(mi)) mi = i; 
  }

  cout << sum - mi << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int max_count = 0;
    int num;
    int count;
    for (int i=1; i <= n; i++){
        num = i;
        count = 0;
        while (true){
            if (num % 2 == 0){
                num /= 2;
                count++;
            }
            else{
                break;
            }
        }
        if (max_count < count){
            ans = i;
            max_count = count;
        }
    }
    if (max_count == 0){
        cout << 1;
    }
    else{
        cout << ans;
    }
    
}

Measured memory_bytes: 888
n=int(input())
l=list(map(int,input().split()))
count=0
for i in range(1,n+1):
            if i !=l[i-1]:
                        count+=1
                     
if count<=2:
            print('YES')
else:
            print('NO')
            
                                    
                                    
                                    


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

int cnt[2010];

void solve() {
	string s;
	cin >> s;
	int num = 0, t = 1, res = 0;
	cnt[0] = 1;
	for(int i = s.size() - 1; ~i; i--) {
		num = (num + (s[i] - '0') * t) % 2019;
		res += cnt[num]++;
		t = t * 10 % 2019;
	}
	printf("%d\n", res);
}

int main() {
//	freopen("in.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
int main ()
{
    int A1,A2,A3;
    scanf ("%d %d %d",&A1,&A2,&A3);
    if (1<=A1,A2,A3<=13)
    {
        if (A1+A2+A3>=22)
    {
        printf ("bust\n");
    }
    else
    {
        printf ("win\n");
    }
    }
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef complex<long double> P;

const long double EPS = 1e-10;

namespace std {
    bool operator <(const P &p1, const P &p2) {
        if(p1.real() != p2.real()) return p1.real() < p2.real();
        return p1.imag() < p2.imag();
    }
};

bool cmp(const P &p1, const P &p2) {
    return p1.imag() < p2.imag();
}

bool eql(const P &p1, const P &p2) {
    return abs(p1 - p2) < EPS;
}

long double calc_at(const P &pa, const P &pb, long double x) {
    P d = pb - pa;
    if(abs(d.real()) < EPS) {
        if(arg(d) < 0) return -1e10;
        else return 1e10;
    }
    return pa.imag() + d.imag() * ((x - pa.real()) / d.real());
}

long double cross(const P &pa, const P &pb) {
    return pa.real()*pb.imag() - pa.imag()*pb.real();
}

bool solve() {
    int W, H, N;
    cin >> W >> H >> N;
    if(!W && !H && !N) return false;
    N *= 2;

    vector<P> ps(N);
    for(int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        ps[i] = P(x, y);
    }
    vector<P> events;
    for(int i = 0; i < N; ++i) {
        for(int j = i+1; j < N; ++j) {
            events.push_back(P(0, calc_at(ps[i], ps[j], 0)));
        }
        events.push_back(P(0, calc_at(ps[i], P(W, 0), 0)));
        events.push_back(P(0, calc_at(ps[i], P(W, H), 0)));
    }
    events.push_back(P(0, 0));
    events.push_back(P(0, H));
    sort(events.begin(), events.end(), cmp);
    //events.erase(unique(events.begin(), events.end(), eql), events.end());
    const int M = events.size();
    long double ans = 0;
    for(int i = 0; i < M-1; ++i) {
        const P &pa = events[i];
        const P &pb = events[i+1];
        if(pa.imag() < 0) continue;
        if(pb.imag() > H) break;
        if(pb.imag() - pa.imag() < EPS) continue;
        //cout << pa << ' ' << pb << endl;
        const P m = (pa+pb) / (long double)2.0;
        long double upper = 0, lower = 0;
        vector<pair<long double,P>> v;
        for(const P &p : ps) {
            const P d = p - m;
            v.push_back(make_pair(arg(d), p));
        }
        sort(v.begin(), v.end());
        //cout << v[0].first << ' ' << v[1].first << endl;
        lower = min<long double>(H, max<long double>(0, calc_at(m, v[N/2-1].second, W)));
        upper = min<long double>(H, max<long double>(0, calc_at(m, v[N/2].second, W)));
        //cout << lower << ' ' << upper << endl;
        long double add = (pb.imag()-pa.imag()) * (upper - lower);
        ans += abs(add);
    }
    printf("%.10Lf\n", ans / H / H);
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 2684
n = int(input())
a = [int(i) for i in input().split()]

i = 0
ans = 0
tmp = 1
for i in range(n):
    if a[i] == tmp:
        tmp += 1
    else:
        ans += 1

if ans == n:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 24744
def solve(N, K):
    mod = 10 ** 9 + 7
    multiples = [[] for _ in range(K + 1)]
    for k in range(1, K + 1):
        for i in range(k, K + 1, k):
            multiples[k].append(i)

    gcdcounts = [0] * (K + 1)  # gcd 毎の組み合わせ個数
    gcdsums = [0] * (K + 1)   # gcd 毎の合計値
    for k in reversed(range(1, K + 1)):
        x = pow(len(multiples[k]), N, mod)
        for l in multiples[k]:
            x -= gcdcounts[l]
        gcdcounts[k] = x % mod
        gcdsums[k] = x * k % mod
    print(sum(gcdsums) % mod)


if __name__ == '__main__':
    N, K = map(int, input().split())
    solve(N, K)


Measured memory_bytes: 70780
#include <iostream>

using ll = long long int;

ll pow(ll x)
{

    ll res = x * x * x * x * x;

    return res;
}

int main()
{

    ll x;
    std::cin >> x;

    for (int i = 1; i <= 1000; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (pow(i) + pow(j) == x)
            {
                std::cout << i << ' ' << -j << std::endl;
                return 0;
            }
            else if (pow(i) - pow(j) == x)
            {
                std::cout << i << ' ' << j << std::endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
using namespace std;
int main(){

int a[1000];
int n;

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

int j;
for(j=n-1;j>-1;j=j-1)
{cout<<a[j];

if(j>0){cout<<" ";}
if(j==0){cout<<endl;}

}
}


Measured memory_bytes: 3084
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define lop(i, n) for(i=0; i<n; i++)

int gcd(int a,int b)
{
	int r=1;
	if(b == 0)
		return a;
	if(a == 0)
		return b;
	while(r!=0){
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main()
{
	int n, i;
	scanf("%d", &n);
	int a[100000], b[100000], c[100000];
	lop(i, n){ scanf("%d", &a[i]); }
	
	b[0]=0, c[0]=0; int max=0;
	
	lop(i, n){ b[i+1]=gcd(b[i], a[i]); }
	lop(i, n){ c[i+1]=gcd(c[i], a[n-i-1]); }
	
	lop(i, n){
		int x=gcd(b[i], c[n-i-1]);
		if(x>max) max=x;
	}
	
	printf("%d", max);
	
return 0;
}

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

#define MAX 101010
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

int n;
int dp[MAX][20];
string num;

ll solve(int i, int s) {
  if (i == n)
    return (s % 13) == 5;

  if (dp[i][s] != -1)
    return dp[i][s];

  ll ans = 0LL;
  if (num[i] == '?') {
    for (int j = 0; j <= 9; ++j) {
      int ss = (s*10 + j) % 13;
      ans = (ans + solve(i + 1, ss)) % MOD;
    }
  } else {
    int ss = (s*10 + (num[i] - '0')) % 13;
    ans = solve(i + 1, ss) % MOD;
  }

  return dp[i][s] = ans;
}

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

  cin >> num;
  n = num.size();

  mset(dp, -1);
  cout << solve(0, 0) % MOD << ende;

  return 0;
}


Measured memory_bytes: 16208
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int rs[];
	boolean used[];
	int r;
	int INF = 1001001001;
	int ans = INF;
	int dp[][];
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		r=sc.nextInt();

		dp= new int[n][n];

		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				dp[i][j] = INF;
				if(i==j) {
					dp[i][j]=0;
				}
			}
		}
		rs = new int[r];
		used = new boolean[r];
		for(int i=0; i<r; i++) {
			int v=sc.nextInt();
			v--;
			rs[i]=v;
		}
		for(int i=0; i<m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			a--;b--;
			int c = sc.nextInt();
			dp[a][b]=c;
			dp[b][a]=c;
		}


		for(int k=0; k<n; k++) {
			for(int i=0; i<n; i++) {
				if(dp[i][k]==INF) continue;
				for(int j=0; j<n; j++) {
					if(dp[k][j]==INF) continue;
					dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k][j]);
				}
			}
		}




		for(int i=0; i<r; i++) {
			used[i]=true;
			dfs(rs[i],1,0);
			used[i]=false;
		}

		System.out.println(ans);
		sc.close();
	}

	private void dfs(int u, int n, int dist) {
		if(n==r) {
			ans = Math.min(ans, dist);
			return;
		}
		for(int i=0; i<r; i++) {
			if(!used[i]) {
				used[i]=true;
				int v = rs[i];
				dfs(rs[i],n+1,dist+dp[u][v]);
				used[i]=false;
			}
		}
	}
}


Measured memory_bytes: 58892
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy\n";
    else if(s=="Cloudy")
        cout<<"Rainy\n";
    else
        cout<<"Sunny\n";
    
    return 0;   
}


 
 


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

vector <pii> F, G;

int main()
{
  fastio;
  int n, tot = 0; cin >> n;  
  for (int i = 1; i <= n; i++){
    string s; cin >> s;
    int cur = 0, mn = 0;
    for (char c : s){
      if (c == '(') cur++;
      else cur--;
      chmin(mn, cur);         
    }
    if (cur >= 0) F.push_back(pii(-mn, cur));
    else G.push_back(pii(cur - mn, -cur));
    tot += cur;
  }
  if (tot) return cout << "No", 0;
  sort(all(F)); sort(all(G));
  bool Check = true; tot = 0;
  for (pii x : F){
    if (tot < x.first) Check = false;
    tot += x.second;  
  }
  tot = 0;
  for (pii x : G){
    if (tot < x.first) Check = false;
    tot += x.second;
  }
  cout << (Check ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 11304
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 51;
const int MAX_M = 21;

struct Edge {
  int id;
  int from;
  int to;

  Edge(int id = -1, int from = -1, int to = -1) {
    this->id = id;
    this->from = from;
    this->to = to;
  }
};

ll paths[MAX_M];
int edgeIds[MAX_N][MAX_N];
vector<Edge> E[MAX_N];
int H[MAX_N];

void dfs(int v, int goal, int parent = -1, int mid = -1) {
  H[v] = parent;

  if (v == goal) {
    int cur = v;

    while (cur != -1) {
      int eid = edgeIds[cur][H[cur]];

      if (eid != -1) {
        paths[mid] |= (1LL << eid);
        // fprintf(stderr, "%d: mid: %d, %d -> %d, %lld\n", eid, mid, cur, H[cur], paths[mid]);
      }

      cur = H[cur];
    }

    return;
  }

  for (Edge edge : E[v]) {
    if (edge.to == parent) continue;

    dfs(edge.to, goal, v, mid);
  }
}

int main() {
  memset(paths, 0, sizeof(paths));
  memset(edgeIds, -1, sizeof(edgeIds));
  int N;
  cin >> N;

  int a, b;
  for (int i = 0; i < N - 1; ++i) {
    cin >> a >> b;

    edgeIds[a][b] = i;
    edgeIds[b][a] = i;
    E[a].push_back(Edge(i, a, b));
    E[b].push_back(Edge(i, b, a));
  }

  int M;
  cin >> M;

  int u, v;
  for (int mid = 0; mid < M; ++mid) {
    cin >> u >> v;

    // fprintf(stderr, "%d -> %d : %d\n", u, v, lca.find_parent(u, v));
    dfs(u, v, -1, mid);
  }

  map<int, ll> counter;

  for (int mask = 0; mask < (1 << M); ++mask) {
    int cnt = __builtin_popcount(mask);
    ll nmask = 0;

    for (int mid = 0; mid < M; ++mid) {
      if ((mask >> mid & 1) == 0) continue;

      nmask |= paths[mid];
    }

    int C = __builtin_popcountll(nmask);
    counter[cnt] += pow(2, N - 1 - C);
    // fprintf(stderr, "mask: %d, nmask: %lld, C: %d\n", mask, nmask, C);
  }

  ll ans = 0;
  ll d = 1;
  for (int c = 0; c <= M; ++c) {
    ans += d * counter[c];

    d *= -1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4032
import itertools
import collections

n = int(input())
name = []
for i in range(n):
    a = input()
    if a[0] in 'MARCH':
        name.append(a[0])

b = collections.Counter(name)
d = []
for v in b.values():
    d.append(v)

c = list(itertools.combinations(list(range(len(b))), 3))

total = 0
for tap in c:
    total += d[tap[0]] * d[tap[1]] * d[tap[2]]
print(total)

Measured memory_bytes: 4224
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w=nii()
a=[list(input()) for i in range(h)]

t_ans=[]
for i in a:
  if '#' in i:
    t_ans.append(i)

t_ans=[i for i in zip(*t_ans)]

ans=[]
for i in t_ans:
  if '#' in i:
    ans.append(i)

ans=[i for i in zip(*ans)]

for i in ans:
  print(''.join(i))

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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
    cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n - 1; ++i)
    {
        int cnt = 0;
        if (p[i - 1] < p[i] && p[i] < p[i + 1] || p[i - 1] > p[i] && p[i] > p[i + 1])

            ans++;
    }
    cout << ans;

    return 0;
}

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

int main() {
	// your code goes here
	int A[6];
	
	for(int i = 1; i <= 6; i++) {
		cin>>A[i];
		
		if(A[i] == 0) {
			cout<<i<<endl;
			return 0;
		}
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 3620
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  s <- getLine
  k <- (read::String -> Int) <$> getLine
  let one_length = length $ takeWhile ((==) '1') s
  if k <= one_length
    then putStrLn "1"
    else putStrLn [s !! one_length]

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define fori(j,n) for(ll i=j;i<n;i++)
#define forb(n,j) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define vec vector<ll>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

void wldd()
{
	string s;
	cin >> s;
	ll x = 0;
	fori(0, 3)
	{
		if (s[i] == 'R' and s[i + 1] == 'R')
			x += 2;
		else if (s[i] == 'R' and s[i + 1] != 'R')
			x = max(1ll, x);
	}
	cout << min(x, 3ll)  << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	IOS;
	/*ll t;
	cin >> t;
	while (t--)*/ wldd();
	return 0;
}

Measured memory_bytes: 3608
using System;
public class Hello{
    public static void Main(){
        int X = 1;
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        
        while(N > 0){
            if(X * 2 < X + K){
                X *= 2;
            }else{
                X += K;
            }
            N--;
        }
        Console.WriteLine(X);
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int L=0;
	int R=0;
	for(int i=0;i<a;i++)R+=p[i];
	int ret=R;
	for(int i=0;i<a;i++){
		R-=p[i];
		L+=p[i];
		ret=min(ret,ABS(R-L));
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#include <limits>
#include <iomanip>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    int size = s.size();
    if(s[size-1]=='s'){
        string last = "es";
        string ans = s + last;
        cout <<  ans << endl;
    }
    else{
        string last = "s";
        string ans = s + last;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3600
s = input()
flag = 0

for i in range(len(s)):
    if (i+1) % 2 == 1:
        if s[i] == "L":
            flag = 1
    else:
        if s[i] == "R":
            flag = 1
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        final String s = sc.next();
        // final String b = sc.next();

        // final int b = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(s.replace(",", " "));

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

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

int main()
{
    ll n, tmp;
    cin >> n;
    vector<ll> a(n, 0);
    rep(i, n)
    {
        cin >> a.at(i);
        if (acnt.count(a.at(i)))
            acnt.at(a.at(i)) += 1;
        else
            acnt[a.at(i)] = 1;
    }
    ll cnt_sum = 0;
    for (auto p : acnt)
    {
        //auto k = p.first;
        auto v = p.second;
        cnt_sum += (v*(v-1))/2;
    }
    // cout << cnt_sum<< endl;
    rep(i,n)
    {
        // ll atmp= acnt[a.at(i)]+1;
        // cout << i << ' ' << cnt_sum << '-' << acnt[a.at(i)] << ' ';
        cout << cnt_sum - acnt[a.at(i)]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 12544
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, q;
    cin >> n >> q;

    fenwick_tree<ll> ft(n);
    REP(i, n) {
        ll a; cin >> a;
        ft.add(i, a);
    }

    REP(i, q) {
        int t, a, b;
        cin >> t >> a >> b;
        if (t == 0) {
            ft.add(a, b);
        } else {
            print(ft.sum(a, b));
        }
    }

}


Measured memory_bytes: 8256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};
use std::time::{Duration, Instant};
use rand::Rng;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    let start = Instant::now();
    input!{
        D:usize,
        C:[isize;26],
        S:[[isize;26];D],
    }
    
    let mut Last = vec![vec![0;26];D+10];
    let mut T = vec![0;D];

    let mut ans = 0;
    for (d,&t) in T.iter().enumerate(){
        ans += S[d][t];
        let d = d+1;
        Last[d][t] = d as isize;
        for i in 0..26{
            Last[d][i] = max(Last[d-1][i],Last[d][i]);
            ans -= C[i]*(d as isize -Last[d][i]);
        }
    }

    let mut rng = rand::thread_rng();

    while {let end = start.elapsed();end.as_millis() < 1900u128} {
        let d = rng.gen::<usize>()%D;
        let mut q = rng.gen::<usize>()%25;
        if q >= T[d] { q += 1;}
        let q = q;

        let p = T[d];
        let mut d_ans = S[d][q] - S[d][p];
        let d = d+1;
        let lip = Last[d-1][p];
        let mut update = Vec::new();
        for i in d..D+1{
            if Last[i][p] == d as isize{
                d_ans -= C[p]*(d as isize - lip);
                update.push((i,p,lip));
            } else { break;}
        }
        for i in d..D+1{
            if Last[i][q]<d as isize{
                d_ans -= C[q]*(Last[i][q]-(d as isize));
                update.push((i,q,d as isize));
            } else { break;}
        }
        if d_ans>0{
            ans += d_ans;
            T[d-1] = q;
            for &(i,c,n) in &update{
                Last[i][c] = n;
            }
        }
    }
    for &t in &T{
        println!("{}",t+1);
    }

}


Measured memory_bytes: 2868
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 2e3 + 1;
ll fac[N];
int power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
 
    while (y > 0)
    {
 
        if (y & 1)
            res = (res * x) % p;
 
 
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll modi(ll a, ll m)
{
    return power(a, m - 2, m);
 
}
ll nCr(ll n, ll r, ll p)
{
 
    if (r == 0)
        return 1;
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
 
    return (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
}
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    fac[0] = 1;
    for(i = 1; i <= 2000; i++){
        fac[i] = fac[i - 1] * i;
        fac[i] %= MOD;
    }
    //cin >> T;
    while (T--) {
        ll n;
        cin >> n;  
        ll ans = 0;
        for(i = 1; i <= n; i++){
            ll sum = n - 3 * i;
            if(sum < 0){
                break;
            }
            ans += nCr(sum + i - 1, i - 1, MOD);
            ans %= MOD;
        }
        cout << ans;
    }
    return 0;
}

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

int main() {
    int N, M;
    int s[M] = {}, c[M] = {}, ans[M] = {};
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> s[i] >> c[i];
      	s[i]--;
    }
    for(int i=0; i < N; i++)
    {
        ans[i] = -1;
    }
    bool tf = 1;
    for (int i = 0; i < M; i++)
    {
        if(ans[s[i]] == -1){
            ans[s[i]] = c[i];
        }else{
            if(ans[s[i]] != c[i]) tf = 0;
        }
    }
    if(N>1){
        if(ans[0] == 0) tf = 0;
    }
    if(N==1&&tf){
        if(ans[0] == -1){
            cout << 0;
        }else{
            cout << ans[0];
        }
    }else{
    if(tf){
        if(ans[0] == -1){
            cout << 1;
        }else{
            cout << ans[0];
        }
        for (int i = 1; i < N; i++)
        {
            if(ans[i] == -1){
                cout << 0;
            }else{
                cout << ans[i];
            }
        }
        
    }else{
        cout << -1 << endl;
    }}
}

Measured memory_bytes: 256
def main():
    for i in xrange(n):
        b, f, r, v = map(int, raw_input().split())
        x[b-1][f-1][r-1] += v
    for b in range(4):
        for f in range(3):
            print(' ' + ' '.join(map(str,x[b][f])))
        if b != 3:
            print('#'*20)

n = input()
x = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
main()

Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())

//変数
ll A, B;
//解法
void solve() {

	cout << A + (B / 2);

	return;
}

int main() {
	//入力
	cin >> A >> B;
	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;


int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  v.push_back(0);
  for(int i=0; i<n; ++i) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  v.push_back(0);

  vector<int> costs;
  int sum = 0;
  for(int i=1; i<n+2; ++i) {
    int cost = abs(v[i]-v[i-1]);
    costs.push_back(cost);
    sum += cost;
  }

  for(int i=0; i<n; ++i) {
    int res = sum - costs[i] - costs[i+1] + abs(v[i]-v[i+2]);
    printf("%d\n", res);
  }
}


Measured memory_bytes: 2168
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){
	int a,b;
	double S,L,h,C;
	cin>>a>>b>>C;
	C=C/180.0*M_PI;
	S=1.0/2.0*a*b*sin(C);
	L=sqrt(a*a+b*b-2.0*a*b*cos(C))+a+b;
	h=b*sin(C);
	cout<<fixed<<setprecision(5)<<S<<endl;
	cout<<fixed<<setprecision(5)<<L<<endl;
	cout<<fixed<<setprecision(5)<<h<<endl;
}


Measured memory_bytes: 3536
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll N, M, ac=0, wa=0, tle=0, re=0;
	cin >> N;
	vector<string> vs(N);

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

	rep(i, N){
		if(vs[i] == "AC") ac++;
		if(vs[i] == "WA") wa++;
		if(vs[i] == "TLE") tle++;
		if(vs[i] == "RE") re++;
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;




}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 6332
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % 2019; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % 2019;
	if (k != 0)rip(i, k)j = j * a % 2019;
	return(j);
}
int main() {
	ll k, a, b;
	cin >> k >> a >> b;
	if (a <= b) {
		if (k <= a)cout << "1" << endl;
			else cout << "-1" << endl;
	}
		else {
			ll p = ((k -b -1) / (a - b));
			cout << 2 * p + 1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    VI ans(n + 1);
    FOR(x,1,100) FOR(y,1,100) FOR(z,1,100){
        int c = x*x + y*y + z*z + x*y + y*z + z*x;
        if (c <= n) ans[c]++;
    }
    FOR(i,1,n) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int substr( char *t, const char *s, int pos, int len )
{
    if( pos < 0 || len < 0 || len > strlen(s) )
        return -1;
    for( s += pos; *s != '\0' && len > 0; len-- )
        *t++ = *s++;
    *t = '\0';
    return 0;
}
int main() {
    int K;
    char S[110];
    char S2[110];
    char S4[]="...";
    scanf("%d",&K);
    scanf("%s",&S);
    if(strlen(S)>K)
    {
        substr(S2,S,0,K);
        printf("%s\n",strcat(S2,S4));
    } else{
        printf("%s\n",S);
    }

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n+x-1) / x) * t << endl;
	return 0;
}


Measured memory_bytes: 3628
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h-1:
            print('#'*w)
        else:
            d = '.' * (w-2)
            print('#' + d + '#')
    print("")


Measured memory_bytes: 5612
#include<iostream>
#include<stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  //整数の時はint
  //int a,b,c;
  //文字の時はstring
  string a;


  cin>>a;
  if(a.length()%2==1){
    cout<<"No"<<endl;
  }else{
    for(int i=0;i<a.length();i+=2){
      if(a[i]!='h' || a[i+1]!='i'){
	cout<<"No"<<endl;
	return 0;
      }
    }
    cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, last, cnt, sum, ans = INF, a[200001];
string str, ss;
bool f[2][10000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { int to, cost; };
vector<Edge>vec;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> a[0] >> a[1] >> a[2];
	cin >> n >> m;
	ans = min(a[2] * n * 2 + (m - n > 0 ? (m - n)*a[1] : 0), ans);
	ans = min(a[2] * m * 2 + (n - m > 0 ? (n - m)*a[0] : 0), ans);
	ans = min(a[0] * n + a[1] * m, ans);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int buffer[1000000];
void merge(long a[],int left,int right){
    if(left<right){
        int axis=(left+right)/2,i=left,p=0,q=left,r=0;
        merge(a,left,axis);
        merge(a,axis+1,right);
        while(i<=axis)buffer[p++]=a[i++];
        while(i<=right && r<p)a[q++]=(a[i]<=buffer[r])?a[i++]:buffer[r++];
        while(r<p)a[q++]=buffer[r++];
    }
}
int main(void){
    int N,K;
    scanf("%d%d",&N,&K);
    long h[N],c,b;
    for(int i=0;i<N;i++)scanf("%ld",&h[i]);
    merge(h,0,N-1);
    c=h[N-1]-h[N-K];
    for(int i=0;i<=N-K;i++){
        b=h[N-1-i]-h[N-K-i];
        if(b<c)c=b;
    }
    printf("%ld\n",c);
    return 0;
}


Measured memory_bytes: 1152
//package com.atcoder.contest173.c;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int m = fs.nextInt();
        int k = fs.nextInt();
        char[][] a = new char[n][m];
        for (int i = 0; i < n; ++i) {
            String s = fs.next();
            for (int j = 0; j < m; ++j) {
                a[i][j] = s.charAt(j);
            }
        }
        int ans = 0;
        for(int mask=0; mask < 1 << (n + m); ++mask){
            int count = 0;
            for(int i=0; i<n; ++i){
                for(int j=0; j<m; ++j){
                    if(a[i][j] == '.') continue;
                    if((mask & ((1 << i)  | (1 << (n + j)))) != 0) continue;
                    count++;
                }
            }
            if(count == k) ans++;
        }
        System.out.println(ans);
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}



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

ll f(const vector<string>& grid, vector<vector<ll>>& dp, int i, int j) {
    if(i < 0 || i >= grid.size() || j < 0 || j >= grid[0].size() || grid[i][j] == '#')
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j]%MOD;
    return dp[i][j] = (f(grid, dp, i-1, j)%MOD + f(grid,dp,i,j-1)%MOD)%MOD;
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for(auto& i: grid)
        cin >> i;
    vector<vector<ll>> dp(H, vector<ll>(W, -1));
    dp[0][0] = 1;
    cout << f(grid, dp, H - 1, W - 1);
    return 0;
}

Measured memory_bytes: 9216