akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 200000000

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }
    int ans_num = INF, ans_min = INF;
    for (int i = 0; i < n; i++)
    {
        ans_num = 1;
        ans_min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
        for (int j = 1; j < m; j++)
        {
            if (ans_min > abs(a[i] - c[j]) + abs(b[i] - d[j]))
            {
                ans_num = j + 1;
                ans_min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            }
        }
        cout << ans_num << endl;
    }

    return 0;
}


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

int main(void){
    string s;
    cin >> s;
    long ans = 0;
    
    for(int i = 0;i < 1 << (s.size() - 1);i++){
          long a = s[0] - '0';
          long b = 0;
          
          for(int j = 1;j < s.size();j++){
                if(i & (1 << (j - 1))){
                      a = a * 10 + (s[j] - '0');
                }else{
                      b += a;
                      a = s[j] - '0';
                }
          }
          b += a;
          ans += b;
    }
    cout << ans << endl;
}


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

int n,m;
int nodes[100001];

int main(){
	cin>>n>>m;
	for(int i=1;i<=100000;i++){
		nodes[i]=0;
	}
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		nodes[b]=max(nodes[b],a);
	}
	int r=0;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(nodes[i]!=0){
			if(nodes[i]>=r){
				r=i;
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var a, b []byte
	fmt.Scan(&a, &b)

	if x, y := len(a), len(b); x > y {
		fmt.Println("GREATER")
	} else if x < y {
		fmt.Println("LESS")
	} else { // x == y
		for i := 0; i < x; i++ {
			if ai, bi := a[i], b[i]; ai > bi {
				fmt.Println("GREATER")
				return
			} else if ai < bi {
				fmt.Println("LESS")
				return
			} else {
				fmt.Println("EQUAL")
				return
			}
		}
	}
}


Measured memory_bytes: 512
#if TEST
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
#endif

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_156_b
    {
        
#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var ar = ReadIntArray();

            int N = ar[0];
            int K = ar[1];

            Console.WriteLine(Solve(N,K).ToString());
        }

        private static int Solve(int n, int k)
        {
            // N を K 進法で 表すと
            int l = 0;
            while(n > 0)
            {
                n = n / k;
                l++;
            }

            return l;
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
#if TEST
#else
    }
}
#endif

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long a,b,num,fin=1;
    cin >> num;
    deque<long long> list;
    for (long long i=0; i<num; i++) {cin >> a; list.push_back(a);}
    sort(list.begin(),list.end());
    a=list[0];
    for (long long i=1; i<num; i++) {
        b=list[i]; 
        if (a==b){}
        else {fin++;}
        a=b;}
    cout << fin;}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int a[4];
    for(int i = 0; i < 4; i++){
        cin >> a[i];
    }
    int ans = 0;
    ans = max({a[0] * a[2], a[0] * a[3],a[1] * a[2],a[1] * a[3]});
    if((a[0] <= 0 && 0 <= a[1]) || (a[2] <= 0 && 0 <= a[3])){
        ans = max(ans,0LL);
    }
    cout << ans;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

int divVal;
string digit;
//vector<int>v;

ll dp[10009][101][2];

ll recur(int pos, int sum, bool tight) {
    //getchar();
    //for(auto it : v)
    //    cerr << it;
    //cerr << " :: " << pos << ", " << sum << ", " << tight << endl;

    ll &ret = dp[pos][sum][tight];
    if(pos >= digit.size()) {
        /*if(sum == 0) {
            for(auto it : v)
                cerr << it;
            cerr << " :: " << pos << ", " << sum << ", " << tight << endl;
        }*/
        return (sum == 0);
    }

    if(ret != -1)
        return ret;
    ret = 0;

    int lim = tight ? (digit[pos]-'0'):9;
    for(int i = 0; i <= lim; ++i) {
        bool newTight = (i == lim) ? tight:0;
        int newSum = (sum + i)%divVal;
        //v.push_back(i);
        //cerr << "AT POS " << pos << " lim " << lim << " placing " << i << " tight " << tight << endl;
        ret += recur(pos+1, newSum, newTight);
        if(ret >= MOD)
            ret %= MOD;
        //v.pop_back();
    }

    return ret;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> digit;
    cin >> divVal;
    ll ans = (recur(0, 0, 1) - 1 + MOD)%MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17024
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){


	string s;

	cin>>s;

	for(int i=0; i<s.size()-8; ++i){
		cout<<s[i];
	}
	cout<<endl;

	return 0;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
deque<int> pos[30];
const int maxn=2e5+7;
int tree[maxn];
void add(int x)
{
    x++;
    while(x<maxn)
    {
        tree[x]++;
        x+=x&-x;
    }
}
int query(int x)
{
    x++;
    int ret=0;
    while(x>0)
    {
        ret+=tree[x];
        x-=x&-x;
    }
    return ret;
}
inline int query(int l,int r)
{
    return query(r)-query(l-1);
}
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
        pos[s[i]-'a'].push_back(i);
    int odd=0;
    for(int i=0;i<26;i++)
        odd+=pos[i].size()&1;
    if(odd>1||(odd==1&&(s.length()%2==0))) print(-1);
    else{
        ll ans=0;
        for(int i=0;i<s.length()/2;i++)
        {
            int tar=-1,cost=0x3f3f3f3f;
            for(int j=0;j<26;j++)
            {
                if(pos[j].size()<2) continue;
                int cur=pos[j].front()-query(0,pos[j].front())+s.length()-1-pos[j].back()-query(pos[j].back(),s.length()-1);
                if(cur<cost)
                {
                    cost=cur;
                    tar=j;
                }
            }
            add(pos[tar].back());
            add(pos[tar].front());
            pos[tar].pop_back();
            pos[tar].pop_front();
            ans+=cost;
        }
        print(ans);
    } 
}

Measured memory_bytes: 2052
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int h,w;cin>>h>>w;
  int n = h*w;
  vvi block(h, vi(w));
  rep(i, h){
    string s;cin>>s;
    rep(j, w){
      block[i][j] = (s[j]=='.'?0:1);
    }
  }
  dump_2d(block, h, w);

  vvi g(n);
  int di[]={1, -1, 0, 0};
  int dj[]={0, 0, 1, -1};
  rep(i, h)rep(j, w){
    if (block[i][j]) continue;
    int u = i*w+j;

    rep(k, 4){
      int ni = i+di[k];
      int nj = j+dj[k];
      int v = ni*w + nj;
      if (is_in(ni, 0, h) && is_in(nj, 0, w) && !block[ni][nj]){
        g[u].pb(v); // 自分から生える辺だけでよい。そうしないと二重辺になってしまう。
      }
    }
  }
  dump(g);
  
  int ans = 1;
  rep(i, h)rep(j, w){
    if (block[i][j]) continue;

    int u = i*w+j;
    queue<int> q;
    vector<int> used(n);
    q.push(u);
    vi d(n, INF);
    d[u] = 0;
    while (!q.empty()){
      auto u = q.front();q.pop();
      if (used[u]) continue;
      used[u] = 1;
      chmax(ans, d[u]);
    
      each(v, g[u]){
        if (d[u]+1<d[v]){
          d[v] = d[u]+1;
          q.push(v);
        }
      }
    }
  }
  assert(ans<INF);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

constexpr unsigned int MAX_N = 200;
unsigned int A[MAX_N + 1];
constexpr unsigned int mod = 1'000'000'007; //'
constexpr unsigned int MAX_V = 100'000; // '

unsigned int DP[MAX_N + 1][MAX_V + 1];

int main(void){
    unsigned int n, X; scanf("%u%u", &n, &X);
    for(unsigned int i = 0; i < n; ++i) scanf("%u", A + i);
    std::sort(A, A + n);

    for(unsigned int i = 1; i <= X; ++i) DP[0][i] = i;
    for(unsigned int i = 0; i < n; ++i){
        for(unsigned int j = 0; j <= X; ++j){
            DP[i + 1][j] = ( (unsigned long long int)(DP[i][j]) * i + DP[i][j % A[i]] ) % mod;
        }
    }
    printf("%u\n", DP[n][X]);
    return 0;
}

Measured memory_bytes: 78720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll n; cin >> n;
	ll ans = 1001001001001;
	for(ll i=1; i<sqrt(n)+1; i++){
		if( n%i==0 ) ans = min(ans,i-1+n/i-1);
	}
	out(ans);
}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
using int64 = long long int;

const int64 MOD = 1000000007;
int64 dp[51][51][2501];
int main() {
    int N, K; cin >> N >> K;
    dp[0][0][0] = 1;
    for(int i=0; i<N; i++) {
        int num = N - i;
        for(int j=0; j<=i; j++) {
            for(int k=0; k<=N*N; k++) {
                if(!dp[i][j][k]) continue;
                // 要素を入れる
                // いま見てるところにそのまま入れる
                (dp[i+1][j][k] += dp[i][j][k]) %= MOD;
                // 前で保留にしていたところに入れ、現在の場所はとっておく
                (dp[i+1][j][k] += j * dp[i][j][k]) %= MOD;
                // 前で保留にしていたところに入れ、現在の場所にもなにか入れる
                if(j) (dp[i+1][j-1][k-2*num] += j * j * dp[i][j][k]) %= MOD;

                // 保留にしてあとで使う
                // 前で保留にしてたものを入れる
                (dp[i+1][j][k] += j * dp[i][j][k]) %= MOD;
                // 前で保留にしてたものも全てとっておく
                (dp[i+1][j+1][k+2*num] += dp[i][j][k]) %= MOD;
            }
        }
    }

    int ans = dp[N][0][K];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 48512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    deque<int> dq;
    rep(i, n) {
        int a;
        cin >> a;
        if (n % 2 == 0) {
            if (i % 2 == 0) dq.push_back(a);
            else dq.push_front(a);
        } else {
            if (i % 2 == 0) dq.push_front(a);
            else dq.push_back(a);
        }
    }

    rep(i, n) {
        cout << dq[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class TreesAndBrackets
{
    public:
string check(string t1, string t2)
{

}
};
int main()
{
    int a,b;
    while(cin>>a>>b){

        char mapr[105][105]={};

        for(int i=0;i<50;i++){
            for(int j=0;j<100;j++){
                mapr[i][j]='.';
            }
        }

        for(int i=50;i<100;i++){
            for(int j=0;j<100;j++){
                mapr[i][j]='#';
            }
        }
        a--,b--;
        int now=0;
        while(b){

                for(int j=0;j<100;j+=2){
                    mapr[now][j]='#';
                    b--;
                    if(b==0)
                        bk;
                }
                now+=2;


        }
        now=99;
        while(a){
                for(int j=0;j<100;j+=2){
                    mapr[now][j]='.';
                    a--;
                    if(a==0)
                        bk;
                }
                now-=2;


        }
        cout<<100<<" "<<100<<endl;

        for(int i=0;i<100;i++){
            cout<<mapr[i]<<endl;
        }

    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

using graph = vector<vector<int>>;
 
void dfs(int v, const graph& G, vector<int>& res, vector<int>& used) {
    used[v] = 1;
    for (auto to : G[v]) if (used[to] == 0) {
        dfs(to, G, res, used);
    }
    res.push_back(v);
    //cout<<v<<endl;
}
 
vector<int> topo_sort(const graph& G) {
    int V = G.size();
    vector<int> ide(V);
    for (int i = 0; i < V; i++) {
        for (auto to : G[i]) {
            //cout<<to<<endl;
            ide[to]++;
        }
    }
    vector<int> res;
    vector<int> used(V);
    for (int i = V - 1; i >= 0; i--) {
        if (ide[i] == 0) {
            //cout<<i<<endl;
            dfs(i, G, res, used);
        }
    }
    if(res.size()==0) res={-1};
    reverse(res.begin(), res.end());
    return res;
}

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

    int n;
    while(cin>>n,n){
        vector<string> s(n);
        for(int i=0;i<n;i++) cin>>s[i];
        if(n==1){
            cout<<"yes"<<endl;
            continue;
        }
        graph g(26);
        for(int i=1;i<n;i++){
            int len=min(s[i-1].length(),s[i].length());
            for(int j=0;j<len;j++){
                if(s[i-1][j]==s[i][j]) continue;
                int st=s[i-1][j]-'a',gt=s[i][j]-'a';
                g[st].push_back(gt);
                break;
            }
        }
        vector<int> res=topo_sort(g);
        //cout<<res.size()<<endl;
        if(res.size()!=26){
            cout<<"no"<<endl;
            continue;
        }
        map<int,int> mp;
        for(int i=0;i<26;i++){
            mp[res[i]]=i;
        }
        for(int i=0;i<n;i++){
            int len=s[i].length();
            for(int j=0;j<len;j++){
                int idx=s[i][j]-'a';
                idx=mp[idx];
                s[i][j]='a'+idx;
            }
        }
        bool f=true;
        for(int i=1;i<n;i++){
            if(s[i-1]>s[i]) f=false;
        }
        if(f) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3188
n = int(input())
s = []
for i in range(n):
  s.append(input())

words = set()
cnt = dict()
for i in range(n):
  if s[i] not in words:
    words.add(s[i])
    cnt[s[i]] = 1
  else:
    cnt[s[i]] += 1

top_words = []
max_val = 0
for k, v in cnt.items():
  if v > max_val:
    max_val = v
    top_words = [k]
  elif v == max_val:
    top_words.append(k)

top_words =sorted(top_words)
for i in range(len(top_words)):
  print(top_words[i])

Measured memory_bytes: 43356
#include <stdio.h>
#define Cn 100

struct card{char suit,value;};

void bubble(struct card C[],int N){
  int i,j;
  struct card k;
  for(i=0;i<=N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(C[j].value < C[j-1].value){
	k = C[j]; C[j] = C[j-1]; C[j-1] = k;
      }
    }
  }
}

void selection(struct card C[],int N){
  int i,j,minj;
  struct card k;
  for(i=0;i<=N-1;i++){
    minj = i;
    for(j=i;j<=N-1;j++){
      if(C[j].value < C[minj].value) minj = j;
    }
    k = C[i]; C[i] = C[minj]; C[minj] = k;
  }
}

int jgS(struct card C1[],struct card C2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit) return 1;
  }

  return 0;
}

int main(){
  int N,i;
  struct card C1[Cn],C2[Cn];
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf(" %c%c",&C1[i].suit,&C1[i].value);
    C2[i] = C1[i];
  }

  bubble(C1,N);
  selection(C2,N);

  for(i=0;i<N;i++){
    printf("%c%c",C1[i].suit,C1[i].value);
    if(i != N-1) printf(" ");
  }
  printf("\n");
  printf("Stable\n");
  
  for(i=0;i<N;i++){
    printf("%c%c",C2[i].suit,C2[i].value);
    if(i != N-1) printf(" ");
  }
  printf("\n");
  if(jgS(C1,C2,N) == 1) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}
  



Measured memory_bytes: 2056
#include<stdio.h>
int main() {
  int x,y;
  scanf("%d %d",&x,&y);
  
  for (int i=0;i<=x;i++) {
    
    if (i*2+(x-i)*4==y) {
      printf("Yes\n");
      break;
    }
    if (i==x) {
      printf("No\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1656
/*
Name                     : Harry Singh (:)
Age                      : 20 (:)
College                  : Lovely Professional University (:)
Email                    : harryamneet600@gmail.com (:)
Hobbies                  : Coding and Typeracer (:)
Goal                     : Long term is fixed and Short term is changing everyday (:)
Relatoinship Status      : Single (:)
Phone no                 : 91-********77 (:)
Waheguru Ji ka Khalsa, Waheguru Ji ki Fateh;
*/
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define double double
#define io ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define ipair pair<int,int>
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,n) for(int i=n;i>=0;i--)
#define F(i,n) for(int i=1;i<=n;i++)
#define f_a(a,i,n) for(int i=a;i<=n;i++)
#define f_b(a,i,b) for(int i=a;i<=b;i++)
#define FO(i,n) for(int i=n;i>=1;i--)
#define mod 1000000007
using namespace std;
#define tr cout<<"\n" 
#define br break
#define N 100005 
#define inf 10000000000000009
#define br break
/*  I know I have that Ability, I can do anything, 
I'll be The _Candidate Master_ 
(Patience and Practice)  */
 
//* ************************************************* Think Simple **********************************************************//
//************************************************HINTS******************************************************//
/* 
1. If we have to make Xor of 3 elements -> X, 3 elements will be Unique, ans->    (z^x^y)^y^z;  this will give us X
2. 
*/

void Waheguru()
{
  
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max({a*c,a*d,b*c,b*d});
  tr;
}
 
 
int32_t main()
{
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
    io;
    int g=1;
    while (g--)Waheguru();
    return 0;
}

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

int main()
{
    int n, d;
    cin >> n >> d;
    int x[n+1][d+1];
    
    for( int i = 1; i < n+1; i++){
        for( int j = 1; j < d+1; j++){
            cin >> x[i][j];
        }
    }

    int num = 0;
    for( int i = 1; i < n+1; i++){
        for( int j = i+1; j < n+1; j++){
            int distance=0;
            for( int k = 1; k < d+1; k++){
                distance += pow( x[i][k] - x[j][k], 2 );
            }
            double sqqrt = sqrt( (float)distance );
            if( (int)sqqrt == sqrt( (float)distance ) ) num ++;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double sum = 0;
            for(int i=0; i<N; i++)
            {
                string S = Console.ReadLine();
                string[] data = S.Split(' ');
                if (data[1].Equals("JPY"))
                {
                    int en = int.Parse(data[0]);
                    sum = sum + en;
                }
                else
                {
                    double btc = double.Parse(data[0]);
                    sum = sum + btc * 380000.0;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

int n, t;
vector<vector<int> > graph;
vector<int> d, f;
vector<bool> visited;

void dfs(int node){
    visited[node] = true;
    d[node] = t;
    t++;
    for(int i=0;i<int(graph[node].size());i++){
        int nxt = graph[node][i];
        if(!visited[nxt]){
            dfs(nxt);
        }
    }
    f[node] = t;
    t++;
}

int main(){
    cin >> n;
    graph.resize(n);
    d.resize(n);
    f.resize(n);
    visited.resize(n, false);
    for(int i=0;i<n;i++){
        int u, k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int v;
            cin >> v;
            graph[u-1].push_back(v-1);
        }
    }
    t = 1;
    for(int i=0;i<n;i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    for(int i=0;i<n;i++){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3172
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.io.IOException;
import java.lang.String;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.BitSet;
import java.io.IOException;
import java.util.Arrays;
import java.util.GregorianCalendar;

public class Main {

    static BigInteger modulo = new BigInteger("1000000007");
    static long mod = 1000000007;
//    Nested ststic class FastReaders

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException io) {
                io.printStackTrace();
            }
            return s;
        }
    }

    static BigInteger exponentialModulo(BigInteger a, BigInteger b) {
        BigInteger previousNumber = BigInteger.ONE;
        while (!(b.equals(BigInteger.valueOf(0)))) {
            if (b.testBit(0)) {
                previousNumber = previousNumber.multiply(a).mod(modulo);
            }
            b = b.shiftRight(1);
            a = a.modPow(BigInteger.valueOf(2), modulo);
        }
        return previousNumber;
    }

    public static int applySearchOfSubstring(String text) {
        int count = 0;
        Pattern p = Pattern.compile("AB");
        Matcher m = p.matcher(text);
        while (m.find()) {
            ++count;
        }

        return count;
    }

    public static void main(String[] args) throws IOException {
        FastReader input = new FastReader();
        long r = input.nextInt();
        long d = input.nextInt();
        long x = input.nextInt();
        for(int i = 0;i < 10;++i){
            x = x*r-d;
            System.out.println(x);
        }
    }

}


Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <queue>
#define P pair<int, int>
using namespace std;

const int MAX_H = 1000, MAX_W = 1000;

int H, W, N;
char C[MAX_H][MAX_W + 1];

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int d[MAX_H][MAX_W];
int sx, sy, gx, gy;

int bfs() {
	queue<pair<int, int>> que;
	que.push(make_pair(sx, sy));
	d[sx][sy] = 0;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gx && p.second == gy) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W && C[nx][ny] != 'X' && d[nx][ny] == -1) {
				que.push(make_pair(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

void solve() {
	int ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (C[i][j] == 'S') {
				sx = i;
				sy = j;
			}
		}
	}

	for (int c = 1; c <= N; c++) {
		memset(d, -1, sizeof(d));

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (C[i][j] - '0' == c) {
					gx = i;
					gy = j;
				}
			}
		}
		ans += bfs();
		sx = gx;
		sy = gy;
	}

	printf("%d\n", ans);
}

int main() {
	scanf("%d %d %d", &H, &W, &N);
	for (int i = 0; i < H; i++) {
		scanf("%s", C[i]);
	}

	solve();
}



Measured memory_bytes: 7540
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		char[] s = sc.next().toCharArray();
		sc.close();
		long r=0,g=0,b=0;
		for (i = 0; i < s.length; i++) {
			switch(s[i]) {
				case 'R':
					r++;
					break;
				case 'G':
					g++;
					break;
				case 'B':
					b++;
					break;
			}
		}
		long total=r*g*b;
		for (i = 1; i < s.length-1; i++) {
			for (j = 1; Math.min(i-j, s.length-1-i-j) >=0; j++) {
				if(s[i-j]!=s[i]&&s[i]!=s[i+j]&&s[i-j]!=s[i+j]) total--;
			}
		}
		out.println(total);
	}
}


Measured memory_bytes: 35796
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  N,K=LI()
  P=LI()
  P=[0]+P
  C=LI()
  C=[0]+C

  l=[[0] for _ in range(N)]
  check=[[False]*(N+1) for _ in range(N)]
  roop=[]
  for i in range(N):
    zahyo=i+1
    check[i][zahyo]=True
    f=False
    for j in range(N+1):
      zahyo=P[zahyo]
      if check[i][zahyo] and not f:
        roop.append(j+1)
        f=True
      score=C[zahyo]
      l[i].append(l[i][-1]+score)
  # for i in range(N):
  #   print(l[i])
  # print(roop)

  ans=-inf
  for i in range(N):
    roop_count=roop[i]
    if K<=roop_count:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内
    else:
      ans=max(ans,max(l[i][1:K+1])) # 1巡以内

      # 2巡目以降（1巡で負になるなら回らない方がいい）
      if l[i][roop_count]>0:
        c=K//roop_count
        _ans1=c*l[i][roop_count]
        k=K%roop_count
        _ans1+=max(l[i][1:k+1]+[0])
        ans=max(ans,_ans1)

        # 可能な巡数まで行かない方がいい場合も
        _ans2=(c-1)*l[i][roop_count]
        _ans2+=max(l[i][:roop_count]+[0])
        ans=max(ans,_ans1,_ans2)

  return ans

# main()
print(main())


Measured memory_bytes: 494180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll MOD = ll(1e9) + 7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    ll sum = 0;
    rep(i,n) sum += a.at(i);
    ll t = 0;
    ll ans = 0;
    rep(i,n-1){
        t += a.at(i);
        ans += (a.at(i)%MOD)*((sum - t)%MOD)%MOD;
    }
    cout << ans%MOD << endl;
}

Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int x[] = new int[w];

        int i;
        for(i = 0; i < w; i++){
            x[i] = i + 1;
        }

        int j, t;
        for(j = 0; j < n; j++){
            String str = sc.next();
            String[] s =str.split(",");
            int a = Integer.parseInt(s[0]) - 1;
            int b = Integer.parseInt(s[1]) - 1;
            t = x[a];
            x[a] = x[b];
            x[b] = t;
        }

        int k;
        for(k = 0; k < w; k++){
            System.out.println(x[k]);
        }

        sc.close();

    }
}


Measured memory_bytes: 26236
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

map<pair<ll, ll>, ll> dp;
ll k[100000*2 +10];

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  ll a,b,c;
  ll A, B, C;
  cin >> n >> A  >> B >> C;
  a = A * inverse(A + B) % mod;
  b = B * inverse(A + B) % mod;
  c = inverse((100 - C) * inverse(100) % mod);
  ll ans = 0;
  k[0] = 1;
  REP(i, 2*n) k[i+1] = k[i] * (i+1) % mod;
  REP(i, n) {
    ll nikou = k[n+i-1] * inverse(k[i]) % mod * inverse(k[n-1]) % mod;
    ll p_a = power(a, n, mod) * power(b, i, mod) % mod * nikou % mod;
    ll p_b = power(b, n, mod) * power(a, i, mod) % mod * nikou % mod;
    ll cnt = c * (n+i) % mod;
    // cout << cnt << endl;
    ll tmp = cnt * ((p_a + p_b) % mod) % mod;
    ans += tmp;
    ans %= mod;
    nikou = nikou * (n+i+1) % mod * inverse(i+1) % mod;
    // cout  << p_a << ":" << p_b << ":" << tmp << endl;
    // cout << "inverse:" << inverse(i + 1) << endl;
    // cout << "nikou:" << nikou << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N=int(input())
    if N==0:
        exit()
    L=list(map(int,input().split()))
    ave = sum(L)//N
    L = sorted(L)
    low = bisect.bisect_right(L,ave)
    print(low)

while True:
    solve()




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

const int MOD = 1e9 + 7;

string s[1002];

int dp[1002][1002];

int main(){
	int h,w;
	cin>>h>>w;
	
	for(int i=0; i<h ;i++){
		cin>>s[i];
	}
	
	dp[0][0] = 1;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j] == '#'){
				dp[i][j] = 0;
				continue;
			}
			if(i > 0) dp[i][j] += dp[i-1][j];
			dp[i][j] %= MOD;
			if(j > 0) dp[i][j] += dp[i][j-1];
			dp[i][j] %= MOD;
		}
	}
	
	cout<<dp[h-1][w-1];
	
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;
  cin >> N;
  
  long ans = 0;
  
  ans += N / 11;
  ans = ans * 2;
  int tmp = N % 11;
  if(tmp==0){
    //
  } else if(tmp > 6){
    ans += 2;
  } else {
    ans += 1;
  }
  cout << ans << endl;

} 

Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);

	int train = A < B ? A : B;
	int bus = C < D ? C : D;
	int res = train + bus;

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

Measured memory_bytes: 128
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	cout << ((a + b) % 2 == 0 ? (a + b) / 2 : (a + b) / 2 + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private class Node {
        List<Integer> path = new ArrayList<>();
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        Node nodes[] = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nodes[a - 1].path.add(b);
            nodes[b - 1].path.add(a);
        }

        int tmp = nodes[0].path.get(0);
        BitSet bset = new BitSet();
        bset.set(1);
        bset.set(tmp);
        LinkedList<Integer> ans = new LinkedList<>();
        ans.add(1);
        ans.add(tmp);
        boolean send = false;
        boolean eend = false;
        while (!send || !eend) {
            if (!send) {
                send = true;
                int s = ans.getFirst();
                for (Integer sp : nodes[s - 1].path) {
                    if (!bset.get(sp)) {
                        bset.set(sp);
                        ans.addFirst(sp);
                        send = false;
                        break;
                    }
                }
            }
            if (!eend) {
                eend = true;
                int e = ans.getLast();
                for (Integer ep : nodes[e - 1].path) {
                    if (!bset.get(ep)) {
                        bset.set(ep);
                        ans.addLast(ep);
                        eend = false;
                        break;
                    }
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        for (Integer p : ans) {
            sb.append(p);
            sb.append(" ");
        }
        System.out.println(ans.size());
        System.out.println(sb.toString().trim());
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 106500
N, M = map(int, input().split())

Adj = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    Adj[a].append(b)
    Adj[b].append(a)

Q = int(input())
v, d, c = [0]*Q, [0]*Q, [0]*Q
for i in range(Q):
    v[i], d[i], c[i] = map(int, input().split())

memo = [[0] * (10+1) for i in range(N+1)]


def paint(v, d, i):
    # すでに塗られていたらもう先は見ない
    if memo[v][d]:
        return

    # 塗られていなければ何番目の操作で色が塗られたかを覚えておく
    memo[v][d] = i

    # 距離-1は存在しないので終了ストッパー
    if d == 0:
        return

    # 何番目の操作で色が塗られたかを0まで伝播
    paint(v, d-1, i)

    # 今見ているところの隣接頂点について同じことをやりにいく
    # ただし離れるにつれて届く範囲は1ずつ減っていく
    for u in Adj[v]:
        paint(u, d-1, i)


# 逆順にクエリを処理
for q in range(Q-1, -1, -1):
    paint(v[q], d[q], q+1)


for i in range(1, N+1):
    # 操作が加わった形跡があれば、それが何番目の操作であるか確認し、その操作に該当する色を取りに行く
    if memo[i][0] != 0:
        print(c[memo[i][0]-1])
    else:
        print(0)


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

const ll mod = 1000000007;
const int INF = 1001001001;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll x, k, d; cin >> x >> k >> d;
	ll cnt = abs(x)/d;
	if(cnt >= k){
		if(x < 0){
			cout << abs(x + d * k) << endl;
		}
		else{
			cout << x - d * k << endl;
		}
	}
	else{
		ll now, res = k - cnt;
		if(x < 0){
			now = x + d * cnt;
			cout << (res % 2 ? now + d : abs(now)) << endl;
		}
		else{
			now = x - d * cnt;
			cout << (res % 2 ? abs(now - d): now) << endl;
		}
	}
} 


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, k, n) for (int i = k; i <= n; ++i)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b, c;
    cin >> a >> b >> c;
    
    swap(a, b);
    swap(a,c);
    
    
    cout << a << " " << b << " " << c;
    cout <<"\n";

    return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
   X = INT()

   print(X//500*1000 + X%500//5*5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
// Five Antennas

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

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

    if (e - a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
number = gets.chomp.to_i
answer_arr = [0,0,0,0]
number.times do
  rank = gets.chomp
  if rank == 'AC'
    answer_arr[0] += 1
  elsif rank == 'WA'
    answer_arr[1] += 1
  elsif rank == 'TLE'
    answer_arr[2] += 1
  elsif rank == 'RE'
    answer_arr[3] += 1
  end
end

puts "AC x #{answer_arr[0]}"
puts "WA x #{answer_arr[1]}"
puts "TLE x #{answer_arr[2]}"
puts "RE x #{answer_arr[3]}"

Measured memory_bytes: 14356
#include <cstdio>
#include <algorithm>

using std::max;

const int MAXN=100;
int bit[MAXN],sum[MAXN];

int main(){
	long long n;
	scanf("%lld",&n);
	while(n){
		bit[++bit[0]]=n%10;
		n/=10;
	}
	for(int i=bit[0];i;--i)
		sum[i]=sum[i+1]+bit[i];
	int ans=0;
	for(int i=bit[0],tmp=0;i;--i){
		tmp=sum[i+1];
		tmp+=bit[i]-1;
		tmp+=9*(i-1);
		ans=max(ans,tmp);
	}
	printf("%d",max(ans,sum[1]));
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main(){
    ll N,M,s,t,e;
    cin >> N >> M;
    vector<ll> S,T,E,c(N);
    while(cin >> s >> t >> e, s){
	S.push_back(s-1);
	T.push_back(t-1);
	E.push_back(e);
    }
    ll L;
    cin >> L;
    for(int i = 0 ; i < L ; i++){
	ll b[M];
	for(int j = 0 ; j < N ; j++){
	    c[j] = 0;
	}
	for(int j = 0 ; j < M ; j++){
	    cin >> b[j];
	}
	for(int j = 0 ; j < (int)S.size() ; j++){
	    c[S[j]] += b[T[j]]*E[j];
	}
	for(int j = 0 ; j < N ; j++){
	    if(j > 0){ cout << " "; }
	    cout << c[j];
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    
  int main(){
      lint N,K;
      cin>>N>>K;
      lint A[N];
      rep(i,N){
          cin>>A[i];
      }
      sort(A,A+N);
      lint min=0;
      lint max=0;
      COMinit();
      rep(i,N-K+1){
          lint g=A[i]*COM(N-i-1,K-1);
          g%=MOD;
          if(g<0)g+=MOD;
          min+=g;
          min%=MOD;
      }
       sort(A,A+N,greater<lint>());
         rep(i,N-K+1){
             lint g=A[i]*COM(N-i-1,K-1);
             g%=MOD;
             if(g<0)g+=MOD;
          max+=g;
          max%=MOD;
      }
     if(max-min<0)cout<<max-min+MOD;
     else cout<<(max-min)%MOD;
      

    }
     
  


Measured memory_bytes: 235392
import java.util.*;

public class Main{

    static long gcd(long a,long b){
        if(b==0)return a;
        return gcd(b,a%b);
    }

    static long lcm(long a,long b){
        return a/gcd(a,b)*b;
    }
    public static void main(String[] srgs){
        Scanner sc=new Scanner(System.in);

        long a=sc.nextLong(),t=2,out=0;
        if(a%2==1){
            System.out.println(0);
        }else{
            while(true){
                t*=5;
                long c=a/t;
                if(c==0)break;
                out+=c;
            }
            System.out.println(out);
        }
    }
}


Measured memory_bytes: 21844
result = [0, 0, 0] 
for i in range(10):
 inp = int(raw_input())
 if result[2] >= inp:
  continue
 elif result[1] >= inp > result[2]:
  result[2] = inp
 elif result[0] >= inp > result[1]:
  result[2] = result[1]
  result[1] = inp
 else:
  result[2] = result[1]
  result[1] = result[0]
  result[0] = inp


for i in range(3):
 print result[i]

Measured memory_bytes: 6404
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<stack>
#include<string>
#include<vector>

#define ll long long
#define ull unsigned long long

using namespace std;
int main(void) {
	int N = 0,ans = 0;
	scanf("%d", &N);

	if (N < 3) {
		printf("1\n");
		return 0;
	}

	for (int i = 2; i * i <= N; i++) {
		for (int j = 2;; j++) {
			if (pow(i, j) > N)
				break;
			if (pow(i, j) > ans)
				ans = pow(i, j);
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
// #define int long long  

//////////

signed main()
{
	fastio;
	string s;
	cin>>s;
	int n=s.length();
	int dp0[n]={},dp1[n]={};
	if(s[0]=='0')
		dp1[0]=1;
	else
		dp0[0]=1;
	for(int i=1;i<n;++i)
	{
		if(s[i]=='0')
		{
			dp0[i]=dp1[i-1];
			dp1[i]=dp0[i-1]+1;
		}
		else
		{
			dp0[i]=dp1[i-1]+1;
			dp1[i]=dp0[i-1];
		}
	}
	cout<<min(dp0[n-1],dp1[n-1]);
}

Measured memory_bytes: 1232