akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

const int INF = 1e+8;
int n;
string add[10][10];
bool memo[10];
vector<string> ans;
int ans_len;

bool is_substring(const string &s, const string &t){
	if( s.size() > t.size() ) return false;
	
	for(int k = 0; k < t.size(); k++){
		int cnt = 0;
		for(int i = 0; i < s.size(); i++){
			if( t.size() <= i + k ) break;
			
			if( s[i] == t[i+k] ){
				cnt++;
			}else{
				break;
			}
		}
		if( cnt == s.size() ) return true;
	}
	return false;
}

string add_string(const string &s, const string &t){
	for(int k = 0; k < s.size(); k++){
		bool flag = true;
		for(int i = k; i < s.size(); i++){
			if( s[i] != t[i-k] ){
				flag = false;
				break;
			}
		}
		if( flag ){
			string res;
			for(int i = s.size() - k; i < t.size(); i++){
				res.push_back(t[i]);
			}
			return res;
		}
	}
	return t;
}

void dfs(int k, string s, int prev){
	if( k == n - 1 ){
		//cout << s << endl;
		if( s.size() < ans_len ){
			ans.clear();
			ans.push_back(s);
			ans_len = s.size();
		}else if( s.size() == ans_len ){
			ans.push_back(s);
		}
	}else{
		//cout << k << " " << s << endl;
		if( s.size() > ans_len ) return ;
		
		for(int i = 0; i < n; i++){
			if( memo[i] ) continue;
			
			memo[i] = true;
			dfs(k + 1, s + add[prev][i], i);
			memo[i] = false;
		}
	}
}

int main(){
	while( cin >> n , n ){
		// 初期化
		ans.clear();
		ans_len = INF;
		for(int i = 0; i < n; i++){
			memo[i] = false;
			for(int j = 0; j < n; j++){
				add[i][j] = "";
			}
		}
		
		// 入力
		vector<string> s(n);
		for(int i = 0; i < n; i++) cin >> s[i];
		
		// s[i]がs[j]の部分文字列になっていたらs[i]を取り除く
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if( i == j ) continue;

				if( is_substring(s[i], s[j]) ){
					s[i] = "";
				}
			}
		}
		vector<string> s_;
		for(int i = 0; i < n; i++){
			if( s[i] != "" ) s_.push_back(s[i]);
		}
		s = s_;
		n = s.size();
		
		// s[i]にどの文字列を連結したら s[i] と s[j] のSSSになるか求める
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if( i == j ) continue;
				add[i][j] = add_string(s[i], s[j]);
			}
		}
		
		// 全探索 O(n!)
		for(int i = 0; i < n; i++){
			memo[i] = true;
			dfs(0, s[i], i);
			memo[i] = false;
		}
		sort(ans.begin(), ans.end());
		cout << ans[0] << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    int count[5] = {};
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        switch(s[0]){
            case 'M': count[0]++; break;
            case 'A': count[1]++; break;
            case 'R': count[2]++; break;
            case 'C': count[3]++; break;
            case 'H': count[4]++; break;
            default: break;
        }
    }

    long long int ans = 0;
    int p[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
    int q[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
    int r[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
    for(int i = 0; i < 10; i++){
        long long int coans = count[p[i]];
        coans *= count[q[i]];
        coans *= count[r[i]];
        ans += coans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n,q=map(int,input().split())
cnt=[0]*(n)
g=[[] for _ in range(n)]
for _ in range(n-1): #木グラフの隣接リストを作成
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for _ in range(q):
    a , b = map(int,input().split())
    a = a - 1
    cnt[a] += b
import collections
q=collections.deque()
q.append(0)
check=[0]*n
while q:
  v=q.popleft()
  check[v]=1
  for u in g[v]:
    if check[u]==1:
      continue
    cnt[u]+=cnt[v]
    q.append(u)
print(*cnt)

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

typedef unsigned long long ull;

ull b=1000000007;

int main()
{
  string s,p;
  int n,m;
  ull t=1,sh=0,ph=0;

  cin>>s>>p;

  n=s.length();
  m=p.length();

  if(n<m)return 0;

  for(int i=0;i<m;i++)t*=b;
  for(int i=0;i<m;i++)sh=sh*b+s[i];
  for(int i=0;i<m;i++)ph=ph*b+p[i];

  for(int i=0;i+m<=n;i++){
    if(sh==ph)printf("%d\n",i);
    if(i+m<n)sh=sh*b+s[i+m]-s[i]*t;
  }

  return 0;
}

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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1e18
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second

ll dp[3005][3005];
ll S,N;
ll A[3005];
const ll MOD = 998244353;

void clear() {
	for(ll i=0;i<3005;i++) {
		for(ll j=0;j<3005;j++) {
			dp[i][j]=0;
		}
	}
}

// ll solve(ll indx, ll sum) {
// 	// if(sum==S && len==0) return 1;

// 	// if(len<=0 && sum<S) return 0;
// 	if(sum==S) return 1;
// 	if(indx>N) return 0;

// 	if(dp[indx][sum]!=-1) return dp[indx][sum];

// 	ll ans = 0;
// 	if(sum+A[indx]<=S) {
// 		ans = (solve(indx+1,sum+A[indx]))%MOD;
// 		// ans = (ans+solve(indx+1,sum+A[indx])+solve(indx+1,sum))%MOD;
// 		ans = (ans+(2*solve(indx+1,sum))%MOD)%MOD;
// 	} else {
// 		ans = (2*solve(indx+1,sum))%MOD;
// 	}

// 	return dp[indx][sum] = ans;
// }

inline ll mul(ll x, ll y, ll mod) {
	x %= mod;
	y %= mod;
	ll res = ((x*y)%mod+mod)%mod;
	return res;
}


ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}


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

	clear();

	for(ll i=1;i<=N;i++) {
		cin>>A[i];
	}

	dp[0][0]=1;
	for(ll i=1;i<=N;i++) dp[0][i]=1;
	ll ans = 0;
	for(ll i=1;i<=S;i++) {
		for(ll j=1;j<=N;j++) {
			if(i>A[j]) {
				dp[i][j] = (dp[i][j-1] + dp[i-A[j]][j-1])%MOD;
			} else if(i==A[j]) {
				dp[i][j] = (j+dp[i][j-1])%MOD;
			} else {
				dp[i][j] = dp[i][j-1]%MOD;
			}
		}
	}

	for(ll i=1;i<=N;i++) {
		ans = (ans + dp[S][i])%MOD;
	}
	cout<<ans<<endl;
	// for(ll i=0;i<=S;i++) {
	// 	for(ll j=0;j<=N;j++) {
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// cout<<dp[S][N]<<endl;
	
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int k=0;
  long long n;
  cin>>n;
  long long count=0,a=0,b=0;
  
  while(s[0]==s[k++] && k<=s.length() && s[0]==s[s.length()-1])a++;
  k=s.length()-1;
  while(s[s.length()-1]==s[k--] && k>=0 &&s[0]==s[s.length()-1])b++;
  if(a==s.length())
  {
    cout<<n*a/2<<endl;
    return 0;
  }
  
    for(int i=a;i<s.length()-b;i++)
    {
		if(s[i]==s[i-1])
        {
          count++;
          i++;
        }
    }
  //cout<<a<<' '<<b<<' '<<count<<endl;
  long long sum=(a/2)+(b/2)+(n-1)*((a+b)/2)+n*(count);
  cout<<sum<<endl;
  return 0;
}

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

int n,a[N],dgr[N]; bool vis[N],b[N][N],mp[N][N];
struct cmp{ bool operator ()(int x,int y){ return a[x]<a[y]; } };
priority_queue<int,vector<int>,cmp> Q;
int gcd(int x,int y){ return y?gcd(y,x%y):x; }
void dfs(int x){
	int y; vis[x]=1;
	for (y=1; y<=n; y++) if (!vis[y] && mp[x][y]){
		b[x][y]=1; dgr[y]++; dfs(y);
	}
}
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (i=1; i<n; i++)
		for (j=i+1; j<=n; j++) mp[i][j]=mp[j][i]=(gcd(a[i],a[j])>1);
	for (i=1; i<=n; i++) if (!vis[i]) dfs(i);
	for (i=1; i<=n; i++) if (!dgr[i]) Q.push(i);
	while (!Q.empty()){
		printf("%d ",a[i=Q.top()]); Q.pop();
		for (j=1; j<=n; j++) if (b[i][j])
			if (!(--dgr[j])) Q.push(j);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll long long
#define MN 250005
using namespace std;
inline ll in(){
    ll x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
map <ll,int> mp;
const ll mod=4172596182543704117ll;
const ll Mod=233;
ll h[MN];
ll n,x,y,sum,bt,res,tmp;
char s[MN];
inline ll qmul(ll x,ll y){
	ll res=0;
	while (y){
		if (y&1) res=(res+x)%mod;
		x=(x+x)%mod;y>>=1; 
	}return res;
}
inline ll qpow(ll x,ll y){
	ll res=1;
	while (y){
		if (y&1) res=qmul(res,x)%mod;
		x=qmul(x,x)%mod;y>>=1;
	}return res;
}
int main()
{
	n=in();scanf("%s",s);
	bt=1;x=Mod;y=qpow(x,mod-2);
	for (int i=1;i<=n;++i){
		h[i]=h[i-1];
		if (s[i-1]=='+') h[i]=(h[i]+bt)%mod;
		else if (s[i-1]=='-') h[i]=(h[i]+mod-bt)%mod;
		else if (s[i-1]=='<') bt=qmul(bt,x);
		else if (s[i-1]=='>') bt=qmul(bt,y);
		++mp[h[i]];
	}bt=1;
	for (int i=1;i<=n;++i){
		tmp=qmul(h[n],bt);tmp=(tmp+sum)%mod;
		res+=mp[tmp];
		if (s[i-1]=='+') sum=(sum+bt)%mod;
		else if (s[i-1]=='-') sum=(sum+mod-bt)%mod;
		else if (s[i-1]=='<') bt=qmul(bt,x);
		else if (s[i-1]=='>') bt=qmul(bt,y);
		--mp[h[i]];
	}printf("%lld",res);return 0;
}

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

int main() {

  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  
  int top, right, bottom, left;
  top = y + r;
  right = x + r;
  bottom = y - r;
  left = x - r;
  
  if ( top > H || right > W || bottom < 0 || left < 0 ) {
	cout << "No" << endl;
  } else {
	cout << "Yes" <<endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'

typedef int64_t Int;
const double pi = M_PI;

using namespace std;

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

    bool ans = true;

    if (a + b < c) {
        ans = false;
    }

    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int a,b;
    cin>>a>>b;
    cout<<a*b-(a+b)+1<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
    { for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
    { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
    { cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

ll dp[2020][2020];

void solve() {
    int n;
    cin >> n;
    vector<pii> A(n);
    rep(i, n) {
        int a;
        cin >> a;
        A[i] = {a, i};
    }
    sort(all(A), greater<pii>());
    rep(i, n) {
        int a, idx;
        tie(a, idx) = A[i];
        REP(l, 0, i) {
            int r = i - l;
            chmax(dp[l + 1][r], dp[l][r] + 1LL * a * abs(idx - l));
            chmax(dp[l][r + 1], dp[l][r] + 1LL * a * abs((n - 1) - idx - r));
        }
    }
    ll ans = 0;
    REP(i, 0, n) {
        chmax(ans, dp[i][n - i]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 26348
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll N, K;
    cin >> N >> K;
    ll value = 1;
    for (ll i = 0; i < N; ++i) {
        if (value < K) {
            value *= 2;
        } else {
            value += K * (N - i);
            break;
        }
    }
    cout << value << endl;
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) {
        	h[i] = sc.nextInt();
        }

        System.out.println(solve(n,k,h)[n-1]);

    }



	private static long[] solve(int n, int k, int[] h) {
		long[] dp = new long[n];
		Arrays.fill(dp, Long.MAX_VALUE);

		dp[0] = 0;
		for(int i = 1; i < n; i++) {
			for(int j = 1; j <= k; j++) {
				if(i-j < 0)
					break;

				dp[i] = Math.min(dp[i], dp[i-j]+Math.abs(h[i-j]-h[i]));
			}
		}

		return dp;

	}
}

Measured memory_bytes: 51456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
l = list(map(int,input().split()))

cnt = 0



while not(l[0] == l[1] == l[2]):
    l = sorted(l)
    
    if l[0]+2 <= l[2]:
        l[0] += 2
        cnt += 1
    
    else:
        l[0] += 1
        l[1] += 1
        cnt += 1

print(cnt)
        

Measured memory_bytes: 3060
import math
N,X = list(map(int, input().split()))
cnt = 0
for i in range(N, 0, -1):
  t = math.pow(2, i + 1) - 2
  if X >= t * 2:
    cnt += t + 1
    break
  elif X >= t:
    cnt += t / 2
    X -= t
    if X > 1:
      cnt += 1
      X -= 1
    elif X == 1:
      cnt += 1
      break
    else:
      break
  else:
    if X > 1:
      X -= 1
    else:
      break
print(int(cnt))

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

int main()
{
    string str;
    int y, m, d;

    while( cin >> str )
    {
        if( str == "#" )
            break;

        cin >> y >> m >> d;
        
        if( y < 31 || y == 31 && m < 5 )
            cout << str << " " << y << " " << m << " " << d << endl;
        else
            cout << "? " << y - 30 << " " << m << " " << d << endl;
    }

    return 0;
}



Measured memory_bytes: 3184
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Macros

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int, int>
#define mii map<pii, int>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(x) (int) x.size()
#define mod 1000000007
#define EPS 1e-9
#define inf 1e18
#define PI acos(-1.0)
#define int long long
#define N 100005

// Solution

void solve() {
  int n;
  cin >> n;
  int a = -inf, b = inf, c = -inf, d = inf;
  vii v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].fi >> v[i].se;
  }
  sort(all(v));
  for (auto[x, y] : v) {
    a = max(a, x + y);
    b = min(b, x + y);
    c = max(c, x - y);
    d = min(d, x - y);
  }
  for (int i = 0; i < n; i++) {
    swap(v[i].fi, v[i].se);
  }
  sort(all(v));
  int e = -inf, f = inf, g = -inf, h = inf;
  for (auto[x, y] : v) {
    e = max(e, x + y);
    f = min(f, x + y);
    g = max(g, x - y);
    h = min(h, x - y);
  }
  int ans = max({a - b, c - d, e - f, g - h});
  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

  int tests;
  tests = 1;
  // cin>>tests;

  for (int test = 1; test <= tests; test++) {
    // cout<<"Case #"<<test<<": ";
    solve();
  }

  return 0;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, a, b) for(int i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

const int MOD = 1e9+7;

void addSelf(int& a, int b){
  a += b;
  if(a >= MOD) a -= MOD;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n; cin >> n;
  vvi v(n, vi(n));
  rep(i,0,n) rep(j,0,n) cin >> v[i][j];
  vi dp(1 << n);
  dp[0] = 1;
  rep(used,0,(1<<n)-1){
    int a = __builtin_popcount(used);
    rep(b,0,n){
      if(v[a][b] && !(used & (1 << b))){
        int m2 = used ^ (1 << b);
        addSelf(dp[m2], dp[used]);
      }
    }
  }
  cout << dp[(1<<n)-1];
}


Measured memory_bytes: 11340
import java.util.Scanner;

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 = sc.nextInt();
        if (a == b && b == c) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 21844
import sys
import numpy as np

from math import gcd

N = int(sys.stdin.readline())
ans = 0
"""
dp = np.zeros((N+1, N+1))
def gcd(a, b):
    if a < b:
        a, b = b, a
    
    if dp[a][b] != 0:
        return dp[a][b]

    while b>0:
        a, b = b, a % b
    
    dp[a][b] = a
    return a
"""
for i in range(1,N+1):
    for j in range(1,N+1):
        temp = gcd(i, j)
        for k in range(1,N+1):
            ans += gcd(temp, k)
            
print(ans)

Measured memory_bytes: 27088
#include <iostream> 
#include<set>
using namespace std; 
int main(){
  set<int> s;
  int a,b;
  cin>>a;
  cin>>b;
  s.insert(1);
  s.insert(2);
  s.insert(3);
  s.erase(a);
  s.erase(b);
  for(int x:s){
    cout<<x;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,flg,x;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		int a,cnt;
		flg=0; cnt=0;
		for(i=0;i<n;i++){
			scanf("%d",&a);
			if(a>0) cnt++;
			if(a>1) flg=1;
		}
//printf("cnt=%d\n",cnt);
		if(flg==0) printf("NA\n");
		else printf("%d\n",cnt+1);
	}
	return 0;
}


Measured memory_bytes: 2768
n = int(input())
a = list(map(int, input().split()))
p_map = {}
q_map = {}
for i, A in enumerate(a):
    p = i + A
    q = i - A
    if p not in p_map:
        p_map[p] = 1
    else:
        p_map[p] += 1
    if q not in q_map:
        q_map[q] = 1
    else:
        q_map[q] += 1
ans = 0
for i, v in p_map.items():
    if i in q_map:
       ans += v*q_map[i]
print(ans)

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> a(n),b(n);
    for (int i = 0; i < n; i++) {
        /* code */
        std::cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        /* code */
        std::cin >> b.at(i);
    }
    int ma=0,s=0;
    for (int i = 0; i < n; i++) {
        /* code */
        s=0;
        for (int j = 0; j <= i ; j++) {
            /* code */
            s+=a.at(j);
        }
        for (int j = i; j < n ; j++) {
            /* code */
            s+=b.at(j);
        }
        if(ma<s)ma=s;
    }
    std::cout << ma << std::endl;
}

Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    R:usize,C:usize,K:usize,
    RCV:[(usize,usize,i64);K]
  }
  let mut RCV: Vec<(usize, usize, i64)> = RCV;
  // dp[r,c,n]位置(r,c)にいるときに、その行でn個以下のアイテムを拾っているときのtotal
  // r,cのスタートは(1,1)から、(R,C)に移動するまで。
  // つまり、r+cがR+C-2になるまで。
  let mut v = vec![vec![0; C + 1]; R + 1];
  for &(r, c, x) in RCV.iter() {
    v[r][c] = x;
  }
  debug!(v);
  let mut dp = vec![vec![vec![0; 4]; C + 1]; R + 1];
  for r in 1..=R {
    for c in 1..=C {
      debug!(r,c);
      // 移動のみ
      dp[r][c][0] = max(dp[r - 1][c][3], dp[r][c - 1][0]);
      dp[r][c][1] = max(dp[r - 1][c][3], dp[r][c - 1][1]);
      dp[r][c][2] = max(dp[r - 1][c][3], dp[r][c - 1][2]);
      dp[r][c][3] = max(dp[r - 1][c][3], dp[r][c - 1][3]);
      debug!(r, c, dp[r]);
      // 拾う。
      dp[r][c][3] = max(dp[r][c][3], dp[r][c][2] + v[r][c]);
      dp[r][c][2] = max(dp[r][c][2], dp[r][c][1] + v[r][c]);
      dp[r][c][1] = max(dp[r][c][1], dp[r][c][0] + v[r][c]);
      debug!(r, c, dp[r]);
    }
  }
  println!("{}", dp[R][C][3])
}


Measured memory_bytes: 713560
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n, a, cnt, min_cnt;
    min_cnt = 10000;

    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cnt = 0;
        cin >> a;
        while(a % 2 == 0)
        {
            a /= 2;
            ++cnt;
        }
        min_cnt = min(min_cnt, cnt);
    }
    cout << min_cnt << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	static int[] cmin = new int[8];
	static int min = 0;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];


		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}

		for (int j=0; j<8; j++){
			cmin[j] = 0;
		}

		int check = 0;
		for (int i=0; i<n; i++){
			if (a[i] < 3200){
				col(a[i]);				
				check++;
			}
		}

		int pro = 0;
		for (int i=0; i<n; i++){
			if (a[i] >= 3200){
				pro++;
			}
		}
		if (check != 0){
			for (int j=0; j<8; j++){
				if (cmin[j] != 0){
					min++;
				}
			}
			System.out.println(min +" "+(min+pro));
		}
		else{
			System.out.println("1 "+pro);
		}

	}

	public static void col(int rate){
		if (rate >= 1 && rate <=399){
			cmin[0]++;
		}
		else if (rate >= 400 && rate <= 799){
			cmin[1]++;
		}
		else if (rate >= 800 && rate <= 1199){
			cmin[2]++;
		}
		else if (rate >= 1200 && rate <= 1599){
			cmin[3]++;
		}
		else if (rate >= 1600 && rate <= 1999){
			cmin[4]++;
		}
		else if (rate >= 2000 && rate <= 2399){
			cmin[5]++;
		}
		else if (rate >= 2400 && rate <= 2799){
			cmin[6]++;
		}
		else if (rate >= 2800 && rate <= 3199){
			cmin[7]++;
		}

	}
}

Measured memory_bytes: 21844
# Author:Fuad Ashraful Mehmet ,CSE-UAP
import sys
input=sys.stdin.readline

def fun(num):
    return num*(num+1)//2
n=int(input())

ans=0

for i in range(1,n+1):
    y=n//i

    ans+= i*fun(y)

print(ans)

Measured memory_bytes: 63808
N, K = map(int,input().split(' '))

tN = N
tK = K
tP = 1
ans = 0

for i in range(20):
    #print(tN,tK,tP)
    if tN >= tK:
        if tK > int(tK):
            ans += ((tN -int(tK)) * tP)/N
            tN = int(tK)
        else:
            ans += ((tN -int(tK)+1) * tP)/N
            tN = int(tK)-1
        #print(ans)
    tP = tP/2
    tK = tK/2
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d", ((a + b) / 2.f - (a + b) / 2 > 0.f) + (a + b) / 2);
  
  return 0;
  
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[2-i]){
            ans++;
        }
    }
    if(ans==3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

  //input
  int N,K;
  cin >> N >> K;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  sort(A,A+N);
  int Total=0;
  for(int i=0;i<K;i++) Total += A[i];
  
  //setup
  
  //output
  cout << Total << endl;

}

Measured memory_bytes: 3624
n=int(input())
m,a,r,c,h=0,0,0,0,0
for i in range(n):
  x=input()[0]
  if x=="M":
    m+=1
  elif x=="A":
    a+=1
  elif x=="R":
    r+=1
  elif x=="C":
    c+=1
  elif x=="H":
    h+=1
s=[m*a*r,m*a*c,m*a*h,m*r*c,m*r*h,m*c*h,a*r*c,a*r*h,a*c*h,r*c*h]
print(sum(s))

Measured memory_bytes: 49768
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
vi vec[100005];
bool vis[100005]={0};
int ans[100005]={0};
map<pair<int,int>,int>mm;

void dfs(int ind){
	// cout<<ind<<"...\n";
    for(auto it:vec[ind]){
        if(!vis[it]){
        	// cout<<ind<<"__"<<it<<"\n";
        	if(mm[{it,ind}]%2==0){
        		ans[it]=ans[ind];
        	}else ans[it]=1^ans[ind];
            vis[it]=1;
            dfs(it);
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input_file.txt", "r", stdin);
    //freopen("output_file.txt", "w", stdout);
    #endif
    int i,j,k,l,n,test_case,m,r;
    test_case=1;
    //cin>>test_case;
    while(test_case--){
        cin>>n;
        m=n-1;
        // memset(vis,0,sizeof vis);
        vi x(m),y(m),z(m);
        rep(i,0,m){
            cin>>x[i]>>y[i]>>z[i];
            x[i]--;
            y[i]--;
            mm[{x[i],y[i]}]=z[i];
            mm[{y[i],x[i]}]=z[i];
            vec[x[i]].pb(y[i]);
            vec[y[i]].pb(x[i]);
        }
        int cnt=0;
        rep(i,0,n){
            if(vis[i]==0){
            	vis[i]=1;
                cnt++;
                ans[i]=0;
                dfs(i);
            }
        }
        rep(i,0,n)cout<<ans[i]<<"\n";



    }
    
    return 0;
}

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

typedef long long ll;
typedef long double ld;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	
	int n,t;
	cin>>n>>t;
	int cost=2000;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		
		if(b<=t) cost=min(cost,a);
		
	}
	
	if(cost<2000) cout<<cost;
	else cout<<"TLE";
					
		
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define pb push_back
#define pi 3.14159265358979323846264338327950288419716939937510
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 100
using namespace std;

int main()
{
    RUN_FAST;
    ll n, x, tmp, i, j, cnt;
    ll sum=0;
    vector <ll> v;
    scanf("%lld", &n);
    tmp=n;
    while (tmp--) {
        scanf("%lld", &x);
        sum+=x;
        v.push_back(x);
    }
    ll arr[100110]={0};
    sort(v.begin(), v.end());
    for (i=0; i<n; i++) {
        cnt=1;
        tmp=v[i];
        for (j=i+1; j<n; j++) {
            if (v[j]!=tmp) {
                break;
            }
            cnt++;
        }
        arr[tmp]=cnt;
        i=j-1;
    }
    ll q, a, b;
    scanf("%lld", &q);
    while (q--) {
        scanf("%lld %lld", &a, &b);
        tmp=arr[a];
        sum-=tmp*a;
        sum+=tmp*b;
        arr[b]=arr[b]+tmp;
        arr[a]=0;
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 4992
def print_list(r):
    for i in range(len(r)):
        if i != len(r)-1:
            print (r[i], end=' ')
        else:
            print(r[i])


n=int(input())
r=list(map(int,input().split()))
count_num = 0
for i in range(0, n):
    minj = i
    for j in range(i, n):
        if r[j] < r[minj]:
            minj = j
    v = r[minj]
    r[minj] = r[i]
    r[i] = v
    if minj != i:
        count_num += 1
print_list(r)
print(count_num)


Measured memory_bytes: 5604
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		VI A(N);
		REP(i, N) cin>>A[i];
		RANGE(i, K, N) {
			ll ans=A[i-K]<A[i];
			cout<<YN(ans)<<endl;
		}
//		DD("A");
	}
	
	return 0;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> card(N);
    for (int i = 0; i < N; i++){
        cin >> card.at(i);
    }
    sort(card.begin(), card.end());
    reverse(card.begin(), card.end());
    int A = 0;
    int B = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){
            A = A + card.at(i);
        }
        else B = B + card.at(i);
    }
    cout << A - B << endl;
}

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

using namespace std;

vector<int> v[200009];


int main(){
  int n;
  cin >> n;
  for(int i=1;i<n;i++){
    int a;cin >> a;
    a--;
    v[a].push_back(i);
  }
  for(int i=0;i<n;i++){
    cout << v[i].size() << endl;
  }
}


Measured memory_bytes: 14512
#include <stdio.h>

char s[200005];
int cnt[1005];

int main(){
    scanf("%s", s);
    int N;
    for(N=0; s[N]; N++);
    long long res = 1LL*N*(N+1)/2;
    for(int i=0; i<N; i++){
        res -= cnt[s[i]]+1;
        cnt[s[i]]++;
    }
    printf("%lld", res+1);
    return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let mut ok = false;

  for i in 1..b + 1 {
    let d = (a * i) % b;
    if d == c {
      ok = true;
    }
  }

  println!("{}", if ok { "YES" } else { "NO" });
}

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

#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"
const ll ll_MAX = 19223372036859;
const ll MOD = 1000000007;
ll fast_expo(ll x,ll p){if(p==0) return 1;
    else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} 
    else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  
    else return gcd(b%a,a); }

ll dp[100001][2];

ll dfs(vector<ll> AdjL[],ll src,ll clr,ll par){
    if(dp[src][clr] != -1) return dp[src][clr];

    dp[src][clr] = 1;
    for(auto i:AdjL[src]){
        if(i != par){
           if(clr == 0) dp[src][clr] = (dp[src][clr]*(dfs(AdjL,i,clr,src)+dfs(AdjL,i,1-clr,src)))%MOD;
           else  dp[src][clr] = (dp[src][clr]*dfs(AdjL,i,1-clr,src))%MOD;
        }
    }
    return dp[src][clr];
}

int main()
{
    ll t_c; t_c = 1;
    // cin >> t_c;
    for(ll t_i=0; t_i<t_c; ++t_i){
        memset(dp,-1,sizeof(dp));
        ll n; cin >> n;
        vector<ll> AdjL[n+1];
        for(ll i=0; i<n-1; ++i){
            ll x,y; cin >> x >> y;
            AdjL[x].pb(y);
            AdjL[y].pb(x);
        }
        cout << (dfs(AdjL,1,0,-1)+dfs(AdjL,1,1,-1))%MOD;
    }   
    return 0;
}

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

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

typedef long long ll;

int main(int argc, char const *argv[]) {
    int A, B, C;
    scanf("%d %d %d",&A,&B,&C);
    int ans;
    ans=C-(A-B);
    if(ans>0){
        printf("%d",ans);
    }else{
        printf("%d",0);
    }
    return 0;
}


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

int main() {
  string input;
  cin >> input;
  int N = input.length();
  int k;
  cin >> k;
  vector<string> vec;

  string a[N];
  for(int i=0;i<N;++i){
    a[i] = input[i];
  }

  string b[N];
  for(int i=0;i<N;++i){
    b[i] = a[i];
  }

  for(int j=0;j<k;++j){
    for(int i=0;i<N-j;++i){
      if(j!=0){
        a[i] += b[i+j];
      }
      vec.push_back(a[i]);
    }
  }

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

  // cout << vec[0] << endl;
  // cout << vec[1] << endl;
  // cout << vec[2] << endl;
  // cout << vec[3] << endl;



  string ans="zzzzz";
  int res = 0;

  for(int i=0;i<k;++i){
    if(ans==vec[res]){
    while(ans==vec[res]) ++res;
    }
    ans = vec[res];
  }

  cout << ans << endl;





  
  }

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

int main()
{
	ll w, h, x, y; cin >> w >> h >> x >> y;
	
	if (2 * x == w && 2 * y == h) {
		cout << fixed << setprecision(11) << (double)w * (double)h / 2 << " " << 1 << endl;
		return 0;
	}

	cout << fixed << setprecision(11) << (double)w * (double)h / 2 << " " << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         int[][][] heya = new int[4][3][10];
          for(int i = 0; i < n; i++) {
         int b = sc.nextInt();
         int f = sc.nextInt();
         int r = sc.nextInt();
         int v = sc.nextInt();
         heya[b-1][f-1][r-1] += v;         }
         for(int i = 0; i < 4; i++) {
         for(int j = 0; j < 3; j++) {
         for(int k = 0; k < 10; k++) {
         System.out.print(" " + heya[i][j][k]);}
         System.out.println();             }
         if(i != 3) {
         System.out.println("####################");
         }
         }
   }
}
 

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

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

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

    int w,a,b;
    cin>>w>>a>>b;
    int s=a<b?a:b;
    int l=a>b?a:b;

    int ans=l-(s+w);

    if(ans<0) cout<<0;
    else cout<<ans;
}


Measured memory_bytes: 3628
# B - Tap Dance
S = input()

count = 1
yesFlag = True
for s in S:
    if count % 2 == 1:
        count += 1
        if s == 'L':
            yesFlag = False
            break
    else:
        count += 1
        if s == 'R':
            yesFlag = False
            break

if yesFlag:
    print('Yes')
else:
    print('No')


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

typedef long long int ll;
ll n, length[107];

int main() {
    cin >> n;
    for(ll i = 0; i < n; ++i) cin >> length[i];

    sort(length, length + n);

    ll ans = 0;
    for(ll i = 0; i < n; ++i) {
        for(ll j = i + 1; j < n; ++j) {
            for(ll k = j + 1; k < n; ++k) {
                if(length[i] < length[j] && length[j] < length[k] && length[i] + length[j] > length[k]) {
                    ans++;
                    //cout << i << ' ' << j << ' ' << k << endl;
                }
            }
        }
    }

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

Measured memory_bytes: 3528
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\,
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int cnt[27];

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string w;
    cin >> w;
    for(int i=0;i<w.size();i++){
        int num = w[i]-'a';
        cnt[num]++;
    }
    for(int i=0;i<27;i++){
        if(cnt[i]%2 == 1){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3532
# vim: fileencoding=utf-8


def main():
    n = int(input())
    max_k = n // 7
    max_d = n // 4
    for i in range(max_k + 1):
        for j in range(max_d + 1):
            if i * 7 + j * 4 == n:
                print("Yes")
                return
    print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61852
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

char s[100];

int main(void){
	scanf("%s",s);
	int ls=strlen(s);
	s[ls-8]='\0';
	puts(s);
	return 0;
}






Measured memory_bytes: 256
ans_list = list(map(int, input().split()))
N = int(input())
ans_list[1] = min(ans_list[0]*2, ans_list[1])
ans_list[2] = min(ans_list[1]*2, ans_list[2])
if ans_list[2]*2<=ans_list[3]:
    print(N*ans_list[2])
else:
    print(ans_list[3]*(N//2)) if N%2==0 else print(ans_list[3]*(N//2)+ans_list[2])

Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u64>();
    let (mut a, mut b, k) = (line[0], line[1], line[2]);

    for _ in 0..k/2{
        a /= 2;
        b += a;

        b /= 2;
        a += b;
    }
    if k%2 == 1{
        a /= 2;
        b += a;
    }
    println!("{} {}", a, b);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	string n;
	cin >> n;
	for (char i=0; i<n.size(); i++) {
		if (n[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3128
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

tmp = a[0]
ans = []
cnt = 0
for i in range(1,len(a)):
    if tmp == a[i]:
        cnt += 1
        if cnt == 1 or cnt == 3:
            ans.append(tmp)
    else:
        tmp = a[i]
        cnt = 0


if len(ans) < 2:
    print(0)
else:
    print(ans[0]*ans[1])

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

class Program
{
    static void Main(string[] args)
    {
        //入力
        var n = crI();
        var arr = arrStr();
        var s = arr[0];
        var t = arr[1];
        var ans = "";
        for (int i = 0; i < n; i++) ans += s[i].ToString() + t[i].ToString();
        Console.WriteLine(ans);
    }

  
    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}

}

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

int main () {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	int x,y;	
	int keep=0;
	
	public void input() {
		x = sc.nextInt();
		y = sc.nextInt();
	}
	
	public void conpute() {
		if(x > y) {
			while(x%y != 0) {
				keep = x;
				x = y;
				y = keep % y;
			}
			System.out.println(y);
		}else {
			while(y%x != 0) {
				keep = y;
				y = x;
				x = keep % y;
			}
			System.out.println(x);
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.conpute();
	}
}




Measured memory_bytes: 26340
#include <stdio.h>

int main()
{
	int num, alp[26] = {};
	char ch;
	while(scanf("%c", &ch) != EOF){
		if(ch >= 'a') ch = ch - 32;
		if('A' <= ch && ch <= 'Z') {
			num = ch - 'A';
			alp[num]++;
		}
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a'+ i, alp[i]);
	}

	return 0;
}


Measured memory_bytes: 2036