akhauriyash/Code-Regression huggingface dataset:
//E
//by Cydiater
//2017.6.3
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define up(i,j,n)	for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)
#define pii		pair<int,int>
#define fi		first
#define se		second
#define FILE		"three"
 
const int MAXN=305;
const int oo=0x3f3f3f3f;
const int mod=1e9+7;
 
int f[MAXN][MAXN][MAXN],N,M;
vector<pii>pre[MAXN];
ll ans=0;
 
namespace solution{
	bool ok(int r,int g,int b){
		int p=max(r,max(g,b));
		up(i,0,(int)pre[p].size()-1){
			ll l=pre[p][i].fi,c=pre[p][i].se;
			if(r>=l)c--;
			if(g>=l)c--;
			if(b>=l)c--;
			if(c!=0)return 0;
		}
		return 1;
	}
	void Prepare(){
		scanf("%d%d",&N,&M);
		up(i,1,M){
			int l,r,c;
			scanf("%d%d%d",&l,&r,&c);
			pre[r].push_back(make_pair(l,c));
		}
	}
	void Solve(){
		f[1][0][0]=f[0][1][0]=f[0][0][1]=1;
		up(i,1,N){
			up(x,0,i)up(y,0,i){
				if(!ok(x,y,i))f[x][y][i]=0;
				(f[x][y][i+1]+=f[x][y][i])%=mod;
				(f[x][i+1][i]+=f[x][y][i])%=mod;
				(f[i+1][y][i]+=f[x][y][i])%=mod;
				if(!ok(x,i,y))f[x][i][y]=0;
				(f[x][i][i+1]+=f[x][i][y])%=mod;
				(f[x][i+1][y]+=f[x][i][y])%=mod;
				(f[i+1][i][y]+=f[x][i][y])%=mod;
				if(!ok(i,x,y))f[i][x][y]=0;
				(f[i][x][i+1]+=f[i][x][y])%=mod;
				(f[i][i+1][y]+=f[i][x][y])%=mod;
				(f[i+1][x][y]+=f[i][x][y])%=mod;
			}
		}
		up(i,0,N-1)up(j,0,N-1)(ans+=1LL*f[N][i][j]+f[i][N][j]+f[i][j][N])%=mod;
		cout<<ans<<endl;
	}
}
 
int main(){
	//freopen(FILE".in","r",stdin);
	//freopen(FILE".out","w",stdout);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}

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

int main(){
  int n;
  for(;cin>>n,n;)
    {
      string s;
      int data[n];
      memset(data,0,sizeof(data));
      cin>>s;
      int mem=0;
      int fi=0;

      for(int i=0;i<s.size();i++)
	{
	  data[mem]++;
	  if(s[i]=='S')
	    {
	      fi+=data[mem];
	      data[mem]=0;
	    }
	  if(s[i]=='L')
	    {
	      data[mem]+=fi;
	      fi=0;
	    }
	  mem++;
	  if(mem>=n)
	    mem=0;
	}
      sort(data,data+n);
      for(int i=0;i<n;i++)
	{
	  cout<<data[i]<<" ";
	}
      cout<<fi<<endl;
    }



  
}
  

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  multiset<Int> ss;
  ss.emplace(as[0]);
  for(Int i=1;i<n;i++){
    if(as[i]<=*ss.begin()){
      ss.emplace(as[i]);
    }else{
      auto it=ss.lower_bound(as[i]);
      assert(it!=ss.begin());
      --it;
      ss.erase(it);
      ss.emplace(as[i]);
    }
  }

  cout<<ss.size()<<endl;
  return 0;
}


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

typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS=1E-9;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<EPS)return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++)if(i!=j)for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int main(){
  int n,s,t,q[100],a[100][100],d[100][100];
  while(cin>>n>>s>>t,n){
    vector<int> v[2][100];
    s--,t--;
    for(int i=0;i<n;i++)cin>>q[i];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	cin>>a[i][j];
	if(!a[i][j])a[i][j]=d[i][j]=1e9;
	else v[0][i].push_back(j),d[i][j]=a[i][j];
      }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    if(d[s][t]==1e9){cout<<"impossible"<<endl;return 0;}
    mat A(n,vec(n));
    vec b(n);
    for(int i=0;i<n;i++){
      if(d[i][t]==a[i][t])v[1][i].push_back(t);
      for(int j=0;j<n;j++)
	if(d[i][t]==a[i][j]+d[j][t])v[1][i].push_back(j);
      }
    for(int i=0;i<n;i++){
      int sz=v[q[i]][i].size();
      if(i==t){A[i][i]=1;continue;}
      double cnt=0;
      for(int j=0;j<sz;j++){
	int p=v[q[i]][i][j];
	A[i][p]=1.0/sz;
	cnt+=a[i][p];
      }
      A[i][i]-=1;
      b[i]-=cnt/sz;
    }
    vec res=gauss_jordan(A,b);
    printf("%.9lf\n",res[s]);
  }
  return 0;
}


Measured memory_bytes: 3268
from itertools import product
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
INF = 10**12

ans = INF
l = [0, 1]
for v in product(l, repeat=n):
    rikai = [0 for _ in range(m)]
    cost = 0
    for i in range(n):
        if v[i]:
            c = ca[i][0]
            a = ca[i][1:]
            cost += c
            for j in range(m):
                rikai[j] += a[j]
    f = True
    for i in range(m):
        if rikai[i] < x:
            f = False
    if f:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)

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

typedef long long ll;
typedef long double ld;
typedef string str;

#define f(i, begin, end) for (auto i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(v) for (auto &x : v)
#define dis(v) trav(v) cout << x << " ";
#define deb(x) cerr << #x << ":" << x << "\n"
#define debv(v) trav(v) cerr << x << " ";
#define all(v) v.begin(), v.end()
#define nl cout << "\n"

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    while (t--)
    {
        ll i, j, k;
        ll n, ans = 0;
        cin >> n;
        k = 10;
        if (!(n & 1))
            while (n / k > 0)
            {
                ans += (n / k);
                k *= 5;
            }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
a,b= map(int,input().split())
ju=ans=0
li=[]
li1=[]

i=0
for i in range(10001):
  if a==math.floor(i*0.08):
    li.append(i)
  if b==math.floor(i*0.1):
    li1.append(i)

li.sort()
li1.sort()

if len(li1)>0:
  ans=min(li1)
if len(li)>0:
  ju=min(li)
for i in range(len(li1)):
  if ju==li1[i]:
    print(ju)
    sys.exit()
for i in range(len(li)):
  if ans==li[i]:
    print(ans)
    sys.exit()
print('-1')

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  int k;cin>>k;
  int i;
  vector<int> a(k);
  vector<int> b(k);
  rep(i,k)cin>>a[i]>>b[i];
  rep(i,k)
  {
    if(a[i]>(n/2))a[i]=n+1-a[i];
    if(b[i]>(n/2))b[i]=n+1-b[i];
    a[i]--;
    b[i]--;
    int kt=min(a[i],b[i]);
    kt%=3;
    cout<<kt+1<<endl;
  }
}




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


def solve():
    if A.count(1) == 0:
        return print(-1)

    number_possible = 1

    for i in range(N):
        if A[i] == number_possible:
            number_possible += 1

    return print(N - number_possible + 1)


solve()


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

struct EDGE
{
	int from, to, cost;
	EDGE(int a, int b, int c){
		from = a;
		to = b;
		cost = c;
	}
	bool operator < (const EDGE& t) const {
		return cost < t.cost;
	}
};

vector<EDGE> v;
int par[100];

void init()
{
	v.clear();
	for (int i = 0; i < 100; i++){
		par[i] = i;
	}
}

int find(int x)
{
	if (par[x] == x) return x;
	return par[x] = find(par[x]);
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

void _union(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y) return;
	par[x] = y;
}

int main()
{
	int n;
	while (scanf("%d", &n), n){
		init();
		int m;
		scanf("%d", &m);
		for (int i = 0; i < m; i++){
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			c = c / 100 - 1;
			
			v.push_back(EDGE(a, b, c));
			v.push_back(EDGE(b, a, c));
		}
		sort(v.begin(), v.end());
		int res = 0;
		for (int i = 0; i < v.size(); i++){
			EDGE& e = v[i];
			if (same(e.from, e.to)) continue;
			_union(e.from, e.to);
			res += e.cost;
		}
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 1396
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);

 //debug func
template<typename T>
void vprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vvprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    LL x;
    cin >> x;
    LL ans = x / 11;
    x -= ans * 11;
    ans *= 2;
    if(x == 0) ;
    else if(x > 6) ans += 2;
    else ans++;
    cout << ans << endl;
}

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

class rect {
public:
  int h,w;
  // 対角線の2乗
  int diagonal() {
    return h * h + w * w;
  }
};

// x > y なら1を返す
int rect_cmp(rect x, rect y) {
  if(x.diagonal() > y.diagonal()) return 1;
  else if(x.diagonal() == y.diagonal()) {
    if(x.h > y.h) return 1;
    else return 0;
  }
  else return 0;
}

int main() {
  rect r;
  while(cin >> r.h >> r.w && r.h && r.w) {
    rect ans, cmp;
    ans.w = 150; ans.h = 150;
    for(cmp.h = 1; cmp.h < 150; ++cmp.h) {
      for(cmp.w = cmp.h + 1; cmp.w < 150; ++cmp.w) {
        if(rect_cmp(cmp, r) && rect_cmp(ans, cmp)) ans = cmp;
      }
    }
    cout << ans.h << ' ' << ans.w << endl;
  }
  return 0;
}



Measured memory_bytes: 3016
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int x;
    cin >> x;
    if(x >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

double dp[3005][3005]; //current, head
double prob[3005];

int main() {
	SET(dp, 0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf", prob + i);
	}
	dp[0][0] = 1 - prob[0];
	dp[0][1] = prob[0];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j == 0) {
				dp[i][0] = dp[i - 1][0] * (1.0 - prob[i]); 
			} else
				dp[i][j] = dp[i - 1][j] * (1.0 - prob[i]) + dp[i - 1][j - 1] * prob[i]; 
		}
	}
	double ans = 0;
	for (int i = (n + 1) / 2; i <= n; i++) {
		ans += dp[n - 1][i];
	}
	printf("%.9lf\n", ans);
	return 0;
}
		

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

int main(){
    
    int n;
    cin >> n;
    vector<int> h(n+1);
    h[0] = 0;
    rep(i,1,n+1)cin >> h[i];

    for(int i=n;i>0;i--){
        if(h[i-1]>h[i])
            if(h[i-1]-h[i]==1)h[i-1]--;
            else{
                cout << "No" << endl;
                return 0;
            }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 640
from fractions import gcd


N,K=map(int,input().split())
A=list(map(int,input().split()))

if max(A)<K:
    ans="IMPOSSIBLE"
elif K in A:
    ans="POSSIBLE"

else:
    g=gcd(A[0],A[1])
    for i in range(2,N):
        g=gcd(g,A[i])

    if g==1:
        ans="POSSIBLE"

    elif g!=0 and K%g==0:
        ans="POSSIBLE"

    else:
        ans="IMPOSSIBLE"

print(ans)

Measured memory_bytes: 16240
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;

    private void solve() {
        N = nextInt();

        long[] L = new long[90];
        L[0] = 2;
        L[1] = 1;
        for(int i = 2;i < 90;i++) {
            L[i] = L[i-1] + L[i-2];
        }

        out.println(L[N]);
    }

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

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 23124
from functools import reduce
h,w = [int(i) for i in input().split()]
a = []
for i in range(0,h):
    a.append('#' + input() + '#')
udFrame = reduce(lambda x,y: x+y, ['#' for i in range(0,w+2)])
print(udFrame)
for pic in a:
    print(pic)
print(udFrame)

Measured memory_bytes: 3572
/*
	ex3_3
	ruuu0048
*/
#include <stdio.h>

int sigma(int max_num); //1から引数までの数の和を返す関数
int answer(int west_height,int east_height); //答えである雪の深さを返す関数

int main(void){

    int west_height,east_height; //西と東の塔の見えるところの高さの変数を宣言

    scanf("%d %d",&west_height,&east_height); //それぞれ入力

    printf("%d\n",answer(west_height,east_height));//答えを出力

    return 0; 
}

int sigma(int max_num){
    int total = 0; //足しあわせていく変数を宣言

    while(max_num > 0){ //max_numが0になったらループが終わる
        total += max_num; //足していく
        max_num -= 1; //足したら1減らす
    }
    return total;

};

int answer(int west_height,int east_height){
    
    int real_east_height,snow_height; //東側の塔全体の高さと積雪の高さの変数を宣言

    real_east_height = sigma(east_height - west_height); //東側の塔全体の高さを計算

    snow_height = real_east_height - east_height; //積雪の高さを計算

    return snow_height;

};

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s; cin >> s;
  int n = s.size();
  ll ans = 0;
  for(int bit = 0; bit < 1<<(n-1); ++bit) {
    vector<int> vec;
    vec.push_back(0);
    rep(i, n-1) if(bit & 1<<i) vec.push_back(i+1);
    vec.push_back(n);
    rep(i, vec.size()-1) ans += stoll(s.substr(vec[i], vec[i+1]-vec[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b!=c)
    printf("Yes");
    else if(a==c&&c!=b)
    printf("Yes");
    else if(b==c&&c!=a)
    printf("Yes");
    else
        printf("No");


}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    print(sorted([a*int(b), b*int(a)])[0])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = next(tokens)  # type: int
    b = next(tokens)  # type: int
    solve(a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <functional>
#include <list>
#include <string>
#include <vector>
#include <climits>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <set>
#include <deque>
#include <stack>
#include <cassert>
using namespace std;
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define ALL(x) (x).begin(),(x).end()
#define CASET2 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d:\n", case_n++) : 0), ___T-- > 0)
#define CASET1 int ___T, case_n = 1; scanf("%d ", &___T); while ((___T > 0 ? printf("Case #%d: ", case_n++) : 0), ___T-- > 0)
#define CASET int ___T; scanf("%d ", &___T); while (___T-- > 0)
#define SZ(X) ((int)(X).size())
#define LEN(X) strlen(X)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define RI1(x) scanf("%d",&x)
#define RI2(x,y) RI1(x), RI1(y)
#define RI3(x,y...) RI1(x), RI2(y)
#define RI4(x,y...) RI1(x), RI3(y)
#define RI5(x,y...) RI1(x), RI4(y)
#define RI6(x,y...) RI1(x), RI5(y)
#define GET_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define RI(argv...) GET_MACRO(argv, RI6, RI5, RI4, RI3, RI2, RI1)(argv)
#define DRI(argv...) int argv;RI(argv)
#define WRI(argv...) while (RI(argv) != EOF)
#define DWRI(x...) int x; WRI(x)
#define RS(x) scanf("%s",x)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define X first
#define Y second
#define V(x) vector<x >

typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int INF = 1000000000;

void print(int i) { printf("%d", i); }
void print(LL i);
template<class T> void PI(T i) { print(i); puts(""); }
template<class T> void PIS(T i) { print(i); printf(" "); }

template<class T>
void PV(T const &v, int N) {
    REP(i, N) {
        print(v[i]);
        printf("%c", i == N-1 ? '\n' : ' ');
    }
}

template<class T> void PV(T const &v) { PV(v, SZ(v)); }

template<class T, class S> bool has_bit(T mask, S i) { return (mask >> i) & 1; }
long long shift(int i) { return 1ll << i; }

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
int popcount(int x) { return __builtin_popcount(x); } 
int popcount(long long x) { return __builtin_popcountll(x); } 

#include <unordered_set>
#include <unordered_map>
#define EB emplace_back
#define RL(x) scanf("%lld", &(x))
#define PL(x) printf("%lld\n", x)
#define DRL(x) LL x; RL(x)

int main() {
    DRI(N);
    VI A(N);
    REP(i, N) {
        RI(A[i]);
    }
    if (A[0]) {
        PI(-1);
        return 0;
    }
    int lb = 0;
    LL ans = 0;
    PER(i, N) {
        if (A[i] < lb) {
            PI(-1);
            return 0;
        }
        if (A[i] > lb) {
            ans += A[i];
            lb = A[i];
        }
        lb--;
    }
    PL(ans);
    return 0;
}


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

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

    if(n % 2 == 0){
        cout << 0.5 << endl;
    }else{
        Ne = n / 2;
        cout << (double) (n - Ne) / n << endl;
    }

    return 0;
}

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

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

char field[20][20];
bool flag[20][20];
int W, H, ans;

void dfs(int x, int y) {
  //field[x][y] = '.';
  //cout << x << ' ' << y << endl;
  //cout << flag[x][y] << endl;
  //cout << ans << endl;
  for(int i = 0 ; i < 4 ; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == '.' &&
       flag[nx][ny] == false) {
      ans++; flag[nx][ny] = true; dfs(nx, ny);
      //cout << "OK" << endl;
    }
    //else dfs(nx, ny);
  }
}

int main(void) {
  int x, y;
  int res;
  
  while(cin >> W >> H, W != 0 && H != 0) {
    memset(flag, false, sizeof(flag));
    ans = 1;
    for(int i = 0 ; i < H ; i++) {
      for(int j = 0 ; j < W ; j++) {
	cin >> field[i][j];
	if(field[i][j] == '@') x = i, y = j;
      }
    }
    /*for(int i = 0 ; i < H ; i++) {
      for(int j = 0 ; j < W ; j++) {
	cout << field[i][j];
      }
      cout << endl;
      }*/
    //printf("@x = %d, @y = %d\n", x, y);
    dfs(x, y);
    cout << ans << endl;
  }
  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll k;
    ll a, b;
    cin >> k >> a >> b;
    repd(i, a, b + 1) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}



Measured memory_bytes: 3636
import copy
N, M = map(int, input().split())
W, V = [], []
for n in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
f = [0 for m in range(M + 1)]
for n in range(N):
    f_ = copy.copy(f)
    for m in range(M + 1):
        if m >= W[n]:
            f_[m] = max(f[m], f[m - W[n]] + V[n])
    f = f_
print(f[M])


Measured memory_bytes: 68184
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt()-1;
		int x = sc.nextInt();
		int upper = x+k;
		int lower = x-k;
		for(int i = lower;i<=upper;i++) {
			System.out.printf("%d ",i);
		}

	}

}


Measured memory_bytes: 21972
#include <stdio.h>
#include <iostream>
#include <vector>

//https://atcoder.jp/contests/abc156/tasks/abc156_c

int main()
{
    std::ios::sync_with_stdio(false); // toggler av synkronisjon mellom c og c++ data streams. kan ikke blade de etter skrudd av
    std::cin.tie(NULL);               //gj;r at man ikke venter på cout og de can printe samtidig tror jeg

    //linjen er opp til 100. det er en linje p[ lengde hundre med hus p[ bare de nevte stedene]]

    int houses;
    std::cin >> houses;

    std::vector<int> vec(99);

    for (int i = 0; i < houses; i++)
    {
        int houseLocation;
        std::cin >> houseLocation;

        for (int u = 0; u < 99; u++)
        {
            int distStam = (u + 1 - houseLocation) * (u + 1 - houseLocation);
            vec[u] = vec[u] + distStam;
            //std::cout << "   " << vec[u] << "\n";
        }
    }

    int min = vec[0];
    for (int u = 1; u < 99; u++)
    {
        //std::cout << "   " << vec[u] << "\n";
        if (vec[u] < min)
        {
            min = vec[u];
        }
    }
    std::cout << min << "\n";
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,K;
	scanf("%d%d",&n,&K);

	vector<pair<double,double>> ps;
	const double PI=3.14159265359;
	rep(i,0,n){
		double x,y,r;
		scanf("%lf%lf%lf",&x,&y,&r);
		if(y+r<=0) continue;
		if(y-r<=0){
			double f,s;
			if(x<0){
				f=atan2(y,x)-asin(r/sqrt(x*x+y*y));
				s=PI;
			}else{
				f=0;
				s=atan2(y,x)+asin(r/sqrt(x*x+y*y));
			}
			while(f<0) f+=PI;
			while(s<0) s+=PI;
			ps.push_back(mp(f,s));
		}else ps.push_back(mp(atan2(y,x)-asin(r/sqrt(x*x+y*y)),atan2(y,x)+asin(r/sqrt(x*x+y*y))));
	}
	
	sort(ps.begin(),ps.end());
	ps.erase(unique(ps.begin(),ps.end()),ps.end());
	
	vector<pair<double,double>> tmp;
	rep(i,0,ps.size()){
		bool ok=true;
		rep(j,0,ps.size()){
			if(i==j) continue;
			if(ps[j].first<=ps[i].first&&ps[i].second<=ps[j].second){
				ok=false;
				break;
			}
		}
		if(ok) tmp.push_back(ps[i]);
	}
	ps=tmp;

	if(ps.size()==0){
		cout << 0 << endl;
		return;
	}

	vector<int> a(ps.size());
	rep(i,1,ps.size()){
		rep(j,0,i+1){
			if(ps[j].second>=ps[i].first){
				a[i]=j;
				break;
			}
		}
		if(a[i]==i) a[i]=i-1;
	}

	static double dp[1500][1501][2];
	dp[0][0][0]=0;
	dp[0][1][1]=ps[0].second-ps[0].first;
	double ans=dp[0][1][1];
	rep(i,1,ps.size()){
		rep(j,0,K+1){
			dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j][1]);
			if(j==0) continue;
			dp[i][j][1]=max(dp[a[i]][j-1][1]+ps[i].second-max(ps[i].first,ps[a[i]].second),dp[a[i]][j-1][0]+ps[i].second-ps[i].first);
			ans=max({ans,dp[i][j][1],dp[i][j][0]});
		}
	}

	printf("%.10lf\n",ans/PI);
}

int main(){
	Solve();
	return 0;
}

Measured memory_bytes: 36584
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

char mat[21][21];
bool vis[21][21];
ll n,m;

bool chk(pll x){
    if(x.f==-1 || x.f==n){
        return false;
    }
    if(x.s==-1 || x.s==m){
        return false;
    }
    if(mat[x.f][x.s]=='#'){
        return false;
    }
    if(vis[x.f][x.s]){
        return false;
    }
    return true;
}


ll bfs(pll start, pll end){
    queue<pll>q;
    memset(vis,false,sizeof(vis));
    q.push(start);
    ll ret=0;
    ll si;
    pll tf;
    pll tin;
    while(!q.empty()){
        si=q.size();
        for(ll i=0;i<si;i++){
            tf=q.front();
            q.pop();
            if(tf==end){
                return ret;
            }
            vis[tf.f][tf.s]=true;
            tin=mp(tf.f-1,tf.s);
            if(chk(tin)){
                q.push(tin);
                vis[tin.f][tin.s]=true;
            }
            tin=mp(tf.f+1,tf.s);
            if(chk(tin)){
                q.push(tin);
                vis[tin.f][tin.s]=true;
            }
            tin=mp(tf.f,tf.s-1);
            if(chk(tin)){
                q.push(tin);
                vis[tin.f][tin.s]=true;
            }
            tin=mp(tf.f,tf.s+1);
            if(chk(tin)){
                q.push(tin);
                vis[tin.f][tin.s]=true;
            }
        }
        ++ret;
    }
}

void Flash(){
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            cin>>mat[i][j];
        }
    }
    ll ans=-1*inf;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            for(ll ii=0;ii<n;ii++){
                for(ll jj=0;jj<m;jj++){
                    if(mat[ii][jj]=='.' && mat[i][j]=='.'){
                        ans=max(ans,bfs(mp(i,j),mp(ii,jj)));
                    }
                }
            }
        }
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

     int a,b,c,d,i,j,k,t=0,u=0;
     string x,y,z;
     vector<int> v;
     set<int> s;
     cin>>a;
     d=a;
     while(a--){
        cin>>b;
        if(b%2==0){
                u++;
        if(b%3==0 || b%5==0){
            t++;
        }
     }}
 if(t==u){
    cout<<"APPROVED"<<endl;
 }
 else cout<<"DENIED"<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m, q = map(int, input().split())
abcd = [tuple(map(int,input().split())) for i in range(q)]

ans = 0

import itertools
for seq in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp = 0
    for a,b,c,d in abcd:
        if seq[b-1] - seq[a-1] == c:
            tmp += d

    ans = max(tmp,ans)

print(ans)


Measured memory_bytes: 9136
n,m = map(int,input().split())
key = []
for i in range(1,n+1):
    key.append(i)
    
ls = [0,100000]
for i in range(m):
    L,R = map(int,input().split())
    if L > ls[0]:
        ls[0] = L
    if R < ls[1]:
        ls[1] = R
    
ans = []    
for i in range(ls[0],ls[1]+1):
    ans.append(i)
    
print(len(set(ans)&set(key)))


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


template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main()
{
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<ll> s(n+1),u(n+1);
    rep(i,n) s[i+1] = s[i] + a[i];
    rep(i,n+1) u[i] = s[i] - k*i;

    vector<ll> v(n+1),hoge;//座圧：u -> v
    rep(i,n+1) hoge.emplace_back(u[i]);
    sort(all(hoge));
    hoge.erase(unique(all(hoge)), hoge.end());
    rep(i,n+1) v[i] = lower_bound(all(hoge),u[i]) - hoge.begin();

    BinaryIndexedTree<int> b(n+1);
    ll res = 0;
    rep(i,n+1) {
        res += b.sum(v[i]);
        b.add(v[i],1);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 11856
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  
  int sum = vec.back() / 2;
  for (int i = 0; i < n - 1; i++) {
    sum += vec[i];
  }
  cout << sum << endl;
  return 0;
}


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

#define ll long long

using namespace std;


int main(){
 int a,b;
 cin>>a>>b;
 if((a<1)||(a>9)||(b<1)||(b>9)){
     cout<<"-1"<<endl;
 }
 else{
     cout<<(a*b)<<endl;
 }


}

Measured memory_bytes: 256
import sys
N, P = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

kisu = 0
gusu = 0
for a in A:
    if a % 2 == 1:
        kisu += 1
    else:
        gusu += 1

total = 2 ** N # 全場合の数
if kisu == 0:
    ans = 2 ** gusu
else:   
    ans = (2 ** gusu) * (2 ** (kisu - 1)) # 偶数になる場合の数

if P == 0:
    print(ans)
else:
    print(total - ans)

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;

int main(){
    string str;
    cin >> str;
    string ans;
    char check = 'a';
    for(int i=0;i<26;i++){
        int flag = 0;
        for(int j=0;j<str.size();j++){
            if(check == str[j]) flag++;
        }
        if(flag%2 != 0) ans = "No";
        check = check+1;
    }
    if(ans != "No") ans = "Yes";
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNING

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm> 
using namespace std;
typedef long long ll;
int main()
{
	int a,b,j,i;
	scanf("%d",&a);
	for(j=1;j<10;j++)
	{
		for(i=j;i<10;i++)
		{
			if(i*j==a)
			{
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

let count5 = 0; 
  let count7 = 0; 
  let result = 'NO'
reader.on('line', (line) => {
  input_lines = line.split(" ")
  
  input_lines.map(i => {
  	if(i == 5) {
      count5++
  }
    if(i == 7) {
       count7++
    }
    
    
  })
  
  if(count7 == 1 && count5 == 2) {
    result = 'YES'
  }
  
});


/* ーーーー入力ーーーー
ここに書くコードを変える


　 ーーーー出力ーーーー */
reader.on('close', () => {
  console.log(result);
});


Measured memory_bytes: 30796
import math
N = int(input())
arr = [0]*N
rtN = int(math.sqrt(N))*2
for x in range(rtN)[1:]:
    for y in range(rtN)[x:]:
        for z in range(rtN)[y:]:
            r = x*x +y*y+z*z+x*y+y*z+z*x
            if r <= N:
                if (x==z):
                    arr[r-1] +=1
                elif(x==y or y==z):
                    arr[r-1] +=3
                else:
                    arr[r-1] +=6
for ar in arr:
	print(ar)

Measured memory_bytes: 74508
def resolve():
    n = int(input())
    d = {}
    for _ in range(n):
        s = input()
        if s not in d:
            d[s] = 1
        else:
            d[s] += 1
    d = sorted(d.items(), key=lambda x:x[1], reverse=True)
    ans = []
    before = d[0][1]
    for t in d:
        if t[1] != before:
            break
        else:
            ans.append(t[0])
    ans = list(sorted(ans))
    for a in ans:
        print(a)
resolve()

Measured memory_bytes: 47640
#include<stdio.h>

typedef struct {
	int a,b,c,f;
} pack;

int main(){
	int a,b,c,n,i,f[301];
	pack list[1000];
	scanf("%d %d %d",&a,&b,&c);
	while(a!=0){
		scanf("%d",&n);
		for(i=1;i<=a+b+c;i++){
			f[i]=2;
		}
		for(i=0;i<n;i++){
			scanf("%d %d %d %d",&list[i].a,&list[i].b,&list[i].c,&list[i].f);
			if(list[i].f==1){
				f[list[i].a]=1;
				f[list[i].b]=1;
				f[list[i].c]=1;
			}
		}
		for(i=0;i<n;i++){
			if(list[i].f==0){
				if(f[list[i].a]==0 || f[list[i].b]==0 || f[list[i].c]==0){
					continue;
				}
				if(f[list[i].a]+f[list[i].b]+f[list[i].c]==4){
					if(f[list[i].a]==2) f[list[i].a]=0;
					else if(f[list[i].b]==2) f[list[i].b]=0;
					else f[list[i].c]=0;
				}
			}
		}
		for(i=1;i<=a+b+c;i++){
			printf("%d\n",f[i]);
		}
		scanf("%d %d %d",&a,&b,&c);
	}
	return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

const int nmax=8;
int graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
    bool all_visited=true;
    rep(i,N) if(visited[i]==false) all_visited=false;

    if(all_visited) return 1;
    int ret=0;

    rep(i,N){
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i]=true;
        ret+=dfs(i, N, visited);
        visited[i]=false;
    }
    return ret;
}

int main(){
    fast_io

    int n,m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
        int A, B;
        cin>>A>>B;
        graph[A-1][B-1]=1;
        graph[B-1][A-1]=1;
    }
    bool visited[nmax];
    rep(i,n) visited[i]=false;
    visited[0]=true;

    cout<<dfs(0, n, visited)<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    while True:
        mid_score,final_score,makeup_score = map(int,input().split())
        if mid_score==-1 and final_score==-1 and makeup_score==-1:
            exit()
        if mid_score == -1 or final_score==-1:
            print("F")
        elif mid_score+final_score>=80:
            print("A")
        elif mid_score+final_score>=65 and mid_score+final_score<80:
            print("B")
        elif mid_score+final_score>=50 and mid_score+final_score<65:
            print("C")
        elif mid_score+final_score>=30 and mid_score+final_score<50:
            if makeup_score >= 50:
                print("C")
            else:
                print("D")
        elif mid_score+final_score<30:
            print("F")
        
if __name__=="__main__":
    main()


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#define A NULL
 
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
typedef struct node * Node;
Node root;
 
Node treeMinimum(Node x){
  while(x->left != A){
    x = x->left;
  }
  return x;
}
 
Node treeSearch(Node u, int k){
  while(u != A && k != u->key){
    if(k < u->key){
      u = u->left;
    }else{
      u = u->right;
    }
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != A) return treeMinimum(x->right);
  y = x->parent;
 
  while(y !=A && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 

 
void inorder(Node u){
  if(u != A){
    if(u->left != A) inorder(u->left);
    printf(" %d", u->key);
    if(u->right != A) inorder(u->right);
  }
}
 
void preorder(Node u){
  if(u != A){
    printf(" %d", u->key);
    if(u->left != A) preorder(u->left);
    if(u->right != A) preorder(u->right);
  }
}
 
int main(){
  int y, i, x;
  char com[20];
  scanf("%d", &y);
   
  for ( i = 0; i < y; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != A ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }
  }
   
  return 0;
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == A || z->right == A) y = z;
  else y = treeSuccessor(z);
 
  if(y->left != A) x = y->left;
  else x = y->right;
 
  if(x != A) x->parent = y->parent;
  if(y->parent == A) root = x;
  else if( y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
 
  if(y != z) z->key = y->key; 
}
 
void insert(int k){
  Node y = A;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = A;
  z->right = A;
 
  while(x != A){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == A){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

Measured memory_bytes: 24040
#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,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,m) cin >> a[i];
    rep(i,m) n -= a[i];
    if(n>=0){
        cout << n << "\n";
    }else{
        cout << -1 << "\n";
    }
    return 0;
}

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

int main(){
    int n, p; cin >> n >> p;
    string s; cin >> s;
    ll ans = 0;
    if(p == 2 || p == 5){
        for(int i = 0; i < n; i++) if((s[n-i-1]-'0') % p == 0) ans += n-i;
        cout << ans << endl;
        return 0;
    }
    vector<ll> cnt(p,0);
    int k = 1;
    int now = 0;
    cnt[now]++;
    for(int i = 0; i < n; i++){
        now = (now + (s[n-i-1] - '0')*k) % p;
        k = (k * 10) % p;
        cnt[now]++;
    }
    rep(i,p) ans += cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
		cin>>arr[i][j];
		}
	}
 int dp[3][n];
 dp[0][0]=arr[0][0];
 dp[1][0]=arr[0][1];
 dp[2][0]=arr[0][2];
	for(int i=1;i<n;i++){
		dp[0][i]=arr[i][0]+max(dp[1][i-1],dp[2][i-1]);
		dp[1][i]=arr[i][1]+max(dp[0][i-1],dp[2][i-1]);
		dp[2][i]=arr[i][2]+max(dp[1][i-1],dp[0][i-1]);
	}
	cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
	return 0;
}

Measured memory_bytes: 2560
#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 argc, const char * argv[]) {



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

    int x,y;
    cin>>x>>y;
    string flag="No";
    for(int i=0;i<=x;i++){
        if(i*2+(x-i)*4==y){
            flag="Yes";
            break;
        }
    }
    cout<<flag<<endl;

    return 0;
}



Measured memory_bytes: 3540
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
int a[N],n,k;
bool check(int mid)
{
    ll res=0;
    for(int i=1;i<=n;i++) res+=(a[i]+mid-1)/mid-1;
    return res<=k;
}
int main()
{
    IO;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    int l=1,r=1e9;
    while(l<r)
    {
        int mid=l+r>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 4384
<?php
while ($first = trim(fgets(STDIN))) {
	seq_sum($first);
}

function seq_sum($first) {
	$sum = $first;
	$prev = $first;
	for ($i = 2; $i <= 10; $i++) {
		if ($i % 2 == 0) {
			$prev *= 2;
		} else {
			$prev /= 3;
		}
		$sum += $prev;
	}
	echo $sum . "\n";
}

Measured memory_bytes: 6616