akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);
bool isMultiOf(LL, LL);

int main() {
	int a, b, c; cin >> a >> b >> c;
	int ans = b * 10 + c;
	if (isMultiOf(ans, 4)) {
		cout << "YES";
	}
	else cout << "NO";
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}
bool isMultiOf(LL a, LL b) {
	return a % b == 0;
}

Measured memory_bytes: 256
/*input
500 500 57 458
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N

int n, m, h, w;
int a[505][505];


signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef UncleGrandpa
	freopen("1test.inp", "r", stdin);
#endif
	cin >> n >> m >> h >> w;
	int need = (n / h) * (m / w);
	int lim = 1000000000; int nlim = (lim * 1.0) / ((h * w - 1) * 1.0);
	if (nlim * 1LL * (h * w - 1) - lim == 0) nlim--;
	lim = nlim * 1LL * (h * w - 1) + 1;
	int sum = nlim * (n * m - need) - lim * need;
	if (sum < 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for (int i = h;; i += h) {
		for (int j = w;; j += w) {
			a[i][j] = -lim;
			need--;
			if (j + w > m) break;
		}
		if (i + h > n) break;
	}
	int x = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i][j] == 0) a[i][j] = nlim;
			cout << a[i][j] << sp;
			x += a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  ll n; cin >> n;
  ll ans = (n-1)*n/2LL;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

double r;
double pi = 3.14159265359;

void solve(){
	cin >> r;

   	cout << fixed << setprecision(9) << 2 * pi * r;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

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

using namespace std;
using ll = long long;

const vector<vector<int>> dir4 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
const vector<vector<int>> dir8 = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> hen(h + 2, vector<bool>(w + 2));
    for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++){
        char tmp; cin >> tmp; hen[i][j] = tmp == '.';
    }
    int res = 0;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(!hen[i][j])continue;
            vector<vector<int>> dist(h + 2, vector<int>(w + 2, -1));
            queue<pair<int,int>> que;
            dist[i][j] = 0;
            que.push({i,j});

            while(que.size()) {
                auto cur = que.front();
                que.pop();
                for(auto d : dir4){
                    int y = cur.first + d[0], x = cur.second + d[1];
                    if(!hen[y][x] || dist[y][x] != -1)continue;
                    dist[y][x] = dist[cur.first][cur.second] + 1;
                    que.push({y,x});
                }
            }
            for(int i = 1; i <= h; i++)res = max(res, *max_element(dist[i].begin(), dist[i].end()));
        }
    }


    cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i=a, _n=b; i<=_n; ++i)
#define REV(i, a, b) for(int i=a, _n=b; i>=_n; --i)
using namespace std;

const int N = 5e3+5, M = 205;
int n, m, a[N], b[N][M];
int64_t add[N], ans;
deque<int> de[M];

int main()
{
    ios::sync_with_stdio(); cin.tie(0);
    ///freopen("a.inp","r",stdin);

    cin >> n >> m;
    FOR(i, 1, n-1) cin >> a[i];
    FOR(i, 1, n) FOR(j, 1, m) cin >> b[i][j];

    FOR(i, 1, n) {
        int64_t tmp;
        FOR(j, 1, m) {
            while (!de[j].empty() && b[de[j].back()][j] <= b[i][j]) {
                tmp = b[de[j].back()][j]; de[j].pop_back();
                if (!de[j].empty())
                    add[de[j].back()] -= b[de[j].back()][j] - tmp;
            }
            if (!de[j].empty()) add[de[j].back()] += b[de[j].back()][j] - b[i][j];
            de[j].push_back(i);
        }

        tmp = 0;
        FOR(j, 1, m) tmp += b[i][j];
        REV(j, i, 1) {
            ///cout << i <<' '<< j << ' '<< tmp << endl;
            ans = max(ans, tmp);
            tmp += add[j-1] - a[j-1];
        }
    }

    cout << ans;
}


Measured memory_bytes: 4480
if __name__ == '__main__':
    a, b, c = tuple([int(n) for n in input().split()])
    if c - a - b < 0:
        print('No')
    elif (c - a - b) * (c - a - b) > 4 * a * b:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	string s; cin >> s;
	
	if(s.size() == 3 && s[0] == s[2]){
		printf("Second\n");
		return 0;
	}

	rep(i, s.size() - 2){
		if(s[i] != s[i + 2])break;
		if(i == s.size() - 3){
			printf("Second\n");
			return 0;
		}
	}

	bool flag = false;
	for (int i = 1; i < s.size() - 1; ++i){
		if(s[i] == s[0] && s[i] == s[s.size() - 1]) flag = true;
	}

	if(flag){
		if(s[0] != s[s.size() - 1]){
			if(s.size() % 2 == 0){
				printf("Second\n");
			}else{
				printf("First\n");
			}	
		}else{
			if(s.size() % 2 == 1){
				printf("Second\n");
			}else{
				printf("First\n");
			}
		}
		return 0;
	}else{
		if(s[0] == s[s.size() - 1]){
			printf("First\n");
			return 0;
		}else{
			if(s.size() % 2 == 0){
				printf("Second\n");
			}else{
				printf("First\n");
			}
		}
		return 0;
	}

	if(s.size() % 2 == 0){
		printf("Second\n");
	}else{
		printf("First\n");
	}
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Ferris Wheel
            var line = ReadLine();
            int age = line[0];
            int price = line[1];

            if (age > 12)
            {
                Console.WriteLine(price);
            }
            else if (age > 5)
            {
                Console.WriteLine(price / 2);
            }
            else
            {
                Console.WriteLine(0);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long H,N;
  cin>>H>>N;
  long long sum=0;
  vector<long long>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum=sum+A.at(i);
  }
  if(sum>=H){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

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

int main(){
  int n,m,tmp2,sum;
  string tmp,make,fa;
  while(cin >> n,n){
    sum = 0;
    map <string,int> item;
    while(n--){
      cin >> tmp >> tmp2;
      item.insert(map<string,int>::value_type(tmp,tmp2));
    }
    cin >> m;
    while(m--){
      cin >> tmp >> tmp2;
      sum = 0;
      while(tmp2--){
	cin >> fa;
	if(item.find(fa)!=item.end()) sum += item[fa];
      }
      if(sum < item[tmp]) item[tmp] = sum;
    }
    cin >> make;
    cout << item[make] << endl;
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mx=1e5+777;
vector<vector<int>> lst(mx);

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M;
	vector<int> A(N), B(N);
	for (int i=0; i<N; i++)
		cin>>A[i]>>B[i];
	for (int i=0; i<N; i++)
		lst[A[i]].push_back(B[i]);
	priority_queue<int> pq;
	int ret=0;
	for (int i=1; i<=M; i++) {
		for (int k:lst[i])
			pq.push(k);
		if (!pq.empty())
			ret+=pq.top(), pq.pop();
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 6528
def insertionsort(values, g):
  global exchange_count
  # for j in range(g, valuenum):
  #   i = j - g
  #   while i >= 0 and values[i] > values[j]:
  #     values[i], values[j] = values[j], values[i]
  #     exchange_count += 1
  #     i -= g
  #     j -= g
  for i in range(g, valuenum):
    v = values[i]
    j = i - g
    while j >= 0 and values[j] > v:
      values[j+g] = values[j]
      j = j - g
      exchange_count += 1
    values[j+g] = v

valuenum = int(input())
values = [int(input()) for _ in range(valuenum)]

# gs = [1]
# g = 4
# while g < valuenum:
#   gs.append(g)
#   g = 3 * g + 1
# gs.reverse()
gs = [int((2.25**i-1)/1.25)for i in range(17,0,-1)]
gs = [v for v in gs if v <= valuenum]

print(len(gs))
print(' '.join(map(lambda g:str(g), gs)).strip())

exchange_count = 0

for g in gs:
  insertionsort(values, g)

print(exchange_count)
for value in values:
  print(value)


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k;
  cin >> k;
  
  queue<ll> q;
  for (int i = 1; i <= 9; i++) q.push(i);
  
  for (int i = 0; i < k - 1; i++) {
    ll x = q.front();
    q.pop();
    if (x % 10 != 0) q.push(10 * x + (x % 10 - 1));
    q.push(10 * x + (x % 10));
    if (x % 10 != 9) q.push(10 * x + (x % 10 + 1));
  }
  
  cout << q.front() << '\n';
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main()
{
    char s1[10000],s2[10000],ch[10000];
    int f,i,j,l,k;
    scanf("%s",s1);
    scanf("%s",s2);
    l=strlen(s1);
    strcat(ch,s1);
    i=0;
    while(i<l)
    {
        if(strcmp(ch,s2)==0)
        {
            f=1;
            break;
        }
        else
        {
            f=0;
            ch[0]=s1[l-1];
            for(j=1,k=0;k<l-1;j++,k++)
            {
                ch[j]=s1[k];
            }
        }
        i++;
        for(j=0;j<l;j++)
        {
            s1[j]=ch[j];
        }
        s1[j]='\0';
    }
    if(f==1)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(N):
    if A[i]%2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            count = 1

if count == 0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#include<string>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
const ll mod=1e9+7;

bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}


void solve(){

    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
        return;
    }
    cout<<"No";
    return;
}

int main()
{
    IOS;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
 
    return 0;
}       

Measured memory_bytes: 256
#include<cstdio>
inline int in();
inline void wr(int);
const int N=(int)1e5+5;
int a[N];
inline int mx(int,int);
inline int mn(int,int);
int main(int argc,char**argv){
#ifndef ONLINE_JUDGE
//	freopen("2386.in","r",stdin);
//	freopen("2386.ans","w",stdout);
#endif
	register int n=in();
	for(register int i=1;i<=n;++i)
		a[i]=in();
	register int x=0,y=n;
	for(register int i=1;i<=n;++i)
		x=mx(x,a[i]),y=mn(y,a[i]);
	if(x-y>1){puts("No");return 0;}
	if(!(x-y)){puts((x==n-1||(x<<1)<=n)?"Yes":"No");return 0;}
	register int m=0;
	for(register int i=1;i<=n;++i)
		m+=(a[i]==y);
	if(1+m<=x&&x<=m+((n-m)>>1))puts("Yes");
	else puts("No");
}
inline int mx(int x,int y){
	return x>y?x:y;
}
inline int mn(int x,int y){
	return x<y?x:y;
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ( abs(a-c) <= d || (abs(b-c) <= d && abs(a-b) <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  long long sum=1;
  long long oba=1;
  int P=0;
  bool huro=false;bool mu=false;
  for(int X=0;X<N;X++){
    long long I;cin>>I;string size=to_string(I);P+=size.size()-1;
    if(I==0){
      mu=true;
      break;
    }
    sum*=I;oba*=I;
    if(sum/1000000000000000001!=0){
      huro=true;
    }
    sum%=1000000000000000001;
  }
  if(mu==true)cout<<0<<endl;
  else if(sum==1000000000000000000)cout<<1000000000000000000<<endl;
  else if(huro==true||P>=18)cout<<-1<<endl;
  else cout<<sum<<endl;
}

Measured memory_bytes: 3772
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


int check(vi&v, int x, int y, int nx, int ny)
{
	int z=3-x-y;

	if(v[x]==1 && v[y]==1 && v[z]==0 && nx>=0)
	{
		vi t=v;
		t[x]++;
		t[y]--;
		if(check(t, nx, ny, -1, -1)<0) swap(x, y);

		v[x]++;
		v[y]--;
	}
	else
	{
		if(v[x]>v[y]) swap(x, y);

		v[x]++;
		v[y]--;
		if(v[y]<0) return -1;
	}
	return x;
}


int main(void)
{
	int n, a, b, c;
	while(scanf("%d%d%d%d\n", &n, &a, &b, &c)==4)
	{
		vi v={a, b, c};
		vi ans;
		vi x, y;
		for(int i=0;i<n;i++)
		{
			char s[2+2];
			scanf("%2[ABC]\n", s);

			x.push_back(s[0]-'A');
			y.push_back(s[1]-'A');
		}
		x.push_back(-1);
		y.push_back(-1);

		bool is_yes=true;
		for(int i=0;i<n;i++)
		{
			ans.push_back(check(v, x[i], y[i], x[i+1], y[i+1]));
//			printf("v = %d %d %d\n", v[0], v[1], v[2]);
			if(ans.back()<0) is_yes=false;
		}
		printf("%s\n", is_yes?"Yes":"No");
		if(is_yes)
		{
			for(int i=0;i<n;i++) printf("%c\n", ans[i]+'A');
		}
	}
	return 0;
}


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

int main(){
    long long N,D,A; cin >> N >> D >> A;
    pair<long long,long long> mon[N];
    vector<long long> X(N);
    for(int i=0;i<N;i++){
        long long x,h; cin >> x >> h;
        mon[i]={x,h};
        X[i]=x;
    }
    sort(mon,mon+N);
    sort(X.begin(),X.end());
    long long imos[N+1]={};
    long long ans=0;
    for(int i=0;i<N;i++){
        if(i>0) imos[i]+=imos[i-1];
        int ind=upper_bound(X.begin(),X.end(),X[i]+2*D)-X.begin();
        long long tmp=(mon[i].second-imos[i]+A-1)/A;
        ans+=max(0LL,tmp);
        if(tmp>0){
            imos[i]+=tmp*A;
            imos[ind]-=tmp*A;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    int a[200000];
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    
    sort(a, a+(n));
    
    int i;
    for(i = 1; i < n; i++){
        if(a[i-1] == a[i]) break;
    }
    
    if(i == n){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
H, W = map( int, input().split())
A = [ input() for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1
Q = 10**9+7
for i in range(H):
    for j in range(W):
        if not i == H-1:
            if A[i+1][j] == ".":
                dp[i+1][j] = (dp[i+1][j] + dp[i][j])%Q
        if not j == W-1:
            if A[i][j+1] == ".":
                dp[i][j+1] = (dp[i][j+1] + dp[i][j])%Q
print(dp[H-1][W-1])


Measured memory_bytes: 53488
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;
	cin >> N >> M;
	vector<vector<int>> routes(N);
	int a,b,loop;
	for(loop=0;loop<M;loop++){
		cin >> a >> b;
		a--;
		b--;
		routes[a].push_back(b);
		routes[b].push_back(a);
	}
	vector<int> vst(N,-1);
	vector<int> ans(N,-1);
	vector<int> isNot(N,0);
	queue<int> Q;
	ans[0]=0;
	vst[0]=0;
	Q.push(0);
	int frt;
	while(!Q.empty()){
		frt=Q.front();
		Q.pop();
		for(int nv:routes[frt]){
			if(vst[nv]!=-1) continue;
			vst[nv]=0;
			ans[nv]=frt+1;
			Q.push(nv);
		}
	}
	if(vst!=isNot){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
		for(loop=1;loop<N;loop++){
			cout << ans[loop] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 10992
import sys
from collections import defaultdict


def main():
    N, A, *xlst = map(int, sys.stdin.read().split())
    x_p = []
    x_n = []
    x_z = 0
    for i in xlst:
        i = int(i)
        if A < i:
            x_p.append(i - A)
        elif i < A:
            x_n.append(A - i)
        else:
            x_z += 1
    x_p.sort()
    x_n.sort()
    x_p_sum = [defaultdict(int, {0: 1})]
    x_n_sum = [{0: 1}]
    for i in range(len(x_p)):
        x_p_sum.append(defaultdict(int, x_p_sum[-1]))
        for j in sorted(x_p_sum[-2]):
            x_p_sum[-1][j + x_p[i]] += x_p_sum[-2][j]

    for i in range(len(x_n)):
        x_n_sum.append(defaultdict(int, x_n_sum[-1]))
        for j in sorted(x_n_sum[-2]):
            x_n_sum[-1][j + x_n[i]] += x_n_sum[-2][j]

    res = 0
    for i in x_n_sum[-1]:
        if i in x_p_sum[-1]:
            res += (x_n_sum[-1][i] * x_p_sum[-1][i])
    res *= 1 << x_z
    res -= 1
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) { 
		sum += n % 10; n /= 10; }
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	llint min, max;
	cin >> min >> max;

	if (min > max)swap(min, max);

	if (min == 1)cout << 1 << rt;

	else cout << (min * max + 1) / 2 << rt;

	please AC;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        long n = in.nextLong();

        if (n % 2 == 1) {
            out.println(0);
            return;
        }

        long next = 5;
        long ans = 0;
        while (true) {
            long toAdd = n / (next * 2);
            if (toAdd == 0) {
                break;
            }
            ans += toAdd;
            next *= 5;
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21332
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(num):
    global N, ans, M
    n = len(num)
    if n == N:
        cnt = 0
        for a, b, c, d in con:
            a -= 1; b -= 1
            if num[b] - num[a] == c:
                cnt += d
        ans = max(ans, cnt)
    else:
        e = 1 if n == 0 else num[-1]
        for i in range(e, M + 1):
            dfs((*num, i))


N, M, Q = map(int, input().split())
con = [tuple(map(int, input().split())) for _ in range(Q)]

ans = 0
dfs(tuple())

print(ans)


Measured memory_bytes: 9092
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	double v;
	while(cin >> v) {
		double t = v / 9.8;
		double y = 4.9 * t * t;
		cout << ((int)ceil(y)+9) / 5 << endl;
	}
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

void solve(){
	int num[10];
	REP(i,10)num[i]=1;
}

int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>> path = vector< vector<int> >(n);
	int h[n];
	int a[m];
	int b[m];
	REP(i,n)cin>>h[i];
	REP(i,m){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		path[a[i]].push_back(b[i]);
		path[b[i]].push_back(a[i]);
	}
	int cnt=0;
	REP(i,n){
		if(path[i].size()==0)cnt++;
		else{
			bool high=true;
			REP(j,path[i].size()){
				if(h[i]<=h[path[i][j]]){
					high=false;
					break;
				}
			}
			if(high)cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 9512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] fd = new int[6];
    for (int i = 0; i < n; i++) {
      double d = sc.nextDouble();
      int l;
      if (d < 165) {
        l = 0;
      } else if (d < 170) {
        l = 1;
      } else if (d < 175) {
        l = 2;
      } else if (d < 180) {
        l = 3;
      } else if (d < 185) {
        l = 4;
      } else {
        l = 5;
      }
      fd[l]++;
    }
    for (int z = 0; z < 6; z++) {
      System.out.print(z+1+":");
      for (int i = 0; i < fd[z]; i++) {
        System.out.print("*");
      }
      System.out.println();
    }
  }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s,t;
    cin>>s;
    char c='a';
    int ans=1000,d=0;
    uset<char> kind;
    rep(i,s.length())kind.insert(s[i]);
    for(auto key:kind){
        t=s;
        d=0;
        while(count(all(t),key)!=t.length()){
            d++;
            for(int i=t.length()-1;i>=0;i--){
                if(t[i]!=key){
                    t.erase(t.begin()+i);
                    for(int j=0;j<i;j++){
                        if(j+1<i&&t[j+1]==key){
                            t[j]=key;
                        }
                    }
                    goto skip;
                }
            }
            skip: ;
        }
        ans=min(ans,d);
    }
    out(ans);
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int con=b+c;
    if(con<a)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<con-a<<endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if((A+B)%2==0){
      System.out.println((A+B)/2);
    }else{
      System.out.println("IMPOSSIBLE");
    }
  }
}

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

const int N = 2e6;

main() {
	clog << "Ready\n";
	
	string s;
	cin >> s;
	int ans = 0;
	#define sz(s) (int)(s.size())
	for (int i = 0; i < sz(s); ++ i) {
		int c = 0, j = i;
		while(s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T') {
			++j;
			++c;
		}
		ans = max(ans, c);
	}
	cout << ans;
	
	cerr << '\n';

	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c] <- readIntegerList
  let s = a + b
      m = a * b
  putStrLn $ if s < c && 4 * m < (c - s) ^ 2 then "Yes" else "No"



Measured memory_bytes: 380
import java.io.*;

public class Main{
    public static void main(String []args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            int [] number;
            number = new int[10000];
            for(int i=0;i<10000;i++){
            String line = reader.readLine();
            number[i] =Integer.parseInt(line);
            if(number[i] == 0){
                break;
            } 
            }
            for(int j=1;j<=10000;j++){
                if(number[j-1]==0){
                    break;
                }
                System.out.println("Case "+j+": "+number[j-1]);
                }
            }
        catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 32168
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int a[33]={0, 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};
signed main(){
	int k=read();cout<<a[k]<<endl;
	return 0;
}

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

int main() {
vector<int> S(3);
  for(int i=0; i<3; i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  int X=S.at(2);
  int Y=S.at(1);
  int Z=S.at(0);
  cout<<X*10+Y+Z<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int R = sc.nextInt();
      int G = sc.nextInt();
      int B = sc.nextInt();
      int N = sc.nextInt();
      
      int k = 0;
      int s = 0;
      for (int i = 0; i <= N / R; i++){
      	for (int j = 0; j <= N / G; j++){
          k = ( N - i*R - j*G ) / B;
          if (k >= 0 && i*R + j*G + k*B == N){
          	s += 1;
          }
        }
      }
      System.out.println(s);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
int main(void) {
	int a[9999], i;
	i = 0;
	while (1) {
		i = i + 1;
		scanf("%d", &a[i]);
		if (a[i] == 0) {
			break;
		}
	}
	i = 0;
	while (1) {
		i=i +1;
		if (a[i] == 0) {
			break;
		}
		printf("Case %d: %d\n", i, a[i]);
	}
	return 0;
}

Measured memory_bytes: 636
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = list(map(int, sys.stdin.readline().split()))
S = [list(sys.stdin.readline().rstrip()) for _ in range(H)]


def ok(h, w):
    return 0 <= h < H and 0 <= w < W and S[h][w] == '.'


dot_count = 0
for r in S:
    dot_count += r.count('.')

# 道の数 - 最短路
sh = sw = 0
que = deque()
que.append((sh, sw, 0))
delta = list(zip(*[[0, 0, 1, -1], [1, -1, 0, 0]]))
distance = -1
while que:
    h, w, d = que.popleft()
    if h == H - 1 and w == W - 1:
        distance = d
        break
    for dh, dw in delta:
        if ok(h + dh, w + dw):
            S[h + dh][w + dw] = '#'
            que.append((h + dh, w + dw, d + 1))

if distance > 0:
    print(dot_count - distance - 1)
else:
    print(-1)


Measured memory_bytes: 13656
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

x=gets.to_i
ans=100
cnt=0
while ans<x
    ans+=(ans*0.01).floor
    cnt+=1
end
puts cnt

Measured memory_bytes: 14388
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def getNodeToInsert(node:Node,keyNode:Node):Node =
    if(node.key > keyNode.key) {
      if(node.left == null) node
      else getNodeToInsert(node.left,keyNode)
    } else {
      if(node.right == null) node
      else getNodeToInsert(node.right,keyNode)
    }

  def insert(tree:Node, keyNode:Node) = {
    val target = getNodeToInsert(tree,keyNode)
    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<100) count += 1
      else { out.flush; count = 0 }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<5) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 310736
import java.util.*;

public class Main {
  public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
        for(;n>0;n--){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int b = sc.nextInt();
            int p = sc.nextInt();
            int s = x*b + y*p;
            b = Math.max(b, 5);
            p = Math.max(p, 2);
            int t = x*b + y*p;
            System.out.println((int)Math.min(s, t*0.8));
        }
    }
}

Measured memory_bytes: 23312
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int main() {
	string s;
	int n;
	cin >> n;
	cin >> s;
	int r = 0, w = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'W')w++;
	
	}
	r = s.length() - w;
	int ans = 0;
	for (int i = r ; i < r + w; i++) {
		if (s[i] == 'W')ans++;
	}
	ans = w - ans;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3744
def input_int():
    return map(int, input().split())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A,B,K=input_int()

ans = list(set(make_divisors(A) ) & set(make_divisors(B)))

ans = sorted(ans, reverse=True)

print(ans[K-1])

Measured memory_bytes: 38384
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <iostream>

using namespace std;

int main() {
	vector<int> n(3);
	cin >> n[0] >> n[1] >> n[2];
	sort(n.begin(), n.end());
	cout << n[0] + n[1] << endl;
}

Measured memory_bytes: 256
#!/usr/local/gnu/bin/bash
read w h n
x0=0
x1=$w
y0=0
y1=$h
for i in `seq $n`
do
    read x y a
    case $a in
        1 ) ((x0<x)) && x0=$x;;
        2 ) ((x1>x)) && x1=$x;;
        3 ) ((y0<y)) && y0=$y;;
        4 ) ((y1>y)) && y1=$y;;
    esac
done
((x0<x1&&y0<y1)) && echo $(((x1-x0)*(y1-y0))) || echo 0


Measured memory_bytes: 660
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}




    vector<pair<ll,ll>>p;

ll n,m,q;
vector<ll>a,b,c,d;
ll ans=0;
void dfs(vector<ll> v){
    if(v.size()==n){
      ll sum=0;
      rep(i,q)if(v[b[i]]-v[a[i]]==c[i])sum+=d[i];
      ans=max(ans,sum);
      return;
    }
    if(v.size()==0)v.push_back(1);
    v.push_back(v.back());
    dfs(v);
    while(v.back()<m){
        v.back()++;
        dfs(v);
    }
    return;
}


int main()
{
 string s;
 cin>>s;
 if(s[s.size()-1]=='s'){
     s+="es";
 }else{
     s+='s';
 }
 cout<<s<<endl;
}



Measured memory_bytes: 3624
import java.util.*;
 
public class Main { 
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		int[] to = new int[n+1];
		int[] moved = new int[n+1];
		for(int i=1; i<=n; i++){
			to[i] = sc.nextInt();
		}
		int now = 1;
		moved[now]++;
		int end = 0;
		int roopCount = 0;
		for(int i=0; i<=to.length; i++){
			if(moved[to[now]] > 0){
				end = to[now];
				roopCount++;
				break;
			}
			now = to[now];
			moved[now]++;
			roopCount++;
			if(k == roopCount){
				System.out.println(now);
				return;
			}
		}
		int roopStartCount = 0;
		if(end != 1){
			now = 1;
			for(int i=0; i<=to.length; i++){
				if(to[now] == end){
					roopStartCount++;
					break;
				} 
				now = to[now];
				roopStartCount++;
			}
		}
		roopCount -= roopStartCount;
		long mod = (k-roopStartCount)%roopCount;
		for(long i=mod; i>0; i--){
			end = to[end];
		}
		System.out.println(end);

	}
}


Measured memory_bytes: 51500
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inputText = sc.nextLine();
		HashSet<String> set = new HashSet<>();
		for(int i = 0; i < inputText.length(); i++) {
			set.add(String.valueOf(inputText.charAt(i)));
		}
		if(set.size() == 26) {
			System.out.println("None");
			return;
		}
		char c = 'a';
		for(int i = 0; i < 26; i++) {
			if(set.contains(String.valueOf(c))) {
				c++;
				continue;
			}
			System.out.println(c);
			break;
		}
		
		
		
		
		
	}	

}



Measured memory_bytes: 31428
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define add(a,b) (a+=b)%=998244353

int main() {
    ll N, S, ans = 0; cin >> N >> S;
    vl dp(6001, 0);
    rep(i,N) {
        ll a; scanf("%ld",&a);
        vl ndp(6001, 0);
        ndp[0] = ndp[a] = 1;
        rep(j,3001) {
            add(ndp[j], dp[j]);
            add(ndp[j+a], dp[j]);
        }
        add(ans, ndp[S]);
        dp = ndp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384