akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int n, m, mx = 1e5 + 1;
    cin >> n >> m;
    vector<int> x(mx, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        x[a]++;
    }

    int is[m] = {}, pr[m] = {};
    for (int i = 0; i < mx; i++) {
        pr[i % m] += 2 * (x[i] / 2);
        is[i % m] += x[i] % 2;
    }
    for (int i = 0; i < m; i++) cerr << pr[i] _ is[i] << endl;

    int ans = 0;
    for (int i = 1; 2 * i < m; i++) {
        int k = min(is[i], is[m - i]);
        ans += k;
        is[i] -= k;  is[m - i] -= k;
    }
    ans += (is[0] + pr[0]) / 2;
    if (m % 2 == 0) {
        ans += (is[m / 2] + pr[m / 2]) / 2;
    }

    for (int i = 1; 2 * i < m; i++) {
        if (is[i] == 0) {
            int k = is[m - i];
            ans += min(k, pr[i]);
            pr[i] -= min(k, pr[i]);
            ans += (pr[i] + pr[m - i]) / 2;
        }
        else {
            int k = is[i];
            ans += min(k, pr[m - i]);
            pr[m - i] -= min(k, pr[m - i]);
            ans += (pr[i] + pr[m - i]) / 2;
        }
    }
    cout << ans << endl;

}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

ll const mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    for (int i = 0;i < n-1;++i) a[i+1] ^= a[i];
    if (a[n-1]) {
        ll x = 1,y = 0;
        for (int i = 0;i < n;++i) {
            if (a[i] == 0) (x += y) %= mod;
            else if (a[i] == a[n-1]) (y += x) %= mod;
        }
        cout << x << endl;
    } else {
        ll b = 5e8+4;
        vector<ll> sum(n+1,0),x(1<<20,1),y(1<<20,0),r(1<<20,0);
        for (int i = 0;i < n;++i) sum[i+1] = sum[i]+(a[i] == 0);
        for (int i = 0;i < n;++i) {
            if (a[i]) {
                (x[a[i]] += y[a[i]]*(sum[i]-sum[r[a[i]]])%mod) %= mod;
                y[a[i]] += x[a[i]];
                r[a[i]] = i;
            } else {
                (b *= 2) %= mod;
            }
        }
        ll ans = 0;
        for (int i = 0;i < (1<<20);++i) ans += y[i];
        cout << (ans+b)%mod << endl;
    }
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef pair<int, int> P;

int n;
ll a[300000]={};
ll sum=0;
ll mod=1000000007;
ll all_sum=0;
ll sqr_sum=0;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  cin>>n;
  
  rep(i,n){
    cin>>a[i];
  }
  
  rep(i,n){
    all_sum+=a[i];
    sqr_sum+=a[i]*a[i];
    all_sum%=mod;
    sqr_sum%=mod;
  }
  
  ll ans=(all_sum*all_sum-sqr_sum);
  ans%=mod;
  ans*=modinv(2,mod);
  ans%=mod;
  
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e3+7;
const ll mod = 1e9+7;
ll ans=0;
int main()
{
    int n,k;
    cin>>n>>k;
    ll x=n/k;
    ans=x+x*(x-1)*3+x*(x-1)*(x-2);
    if(k%2==0){
        k/=2;
        ll y=n/k-x;
        x=y;
        ans+=x+x*(x-1)*3+x*(x-1)*(x-2);
    }
    cout<<ans<<endl;
}


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

typedef unsigned long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    ll prev = INF;
    ll m = 0;
    ll count = 0;
    REP(i,N){
       ll h;
       cin >> h;
       if( h <= prev ){
          count++;
          prev = h;
       }else{
          m = max(m, count);
          count=1;
          prev = h;
       }
    }

    m = max(m, count);

    cout << (m-1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MA 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 10000000


int n,A[MA][MA];



void a(){
  int w;
  int s[MA],co[MA];
  
  for(int i = 0;i<n;i++){
    s[i] = INFTY;
    co[i] = WHITE;
  }

  s[0] = 0;
  co[0] = GRAY;
  while(1){
    w = INFTY;
    int q = -1;
    for(int i = 0;i<n;i++){
      if(w >s[i]&&co[i]!=BLACK){
	q = i;
	w = s[i];
      }
    }
    if(q == -1)break;
    co[q] = BLACK;
    for(int x = 0;x<n;x++){
      if(co[x]!=BLACK&&A[q][x]!=INFTY){
	if(s[x] >s[q]+A[q][x]){
	  s[x]= s[q]+A[q][x];
	  co[x] = GRAY;
	}
      }
    }
  }
  for(int i = 0;i<n;i++){
    printf("%d %d\n",i,s[i]);
  }
}
      
  
  

int main(){
  int v,k,u,c,i,j;
  

  scanf("%d",&n);
  for(i = 0;i<n;i++){
    for(j= 0;j<n;j++){
      A[i][j] = INFTY;
    }
  }
  

  for( i = 0;i<n;i++){
    scanf("%d%d",&v,&k);
    for(j = 0;j<k;j++){
      scanf("%d%d",&u,&c);
      A[v][u] = c;
    }
  }


  a();
  
     




  return 0;
}




Measured memory_bytes: 2036
#include<cstdio>
typedef long long LL;
const int MOD=1e9+7;
const int N=2005;
const int A=2005;

int n;
int a[N];
int cnt[N];
LL ans,k;

int main() {
	scanf("%d %lld",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		ans+=cnt[a[i]+1];
		for(int j=a[i];j>=0;j--)
			cnt[j]++;
	}
	ans=ans*k%MOD;
	LL tot=(k*(k-1)/2)%MOD;
	for(int i=1;i<=n;i++)
		ans=(ans+tot*cnt[a[i]+1])%MOD;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    cout<<24 - n + 24;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<int> lstEat = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstEat.Add(int.Parse(sS[i]) - 1); }                       // 料理Noは0始まりに変更
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<ClsDis> lstDis = new List<ClsDis>();
            for (int i = 0; i < sS.Length; i++) { lstDis.Add(new ClsDis() { iB = int.Parse(sS[i]) }); }     // ある料理のB
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++) { lstDis[i].iC = int.Parse(sS[i]); }                        // ある料理のC

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            int iBak = -100;
            for (int i = 0; i < lstEat.Count; i++)
            {
                iOut += lstDis[lstEat[i]].iB;                                                               // 食べたので加算
                if (lstEat[i] == iBak + 1) { iOut += lstDis[lstEat[i] - 1].iC; }                            // Noが連番の場合C加算
                iBak = lstEat[i];                                                                           // 今食べたNo保持
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        private class ClsDis
        {
            public int iB { get; set; } = 0;
            public int iC { get; set; } = 0;
        }

}


Measured memory_bytes: 13268
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let mut v: Vec<u32> = (0..5).map(|_| iter.to()).collect();
    let min_ = v.iter().filter(|&x| x % 10 != 0).map(|x| x % 10).min();
    if let Some(min) = min_ {
        if let Some(i) = v.iter().position(|&x| x % 10 == min) {
            let val = v.remove(i);
            let sum: u32 = v.into_iter().map(|x| ((x + 9) / 10) * 10).sum();
            println!("{}", sum + val);
        } else {
            assert!(false);
        }
    } else {
        println!("{}", v.into_iter().sum::<u32>());
    }
}

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

int n;

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main() {
  bool ans = 0;

  cin >> n;
  for(int i = 0; i * 4 <= n; ++i)
    if((n - 4 * i) % 7 == 0) ans = 1;
  prians(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)

int main(){
    int ans = 1;
    int n;
    cin >> n;
    REP(i,3)
        ans *= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 and i % 5 != 0)ans += i;
	}
	printf("%lld\n", ans);

	Please AC;
}

Measured memory_bytes: 3808
s = input().split()
intA = int(s[0])
#print(intA)
intR = intA
intR2 = intA*intA
intR3 = intA*intA*intA
#print(intR)
#print(intR2)
#print(intR3)
print(intR + intR2 + intR3)

Measured memory_bytes: 9032
import java.util.Comparator;
import java.util.Scanner;

class Main{


	static int[][] map ;
	static long INF =Long.MAX_VALUE/2;
	static int n,m ;
	static	long[] dis;

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)){
			System.out.println("YES");
		}else{
			System.out.println("NO");

		}
		
		
	}
}





class MyComparator implements Comparator {

	public int compare(Object obj1, Object obj2) {

		int num1 = (int)obj1;
		int num2 = (int)obj2;

		if(num1 < num2) {
			return 1;
		} else if(num1 > num2) {
			return -1;
		} else{
			return 0;
		}
	}
}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e6+10;
int ss;
ll dp[1000][2005];

void cal(int n)
{
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=n;++i){
	    ll psum = 0;
		for(int j=3;j<=2000;++j){
		    (psum += dp[i-1][j-3])%=MOD;
		    dp[i][j]=psum;
		}
	}
}

void solve()
{
	if(ss<3){
		cout<<0<<'\n';
		return;
	}
	cal(700);
	ll ans = 1;
	for(int len=2;3*len<=ss;++len){
		(ans += dp[len][ss])%=MOD;
	}
	cout<<ans<<'\n';
}

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

Measured memory_bytes: 19296
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    sort(a,a+n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll ans[k+1];
    ans[0]=0;
    for(ll i=1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(a[j]>i) ans[i]=0;
            else if(ans[i-a[j]]==0) {ans[i]=1; break;}
            else ans[i]=0;
        }
    }
    if(ans[k]==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

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

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

  int x[N][N], y[N][N];
  int A[N];
  rep(i, N) {
    cin >> A[i];
    rep(j, A[i]) {
      cin >> x[i][j] >> y[i][j];
      --x[i][j];
    }
  }

  int ans = 0;
  rep(bit, 1 << N) {
    bool flag = true;
    rep(i, N) {
      if (bit & (1 << i)) {
        // 人iが正直者
        rep(j, A[i]) {
          if (bit & (1 << x[i][j])) {
            // x[i][j]は正直者
            if (y[i][j] == 0)
              flag = false;
          } else {
            if (y[i][j] == 1)
              flag = false;
          }
        }
      }
    }
    if (flag) {
      chmax(ans, __builtin_popcount(bit));
    }
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    string s = to_string(n);

    int sum = 0;
    for (int i = 0; i < s.size(); i++)
    {
        sum += s[i] - '0';
    }

    if (n % sum == 0)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    ll N = S.size(), flag;
    vector<string> t(4);
    t = {"dream", "dreamer", "erase", "eraser"};
    while (N != 0)
    {
        flag = 1;
        rep(0, i, 4)
        {
            if (t.at(i) == S.substr(max((ll)0, (ll)(N - t.at(i).size())), t.at(i).size()))
            {
                flag = 0;
                N -= t.at(i).size();
                break;
            }
        }
        if (flag)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    ll r = 0;
    for (int i = 0; i < n - k; i++) {
        r += h[i];
    }

    cout << r << endl;

    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 h,w,n;
    cin >> h >> w >> n;
    set<pii> isBlack;
    vector<int64> ans(10,0);
    ans[0] = (h-2) * (w-2);
    REP(i,n){
        int64 a,b;
        cin >> a >> b;
        a--;b--;
        FOR(y,a-2,a+1)FOR(x,b-2,b+1){
            if(y < 0 || h-2 <= y)continue;
            if(x < 0 || w-2 <= x)continue;
            int64 cnt = 0;
            REP(j,3)REP(k,3){
                // if(isBlack[y+j][x+k])cnt++;
                if(isBlack.find(pii(y+j,x+k)) != isBlack.end())cnt++;
            }
            ans[cnt]--;
            ans[cnt+1]++;
        }
        // isBlack[a][b] = true;
        isBlack.insert(pii(a,b));
    }
    REP(i,10){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6784
#include<stdio.h>
int main()
{
    float a1, b1, c1, a2, b2, c2;
    while(scanf("%f%f%f%f%f%f",&a1, &b1, &c1, &a2, &b2, &c2)!=EOF)
    {
        float x=(b2*c1-b1*c2)/(a1*b2-a2*b1);
        float y=(c2*a1-c1*a2)/(a1*b2-a2*b1);
        if(x==-0.0) x=0.0;
        if(y==-0.0) y=0.0;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
cin >>N>>K;
string S;
cin >>S;
if(S.at(K-1)=='A'){
  S.at(K-1)='a';
}
  if(S.at(K-1)=='B'){
  S.at(K-1)='b';
}
  if(S.at(K-1)=='C'){
  S.at(K-1)='c';
  }
  cout <<S<<endl;
}
  

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0ll; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using T=tuple<in,in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in k;
    cin>>k;
    queue<T> q;//ans,max,keta
    rep(i,10) q.emplace(i,i,1ll);
    set<in> a;
    REP(i,1,10) a.insert(i);
    in x=0ll;
    in MAX_ans=3234566667ll;
    while(x<1e10){
        in y,z,w;
        tie(w,y,z)=q.front();
        q.pop();
        if(z==1000000000ll && y>4ll) continue;
        z *=10ll;
        q.emplace((y)*z+w,y,z);
        if(y!=0ll) q.emplace((y-1ll)*z+w,y-1ll,z);
        if(y!=9ll && !(y==3ll&&z==1000000000ll)) q.emplace((y+1ll)*z+w,y+1ll,z);
        x=z;
        if(y!=0ll) a.insert((y)*z+w);
        if(y>1ll) a.insert((y-1ll)*z+w);
        if(y!=9ll) a.insert((y+1ll)*z+w);
    }
    rep(i,k-1){
        in mini=*a.begin();
        a.erase(mini);
    }
    cout<<*(a.begin())<<endl;
}

Measured memory_bytes: 12928
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG =  True   and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
b = inl()
seq = [0] * n
for i in range(n-1,-1,-1):
    ok = False
    for j in range(i,-1,-1):
        ddprint("i {} j {} bj {}".format(i,j,b[j]))
        if b[j] == j+1:
            seq[i] = j
            ddprint("j {} to seq i {}".format(j,i))
            b.pop(j)
            ok = True
            break
    ddprint("ok {}".format(ok))
    ddprint(b)
    if not ok:
        print(-1)
        exit()

for i in range(n):
    print(seq[i]+1)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ll n;
    cin >> n;
    ll arr[n] = {0};
    for (ll i = 0; i < n; i++) {
        arr[i] = 0;
    }
    for (ll i = 0; i < n - 1; i++) {
        ll a;
        cin >> a;
        arr[a - 1]++;
    }
    for (ll i = 0; i < n; i++) {
        cout << arr[i] << '\n';
    }


}

Measured memory_bytes: 5184
// abc.cpp : 此檔案包含 'main' 函式。程式會於該處開始執行及結束執行。
//

#include <iostream>

int main()
{
	int a, b, c,d[3];
	char we[3];
	d[0] = 0;
	d[1] = 0;
	d[2] = 0;
	b = 0;
	
	
	for (a = 0; a < 3; a++) {
		scanf("%c", &we[a]);
		if (we[a] == 'R') {
			d[a]=1;
			b++;
		}
	}
	if (b == 0) {
		printf("0");
	}
	else if (b == 1) {
		printf("1");
	}
	else if (b == 2) {
		if ((d[0] == 1) && (d[2] == 1)) {
			printf("1");
		}
		else {
			printf("2");
		}
	}
	else {
		printf("3");
	}
	return 0;
}

// 執行程式: Ctrl + F5 或 [偵錯] > [啟動但不偵錯] 功能表
// 偵錯程式: F5 或 [偵錯] > [啟動偵錯] 功能表

// 開始使用的提示: 
//   1. 使用 [方案總管] 視窗，新增/管理檔案
//   2. 使用 [Team Explorer] 視窗，連線到原始檔控制
//   3. 使用 [輸出] 視窗，參閱組建輸出與其他訊息
//   4. 使用 [錯誤清單] 視窗，檢視錯誤
//   5. 前往 [專案] > [新增項目]，建立新的程式碼檔案，或是前往 [專案] > [新增現有項目]，將現有程式碼檔案新增至專案
//   6. 之後要再次開啟此專案時，請前往 [檔案] > [開啟] > [專案]，然後選取 .sln 檔案


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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		last[a[i]] = i+1;
		for(int j = 0;j < M;j++){
			ans -= c[j] * ((i+1)-last[j]); 
		}
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	const int fin = 1990;
	const double C = fin*1000.0;

	int now_time = 0;
	//int cnt = 0;
	int AS = ans_score;
	short ANS[365];
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(26);
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				if(AS < ans_score){
					memcpy(ANS, ans, sizeof(ans));
					AS = ans_score;
				}
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}
		//cnt++;
	}

	//cerr << cnt << endl;
	output(ANS);

	return 0;
}

Measured memory_bytes: 3840
N = int(input())
prices = [ int(v) for v in input().split(" ") ]

money = 1000
stock = 0
p_price = float("inf")

for i in range(N):
  c_price = prices[i]
  
  # sell strategy
  if c_price > p_price:
    money += int(c_price * stock)
    stock = 0

  # buy strategy
  for j in range(i+1, N):
    if prices[j] > c_price:
      stock += int(money / c_price)
      money -= int(c_price * stock)
      p_price = c_price
      break
    elif prices[j] <= c_price:
      break # wait
      
  #print(money,stock)
print(money)

Measured memory_bytes: 9208
#include<stdio.h>

int main()
{
  long long int a,b,x,ans;

  scanf("%lld %lld %lld",&a,&b,&x);

  if (a%x==0) {
    ans=b/x-a/x+1;
  } else {
    ans=b/x-a/x;
  }
  
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 128
A, B, C, K = map(int,input().split())
# 1 2 3 4
card = K#4
# 取れるカードの数
result = 0
# 得点は0
if card < A: # 4 < 1 false
	print(card)
	# Aのカードを取るだけで済むパターン
else:
	card -= A # 4 - 1
	# print("カード残り",card)
	# Aのカードを取り切ってもまだとれるカードの数
	if card < B:
		print(A)
	else:
		card -= B # 3 - 2
		#print("カード残り", card)
		x = card * -1
		#print("X",x)
		print(A+x)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	bool b = false;
	for(int i = 0; i < 3; i++){
		char c;
		cin>>c;
		if(c == '7')
			b= true;
	}
	if(b)
		cout << "Yes\n";
	else
		cout << "No\n";
}


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


int main() {

  int x,n;
  cin>>x>>n;


  if(n==0)
    cout<<x<<endl;
  else{
    vector<int> p(n);
    for(int i=0;i<n;i++){
      cin>>p.at(i);
    }

    int min_wk=10000;
    int index;
    for(int i=-1;i<=101;i++){
      int wk;
      wk=abs(x-i);
      if(wk<min_wk){
        bool flg=false;
        bool flg2=false;
        for(int j=0;j<n;j++){
          if(i!=p.at(j)){
            flg=true;
          }
          else{
            flg2=true;
          }
        }
        if(!flg2){
            min_wk=wk;
            index=i;
        }
      }
    }

    cout<<index<<endl;
  }



    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int N, C;
vector< tuple<int, int, int> > STC;

vector< vector<int> > schedule(30, vector<int>(MAX_N, 0));

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

    cin >> N >> C;

    REP(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        STC.push_back(make_tuple(s, t, c));
    }
    SORT(STC);

    REP(i, N) {
        int s = get<0>(STC[i]);
        int t = get<1>(STC[i]);
        int c = get<2>(STC[i]);
        // 空きを探す
        int rec = -1;
        REP(j, 30) {
            // 同チャンネル優先
            if(schedule[j][s] == 0 && schedule[j][s-1] == c) {
                rec = j;
                break;
            }
        }
        if(rec == -1) {
            REP(j, 30) {
                if(schedule[j][s] == 0 && schedule[j][s-1] == 0) {
                    rec = j;
                    break;
                }
            }
        }
        //DBG("s: %lld t: %lld c: %lld rec: %lld\n", s, t, c, rec);
        assert(rec >= 0);
        // 録画
        for(int j = s; j < t; ++j) {
            schedule[rec][j] = c;
        }
    }

    int ans = 0;
    REP(j, MAX_N) {
        int cand = 0;
        REP(i, 30) {
            if(schedule[i][j] > 0) { cand = i; }
        }
        chmax(ans, cand + 1);
    }

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

Measured memory_bytes: 28268
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

if N==1:
    print(1)
elif N%2==0:
    print(0.5)
else:
    print(((N//2)+1)/N)
print()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>

int main(){
    //---------------
    // input section
    //---------------
    int n, m;
    std::cin >> n >> m;

    std::vector<std::string> vlvs;
    for(int i = 0; i < m; ++i){
        int k;
        std::cin >> k;
        std::string str(10, '0');
        for(int j = 0; j < k; ++j){
            int val;std::cin >> val;
            ++str.at(10 - val);
        }
        vlvs.push_back(str);
    }

    std::vector<int> p(m);
    for(int i = 0; i < m; ++i){
        std::cin >> p.at(i);
    }

    //--------------------
    // processing section
    //--------------------
    int count = 0;
    for(int i = 0; i < std::pow(2, n); ++i){
        bool flg = true;
        std::bitset<10> numBt(i);
//        std::cout << numBt << std::endl;
        for(int j = 0; j < m; ++j){
            std::bitset<10> refBt(vlvs.at(j));
            refBt &= numBt;
//            std::cout << "" << i << "," << j << ":" << refBt << std::endl;
//            if(refBt.none() || refBt.count() % 2 != p.at(j)){
            if(refBt.count() % 2 != p.at(j)){
                flg = false;
//                break;
            }
        }
        
        if(flg){
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll count[N+1] = {};
  repr(x,1,101) repr(y,1,101) repr(z,1,101) {
    ll sum = x*x + y*y + z*z + x*y + y*z + z*x;
    if (sum<=N) count[sum]++;
  }
  repr(i,1,N+1) cout << count[i] << endl;
  return 0;
}

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

int main() {
    int N,Q;
    cin >> N;
    vector<int> A(N);
    map<int,int> cnt;
    ll sum = 0;
    rep(i,N){
        cin >> A[i];
        cnt[A[i]]++;
        sum += A[i];
    }
    cin >> Q;

    rep(i,Q){
        int B,C;
        cin >> B >> C;
        int cntA = cnt[B];
        int sub = C - B;
        sum += cntA * sub;
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n - 1; j++)
        {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    vector<int> idx(n, n - 2);
    int day = 1;
    set<int> s1, s2;
    vector<int> end;
    for (int i = 0; i < n; i++)
    {
        int rival = a[i][idx[i]];
        if (s1.find(i) != s1.end())
        {
            continue;
        }
        if (s1.find(rival) != s1.end())
        {
            continue;
        }
        if (idx[rival] >= 0 && a[rival][idx[rival]] == i)
        {
            s1.insert(i);
            s1.insert(rival);
            a[i].pop_back();
            a[rival].pop_back();
            idx[i]--;
            idx[rival]--;
        }
    }
    while (true)
    {
        if (end.size() == n)
        {
            break;
        }
        if (s1.empty())
        {
            cout << -1 << endl;
            return 0;
        }
        s2 = s1;
        for (int i : s2)
        {
            if (idx[i] == -1)
            {
                s1.erase(i);
                continue;
            }
            int rival = a[i][idx[i]];
            s1.erase(i);
            if (s1.find(rival) != s1.end())
            {
                continue;
            }
            if (idx[rival] >= 0 && a[rival][idx[rival]] == i)
            {
                s1.insert(i);
                s1.insert(rival);
                a[i].pop_back();
                a[rival].pop_back();
                idx[i]--;
                idx[rival]--;
                if (idx[i] == -1)
                {
                    end.push_back(i);
                }
                if (idx[rival] == -1)
                {
                    end.push_back(rival);
                }
            }
        }
        day++;
    }
    cout << day << endl;
}

Measured memory_bytes: 4352
//fifer a tak luboin
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mp make_pair
#define pb push_back
#define s second
#define f first
#define endl "\n"

// using namespace __gnu_pbds;
using namespace std;
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

const ll inf = (ll)1e14;
const double eps = 1e-10;                                     
const double pi = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll n;
    cin >> n;
    cout << n * n << endl; 
    return 0; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

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

struct Dice{
    vector<int> face;

    void roll(int dir){
        if(dir == -1){
            int tmp = face[0];
            rep(i, 3) face[i] = face[i+1];
            face[3] = tmp;
        }
        if(dir == 0){
            face = {face[4], face[1], face[5], face[3], face[2], face[0]};
        }
        if(dir == 1){
            face = {face[0], face[4], face[2], face[5], face[3], face[1]};
        }
        if(dir == 2){
            face = {face[5], face[1], face[4], face[3], face[0], face[2]};
        }
        if(dir == 3){
            face = {face[0], face[5], face[2], face[4], face[1], face[3]};
        }
    }

    Dice(int top, int front){
        if(top == 1) face = {2, 3, 5, 4, 1, 6};
        if(top == 2) face = {3, 1, 4, 6, 2, 5};
        if(top == 3) face = {1, 2, 6, 5, 3, 4};
        if(top == 4) face = {5, 6, 2, 1, 4, 3};
        if(top == 5) face = {6, 4, 1, 3, 5, 2};
        if(top == 6) face = {4, 5, 3, 2, 6, 1};
        while(face[0] != front) roll(-1);
    }
};

int n;

void solve(){
    map<pii, int> top, height;
    rep(_, n){
        int t, f;
        scanf("%d%d", &t, &f);
        Dice d(t, f);
        int x = 0, y = 0;
        while(true){
            int dir, tv = 0;
            rep(i, 4){
                int nx = x + dx[i], ny = y + dy[i];
                    if(height[{x, y}] > height[{nx, ny}] && chmax(tv, d.face[i])){
                    dir = i;
                }
            }
            if(tv >= 4){
                d.roll(dir);
                x += dx[dir]; y += dy[dir];
            }
            else break;
        }
        ++height[{x, y}];
        top[{x, y}] = d.face[4];
    }
    int cnt[7];
    memset(cnt, 0, sizeof(cnt));
    for(auto p: top) ++cnt[p.se];
    For(i, 1, 7) printf("%d%c", cnt[i], (i == 6 ? '\n' : ' '));
}

int main(){
    while(scanf("%d", &n) && n){
        solve();
    }
}


Measured memory_bytes: 3268
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0


for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            am = 500 * i + 100 * j + 50 * k
            if am == X:
                ans += 1
                break
            else:
                continue

print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;
 
int main() {
    long long N;
    cin >> N;
    string S;
    cin >> S;
    vector<long long> ans;
    
    long long Black = 0; //黒いタイルの数
    long long White = 0; //白いタイルの数

    //白いタイルの数を数える
    for (int i = 0; i < N; i++)
    {
        if(S[i] == '.') {
            White++;
        }
    }

    //wakaranai
    for (int i = 0; i < N; i++)
    {
        if(S[i] == '.') {
            White--;
        }
        ans.push_back(White+Black); //push_back...末尾に追加
        if(S[i] == '#') {
            Black++;
        }
    }
    sort(ans.begin(),ans.end());
    cout << ans[0] << endl;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> L;

int main() {
  cin >> N;
  L.resize(N);
  rep(i, N) cin >> L[i];

  sort(all(L));

  ll ans = 0;
  for (auto it = L.begin(); it != L.end(); it++) {
    for (auto it2 = next(it); it2 != L.end(); it2++) {
      ans += distance(upper_bound(it2, L.end(), abs(*it - *it2)),
                      lower_bound(it2, L.end(), *it + *it2)) -
             1;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000



int main(){
	
	int N;
	cin>>N;
	
	long long K;
	cin>>K;
	
	vector<int> P(N);
	for(int i=0;i<N;i++){
		cin>>P[i];
		P[i]--;
	}
	
	vector<long long> C(N);
	for(int i=0;i<N;i++){
		cin>>C[i];
	}
	
	long long ans = -Inf;
	
	for(int i=0;i<N;i++){
		int now = i;
		vector<long long> costs;
		while(true){
			now = P[now];
			costs.push_back(C[now]);
			if(now==i)break;
		}
		
		long long t = 0LL;
		for(int j=0;j<min(K,(long long)costs.size());j++){
			t += costs[j];
			ans = max(ans,t);
		}
		if(t<0)continue;
		
		
		
		if(K>=costs.size()){
			long long Kc = K;
			
			K -= costs.size();
			t *= (K/costs.size());
			K %= costs.size();
			K += costs.size();
			ans = max(ans,t);
			
			for(int j=0;j<K;j++){
				t += costs[j%costs.size()];
				ans = max(ans,t);
			}
			K = Kc;
		}
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int a[100005];
bool f[100001];
int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> a[i];
    }
    int temp;
    int count = 1;
    f[1] = true;
    for(temp = a[1]; temp != 2; temp = a[temp]) {
        count ++;
        if(f[temp]) break;
        else f[temp] = true;
    }
    if(temp == 2) cout << count << endl;
    else cout << -1 << endl;
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    string tmp = to_string(N);
    if (tmp[0] == '9' || tmp[1] == '9') cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
  vector<int> n(4);
  cin >> n[0] >> n[1] >> n[2] >> n[3];
  sort(n.begin(), n.end());
  if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
def main():
  u = 1  
  n = int(input())
  a = list(map(int,(input().split())))
  
  if 0 in a:
    print(0)
    sys.exit()
	
  for i in a:
    u *=i
    if u > 1000000000000000000:
      print(-1)
      sys.exit()

  print(u)


main()

Measured memory_bytes: 21448