akhauriyash/Code-Regression huggingface dataset:
import math
a, b = map(int, input().split())
if abs(a - b) >= 2:
    print(0)
else:
    x = math.factorial(a)
    y = math.factorial(b)
    ans = x * y
    if a == b:
        print(ans * 2 % (10 ** 9 + 7))
    else:
        print(ans % (10 ** 9 + 7))

Measured memory_bytes: 5180
<?php

fscanf(STDIN, "%d %d", $x, $n);
if ($n == 0) { echo $x, PHP_EOL; return; }

$P = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($P);

$rp = [];
for ($i = 0; $i >= -100; --$i) {
    $rp[] = $i;
}
for ($i = 1; $i <= 200; ++$i) {
    if (!in_array($i, $P)) {
        $rp[] = $i;
    }
}
$rp[] = PHP_INT_MAX;
sort($rp);

if (in_array($x, $rp)) {
    echo $x, PHP_EOL;
    return;
}

$l = 0;
$r = count($rp);
while ($r - $l >= 1) {
    $mid = intdiv($r + $l, 2);
    if ($rp[$mid] > $x) {
        $r = $mid;
    } else {
        $l = $mid + 1;
    }
}

if (abs($x - $rp[$r]) == abs($x - $rp[$r - 1])) {
    echo $rp[$r - 1], PHP_EOL;
} else if (abs($x - $rp[$r]) > abs($x - $rp[$r - 1]) ) {
    echo $rp[$r - 1], PHP_EOL;
} else {
    echo $rp[$r], PHP_EOL;
}


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

int main()
{
    int a,n;
    char c,m;
    cin >> n >> c;
    a=n;
    m=c;
    if(m=='='){
        cout << n << endl;
        return 0;
    }
    for(;;){
        cin >> n >> c;
        if(m=='-') a-=n;
        else if(m=='*') a*=n;
        else if(m=='/') a/=n;
        else if(m=='+') a+=n;
        if(c=='='){
            cout << a << endl;
            break;
        }
        m=c;
    }
    return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>

int main()
{
	int a, b, op, total;
	
	
	while(scanf("%d %c %d", &a, &op, &b))
	{
		if(op == '+')
		{
			total = a + b;
			printf("%d\n", total);
		}
		else if(op == '-')
		{
			total = a - b;
			printf("%d\n", total);
		}
		else if(op == '*')
		{
			total = a * b;
			printf("%d\n", total);
		}
		else if(op == '/')
		{
			total = a / b;
			printf("%d\n", total);
		}
		else
		{
			break;
		}
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 2692
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
count = []
for m in range(M):
    x, y, c = map(int, input().split())
    price = a[x - 1] + b[y - 1] - c
    count.append(price)

if min(count) <= ans:
    print(min(count))
else:
    print(ans)

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

using namespace std;
#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int h,a;  cin>>h>>a;
    cout<<(h+a-1)/a;
    return 0;
}

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

char S[ 100010 ];
int X[ 100010 ];


int main()
{
int i;
int N;
int Q;
int L;
int R;
int iCnt;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> Q;
	cin >> S;

	i = 0;
	iCnt = 0;
	while( ( C = S[ i ] ) != '\0' )
	{
		i++;
		if( C == 'A' && S[ i ] == 'C' ) iCnt++;

		X[ i ] = iCnt;
	}

	for( i = 0; i < Q; i++ )
	{
		cin >> L;
		cin >> R;

		cout << X[ R - 1 ] - X[ L - 1 ] << endl;
	}

	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

    int main(){
      int n,m;
      string s;
      cin >> n >> m;
      vector<int> v(n,0);
      rep(i,m){
        int x,y;
        cin >> x >> y;
        x--; y--;
        v[x]++;
        v[y]++;
      }
      for (int w:v){
        cout << w << endl;
      }
      return 0;
    }


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int a1[101], a2[101];

int main() {
    int n;
    cin >> n;
    int sum1 = 0, sum2 = 0;
    rep(i, n) {
        cin >> a1[i];
        sum1 += a1[i];
    }
    rep(i, n) {
        cin >> a2[i];
        sum2 += a2[i];
    }
    int ans = 0;
    int tmp = 0;
    rep(i, n) {

        tmp += a1[i];
        ans = max({ans, sum1, sum2+tmp});
        sum2 -= a2[i];
    }
    cout << ans << endl;
}


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);} //
  void roll_y(){ roll(0, 2, 5, 3);} // to W
  void roll_x(){ roll(0, 1, 5, 4);} // to N
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
  void move(char ch){
    if ( ch == 'E' ) for ( int i = 0; i < 3; i++ ) roll_y();
    if ( ch == 'W' ) roll_y();
    if ( ch == 'N' ) roll_x();
    if ( ch == 'S' ) for ( int i = 0; i < 3; i++ ) roll_x();
  }
};

int main(){
  Cube c;
  string com;

  for ( int i = 0; i < 6; i++ ) cin >> c.f[i];
  cin >> com;

  for ( int i = 0; i < com.size(); i++ ) c.move(com[i]);

  cout << c.f[0] << endl;

  return 0;
}



Measured memory_bytes: 3140
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ForBlue.ABC_070
{
    class AtTemplate
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var ts = new long[n];
            for (int i = 0; i < n; i++)
            {
                ts[i] = long.Parse(Console.ReadLine());
            }

            Array.Sort(ts);
            long gcm = 1;
            long lcm = 1;

            for (int i = 0; i < n; i++)
            {
                if (ts[i] < lcm)
                {
                    gcm = GCM(lcm, ts[i]);
                }
                else
                {
                    gcm = GCM(ts[i], lcm);
                }
                lcm = lcm / gcm * ts[i];
                //Console.WriteLine(gcm);
                //Console.WriteLine(lcm);
            }

            Console.WriteLine(lcm);
        }

        static long GCM(long a,long b)
        {
            if (b == 0) return a;

            return GCM(b, a % b);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int leg[2]={0};
    int cnt=0,last=0;
    string s;
    for(int i=0;i<n;i++){
      cin>>s;
      if(s=="lu"){
	leg[0]=1;
      }else if(s=="ru"){
	leg[1]=1;
      }else if(s=="ld"){
	leg[0]=0;
      }else{
	leg[1]=0;
      }
      if(leg[0]==1&&leg[1]==1){
	if(last==0){
	  cnt++;
	  last=1;
	}
      }else if(leg[0]==0&&leg[1]==0){
	if(last==1){
	  cnt++;
	  last=0;
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb(a) push_back(a)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using vP = vector<P>;
const int INF = 1001001001;

int main(){
    int n;
    cin>>n;
    
    vi a(n);
    //map<int,ll> m;
    vector<ll> m(n,0);
    
    
    rep(i,n){
        cin>>a[i];
        a[i]--;
        m[a[i]]++;
    }
    
    ll ans = 0;
    /*
    for(auto p: m){
        ans += p.second*(p.second-1)/2;
    }
    */
    
    rep(i,n){
        ans += m[i]*(m[i]-1)/2;
    }
    
    for(int i=0; i<n; i++){
        cout << ans -( m[a[i]] - 1 ) << endl;
    }
    
    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

vector<lint> convert(vector<lint> v) {
    int n = v.size(), idx = 0;
    for (int i=63; i>=0; --i) {
        bool ok = false;
        for_(j,idx,n) {
            if ((v[j] >> i) & 1) {
                ok = true;
                swap(v[idx], v[j]);
                break;
            }
        }

        if (ok) {
            for_(j,idx+1,n) {
                if ((v[j] >> i) & 1) {
                    v[j] ^= v[idx];
                }
            }
            ++idx;
        }
    }
    v.resize(idx);
    return v;
}

bool able(lint x, const vector<lint>& c) {
    int n = c.size();
    vector<int> b;
    for (int i=63; i>=0; --i) {
        int k = b.size();
        if ((c[k] >> i) & 1) b.push_back(i);
    }

    for_(i,0,n) {
        if ((x >> b[i]) & 1) x ^= c[i];
    }
    return (x == 0);
}

void solve() {
    int N;
    cin >> N;

    vector<lint> A(N);
    for_(i,0,N) cin >> A[i];

    string S;
    cin >> S;

    if (S.back() == '1') {
        puts("1");
        return;
    }

    int L = 0;
    while (L < N and S[L] == '0') ++L;

    if (L == N) {
        puts("0");
        return;
    }

    vector<vector<lint>> v[2];
    v[1].push_back(vector<lint>());
    
    for_(i,L,N) {
        int k = int(S[i] - '0');
        if (i > L and S[i] != S[i - 1]) v[k].push_back(vector<lint>());
        v[k].back().push_back(A[i]);
    }

    reverse(ALL(v[0]));
    reverse(ALL(v[1]));

    int m = v[0].size();
    vector<lint> cur;
    bool ok = true;
    for_(i,0,m) {
        cur.insert(cur.end(), ALL(v[0][i]));
        vector<lint> c = convert(cur);
        for (lint x : v[1][i]) ok &= able(x, c);
    }
    puts(ok ? "0" : "1");
}

int main() {
    int T;
    cin >> T;
    for_(i,0,T) solve();
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PI;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second





signed main(){
	int n;
	cin >> n;
	int a[n];
	
	rep(i,0,n) cin >> a[i];
	
	sort(a,a+n,greater<int>());
	
	int memo = a[0] / 2;
	
	rep(i,1,n){
		memo += a[i];
	}
	
	cout << memo << endl;
	
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string s;
vector < int > z_function(string& s) {
    vector < int > z(s.size());
    int l = 0;
    int r = 0;
    for (int i = 1; i < s.size(); i++) {
        if (r < i) {
            l = r = i;
        }
        z[i] = min(r - i, z[i - l]);
        while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) z[i]++;
        if (i + z[i] > r) {
            l = i;
            r = i + z[i];
        }
    }
    return z;
}
vector < bool > get(string& s) {
    int n = s.size();
    vector < bool > f(n + 1, true);
    auto z = z_function(s);
    for (int i = 1; i <= n; i++) {
        for (int j = 2 * i; j <= n; j += i) {
            if (z[i] >= j - i) {
                f[j] = false;
            }
        }
    }
    return f;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> s;
    bool ok = false;
    for (int i = 0; i + 1 < s.size(); i++) {
        if (s[i] != s[i + 1]) ok = true;
    }
    if (!ok) {
        cout << s.size() <<'\n' << 1;
        return 0;
    }
    auto p1 = get(s);
    reverse(s.begin(), s.end());
    auto p2 = get(s);
    if (p1[s.size()]) {
        cout << 1 << "\n" << 1;
        return 0;
    }
    else {
        int ans = 0;
        for (int i = 1; i <= s.size() - 1; i++) {
            if (p1[i] && p2[s.size() - i]) {
                ans++;
            }
        }
        cout << 2 << "\n" << ans;
    }
    return 0;
}

Measured memory_bytes: 2844
#include <bits/stdc++.h>
using namespace std;
#define int		long long
#define mp		make_pair
#define pb		push_back
#define pf		push_front
#define fi 		first
#define se		second
#define db(x)	{ cerr << #x << " = " << x << endl; }
#define sz(x)	((int)(x).size())
#define w(x)		int x; cin>>x; while(x--)
#define rep(i,a,n)		for (int i=a;i<n;i++)
#define per(i,a,n)		for (int i=n-1;i>=a;i--)
#define mod		1000000007
#define inf		1e18

void c_p_c(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main(){
	c_p_c();
	string s; cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
	return 0;
}

// g++ -std=c++17 -Wshadow -Wall -o "a" "a.cpp" -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<cstdio> 
#include<limits.h>
using namespace std;
typedef pair<int,int>	P;
//int sx,sy;
//int gx,gy;
int	h,w,n;		//h行w列 
int factory[16][2];
char arr[1000][1000];
int movx[4]={-1,0,0,1};
int movy[4]={0,1,-1,0};
int d[1000][1000];
int bfs(int x1,int y1,int x2,int y2){
	queue<P>	myQ;
	myQ.push(P(x1,y1));
	fill_n(&d[0][0],1000*1000,-1);
	d[x1][y1]=0;
	while(!myQ.empty()){
		P pos=myQ.front();
		if(pos.first==x2&&pos.second==y2){
			arr[pos.first][pos.second]='.';
			break;
		}
		myQ.pop();
		for(int i=0;i<4;i++){
			int xx=pos.first+movx[i];
			int yy=pos.second+movy[i];
			if(d[xx][yy]==-1&&xx>=0&&xx<h&&yy>=0&&yy<w&&arr[xx][yy]!='X'){	//(arr[xx][yy]=='.'||arr[xx][yy]==arr[x2][y2])
				d[xx][yy]=d[pos.first][pos.second]+1;
				myQ.push(P(xx,yy));
			}
		}
	}
	return d[x2][y2];
}
int main(){
	while(scanf("%d%d%d",&h,&w,&n)!=EOF){
		for(int i=0;i<h;i++){
			getchar();
			for(int j=0;j<w;j++){
				scanf("%c",&arr[i][j]);
				if(arr[i][j]=='S'){
					arr[i][j]='.';
					factory[0][0]=i;
					factory[0][1]=j;
				}
				else if(isdigit(arr[i][j])){
					int index=arr[i][j]-'0';
					factory[index][0]=i;
					factory[index][1]=j;
				}
			}
		}
		int res=0;
		for(int i=0;i<n;i++){
			res+=bfs(factory[i][0],factory[i][1],factory[i+1][0],factory[i+1][1]);
		}
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

bool solve(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		if(a[i]%2==0){
			if(a[i]%5!=0&&a[i]%3!=0) return false;
		}  
	}
	return true;
}

int main(){
	//freopen("in","r",stdin);
	if(solve()) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

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

using namespace std;

const int maxn = 1e5+10;
const int inf = 1e9+10;

int num[maxn], dp[maxn];

int main(void)
{
	int n, k;
	cin >> n >> k;

	for (int i = 1; i <= n; i++)
		cin >> num[i], dp[i] = inf;

	dp[1] = 0;
	for (int i = 2; i <= n; i++)
		for (int j = max(1, i-k); j < i; j++)
			dp[i] = min(dp[i], dp[j]+abs(num[i]-num[j]));

	cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200010

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N,M,Q;
int grid[2050][2050]={0};
int choten[2050][2050]={0};
int yoko[2050][2050]={0};
int tate[2050][2050]={0};
int main(){
	cin>>N>>M>>Q;
	for(int i=0;i<N;i++){
		int sum=0,sumy=0;
		string str;
		cin>>str;
		for(int j=0;j<M;j++){
			grid[i+1][j+1]=str[j]-'0';
			sum+=grid[i+1][j+1];
			if(grid[i+1][j+1]==1){
				sumy+=grid[i+1][j];
			}
			choten[i+1][j+1]=sum+choten[i][j+1];
			yoko[i+1][j+1]=yoko[i][j+1]+sumy;
			//cout<<yoko[i+1][j+1]<<" ";
		}
		//cout<<endl;
	}
	for(int j=0;j<M;j++){
		int sumt=0;
		for(int i=0;i<N;i++){
			if(grid[i+1][j+1]==1){
				sumt+=grid[i][j+1];
			}
			tate[i+1][j+1]=tate[i+1][j]+sumt;
		}
	}
	/*for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cout<<tate[i+1][j+1]<<" ";
		}
		cout<<endl;
	}*/
	for(int i=0;i<Q;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;a--;b--;
		int chotennum=choten[c][d]-choten[a][d]-choten[c][b]+choten[a][b];
		int tatenum=tate[c][d]-tate[a+1][d]-tate[c][b]+tate[a+1][b];
		int yokonum=yoko[c][d]-yoko[a][d]-yoko[c][b+1]+yoko[a][b+1];
		cout<<chotennum-tatenum-yokonum<<endl;
	}
}

Measured memory_bytes: 67328
def N(Dice):
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E(Dice):
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W(Dice):
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S(Dice):
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
def DICE(Dice,Dice2):
    if (Dice[0] in Dice2)==False:
        """print('No')"""
        return 0
    else:
        for j in range(6):
            if j%2==0:
                N(Dice2)
            else:
                W(Dice2)
            for i in range(4):
                N(Dice2)
                W(Dice2)
                S(Dice2)
                if Dice==Dice2:
                    break
            if Dice==Dice2:
                break
    if Dice==Dice2:
        """print('Yes')"""
        return 1
    else:
        """print('No')"""
        return 0
cnt=0             
a=int(input())
Dice=[i for i in range(a)]
for i in range(a):
     Dice[i]=[int(i) for i in input().split()]
for i in range(a-1):
    for j in range(i+1,a):
        cnt+=DICE(Dice[i],Dice[j])
if cnt==0:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 7808
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int main(){
	LL n,m,k;
	scanf("%lld %lld %lld",&n,&m,&k);
	for(LL i = 0;i <= m;i++){
		for(LL j = 0;j <= n;j++){
			if(j * m - j * i + i * n - j * i == k){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
}

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

# min, max, sum は関数名なので
# 別名を使うとよい
min0 = 10000000
max0 = -10000000
sum0 = 0
for x in ns:
  min0 = min(min0, x)
  max0 = max(max0, x)
  sum0 += x
 
print(min0, max0, sum0)


Measured memory_bytes: 6584
#include <iostream>
#include <string>
char pic[101][101],pic2[201][201];

int main(){
    int H, W;
    std::cin>>H>>W;
    std::string s;
    for(int i=0;i<H;++i){
        std::cin>>s;
        std::cout<<s<<std::endl;
        std::cout<<s<<std::endl;
        //std::cout<<std::endl;
    }
    /*for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            std::cin>>pic[i][j];
            pic2[2*i+1][j]=pic[i][j];
            pic2[2*i][j]=pic[i][j];
        }
    }
    for(int i=0;i<2*H;++i){
        for(int j=0;j<W;++j){
            std::cout<<pic2[i][j];
        }
        std::cout<<std::endl;
    }*/
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
bool NG[10];
int N;
int ans;
void dfs(int x) {
	if (x >= N) {
		ans = min(ans, x);
		return;
	}
	for (int i = 0; i < 10; i++) {
		if (NG[i] || (x == 0 && i == 0)) continue;
		dfs(x * 10 + i);
	}
}
int main() {
	int K;
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int D;
		cin >> D;
		NG[D] = 1;
	}
	ans = 1 << 30;
	dfs(0);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String text = sc.next();
        String result = (isReversible(text) && isReversible(text.substring((text.length() + 2) / 2))) ? "Yes" : "No";

        System.out.println(result);
    }

    private static boolean isReversible(String text) {
        return text.equals(new StringBuilder(text).reverse().toString());
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  int n;
  cin >> n;

  ll sum = 0;

  ll a[n];
  REP(i, n){
    cin >> a[i];
    sum += a[i];
  }

  SORT(a, n);
  sum -= a[n - 1];

  if(a[n - 1] < sum) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

int a[100006];
int b[100006];

signed main(){
    int n;cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    if(n&1){
        for(int i=1;i<n;i++){
            b[i]=(i+1)/2*2;
        }
    }
    else{
        for(int i=0;i<n;i++){
            b[i]=i/2*2+1;
        }
    }
    rep(i,n){
        if(a[i]!=b[i]){
            cout<<0<<endl;
            return 0;
        }
    }
    int ans=1;
    rep(i,n/2){
        ans*=2;ans%=mod;
    }
    cout<<ans<<endl;
}

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

int n;
struct edge{
	int to, color, weight;
};
edge make_edge(int t, int c, int w){
	edge ret;
	ret.color = c;
	ret.to = t;
	ret.weight = w;
	return ret;
}
vector<edge> v[100100];
int ans[100100];
int Q;
struct query{
	int qcolor, co1, co2, pos;
};
int sum[100100], num[100100], dist;
int dep[100100], par[100100][22];
vector<query> q[100100];

void dfs1(int now){
	rep(i, 20) par[now][i+1] = par[par[now][i]][i];
	rep(i, v[now].size()){
		if(v[now][i].to != par[now][0]){
			dep[v[now][i].to] = dep[now]+1;
			par[v[now][i].to][0] = now;
			dfs1(v[now][i].to);
		}
	}
}
int lca(int a, int b){
	if(dep[a] > dep[b]) swap(a, b);
	for(int i = 20; i >= 0; i--) if(dep[par[b][i]] >= dep[a]) b = par[b][i];
	for(int i = 20; i >= 0; i--) if(par[b][i] != par[a][i]) a = par[a][i], b = par[b][i];
	if(a != b) return par[a][0];
	else return a;
}

void dfs2(int now){
	rep(i, q[now].size()){
		ans[q[now][i].pos] += q[now][i].co1 * (dist - sum[q[now][i].qcolor] + q[now][i].co2 * num[q[now][i].qcolor]);
	}
	rep(i, v[now].size()){
		if(v[now][i].to == par[now][0]) continue;
		sum[v[now][i].color] += v[now][i].weight; dist += v[now][i].weight;
		num[v[now][i].color]++;
		dfs2(v[now][i].to);
		sum[v[now][i].color] -= v[now][i].weight; dist -= v[now][i].weight;
		num[v[now][i].color]--;
	}
} 

int main(){
	scanf("%d%d", &n, &Q);
	rep(i, n-1){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--, b--;
		v[a].push_back(make_edge(b, c, d));
		v[b].push_back(make_edge(a, c, d));
	}
	dfs1(0);
	rep(i, Q){
		int tcolor, tweight, pos1, pos2;
		scanf("%d%d%d%d", &tcolor, &tweight, &pos1, &pos2);
		pos1--, pos2--;
		int l = lca(pos1, pos2);
		query ql, q1;
		ql.co1 = -2, ql.co2 = tweight, ql.pos = i, ql.qcolor = tcolor;
		q1.co1 = +1, q1.co2 = tweight, q1.pos = i, q1.qcolor = tcolor;
		q[l].push_back(ql);
		q[pos1].push_back(q1);
		q[pos2].push_back(q1);
	}
	dfs2(0);
	rep(i, Q) cout << ans[i] << endl;
	return 0;
} 

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

  int n;
  long long p=1;

  cin >> n;

  for(int i=1; i<=n; i++){
    p*=i;
    p%=1000000007;
  }

  p%=1000000007;

  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ch =0;
    int ans = 0;
    reps(i, n-1){
        if(s[i] != s[i-1]){
           ch++;
        }else{ans++;}
    }
    if(k >= ceil(ch/2.0)){
        cout << n - 1<< endl;
    }else{
        int middle = min(k, ch / 2);
        ans += middle * 2;
        cout << ans << endl;
    }
}



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n;cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    auto b = a;
    sort(all(b));
    rep(i,n){
        int index = lower_bound(all(b),a[i]) - b.begin();
        //cout << index << " ";
        if(index<n/2)cout << b[n/2] << endl;
        else cout << b[n/2-1] << endl;
    }
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 500005;
const ll MOD = 998244353;

int n,k;

ll ans;
ll fac[MAXN];
ll inv[MAXN];

ll power(ll a,ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
			(res *= a) %= MOD;
		(a *= a) %= MOD;
		b >>= 1;
	}
	return res;
}

void init()
{
	fac[0] = 1;
	for (int i = 1;i <= k;i++)
		fac[i] = fac[i - 1] * i % MOD;
	inv[k] = power(fac[k],MOD - 2);
	for (int i = k;i >= 1;i--)
		inv[i - 1] = inv[i] * i % MOD;
}

ll C(int x,int y)
{
	return x < y ? 0 : fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

ll ways(int x,int y)
{
	return C(x,(x - y) / 2);
}

int main()
{
	scanf("%d%d",&n,&k);
	init();
	for (int i = max(n,(k + 1) / 2);i <= k;i++)
	{
		int match = n - (i - (k - i));
		if (match >= n)
			continue;
		int low = match - (k - i);
		int des = 2 * i - k;
		int sub = low - 1 - (des - (low - 1));
		(ans += ways(k,des) - ways(k,sub)) %= MOD;
	}
	if ((~k & 1) && k / 2 >= n)
	{
		int tmp = ans;
		int low = n - 1 - (k / 2 - 1);
		int des = 1;
		int sub = low - 1 - (des - (low - 1));
		(ans += ways(k - 1,des) - ways(k - 1,sub)) %= MOD;
		cerr << ans - tmp << endl;
	}
	printf("%lld\n",(ans + MOD) % MOD);
	return 0;
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

int A[1001][1001], B[100001];

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

	int n, m, i, j, k, x, y, z;

	cin >> n >> m >> k;
	for (i = 1; i <= k; ++i) cin >> B[i];

	int dir = 0;
	x = 1;
	y = 1;

	i = 0;
	z = 0;
	for (i = 1; i <= k; ++i) {
		z = B[i];
		if (z == 0) continue;
		while (z--) {
			A[x][y] = i;
			if (dir == 0) {
				y += 1;
			} else {
				y -= 1;
			}
			if (y == m+1) {
				y = m;
				x += 1;
				dir = 1;
			}
			if (y == 0) {
				y = 1;
				x += 1;
				dir = 0;
			}
		}
	}

	for (i = 1; i <= n; ++i) {
		for (j = 1; j <= m; ++j) {
			cout << A[i][j] << " ";
		} cout << endl;
	}

	return 0;
}

Measured memory_bytes: 768
<?php
list($n, $a) = ints();
$x = ints();
for ($i = 0; $i < $n; ++$i) $x[$i] -= $a;
// dp[i][t]=v x0~xiから0枚以上を選んで合計がtになる組み合わせ数v
$dp[-1][0] = 1;
for ($i = 0; $i < $n; ++$i) {
    foreach ($dp[$i - 1] as $t => $v) {
        if (isset($dp[$i][$t])) $dp[$i][$t] += $v;
        else $dp[$i][$t] = $v;
        if (isset($dp[$i][$t + $x[$i]])) $dp[$i][$t + $x[$i]] += $v;
        else $dp[$i][$t + $x[$i]] = $v;
    }
}
echo $dp[$n - 1][0] - 1; // 1枚も選ばない場合は除去
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> c(3);
  c.at(0) = 1;
  c.at(1) = 2;
  c.at(2) = 3;
  rep(i, 3) {
    if (a != c.at(i) && b != c.at(i)) cout << c.at(i) << endl;
  }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int fact[2000005],fact_inv[2000005];
void pre(){
    fact[0]=1;
    fact_inv[0]=1;
    for(int i=1;i<2000005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inv[i]=power(fact[i],mod-2);
    }
}
long long ncr(long long n,long long r){
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;
    pre();
    //int n=r2-r1,m=c2-c1;
    int ans=0;
    for(int i=r1;i<=r2;i++){
        ans+=(ncr(i+c2+1,i+1)-ncr(i+c1,i+1)+mod)%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
int par[100005],ran[100005];
set<int>S;
void init(){ for(int i=0;i<100005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int main(){
	cin>>n>>m;
	init();
	rep(i,n){
		int x; cin>>x;
		int pre = -1;
		rep(j,x){
			int a; cin>>a; S.insert(a);
			if(pre != -1){
				unite(pre,a);
			}
			pre = a;
		}
	}
	set<int>SS;
	for(set<int>::iterator it=S.begin();it!=S.end();++it){
		SS.insert(find(*it));
	}
	puts((SS.size()==1?"YES":"NO"));
}

Measured memory_bytes: 3968
import networkx as nx
N = int(input())
AB = [[int(_) for _ in input().split()] for _ in range(N)]
CD = [[int(_) for _ in input().split()] for _ in range(N)]
G = nx.DiGraph()
for a, b in AB:
    G.add_edge(-1, a * 1000 + b, capacity=1)
for c, d in CD:
    G.add_edge(c * 1000 + d, -2, capacity=1)
for a, b in AB:
    for c, d in CD:
        if a < c and b < d:
            G.add_edge(a * 1000 + b, c * 1000 + d, capacity=1)
flow_value, flow_dict = nx.maximum_flow(G, -1, -2)
print(flow_value)


Measured memory_bytes: 56328
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// longest increasing subsequence
template <typename T>
int lis(vector<T> &v, T inf) {
    vector<T> a(v.size(), inf);
    for (int i = 0; i < v.size(); ++i) {
        *lower_bound(a.begin(), a.end(), v[i]) = v[i];
    }
    return lower_bound(a.begin(), a.end(), inf) - a.begin();
}

int main() {
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
    }
    bool incl = y2 >= y1;
    ll miny   = min(y1, y2);
    ll maxy   = max(y1, y2);
    int n;
    cin >> n;
    vector<pll> xy;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        if (x1 <= x && x <= x2 && miny <= y && y <= maxy) {
            if (!incl)
                y *= -1;
            xy.emplace_back(x, y);
        }
    }
    sort(xy.begin(), xy.end());
    vl yseq;
    for (auto &p : xy) {
        yseq.emplace_back(p.second);
    }
    int l                 = lis(yseq, INF);
    long double ret       = 0.0;
    const long double pi  = acos(-1L);
    const long double sub = 0.25 * 20.0 * pi - 20.0;
    const long double add = 0.5 * 20.0 * pi - 20.0;
    ret += sub * l;
    if (l == min(x2 - x1 + 1, maxy - miny + 1)) {
        ret -= sub;
        ret += add;
    }
    ret += 100.0 * (x2 - x1 + maxy - miny);
    cout << fixed << setprecision(15) << ret << "\n";
    return 0;
}

Measured memory_bytes: 7916
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

bool is_prime[100005]={};

void check_prime(void){
    rep(i,100005)is_prime[i]=true;
    is_prime[0]=false;
    is_prime[1]=false;
    for(int i=2;i<100005;i++){
        if(!is_prime[i])continue;
        for(int j=2;i*j<100005;j++)is_prime[i*j]=false;
    }
}

int main(void) {
    ll q;
    cin >> q;
    ll lr[q][2];
    ll sum[100006]={};
    check_prime();
    rep(i,q){
        cin >> lr[i][0] >> lr[i][1];
    }
    DEBUG{
        cout << is_prime[2] << endl;
        cout << is_prime[3] << endl;
    }
    rep(i,100006){
        if(i==0)continue;
        sum[i]=sum[i-1];
        if(i%2&&is_prime[i]&&is_prime[(i+1)/2])sum[i]++;
    }
    rep(i,q){
        cout << sum[lr[i][1]]-sum[lr[i][0]-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String num = br.readLine();
		String[] str = num.split(" ", 0);
		int k = Integer.parseInt(str[0]);
		int c = Integer.parseInt(str[1]);
		k--;
		c--;
		System.out.println(c*k);
	}
}

Measured memory_bytes: 23124
#include<iostream>

using namespace std;

int main()
{
    int m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(m2 > m1)
    {
    	if(m2 - m1 == 1)
    		cout <<"1" << endl;
    }
    else if(m2 < m1)
    {
    	cout << "1" << endl;
    }
    else 
    	cout << "0" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int hantei(int);
int main(){
  int i,kazu,x,y,z,kosuu=0;
  int n[10000];
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++){
    scanf("%d",&n[i]);

  if(hantei(n[i])==1){
    kosuu++;
  }
  else{}
  }

  printf("%d\n",kosuu);
  return 0;
}

int hantei(int x){
  int i;
  if(x==2){return 1;}
  if(x<2 || x%2==0){return 0;}
  i = 3;
  while(i<=sqrt(x)){
    if(x%i==0){
      return 0;
    }
    i=i+2;
  }
  
  return 1;
}

  



Measured memory_bytes: 2060
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }


int main() {
	int n;
	cin >> n;
	vector<int> a(n - 1), b(n - 1), c(n), k(n);
	vector<vector<int>> p(n);
	vector<int> d(n, 0);
	REP(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		p[a[i]].push_back(b[i]);
		p[b[i]].push_back(a[i]);
	}
	REP(i, n) {
		cin >> c[i];
		k[i] = c[i];
	}
	sort(all(k));
	ll sum = 0;
	REP(i, n-1) {
		sum += k[i];
	}
	put(sum);
	queue<int> q;
	vector<int> res(n);
	int cnt = 0;
	reverse(all(k));
	q.push(0);
	d[0] = 1;
	res[0] = k[cnt++];
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		REP(i, p[t].size()) {
			if (d[p[t][i]] == 0) {
				res[p[t][i]] = k[cnt++];
				q.push(p[t][i]);
				d[p[t][i]] = 1;
			}
		}
	}
	REP(i, n) {
		cout << res[i] << " ";
	}
	put("");
	/*REP(i, n) {
		if (p[i].size() == 1) {
			q.push(i);
			d[i] = 1;
		}
	}
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		REP(i, p[t].size()) {
			if (d[p[t][i]] == 0) {
				d[p[t][i]] = d[t] + 1;
				q.push(p[t][i]);
			}
		}
	}
	vector<P> r(n);
	REP(i, n) {
 		r[i].first = d[i];
		r[i].second = i;
	}
	sort(all(r));
	vector<int> res(n);
 	REP(i, n) {
		res[r[i].second] = k[i];
	}
	REP(i, n-1) {
		cout << res[i] << " ";
	}
	put(res.back());*/
	return 0;
}


Measured memory_bytes: 1152
package main

import "fmt"

func main(){
	var n,temp int
	fmt.Scan(&n)
	a := make([]int,n)
	for i:=0 ; i<n-1;i++ {
		fmt.Scan(&temp)
		temp--
		a[temp]++
	}
	for i:=0 ; i<n; i++{
		fmt.Println(a[i])
	}
}


Measured memory_bytes: 6484
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

struct Node {
  int location, p, l, r;
  Node() {}
};

struct Point {
  int id, x, y;
  Point() {}
  Point(int id, int x, int y): id(id), x(x), y(y) {}

  bool operator < (const Point &p) const {
    return id < p.id;
  }

  void print() {
    printf("%d\n", id);
  }
};

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int np = 0;
int make2DTree(vector<Point> &p, vector<Node> &t, int l, int r, int depth = 0) {
  if (r <= l) return NIL;

  int mid = (l + r) / 2;
  if (depth % 2 == 0) sort(p.begin() + l, p.begin() + r, lessX);
  else sort(p.begin() + l, p.begin() + r, lessY);
  
  int nt = np++;
  t[nt].location = mid;
  t[nt].l = make2DTree(p, t, l,  mid, depth + 1);
  t[nt].r = make2DTree(p, t, mid + 1, r, depth + 1);

  return nt;
}

void find(vector<Point> &p, vector<Node> &t, int v, int sx, int tx, int sy, int ty, vector<Point> &ans, int depth = 0) {
  auto cp = p[t[v].location];
  int x = cp.x, y = cp.y;
  
  if (sx <= x && x <= tx && sy <= y && y <= ty) ans.push_back(cp);

  if (depth % 2 == 0) {
    if (t[v].l != NIL && sx <= x) find(p, t, t[v].l, sx, tx, sy, ty, ans, depth + 1);
    if (t[v].r != NIL && x <= tx) find(p, t, t[v].r, sx, tx, sy, ty, ans, depth + 1);
  } else {
    if (t[v].l != NIL && sy <= y) find(p, t, t[v].l, sx, tx, sy, ty, ans, depth + 1);
    if (t[v].r != NIL && y <= ty) find(p, t, t[v].r, sx, tx, sy, ty, ans, depth + 1);
  }
}

int main() {
  int n;
  cin >> n;
  
  vector<Point> p(n);
  vector<Node> t(n);

  int x, y;
  rep(i, n) {
    scanf("%d %d", &x, &y);
    
    p[i] = Point(i, x, y);
    t[i].p = t[i].l = t[i].r = NIL;
  }
  
  int q, root = make2DTree(p, t, 0, n);
  cin >> q;

  int sx, tx, sy, ty;
  vector<Point> ans;
  rep(i, q) {
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    ans.clear();
    find(p, t, root, sx, tx, sy, ty, ans); 
    sort(ans.begin(), ans.end());
    for (auto &a: ans) a.print();
    cout << endl;
  }
}



Measured memory_bytes: 16276
from collections import deque

N,M=map(int,input().split())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[]for i in range(N+1)]
deq=deque()

for i in range(M):
    A,B=map(int,input().split())
    S[A].append(B)
    S[B].append(A)
    
#print(S)    
lenN=len(S[N])
for i in range(lenN):
    v=S[N][i]
    #print(v)
    #print(S[v])
    
    if 1 in S[v]: 
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")        

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

int main() {
  int N,a,b,c,sum;
  b = 1;
  cin >> N;
  for (int i=0;i<N;i++){
    a = N/b;
    if (a != 0){
      a %= 10;
      b *= 10;
      sum += a;
    }
    else{
      break;
    }
  }
  if (N%sum==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
vector<int> a;

int main(void){
    cin >> N;
    a.resize(N);
    for (int i=0; i<N; i++) cin >> a[i];
    
    ll curr_money = 1000;
    ll stocks = 0;
    for (int i=0; i<N-1; i++){
        if (a[i] < a[i+1]){
            stocks = curr_money / a[i];
            curr_money -= stocks * a[i];
            curr_money += stocks * a[i+1];
        }
        
    }
    cout << curr_money << endl;
}


Measured memory_bytes: 3540
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap <String,Integer> m = new HashMap<>();
        for(int i=0;i<n;i++){
			char [] c = sc.next().toCharArray();
			Arrays.sort(c);
			m.merge(String.valueOf(c),1,Integer::sum);
		}
        System.out.println(m.values().stream().mapToLong(i->(long)(i-1)*i/2).sum());
	}
}

Measured memory_bytes: 57120
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,K; cin>>N>>K;
    ll H[N];
    ll dp[N];
    
    for(ll i=0;i<N;++i)
    {
        dp[i] = MAXX;
        
        cin>>H[i];
        
        if(i == 0)
        {
            dp[i] = 0;
            continue;
        }
        
        for(ll j=(i - 1);j>=max(0LL,i - K);--j)
            dp[i] = min(dp[i],dp[j] + abs(H[i] - H[j]));
    }
    
    cout<<dp[N - 1]<<endl;
}

Measured memory_bytes: 5172
#include <iostream>
using namespace std;
int main(){
          int n;
           cin >> n;
          int k=n%10;
          if(k==2||k==4||k==5||k==7||k==9){
                         cout << "hon";
                         return 0;
            }
            else  if(k==0||k==1||k==6||k==8){
                         cout << "pon";
                         return 0;
            }
              else  if(k==3){
                         cout << "bon";
                         return 0;
            }
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  ll n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(a, n % (a + b)) << endl;

  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc123/tasks/abc123_c
# C - Five Transportations
import copy
import math

n = int(input().split()[0]) # 人数
a = int(input().split()[0]) # 電車の定員
b = int(input().split()[0]) # バスの定員
c = int(input().split()[0]) # タクシーの定員
d = int(input().split()[0]) # 飛行機の定員
e = int(input().split()[0]) # 船の定員

# 貪欲法だと時間内に解けないので、
# 一番きついところを考える
min_cap = min([a, b, c, d, e])

# (i - 1) + (5 - i) = 4
# 4分間は乗れない時間帯がある
ans = math.ceil(float(n) / min_cap) + 4

print(ans)


Measured memory_bytes: 3444
/*
      author  : nishi5451
      created : 15.08.2020 12:38:21
*/

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


int main(){
    string s;
    cin >> s;
    rep(i,(int)s.size()){
        if((i+1)%2==0){
            if(s[i]=='R'){
                cout << "No" << endl;
                return 0;
            }
        }   
        else{
            if(s[i]=='L'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<cstdio>
#include<algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    int A[3];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d %d %d", &A[0], &A[1], &A[2]);
        sort(A, A+3);
        double a= (double)A[0], b= (double)A[1], c= (double)A[2];
        double cosine = (b*b+a*a-c*c)/(2*b*c);

        if(cosine == 0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 2560