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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(){
    int x;
    cin >> x;

    int y = lcm(360,x);
    int ans = y/x;

    

    cout << ans << endl;
}


Measured memory_bytes: 3624
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a*b%2;
        if(c > 0) {
            System.out.print("Odd");  
        } else {
            System.out.print("Even");  
        }
    }
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll s;
	scanf("%lld", &s);
	ll t = 1000000000;
	printf("0 0 %lld 1 %lld %lld\n", t, (t - s%t) % t, (s + t - 1) / t);
}

Measured memory_bytes: 128
# include <cstdio>
int C[100000+10];
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        for(int i = 1;i <= n;++i){
            scanf("%d",&C[i]);
        }
        long long ans4 = 0;
        for(int i = 1;i <= n;++i){
            ans4 += C[i]/2;
            C[i] = C[i]%2;
            if(C[i]&&C[i+1]){
                ans4 ++;
                C[i] = 0;
                C[i+1] --;
            }

        }
        printf("%lld\n",ans4);
    }
    return 0;
}

/*
    #include<bits/stdc++.h>
    //#pragma comment(linker, "/STACK:102400000,102400000")
    using namespace std;
    typedef long long LL;
    typedef unsigned long long ULL;
    typedef double db;
    typedef long double ldb;
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define repu(i,a,b) for(i=a;i<=b;i++)
    #define repd(i,a,b) for(i=a;i>=b;i--)
    #define repc(i,a,b,c) for(i=a;i<b;i+=c)
    #define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
    #define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
    #define FIN freopen("input.in","r",stdin)
    #define FOUT freopen("output.out","w",stdout)
    #define CC(a) memset(a,0,sizeof(a))
    #define MST(a,b) memset(a,b,sizeof(a))
    #define PII pair<int,int>
    #define PLL pair<long long,long long>
    #define VI vector<int>
    #define VL vector<long long>
    #define VII vector<PII>
    #define VLL vector<PLL>
    #define all(x) x.begin(),x.end()
    #define mp make_pair
    #define pb push_back
    #define pf push_front
    #define fi first
    #define se second

    template<typename T>inline void gn(T &x){
    	x=0;T f=1;char ch=getchar();
    	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    	x*=f;
    }
    template<typename T>inline void gt(T x){
    	if(!x)return;
    	gt(x/10);putchar(x%10+'0');
    }

    const LL N=100003;
    struct NODE{
    	db o,r,d;
    };
    LL t,n,m,ans;
    LL MOD=1e9+7,inf=0x1f1f1f1f;
    db eps=1e-5;
    LL a[N];

    int main()
    {
    	ios_base::sync_with_stdio(false);cin.tie(0);
    	LL i,j,k,l,ca=0,u,v,d;
    	cin>>n;
    	repu(i,1,n)cin>>a[i];

    	repu(i,1,n){
    		ans+=a[i]/2,a[i]%=2;
    		if(a[i]&&a[i+1]){
    			ans++;
    			a[i]=0;
    			a[i+1]-=1;
    		}
    	}
    	cout<<ans<<endl;
    	return 0;
    }


*/


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

int main()
{
    ios::sync_with_stdio(false);
    int n = 0;
    while (cin >> n && n) {
        long long x = 0;
        map<long long, int > m;
        for (int i = 0; i < n; i++) {
            cin >> x;
            m[x]++;
        }
        long long Max4 = 0, Max21 = 0, Max22 = 0;
        map<long long, int >::iterator it;
        for (it = m.begin(); it != m.end(); it++) {
            if (it->second > 3 && it->first > Max4) Max4 = it->first;
            if (it->second > 1 && it->first > Max21 &&it->second < 4) Max21 = it->first;
        }
        if (Max4 > Max21) cout << Max4*Max4 << endl;
        else {
            for (it = m.begin(); it != m.end(); it++)
                if (it->second > 1 && it->first > Max22  && it->first != Max21) Max22 = it->first;
            cout << Max21 * Max22 << endl;
        }      
    }
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main()
{
    int k=500,x,sum=0,n,i;
    cin>>n>>x;
    for(i=0;i<n;i++)
    {
        sum=sum+k;
    }

    if(sum>=x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
 return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

ll a, b, n, ans;

int main() {
   cin>>a>>b>>n;
   ans = b-1;
   if(n<ans) ans=n;
   ans = a*ans/b;
   cout<<ans;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<vector<int>> E;
vector<int> D;
ll dp[1020][1020];
ll mo=1000000007;

pair<int,int> farthest(vector<vector<int>>& E, int cur,int pre,int d,vector<int>& D) {
	D[cur]=d;
	pair<int,int> r={d,cur};
	FORR(e,E[cur]) if(e!=pre) r=max(r, farthest(E,e,cur,d+1,D));
	return r;
}

pair<int,vector<int>> diameter(vector<vector<int>>& E) { // diameter,center
	vector<int> D[2];
	D[0].resize(E.size());
	D[1].resize(E.size());
	auto v1=farthest(E,0,0,0,D[0]);
	auto v2=farthest(E,v1.second,v1.second,0,D[0]);
	farthest(E,v2.second,v2.second,0,D[1]);
	pair<int,vector<int>> R;
	R.first = v2.first;
	for(int i=E.size()-1;i>=0;i--) if(D[0][i]+D[1][i]==R.first && abs(D[0][i]-D[1][i])<=1) R.second.push_back(i);
	return R;
}

void dfs(int cur,int pre,int d,int md,int p) {
	FORR(e,E[cur]) if(e!=pre) dfs(e,cur,d+1,md,p);
	for(int x=-503;x<=503;x++) if((abs(x+p) <= md-d)&&(abs(x-p) <= md-d)){
		dp[cur][505+x]=1;
		FORR(e,E[cur]) if(e!=pre) (dp[cur][505+x] *= (dp[e][505+x+1]+dp[e][505+x-1]))%=mo;
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	E.resize(N);
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	auto dia = diameter(E);
	if(dia.first%2==0) {
		dfs(dia.second[0],-1,0,dia.first/2,0);
		cout<< accumulate(dp[dia.second[0]],dp[dia.second[0]]+1010,0LL)%mo<<endl;
	}
	else {
		ll ret=0;
		dfs(dia.second[0],dia.second[1],0,dia.first/2,0);
		dfs(dia.second[1],dia.second[0],0,dia.first/2+1,0);
		for(x=3;x<=1008;x++) (ret += dp[dia.second[0]][x]*(dp[dia.second[1]][x+1]+dp[dia.second[1]][x-1]))%=mo;
		
		ZERO(dp);
		dfs(dia.second[0],dia.second[1],0,dia.first/2+1,0);
		dfs(dia.second[1],dia.second[0],0,dia.first/2,0);
		for(x=3;x<=1008;x++) (ret += dp[dia.second[0]][x]*(dp[dia.second[1]][x+1]+dp[dia.second[1]][x-1]))%=mo;
		
		ZERO(dp);
		dfs(dia.second[0],dia.second[1],0,dia.first/2,0);
		dfs(dia.second[1],dia.second[0],0,dia.first/2,0);
		for(i=3;i<=1008;i++) ret -= 2*dp[dia.second[0]][i]*dp[dia.second[1]][i]%mo;
		for(i=3;i<=1008;i++) ret -= dp[dia.second[0]][i]*dp[dia.second[1]][i+2]%mo;
		for(i=3;i<=1008;i++) ret -= dp[dia.second[0]][i]*dp[dia.second[1]][i-2]%mo;
		cout<<(ret%mo+mo)%mo<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 8576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    string s; cin >> s;
    int tot = 0;
    for(char i : s) tot += i-'0';
    tot = max(tot, (int)(s.size()-1)*9+s[0]-'1');
    cout << tot;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{

  int a,b;
  cin>>a>>b;
  cout<<std::defaultfloat<<std::setprecision(6);
  cout<<a/b<<" "<<a%b<<" " <<std::fixed<<double(double(a)/double(b))<<endl;
  
  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3268
IDENTIFICATION DIVISION.
      PROGRAM-ID. 055A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 N PIC 9(3).
      01 X PIC 9(5).
      01 Y PIC 9(5).
      01 SHO PIC 9(2).
      01 AMA PIC 9(2).
      01 ANS PIC 9(5).
      01 ANSS PIC Z(5).
      
      PROCEDURE DIVISION.
      ACCEPT N.
      COMPUTE X = 800 * N.
      DIVIDE N BY 15 GIVING SHO REMAINDER AMA.
      COMPUTE Y = 200 * SHO.
      COMPUTE ANS = X - Y.
      MOVE ANS TO ANSS.
      DISPLAY ANSS.
      STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
ll t[1000];
int main(){
	cin>>n;
	ll ans=1;
	for(int i=2;i<=n;i++){
		int anst=0;
		int s=i;
		for(int j=2;j<=i;j++){
			while(s%j==0){
				s/=j;
				anst++;
			}
			if(anst)
				t[j]+=anst;
			anst=0;
		}
	}

	
	for(int i=1;i<1000;i++){
		ans*=(t[i]+1);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
min, max, sum = 1000000, -1000000, 0
for i in range(n):
    if a[i]< min:
        min = a[i];
    if a[i] > max:
        max = a[i];
    sum += a[i];
print(min, max, sum)

Measured memory_bytes: 8636
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int N, K, X, Y;

int main()
{
	in >> N >> K >> X >> Y;

	if (N > K)
	{
		out << K*X + (N - K)*Y << std::endl;
	}
	else
	{
		out << N*X << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import random
num = int(input()) - 1

def is_prime(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if(q == 2):
        return(True)
    if(q < 2 or q&1 == 0):
        return(False)

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while(d&1 == 0):
        d >>= 1

    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while(t != q-1 and y != 1 and y != q-1):
            y = pow(y,2,q)
            t <<= 1
        if(y != q-1 and t&1 == 0):
            return(False)
    return(True)

result = False
while(result == False):
    num += 1
    result = is_prime(num)

print(num)


Measured memory_bytes: 4208
#include <stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0 || x+r>W || y-r<0 || y+r>H){
        printf("No\n");
    } 
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }    
    return 0;
}



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

int main(int argc, char *argv[])
{
    long long n, d;

    std::cin >> n >> d;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        long long x, y;
        std::cin >> x >> y;
        if (x * x + y * y <= d * d) {ans++;}
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
/* 
const double PI = 3.1415926535897
const double EPS = le-12;
const ll INF = lLL<<29;
const ll mod = le9+7;
*/
#define rep(i,a,b) for(ll (i) = (a); (i)<(b) ; ++i)

int main(){
    ll ans=0;
    ll N,M;
    ll a,b;
    cin>>N>>M;
    priority_queue<ll>que; 
    vector<ll>data[101010];
    rep(i,0,N){
        int a,b;
        cin >> a >> b;
        if(M-a >=0) data[M-a].push_back(b);
    }
    for(int i=M; i>=0 ; i--){
        for(auto x:data[i]){
            que.push(x);
        }
        if(que.size()>=1){
            ans+=que.top();
            que.pop();
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		rep(i, n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;

			int ave = (pm + pe + pj) / 3;
			int me_ave = (pm + pe) / 2;
			if (pm == 100 || pe == 100 || pj == 100 || ave >= 80 || me_ave >= 90)
				cout << 'A' << endl;
			else if (ave >= 70 || (ave >= 50 && (pm >= 80 || pe >= 80)))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return	0;
}

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

int main(){
	string s;
	while(cin>>s){
		int joi=0,ioi=0;
		for(int i=0;i<s.size();i++){
			string t=s.substr(i,3);
			if(t=="JOI")joi++;
			else if(t=="IOI")ioi++;
		}
		cout<<joi<<endl;
		cout<<ioi<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
from collections import Counter
S = input()[::-1]
MOD = 2019

X = [0]
for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)

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

int a[8],u[8];
bool pp(){
    for(int i=0;i<7;i++){
        for(int j=i+1;j<8;j++){
            if(a[i]==a[j]||abs(a[i]-a[j])==j-i){
                return false;
            }
        }
    }
    return true;
}
void qq(int f){
    if(f==8){
        if(pp()){
            for(int i=0;i<8;i++){
                for(int j=0;j<8;j++){
                    if(a[i]==j){
                        cout<<"Q";
                    }
                    else{
                        cout<<".";
                    }
                }
                cout<<endl;
            }
        }
        return;
    }
    if(u[f]==1){
        qq(f+1);
    }
    else{
        for(int i=0;i<8;i++){
            a[f]=i;
            qq(f+1);
        }
    }
}
int main(){
    for(int i=0;i<8;i++){
        a[i]=-1;
        u[i]=0;
    }
    int k,r,c;
    cin>>k;
    for(int i=0;i<k;i++){
        cin>>r>>c;
        a[r]=c;
        u[r]=1;
    }
    qq(0);
    return 0;
}


Measured memory_bytes: 3092
n = int(input())
for _ in range(n):
    xa,ya,ra,xb,yb,rb = map(float, input().split())
    dr = ((xa-xb)**2+(ya-yb)**2)**0.5
    if rb > (ra+dr):
        print(-2)
        continue
    elif ra > (rb+dr):
        print(2)
        continue
    elif dr > (ra+rb):
        print(0)
        continue
    else:
        print(1)



Measured memory_bytes: 5644
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/lcm(c,d)-(a-1)/lcm(c,d))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll x;
  cin>>x;
  ll a = x/11;
  ll b = x%11;
  if(b==0){
    printf("%lld\n",a*2LL);
  }
  else if(b<=6){
    printf("%lld\n",a*2LL+1);
  }
  else{
    printf("%lld\n",a*2LL+2);
  }
  return 0;
}





Measured memory_bytes: 256
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_M(n):
	return [INSTR() for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

import math
N = INNUM()
print(math.factorial(N) % (10**9 + 7))


Measured memory_bytes: 4080
a=int(input())
b=list(map(int, input().split()))
dic = {}
for i in range(len(b)):
    c = b[i] 
    if not c in dic.keys():
        dic[c] = 0
    dic[c] += 1

for j in range(1, a + 1):
    if j in dic.keys():
        print(dic[j])
    else:
        print(0)


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

int main(){
	int a, b;
  cin >> a >> b;
  if (a >=1 && a<=9 && b>=1 && b<=9){
    cout << a*b << endl;
    return 0;
  }else{
    cout << -1 << endl;
	return 0;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();

		double hDegree = 360.0 * (h + m / 60.0) / 12;
		double mDegree = 360.0 * m / 60;
		double theta = Math.toRadians(Math.max(hDegree, mDegree) - Math.min(hDegree, mDegree));
		double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(theta));
		System.out.printf("%.12f", ans);
	}

}


Measured memory_bytes: 36092
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  ll N = 205;
  ll x, y;
  std::cin >> x >> y;

  std::vector<ll> va(N+1, 0LL);
  va[1] = 300000;
  va[2] = 200000;
  va[3] = 100000;

  ll ans = 0LL;
  if (x == 1 && y == 1) ans = 400000;
  ans += va[x] + va[y];

  print(ans);
  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 256
from fractions import*
n,*a=map(int,open(0).read().split())
p=gcd(a[0],a[1])
l=[a[0],p]
c=list(reversed(a))
q=gcd(c[0],c[1])
r=[q]
for i in range(1,n-1):
    p=gcd(p,a[i+1])
    l.append(p)
    q=gcd(q,c[i+1])
    r.append(q)

r=r[::-1]+[a[-1]]
r=r[1:]+[0]
l=[0]+l

print(max(gcd(s,t)for s,t in zip(r,l)))

Measured memory_bytes: 16120
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template <typename A, typename B>
using unordered_map2 = __gnu_pbds::gp_hash_table<A, B>;
using namespace __gnu_pbds;
template <typename T> using ordered_set =
  __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag,
                   __gnu_pbds::tree_order_statistics_node_update>;
// ordered_set<int> s; s.insert(1); s.insert(2);
// s.order_of_key(1);    // Out: 0.
// *s.find_by_order(1);  // Out: 2.

using ld = long double;
using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, ll b) { int res = 1; while (b) { if (b % 2 == 1) MnozDo(res, a); a = Mnoz(a, a); b /= 2; } return res; }
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) { x %= mod; if (x < 0) x += mod; return x; }

template <typename T> T Maxi(T& a, T b) { return a = max(a, b); }
template <typename T> T Mini(T& a, T b) { return a = min(a, b); }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> s(n);
  vector<int> odw(n + 1);
  for (int i = 1; i <= n; i++) {
    odw[i] = Odw(i);
  }
  for (int& x : s) {
    cin >> x;
  }
  int tmp = 0;
  for (int i = 1; i <= n; i++) {
    DodajDo(tmp, odw[i]);
  }
  int suma = 0;
//  for (int i = 0; i < n; i++) {
//    for (int j = 0; j < n; j++) {
//      const int d = abs(i - j) + 1;
//      DodajDo(suma, Podziel(Moduluj(s[j]), d));
//    }
//  }
  for (int i = 0; i < n; i++) {
    DodajDo(suma, Mnoz(tmp, Moduluj(s[i])));
    OdejmijOd(tmp, odw[n - i]);
    if (i + 1 < n) {
      DodajDo(tmp, odw[i + 2]);
    }
  }
  for (int i = 0; i < n; i++) {
    MnozDo(suma, i + 1);
  }
  cout << suma << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int H,W,h,w;
int board[105][105];
int mxindex,mxchain=0;
int main(void)
{
  int A,B,T;
  cin >> A >> B >> T;
  cout << T/A*B << endl;
  return 0;
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

type ModInt(x: int64) =
    static let modulo = (int64 1e9) + 7L

    member __.Value: int64 =
        let y = x % modulo
        match y with
        | _ when y < 0L -> y + modulo
        | _ when y >= modulo -> y - modulo
        | _ -> y

    override __.ToString() = __.Value.ToString()

    static member (+) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value + rhs.Value)

    static member (-) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value - rhs.Value)

    static member (*) (lhs: ModInt, rhs: ModInt) = ModInt(lhs.Value * rhs.Value)

    static member (*) (lhs: ModInt, rhs: int64) = ModInt(lhs.Value * rhs)

    /// フェルマーの小定理
    /// a / b = a * b^-1 (mod p)
    /// b * b^p-2 = 1 (mod p) -> 両辺を b^-1 倍して、b^p-2 = b^-1 (mod p)
    static member (/) (lhs: ModInt, rhs: ModInt) = lhs * (rhs ** (modulo - 2L))

    /// **
    /// 繰り返し二乗法
    static member Pow(n: ModInt, m: int64) =
        let mutable res = ModInt(1L)
        let mutable n = n
        let mutable m = m
        while m > 0L do
            if (m &&& 1L) = 1L then res <- res * n
            n <- n * n
            m <- m >>> 1
        res

[<EntryPoint>]
let main _ =
    let n = read int64
    let mutable ans = ModInt(1L)
    for i in 1L..n do
        ans <- ans * i
    printfn "%A" ans
    0 // return an integer exit code


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

int main() {
	int A;
	cin>>A;
	int B=A/100;
	int C=A%100;
	bool b=(1<=B&&B<=12);
	bool c=(1<=C&&C<=12);
	if(!b&&!c){
		cout<<"NA"<<endl;
	}else if(!b){
		cout<<"YYMM"<<endl;
	}else if(!c){
		cout<<"MMYY"<<endl;
	}else{
		cout<<"AMBIGUOUS"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
using namespace std;

const int lastMonth = 4280;

int main(void){
  int w, ans;
  
  while (cin >> w, w!=-1){
    ans = 1150;
    if (w>10) ans += MIN(w-10,10)*125;
    if (w>20) ans += MIN(w-20,10)*140;
    if (w>30) ans += (w-30)*160;
    ans = lastMonth-ans;
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>

using namespace std;

long long A[3];
bool even;

void print()
{
	for (int i = 0; i < 3; i++)
		cout << A[i] << " ";
	cout << endl;
}

int main()
{
	even = false;
	for (int i = 0; i < 3; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) even = true;
	}
	sort(A, A + 3);

	//print();

	if (even) cout << 0 << endl;
	else cout << A[0] * A[1] << endl;

	return 0;
}

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

int main (){
    int n, A[1000];
    while(1){
        cin >> n;
        if (n== 0)break;
        
        for (int i = 0; i<n; i++ )cin >> A[i];
        int sum = 0;
        for (int i = 0; i<n; i++)sum += A[i];
        double av = 1.0*sum/n;
        double dis = 0.0;
        for (int i =0; i < n; i++){
            dis += (av - A[i])*(av - A[i]);
            
        }
        printf("%lf\n", sqrt(dis/n));
    }
}


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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    vector<int> x(5);
    rep(i,5){
        cin >> x[i];
        if(x[i]==0) print(i+1);
    }
    return 0;
}

Measured memory_bytes: 3640
n=int(input())
ls=list(map(int,input().split()))
ls.sort()
cnt=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if ls[i]+ls[j]>ls[k] and (ls[i]!=ls[j] and ls[j]!=ls[k] and ls[i]!=ls[k]):
                cnt+=1
print(cnt)

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

using namespace std;

const int INF = 2e9;

struct Node {
    typedef Node* NP;
    NP l, r;
    int sz, mi;
    Node(int _sz) : l(NULL), r(NULL), sz(_sz) {
        mi = INF;
        if (sz == 1) return;
        l = new Node(sz/2);
        r = new Node(sz-sz/2);
    }
    void set(int k, int v) {
        if (sz == 1) {
            mi = min(mi, v);
            return;
        }
        if (k < sz/2) {
            l->set(k, v);
        } else {
            r->set(k-sz/2, v);
        }
        mi = min(l->mi, r->mi);
    }
    int get(int a, int b) {
        if (b <= 0 || sz <= a) return INF;
        if (a <= 0 && sz <= b) return mi;
        return min(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

const int MN = 200010;
int n, q;
int b[MN];
vector<int> v[MN];

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

    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (b[i] == 0) {
            ans++;
            b[i]--;
        }
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r; l--;
        v[l].push_back(r);
    }
    Node* tr = new Node(n+1);
    for (int i = 0; i <= n; i++) {
        if (i) {
            tr->set(i, tr->get(i-1, i) + b[i-1]);
        } else {
            tr->set(0, 0);
        }
        for (int j = 0; j < int(v[i].size()); j++) {
            int r = v[i][j];
            tr->set(r, tr->get(i, r));
        }
    }
    ans += tr->get(n, n+1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22144
def sum(n):
    sum=0
    while n!=0:
        sum+=n%10
        n=n//10
    return sum



n=int(input())

min=100000

for i in range(n):
    if i==0:
        continue
    sub=n-i
    sub=sum(sub)
    i=sum(i)
    #subとiの各桁の和を足す
    if min>sub+i:
        min=sub+i
print(min)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n,0);
  int min_cost=1001001;
  for(int i=0;i<n;i++){
     cin>>a[i];
  }
  for(int i=-100;i<=100;i++){
    int cost=0;
    for(int j=0;j<n;j++){
      int re=i-a[j];
      cost+=pow(re,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout<<min_cost<<endl;
  return 0;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  
  int sum;
  sum += max(A,B);
  if(max(A,B)==A) --A;
  else --B;
  sum+=max(A,B);
  cout << sum << endl;
}

Measured memory_bytes: 256
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=1e5+5;



int main()
{

         ios_base::sync_with_stdio(false);
         
         int a,b,c,k;
         cin >> a >> b >> c >> k;
         int count=0;
         while(b<=a)
         {
          b*=2;
          count++;
         }
         while(c<=b)
         {
          c*=2;
          count++;
         }
         if(count<=k)
          cout<<"Yes";
        else cout<<"No";
         
        
     return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
int a, b;
cin >> a >> b;

cout << lcm(a, b) << endl;

return 0;
}

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
vector<int> v[100005];
int vis[100005];
void dfs(int r){
	vis[r]=1;
	for(int x: v[r]){
		if(vis[x]==0)
			dfs(x);
	}
}
int main()
{
	ios_base::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 n,m;
	cin>>n>>m;
	while(m--){
		int a,b,q;
		cin>>a>>b>>q;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int cou=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			cou++;
			dfs(i);
		}
	}
	cout<<cou<<endl;
	return 0;
}

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(ll i=0;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define vec_input(A) for(auto &a : A) cin >> a;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;


void run_case(){
	ll x , k , d; cin >> x >> k >> d;

	ll q = x/d;
	if(x < 0) x = -x;
	q = abs(q);
	if(abs(q) > k) x= x-(d*k);
	else
	{
		x = x  - (d*q);
		k -=q;
		if(x > 0) d = -d;
		if(k%2) x = x+d;

	}

	
	

	cout <<abs(x);
}


int main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input", "r", stdin);
    freopen("output", "w", stdout);
    freopen("error", "w", stderr);
	#endif

	
	

	int t = 1;
	// cin >> t;
	while(t--) 
	{
		run_case();



	}

	return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  
  int res = 0;
  for(int i = 0; i < 2; ++i){
    if(a > b){
      res += a;
      --a;
    }else{
      res += b;
      --b;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

int N;
string S;

int Z_algo(int x) {
	vector<int> V(N - x);
	V[0] = N;
	for (int i = 1, j = 0;i < N - x;) {
		while (i + j < N - x && S[x + j] == S[x + i + j])j++;
		V[i] = j;
		if (j == 0) {
			i++;continue;
		}

		int k = 1;
		for (;i + k < N && k + V[k] < j;k++) V[i + k] = V[k];
		i += k;j -= k;//Manacher同様、位置iを右にシフトさせ、長さjを縮める
	}
	int a = 0;
	for (int i = 0;i < N - x;i++) {
		a = max(a, min(i, V[i]));
		//cout << V[i] << " ";
	}
	//cout << endl;
	return a;
}

int main(){
	int ans = 0;
	cin >> N;
	cin >> S;
	for (int i = 0;i < N;i++) {
		ans = max(ans, Z_algo(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, W, A[105], B[105], dp[100005];
int main(){
    scanf("%lld %lld", &N, &W);
    for(int i = 1; i <= N; i++){
        scanf("%lld %lld", A + i, B + i);
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for(int i = 1; i <= N; i++){
        int w = A[i], v = B[i];
        for(int j = W; j >= w; j--){
            if(dp[j - w] == -1) continue;
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= W; i++){
        ans = max(ans, dp[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
/**
*   @author Mustafa Khaled.
*/
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std ;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define FastInputOutput ios_base :: sync_with_stdio( 0 ) ; cin.tie( 0 ) ; cout.tie( 0 ) ;
#define ReadFromFile(x)  freopen( x, "rt" , stdin ) ;
#define WriteToFile(x)  freopen( "in.txt", "wt" , stdout ) ;
#define D(x) scanf("%d",&x);
#define LLD(X) scanf("%lld",&x);
#define in(x,...) scanf(x,__VA_ARGS__)
#define out(x,...) printf(x,__VA_ARGS__)
typedef long long ll;

/// for debugging
string to_string(string s) {return '"' + s + '"';}string to_string(const char* s) {return to_string((string) s);}string to_string(bool b) {return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {cerr << " " << to_string(H);debug_out(T...);}
#ifndef ONLINE_JUDGE
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define dbg(...) {}
#endif

/// start driven program
const int OO = 0x3f3f3f3f , N=1e3;


void seive(){
int lp[1000000+7];
vector<int> pr;
	for (int i=2; i<=1000000+1; ++i) {
			if (lp[i] == 0) {
					lp[i] = i;
					pr.push_back(i);
			}
			for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=1000000; ++j) lp[i * pr[j]] = pr[j];

	}
}

bool ok(int val){
}
int bin_search(){ //max
    int l =0 , h =1000;
    int mid;
    while(l<h){
        mid=(l+h)>>1;
        if( ok(mid) ){
            h=mid;
        }else{
            l=mid+1;
        }
    }
    return h;
}

int main(){
    int n ; cin>>n;
    unordered_map<string , ll> mp;
    ll ans=0;
    for(int i=0 ; i < n ; ++i){
        string s; cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
        if(mp[s]>1) ans += mp[s]-1;
    }

    cout<<ans;
}


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

int main() {
  int W, H, X, Y;
  cin >> W >> H >> X >> Y;
  cout << fixed << setprecision(9) << (long) W * H / 2.0 << "\n";

  cout << ((X * 2 == W && Y * 2 == H) ? 1 : 0) << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  vector<char> s(3);
  vector<char> ans = { 'a', 'b', 'c'};
  for (int i = 0; i < 3; i++){
    s.at(i) = S.at(i);
  }
  sort(s.begin(),s.end());
  if (s == ans)
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const int D = 365;
vector<int> C(26), ans(D, 0), last(26,-1);
vector<vector<int>> S(D, vector<int>(26));

void debug1()
{
    //rep(i,26) cout << C[i] << " "; cout << endl;
    rep(i,D){
        rep(j,26) cout << S[i][j] << " "; cout << endl;
    }
}

void input()
{
    int tmp;
    cin >> tmp;
    rep(i,26) cin >> C[i];
    rep(i,D)rep(j,26) cin >> S[i][j];
    //rep(i,D) cin >> ans[i]; rep(i,D) ans[i]--; //B,C問題用
}

void output()
{
    for(auto x : ans)
        cout << x+1 << "\n";
}

void greedy()
{
    rep(i,D)
    {
        rep(j,26)
        {
            if(S[i][j] > S[i][ans[i]])
            {
                ans[i] = j;
            }
        }
    }

}

int test()
{
    int score = 0;
    rep(i,D)
    {
        int cur = ans[i];
        score += S[i][cur];
        last[cur] = i;
        rep(j,26)
        {
            score -= C[j] * (i - last[j]);
        }
        //cout << score << endl;
    }
    return score;
}

void rand_test(int r)
{
    rep(q,r)
    {
        
        rep(i,26) C[i] = rand() % 100;
        rep(i,D) rep(j,26) S[i][j] = rand() % 20000;
        //debug1();
        greedy();
        cout << test() << endl;
    }
}

int main()
{
    input();
    //rand_test(10);
    greedy();
    output();
    return 0;
}

Measured memory_bytes: 3680
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define mod 998244353
using ll = long long;
using namespace std;
int modPow(ll a, ll n, ll p) { //繰り返し二乗法 a**n % p
  if(n == 1) return a % p;
  if(!n) return 1;
  if(n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main(){
  vector<ll> fact(200001), invfact(200001);
  fact[0] = 1;
  for(int i = 1; i <= 200000; i++){
    fact[i] = fact[i - 1] * i % mod;
  }
  invfact[200000] = modPow(fact[200000], mod - 2, mod);
  for(int i = 200000 - 1; i >= 0; i--){
    invfact[i] = invfact[i + 1] * (i + 1) % mod;
  }
  ll n,m,k;
  cin >> n >> m >> k;
  ll ans = 0;
  for(ll i = 0; i <= k; i++){
    ll num = m * modPow(m - 1, n - i - 1, mod) % mod;
    ll val = fact[n - 1] * (invfact[i] * invfact[n - i - 1] % mod) % mod;
    ans += num * val % mod;
    ans %= mod;
  }
  cout << ans << endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  int ans = 0;
  for(int i=2;i<SZ(S);i+=2){
	if(S.substr(0,i/2) == S.substr(i/2,i/2)){
	  ans = i;
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <atcoder/convolution>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;
namespace ac = atcoder;

int main() {
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    rip(i,n,0) cin >> a[i];
    vector<ll> b(m);
    rip(i,m,0) cin >> b[i];
    vector<ll> c = ac::convolution<998244353>(a, b);
    vdeb(c);
}


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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double n;
	cin>>n;
	int nzz;
	nzz = n;
	int nx;
	nx = n*100;
	n*=100.0;
	if(nx%108==0)
		cout<<nx/108;
	else {
		n/=108.0;
		int ny = n;
		ny++;
		double nz = (double) ny * 1.08;
		int nn = nz;
		if(nn==nzz)
			cout<<ny;
		else
			cout<<":(";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int i,j,k,n,m,x,y,z,a[100000],ans=0,b[100000]={0};
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	z=0;
	for(i=1;i<n;i++)
	{
		for(j=i-1;j>=max(z,(i-k));j--)
		{
			x=a[i]-a[j];
			if(x<0)
			x=x*(-1);
			x=x+b[j];
			if(j==(i-1))
			b[i]=x;
			else
			b[i]=min(b[i],x);
		}
	}
	cout<<b[n-1];
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,l,r,m,c;
  char s[20],b[20],lc,rc;
  scanf("%d",&n);
  printf("0\n");
  fflush(stdout);
  scanf("%s",b);
  l=0;
  r=n;
  lc=rc=b[0];
  while(b[0]-'V'){//printf("%d %d\n",l,r);
    m=(l+r)/2;
    printf("%d\n",m);
    fflush(stdout);
    scanf("%s",s);
    if(lc==s[0]){
      if((m-l)%2){
	r=m;
	rc=s[0];
      }
      else{
	l=m;
	lc=s[0];
      }
    }
    else{
      if((m-l)%2){
	l=m;
	lc=s[0];
      }
      else{
	r=m;
	rc=s[0];
      }
    }
    b[0]=s[0];
  }
  return 0;
}


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


int main() {
  int N;
  cin >> N;
  vector<ll> A(N);

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

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  ll ans = A[0];
  int t = 1;
  int count = 0;
  for(int i = 1; i < A.size() - 1; i++) {
    
    if(count < 2) { ans += A[t]; count++; }
    if(count == 2) { count = 0; t++;}
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 4848