akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

map<int64_t,int> prime_factor(int64_t n) {
  map<int64_t,int> ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    ll N, ans = 0;
    cin >> N;
    map<ll, int> p;
    p = prime_factor(N);
    for (auto x: p){
        int a, b, c = 1;
        a = x.first;
        b = x.second;
        while(c <= b){
            b -= c;
            ans++;
            c++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
n = int(input())
w = list(map(int, input().split()))
l = []
for i in range(n):
  s1 = sum(w[j] for j in range(i))
  s2 = sum(w[j] for j in range(i,n))
  l.append(abs(s1-s2))
print(min(l))

Measured memory_bytes: 3060
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int[] H, W;
        int i, j, k, count;

        H = new int[100000];
        W = new int[100000];

        i=0;
        while(true){
            if(i == 100000){break;}

            H[i] = sc.nextInt();
            W[i] = sc.nextInt();

            if(H[i] == 0 && W[i] == 0){break;}
            i++;
        }
        count = i;

        for(k=0;k<count;k++){
            for(i=0;i<H[k];i++){
                for(j=0;j<W[k];j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 35796
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
	let cin = stdin();
	let cin = cin.lock();
	let mut sc = Scanner::new(cin);
        let (x,a,b) : (isize, isize, isize) = (sc.read(), sc.read(), sc.read());
        println!("{}", if isize::abs(x-a) < isize::abs(x-b) {
            "A"
        } else {
            "B"
        });
	
}



Measured memory_bytes: 4352
from heapq import heappush, heappop

def dijkstra(G, s):
    n = len(G)
    fixed = set()
    d = {}
    for i in range(n):
        d[i] = 9999999999999999999999999999999999999
    d[s] = 0
    heap = [(0, s)]
    while len(fixed) < n:
        du, u = heappop(heap)
        for v in G[u]:
            if v in fixed:
                continue
            if du + G[u][v] < d[v]:
                d[v] = du + G[u][v]
                heappush(heap, (d[v], v))
        fixed.add(u)
    return d




n = int(raw_input())
G = {}
for _ in range(n):
    entries = map(int, raw_input().split(' '))
    u = entries[0]
    k = entries[1]
    G[u] = {}
    for i in range(k):
        v = entries[i*2+2]
        c = entries[i*2+3]
        G[u][v] = c

d = dijkstra(G, 0)

for i in range(n):
    print i, d[i]

Measured memory_bytes: 75460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	cout << max(0ll,(A+B*(N-1))-(A*(N-1)+B)+1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define dump(x)  cerr << #x << " => " << (x) << endl
using namespace std;
constexpr int c = 100001;
template <typename V,typename Weight>
class Adjacency_List {
public:
	vector<vector<pair<V,Weight>>> E;
	V sz;
	Adjacency_List(V v) : E(v),sz(v){}
	void addEdgeDirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
	}
	void addEdgeUndirected(V from,V to,Weight dis){
		E[from].push_back(make_pair(to,dis));
		E[to].push_back(make_pair(from,dis));
	}
};

template <typename V,typename Weight>
pair<bitset<c>,bitset<c>> separate(vector<vector<pair<V,Weight>>> &E) {
	typedef bitset<c> bs;
	queue<pair<int,bool>> que;
	que.push(make_pair(0,true));
	bs S1(0),S2(0);
	while (!que.empty()) {
		pair<int,bool> n = que.front();que.pop();
		if (n.second && S2[n.first]) {
			return make_pair(bs(0),bs(0));
		}
		if ((!(n.second)) && S1[n.first]) {
			return make_pair(bs(0),bs(0));
		}
		if (n.second) {
			S1.set(n.first);
			for (int i = 0;i < E[n.first].size();i++) {
				V next = E[n.first][i].first;
				if (S2[next]) continue;
				que.push(make_pair(next,!(n.second)));
			}
		}
		else {
			S2.set(n.first);
			for (int i = 0;i < E[n.first].size();i++) {
				V next = E[n.first][i].first;
				if (S1[next]) continue;
				que.push(make_pair(next,!(n.second)));
			}
		}
	}
	return make_pair(S1,S2);
}

int main(void) {
	long long N,M,x,y;
	cin >> N >> M;
	Adjacency_List<int,int> e(N);
	REP(i,M) {
		cin >> x >> y;
		e.addEdgeUndirected(x-1,y-1,1);
	}
	auto p = separate(e.E);
	long long s1 = p.first.count();
	long long s2 = p.second.count();
	if (s1 == 0 && s2 == 0) cout << (N * (N-1))/2LL - M <<  endl;
	else cout << s1 * s2 - M << endl;
}



Measured memory_bytes: 8320
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String ans="No";
String s=sc.next();
String t=sc.next();
int n=s.length();
int temp=0;
int count=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(s.charAt(j)!=t.charAt((j+temp)%n)){temp++;count=0;break;}else{count++;}
    
    }
if(count==n){ans="Yes";break;}
}

System.out.println(ans);


}}

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		
		int [][]x = new int [n][2];
		
		for(int i = 0 ; i < n ;i++) {
			x[i][0] = Integer.parseInt(sc.next());
			x[i][1] = Integer.parseInt(sc.next());
		}
		
		Arrays.sort(x,(p,q) -> Integer.compare(p[0],q[0]));
		
		long []nd = new long [n+1];
		for(int i = 0 ; i < n ;i++) {
			nd[i] = (long)x[i][0];
		}
		nd[n] = 20000000000000000L;
		long []sum = new long [n+1];
		long ans = 0;
		
		for(int i = 0 ; i < n ; i++){
			if(sum[i] < x[i][1]) {
				long A = (x[i][1] - sum[i] + a - 1)/a;	//x[i]を０にするために必要な爆弾の回数
				long D = nd[i] + 2 * d;
				int l = upper_bound(nd,D,n,i);
				sum[i] += A*a;
				sum[l] += -A*a;
				ans += A;
			}
			sum[i+1] += sum[i];
		}
		
		System.out.println(ans);
	}
	
	public static int upper_bound(long[] nd , long d , int n, int f) {		
		int p = n;
		int q = f;
		while(p - q > 1) {
			int mid = (p+q)/2;
			if(nd[mid] == d) {
				return mid+1;
			}
			if(nd[mid] < d) {
				q = mid;
			}
			else {
				p = mid;
			}
		}
		return p;
		
		
	}

}


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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 1e18 + 12;
const int inf = 1e9;

vector <pair <int, int> > ans;

int main () {
	boost;
	int n, k;
	cin >> n >> k;
	k -= (n - 1) * (n - 2) / 2;
	for (int i = 2 ; i <= n ; ++ i) {
		ans.push_back ({1, i});
	}
	for (int i = 2 ; i <= n ; ++ i) {
		for (int j = i + 1 ; j <= n ; ++ j) {
			if (k < 0) {
				++k;
				ans.push_back ({i, j});
			}
		}
	}
	if (k != 0) cout << -1, exit(0);
	cout << ans.size() << "\n";
	for (auto p : ans) cout << p.first << " " << p.second << "\n";
}

Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    string s;
    cin >> s;
    bool judge = false;
    rep(i, 7) {
        string k, kk;
        k = s.substr(0, i);
        kk = s.substr(s.size() - 7 + i);
        if (k + kk == "keyence")
            judge = true;
    }

    if (judge)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
n = int(input())
t, a = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
b = list()

for i in range(n):
  c = abs(a-(t-h[i]*0.006))
  b.append([c, i+1])
b.sort()
print(b[0][1])

Measured memory_bytes: 3188
# C - Cat Snuke and a Voyage
def main():
    n, m = map(int, input().split())
    li = [0]*200001

    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            if li[b] == 0:
                li[b] = 1
            else:
                print('POSSIBLE')
                exit()
        if b == n:
            if li[a] == 0:
                li[a] = 1
            else:
                print('POSSIBLE')
                exit()
    else:
        print('IMPOSSIBLE')

if __name__ ==  "__main__":
    main()

Measured memory_bytes: 76188
let N = Int(readLine()!)!
let ball: [(Int, Int)] = (0..<N).map { _ in
	let input = readLine()!.characters.split(" ").map{Int(String($0))!}
	return (input[0], input[1])
}
var dic = [String : Int]()
for i in ball {
	for j in ball {
    	if i != j {
			let key = "\(i.0 - j.0),\(i.1 - j.1)"
			dic[key] = (dic[key] ?? 0) + 1
        }
	}
}
print(N - (dic.values.maxElement() ?? 0))

Measured memory_bytes: 4336
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.trim().split(',');
	let mut v:Vec<String> = Vec::new();
	for i in iter {
		v.push((*i).to_string());
	}
	let s = format!("{} {} {}", v[0], v[1], v[2]);
	println!("{}", s);
}

Measured memory_bytes: 4352
<?php

$input = explode(' ', trim(fgets(STDIN)));

$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];
$d = (int)$input[3];
$e = (int)$input[4];
$f = (int)$input[5];

$water = [];
for ($i=0; $i <= 30/$a; $i++) { 
	for ($j=0; $j <= 30/$b; $j++) { 
		$sum = $a * 100 * $i + $b * 100 * $j;
		if ($sum <= $f && $sum > 0) {
			$water[] = $sum;
		}
	}
}
rsort($water);
$water = array_unique($water);
$water = array_values($water);

$result = [
	'rate' => 0,
	'weight' => 0,
	'sugar' => 0
];
foreach ($water as $value) {
	if ($result['weight'] === 0) {
		$result['weight'] = $value;
	}
	$sugar_max = $value*$e /100;
	$c_max = floor($sugar_max/$c);
	$d_max = floor($sugar_max/$d);
	for ($k=$c_max; $k >= 0; $k--) { 
		for ($m=$d_max; $m >= 0; $m--) { 
			$sugar = $k * $c + $m * $d;
			$weight = $sugar + $value;
			if ($sugar > 0 && $sugar <= $sugar_max && $weight <= $f) {
				$rate = 100 * $sugar / ($value + $sugar);
				if ($result['rate'] < $rate) {
					$result['weight'] = $value + $sugar;
					$result['sugar'] = $sugar;
					$result['rate'] = $rate;
				}
			}
		}
	}
}

echo $result['weight'] . ' ' . $result['sugar'];

Measured memory_bytes: 4728
#include<iostream>
using namespace std;
int main(){
	long long sum,num1,num2;
	cin>>sum>>num1>>num2;
	if(num1>num2){
		cout<<"0";
		return 0;
	}
	if(num1!=num2 && sum==1){
		cout<<"0";
		return 0;
	}
	long long max,min;
	min=(sum-1)*num1+num2;
	max=(sum-1)*num2+num1;
	cout<<max-min+1;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
  long long int N;
  long  long int c1=0,r;
     scanf("%lld",&N);
        while(r!=0)
        {
            r=N%10;
            N=N/10;
            if(r==7)
            {
                c1++;
            }

        }
    if(c1==1||c1==2||c1==3)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2088
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <chrono>
using namespace std;
 
typedef long long ll;
typedef pair<int, ll> Pl;

ll dist[100005];
vector<Pl> graph[100005];

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

    Timer() { reset(); }

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

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

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

    Timer t;
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        int l, r;
        ll c;
        cin >> l >> r >> c;
        --l, --r;
        graph[l].push_back(Pl(r, c));
    }
    for(int i = 0; i < n-1; ++i){
        graph[i+1].push_back(Pl(i, 0));
    }
    
    fill(dist, dist+n, (ll)1e+17);
    dist[0] = 0;
    priority_queue<Pl, vector<Pl>, greater<Pl>> que;
    que.push(Pl(0, 0));
    while(!que.empty() && t.elapsed() < 1950){
        Pl p = que.top();
        que.pop();
        ll d = p.first;
        int u = p.second;
        if(dist[u] < d)     continue;
        for(int i = 0; i < (int)graph[u].size(); ++i){
            int v = graph[u][i].first;
            ll cost = graph[u][i].second;
            if(dist[v] > dist[u] + cost){
                dist[v] = dist[u] + cost;
                que.push(Pl(dist[v], v));
            }
        }
    }
    if(dist[n-1] == (ll)1e+17)  dist[n-1] = -1;
    cout << dist[n-1] << "\n";
}

Measured memory_bytes: 12916
#include <iostream>

using namespace std;

int main(){
  int n, l, sum = 0, mn = int(1e9);
  cin >> n >> l;
  for(int i=1; i<=n; ++i){
  	sum += l + i - 1;
    if (abs(mn) > abs(l + i - 1))
	  mn = l + i - 1;
  }
  cout << sum - mn;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>arr;
long long cut(int x){
	long long ret = 0;
	for(int i=0; i<arr.size(); i++){
		if(arr[i]>x){
			ret+=arr[i]/x;
			if(arr[i]%x==0) ret--;
		}
	}
	return ret;
}
int main(){
	int n,k;
	cin>>n>>k;
	arr = vector<int>(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	int start = 1;
	int fin = *max_element(arr.begin(),arr.end());
	while(start<=fin){
		int mid = (start+fin)/2;
		if(cut(mid)<=k) fin = mid-1;
		else start = mid+1;
	}
	cout<<start;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    ll ans=0;
    repr(b,k+1,n+1) {
        int s=k,t=n%b;
        int r=b-k+max(0,t-k+1)+(n-t-b)/b*(b-k);
        if (k==0) --r;
        ans+=r;
    }
    cout << ans  << endl;


    return 0;   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N,M;
    int P[114514];
    string S[114514];
    bool ac[114514]={};
    int wa[114514]={};
    int Ans=0,pena=0;
    cin >> N >> M;
    REP(i,M){
        cin >> P[i] >> S[i];
        P[i]--;
    }
    
    REP(i,M){
        if(ac[P[i]]==true)continue;
        if(S[i]=="AC"){
            ac[P[i]]=true;
            Ans++;
            pena+=wa[P[i]];
        }else{
            wa[P[i]]++;
        }
    }
    cout << Ans <<" "<<pena << endl;
    return 0;
}



Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int cnt=0;
	cin>>s;
	string x;
	x="CODEFESTIVAL2016";
	for(int i=0;i<16;i++)
		if(s[i]!=x[i])cnt++;
	cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  cin>>h>>w;
  cout<<string(w+2,'#')<<endl;
  REP(i,h){
    string s;
    cin>>s;
    cout<<"#"<<s<<"#"<<endl;
  }
  cout<<string(w+2,'#')<<endl;
  return 0;
}


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

const int maxn = 20;
int n, a[1<<maxn];

void merge(multiset<int>& a, multiset<int> b) {
    for (auto i: b) a.insert(i);
    while (a.size() > 2) a.erase(a.begin());
}

int sum(multiset<int>& a) {
    int res = 0;
    for (int i: a) res += i;
    return res;
}

multiset<int> f[1<<maxn];
int ans[1<<maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < (1<<n); i++) {
        cin >> a[i];
        f[i].insert(a[i]);
    }
    for (int k = 0; k < n; k++) {
        for (int mask = 0; mask < (1<<n); mask++) {
            if (mask & (1<<k)) continue;
            merge(f[mask|1<<k],f[mask]);
        }
    }
    for (int k = 1; k < (1<<n); k++) {
        ans[k] = sum(f[k]);
        ans[k] = max(ans[k],ans[k-1]);
        cout << ans[k] << '\n';
    }
}



Measured memory_bytes: 79872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int x,p=100,n=0;
   cin>>x;
   while(p<x)
   {
       ++n;
       p+=p/100;
   }
   cout<<n;
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int i,j,a[10000];
	i=1;
	while(1){
		scanf("%d",&a[i]);
		if(a[i]==0){
			break;
		}
		i++;
	}
	j=i;
	i=1;
	while(j>i){
		printf("Case %d: %d\n",i,a[i]);
		if(a[i]==0){
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))

using namespace std;


struct Marathon{
  using timer = chrono::system_clock;
  timer::time_point tstart,tend;
  random_device rd;
  mt19937 mt{rd()};
  
 //define variable
  const int limit = 1900;
  int D,day,alpha,ncost,bcost;
  int c[26];
  int d[365][26];
  vector<int> ans,state;

  Marathon(){
    tstart = timer::now();
    tend = timer::now();
    input();
    init();
    solve();
  }

  bool until(){
     int time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(tend-tstart).count()/1000.0);
     return limit > time;
  }

  int cost(){
    int mae[26] = {};
    int ret = 0;
    for(int i=0;i<D;i++){
      mae[state[i]] = i+1;
      ret += d[i][state[i]];
      for(int j=0;j<26;j++){
	//	cout<<c[j]<<" "<<(i+1-mae[j])<<endl;
	ret -= c[j] * (i+1-mae[j]); 
      }
    }
    return ret;
  }

  void ch_state(){
    state[day] = alpha;
  }

  int nextInt(int to){
    uniform_int_distribution<int> ranum(0,to);
    return ranum(mt);
  }

  double nextDouble(double to){
    uniform_real_distribution<double> ranumf(0,to);
    return ranumf(mt);
  }

  void init(){
    ans.resize(D);
    state.resize(D);
    for(int i=0;i<D;i++){
      ans[i] = i%26;
      state[i] = i%26;
    }
    bcost = cost();
  }

  void solve(){
    while(until()){
      day = nextInt(D-1);
      alpha = nextInt(25);
      int bef = state[day];
      ch_state();
      ncost = cost();

      if(ncost > bcost){
	bcost = ncost;
	ans = state;
      }else{
	alpha = bef;
	ch_state();
      }
      tend = timer::now();
    }
  }

  void input(){
    cin>>D;
    for(int i=0;i<26;i++){
      //c[i] = nextInt(100);
      cin>>c[i];
    }
    for(int i=0;i<D;i++){
      for(int j=0;j<26;j++){
	cin>>d[i][j];
	//d[i][j] = nextInt(20000);
      }
    }
  }

  void output(){
    for(int i=0;i<D;i++){
      cout<<ans[i]+1<<endl;
    }
    /* for(int i=0;i<D;i++){
      cout<<state[i]+1<<endl;
    }
    cout<<cost()<<endl;
    cout<<bcost<<endl;
    */
  }
};
int main(){
  Marathon solver;
  solver.output();
  return 0;
}


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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
ll n, s, flag, ans;
inline ll read(){
	ll x = 0, f = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar();}
	while(ch >='0' && ch <='9') { x = (x<<3)+(x<<1)+(ch^48); ch = getchar();}
	return x*f;
}
ll f(ll b, ll n) {
	if(b > n) return n;
	else return f(b, n/b) + n%b;   
}
int main(){ 
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	n = read(); s = read(); 
	if(n < s) { puts("-1"); return 0; }
	if(n == s) { printf("%lld\n", n+1); return 0; }
	for(ll i = 2; i <= sqrt(n)+1; i++) {
		if(f(i, n) == s) { flag = 1; ans = i; break; }
	}
	if(flag) { printf("%lld\n", ans); return 0; }
	ll k = n-s;
	for(ll i = k/sqrt(n)+1; i >= 1; i--) {
		 if(!(k%i) && s - i <= k/i && s >= i && i <= k/i) { ans = (k/i) + 1; flag = 1; break; }
	}
	if(flag) { printf("%lld\n", ans); return 0; }
	else puts("-1");
	return 0;
}


Measured memory_bytes: 256
DMG = 0
MP = 1

H,N = gets.split(/ /).map(&:to_i)
kind = readline('').split(/\r?\n/).map{|l| l.split(/ /).map(&:to_i)}.sort_by{|dmg,mp| dmg.to_f / mp}
KIND = kind.select{|m| !kind.any?{|m2| m2[DMG] >= m[DMG] && m2[MP] < m[MP]}}

dp = Array.new(H + 1, (H.to_f / KIND.last[DMG]).ceil * KIND.last[MP])
dp[0] = 0

1.upto(H) do |hp|
  KIND.each do |m|
    cost = (m[DMG] > hp ? 0 : dp[hp - m[DMG]]) + m[MP]
    dp[hp] = cost if dp[hp] > cost
  end
end

puts dp[H]

Measured memory_bytes: 2168
#include <bits/stdc++.h>
    using namespace std;
     
     
    int main() {
    long long n;
    cin >> n;
    vector<long long> p;
    vector<long long> q;
      long long s=0;
      for(int i = 0;i < n;i++){
        long long a;
        cin >> a;
       if(i%2==0)p.push_back(a);
        else {q.push_back(a);s+=a;}
      }
      if(n%2==0){
        long long t=0;
        long long h=0;
        for(int i = 0;i < n/2;i++){
          h += p.at(i)-q.at(i);
          t = max(h,t);
        }
        cout << s+t << endl;}
          else{
         vector <long long> t(n/2+1);
         vector <long long> r(n/2+1);
        long long h=0;
        for(int i = 0;i < n/2;i++){
          h += p.at(i)-q.at(i);
          t.at(i+1) = max(h,t.at(i));
        }
        h = 0;
        for(int i = n/2-1;i > -1;i--){
          h += p.at(i+1)-q.at(i);
          r.at(i) = max(h,r.at(i+1));
        } 
        long long ans = 0;
        for(int i = 0;i < n/2+1;i++){
          ans = max(t.at(i)+r.at(i),ans);
        }
            cout << ans+s << endl;
          }
    }  

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

int main()
{
	  int n;
      cin>>n;
      int a[n][3];
      for(int i=0;i<n;i++)
      {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        if(i>0)
        {
          a[i][0]=max(a[i-1][1],a[i-1][2])+a[i][0];
          a[i][1]=max(a[i-1][0],a[i-1][2])+a[i][1];
          a[i][2]=max(a[i-1][1],a[i-1][0])+a[i][2];
        }
      }
      cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y123123
#define int ll

using namespace std;

const int N = 3e3 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;

string s;
string last;
int ans;

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

    cin >> s;
    last = s[0];
    ans++;
    for(int i = 1; i < s.size(); ++i){
        string tec = "";
        tec += s[i];
        if(tec == last){
            if(i + 1 == s.size()){
                break;
            }
            last = "";
            last += s[i];
            last += s[i + 1];
            i++;
            ans++;
        }else{
            last = "";
            last += s[i];
            ans++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b;
vector<int> e[100001];

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++)
    cin>>a>>b,e[a].push_back(b),e[b].push_back(a);
  bool used[100001];
  memset(used,0,sizeof(used));
  int p=1;
  deque<int> ans;
  while(!used[p]){
    used[p]=1;
    ans.push_back(p);
    for(int i=0;i<(int)e[p].size();i++)
      if(!used[e[p][i]]){p=e[p][i];break;}
  }
  p=1;
  used[1]=0;
  while(!used[p]){
    used[p]=1;
    if(p!=1)ans.push_front(p);
    for(int i=0;i<(int)e[p].size();i++)
      if(!used[e[p][i]]){p=e[p][i];break;}
  }
  cout<<ans.size()<<endl;
  while(!ans.empty()){
    cout<<ans.front()<<" ";
    ans.pop_front();
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    bool humi=true;
    REP(i, s.size()) {
        if (i%2==0) {
            if (s[i] == 'L') {
                humi = false; break;
            }
        } else {
            if (s[i] == 'R') {
                humi = false; break;
            }
        }
    }
    if (humi) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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


int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> E(N,(vector<int>()));
    int a,b;
    rep(i,M){
        cin >> a >> b;
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    int cnt=0;
    stack<pair<int,int>> st;
    st.push(make_pair(0,0));
    while(!st.empty()){
        int v = st.top().first;
        int s = st.top().second;
        st.pop();
        if(((s >> v) & 1)) continue;
        s += (1 << v);
        if(s == (1 << N) - 1){
            cnt++;
            continue;
        }
        for(auto& next:E[v]){
            st.push(make_pair(next,s));
        }
    }
    cout << cnt << endl;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}


Measured memory_bytes: 3112
fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val dice = readLine()!!.split(" ").map { it.toDouble().let { (1+it)/2 } }
    val subTotal = dice.take(m).sum()
    val subTotalList = mutableListOf(subTotal)
    if(n > m) {
        for(i in (m until n)) {
            val tmp = subTotalList.last() + dice[i] - dice[i-m]
            subTotalList.add(tmp)
        }
    }
    println(subTotalList.max())
}


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

int main() {
  long N,K;
  cin>>N>>K;
  vector<long> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  long ans=0;
  long high=1e18,low=0;
  long  mid;
  while(high-low>1){
    mid=(high+low)/2;
    long t=K;
    vector<long> b(N);
    //for(int i=0;i<N;i++) b[i]=a[i];
    for(int i=0;i<N;i++){
      if(a[i]>mid){
        //cout<<mid<<a[i]/mid<<endl;
        if(a[i]%mid==0) t-=(a[i]/mid-1);
        else t-=(a[i]/mid);
      }
    }

    if(t>=0){
      high=mid;
    }
    else{
      low=mid;
    }

  }

  cout<<high<<endl;


}


Measured memory_bytes: 6192
#include <stdio.h>

#define min(x, y) ((x)<(y)?(x):(y))

int s[200], dp0[1000010], dp1[1000010];

int main(void)
{
    int i, j, k, n;
    for(k=1;k*(k+1)*(k+2)<6000000;++k) {
        int t=k*(k+1)*(k+2)/6;
        dp0[t]=1;
        if (t%2) dp1[t]=1;
        s[k]=t;
    }
    for(i=1;i<1000010;++i) {
        if (!dp0[i]) {
            dp0[i]=i;
            for(j=1;j<k&&s[j]<i;++j)
                dp0[i]=min(dp0[i], dp0[i-s[j]]+dp0[s[j]]);
        }
        if (!dp1[i]) {
            dp1[i]=i;
            for(j=1;j<k&&s[j]<i;j+=2)
                dp1[i]=min(dp1[i], dp1[i-s[j]]+dp1[s[j]]);
        }
    }

    while (scanf("%d", &n), n) {
        printf("%d %d\n", dp0[n], dp1[n]);
    }
    return 0;
}

Measured memory_bytes: 8412
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[10000],a[300000], b[300000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<vector<Edge>>vec;
vector<LL>v[100000];
map<Pll,LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	if (n == 1) {
		cout << "Yes" << endl;
		cout << 2 << endl;
		cout << "1 1" << endl;
		cout << "1 1" << endl;
		return 0;
	}
	rep(i,n+1) {
		if (2 * n == i * (i - 1)) {
			s = i;
			break;
		}
	}
	if (s == 0) {
		cout << "No" << endl;
		return 0;
	}
	else {
		cnt = 1;
		rep(i, s) {
			rep(j, s - i - 1) {
				v[i].push_back(cnt);
				v[i + j+1].push_back(cnt);
				cnt++;
			}
		}
		cout << "Yes" << endl;
		cout << s << endl;
		rep(i,s) {
			cout << v[i].size()<<" ";
			rep( j, v[i].size()) {
				cout << v[i][j] << " \n"[j == v[i].size() - 1];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 7296
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200;

set <int> S;
vector <int> g;
int n, m, k;
int a[N];
string ss;

int ch(vector <int> &v){
	int sum = 0;
	for (int i = 0; i < n; i++) sum += v[i];
	for (int i = 0; i < n; i++){
		if (__gcd(v[i], sum) == 1) return 0;
	}
	int x = 0;
	for (int i = 0; i < n; i++){
		x = __gcd(x, v[i]);
	}
	if (x == 1) return 1;
	return 0;
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	srand(time(0));
	cin >> n;
	if (n == 3){
		cout << "2 3 25";
		return 0;
	}
	if (n == 4){
		cout << "2 3 4 9";
		return 0;
	}
	if (n == 5){
		cout << "2 3 4 5 16";
		return 0;
	}
	vector <int> v;
	for (int i = 2; i <= 30000; i += 2) v.pb(i);
	for (int i = 3; i <= 30000; i += 6) v.pb(i);
	while (!ch(v)) random_shuffle(all(v));
	for (int i = 0; i < n; i++){
		cout << v[i] << " ";
	}
	return 0;
}












Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<long long >where;
int n, k, a, b;
long long solve(long long start , long long end){
    long long  r = upper_bound(where.begin(), where.end(), end)-where.begin();
    long long l = lower_bound(where.begin(), where.end(), start)-where.begin();
    
    long long  aveng = r - l;
   
    if(start == end){
        if(aveng)return 1 * aveng * b;
        return a;
    }
    
    
    long long ch1 ;
    if(aveng)
    ch1 = (end - start + 1) * aveng * b;
    else return  a;
   
    long long ch2 = solve(start, (end + start)/ 2) + (solve((end + start)/ 2 + 1, end));
    

    return min(ch1, ch2);
    
}
int main(void){
 int n;
 cin >> n;
 if(n >= 30)cout << "Yes";
 else cout << "No";
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n],b[n]={0};
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    for(ll i=0;i<k;i++){
        ll ai,bi;
        cin>>ai>>bi;
        if(a[ai-1]<=a[bi-1])
            b[ai-1]=1;
        if(a[bi-1]<=a[ai-1])
            b[bi-1]=1;
    }
    for(ll i=0;i<n;i++){
        if(b[i]==0)
            ans+=1;
        //cout<<b[i]<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5156
#include <iostream>
using namespace std;
int main(void){
   int i=1,a[1000000]={},cnt=0;
   
   cin>>a[0];
   
   while(1){
      if(a[i-1]%2==0) a[i]=a[i-1]/2;
      else if(a[i-1]%2==1) a[i]=3*a[i-1]+1;
      int c=a[i];
      
      for(int j=0;j<i;j++){
          if(c==a[j]) cnt++;
          
      }
      if(cnt!=0) break;
      i++;
   }
   cout<<i+1<<endl;
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j;
	long int h;
	long int count = 0;
	long int num = 1;
	
	scanf("%ld", &h);
	
	while(h > 0) {
		count += num;
		h /= 2;
		num *= 2;
	}
	
	printf("%ld\n", count);
	
	return 0;
}

Measured memory_bytes: 128
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, p = map(int, readline().split())
  print((3*a+p)//2)
  
  
  
  
if __name__ == '__main__':
  main()

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

int main() {
  int t,a,b;
  cin >> t >> a >> b;
  
  int m1 = t * a;
  int m2 = b;
  if(m1 < m2) {
    cout << m1 << endl;
  }else {
    cout << m2 << endl;
  }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const int MAX_LOG = (int)(335 + 5);

string s;

int n;
int doubling[MAX_LOG][MAX_N];

map<int, vector<int>> mp;

string binexp = "100100100100110101101001001011001010011000011011111010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

void make_doubling() {
  int dp[2][MAX_N];

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      dp[0][i] = i + 1;
      // last.push_back(i + 1);
      // doubling[0][i] = i + 1;
    } else {
      dp[0][i] = i - 1;
      // last.push_back(i - 1);
      // doubling[0][i] = i - 1;
    }
  }

  for (int i = 0; i < n; ++i) {
    mp[0].push_back(dp[0][i]);
  }

  for (int i = 1; i < binexp.size(); ++i) {
    int cur = i % 2;
    int last = (i - 1) % 2;

    for (int j = 0; j < n; ++j) {
      int fst = dp[last][j];
      int snd = dp[last][fst];
      dp[cur][j] = snd;
      // int fst = doubling[i - 1][j];
      // int snd = doubling[i - 1][fst];
      // doubling[i][j] = snd;
    }

    if (binexp[i] == '1') {
      for (int j = 0; j < n; ++j) {
        mp[i].push_back(dp[cur][j]);
      }
    }
  }
}

int after[MAX_N];

int ans[MAX_N];

int main(void) {
  // Here your code !
  cin >> s;

  n = s.size();

  reverse(binexp.begin(), binexp.end());

  make_doubling();

  for (int i = 0; i < n; ++i) {
    after[i] = i;
  }

  for (int i = 0; i < binexp.size(); ++i) {
    if (binexp[i] == '0') continue;

    for (int j = 0; j < n; ++j) {
      after[j] = mp[i][j];
    }
  }

  for (int i = 0; i < n; ++i) {
    ans[after[i]] += 1;
  }

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

  return 0;
}


Measured memory_bytes: 12920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio;
    ll n,l;cin>>n>>l;
    vector<string>s;
    while(n--){
        string u;cin>>u;s.pb(u);
    }
    sort(s.begin(),s.end());
    for(auto x:s){
        cout<<x;
    }cout<<endl;
    
    
    return 0;
}








Measured memory_bytes: 256
#define mod 1000000007
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=1e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
int t,cas;
int n,m;
int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		if(n<=(m<<1))printf("0\n");
		else printf("%d\n",n-(m<<1));
	}
}


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

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO 自動生成されたメソッド・スタブ
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        String[] line = br.readLine().split(" ");
	        int a = Integer.parseInt(line[0]);
	        int b = Integer.parseInt(line[1]);

	        if(a+b==15){
	            System.out.println("+");
	        }else if(a*b==15){
	            System.out.println("*");
	        }else{
	            System.out.println("x");
	        }
	}

}


Measured memory_bytes: 20564
#include <cstdio>
#include <limits>
#include <vector>
#include <algorithm>
using namespace std;
template<typename Type> class RMQ {
private:
	int size_; vector<Type> dat;
	Type query_(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return numeric_limits<Type>::max();
		if (a <= l && r <= b) return dat[k];
		int lc = query_(a, b, 2 * k, l, (l + r) / 2);
		int rc = query_(a, b, 2 * k + 1, (l + r) / 2, r);
		return min(lc, rc);
	}
public:
	RMQ(int size__) {
		for (size_ = 1; size_ < size__; size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
	}
	RMQ(vector<Type> v) {
		for (size_ = 1; size_ < dat.size(); size_ <<= 1); dat.resize(size_ * 2, numeric_limits<Type>::max());
		for (int i = 0; i < v.size(); i++) dat[i + size_] = v[i];
		for (int i = size_ - 1; i >= 1; i--) dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	int size() { return size_; }
	int ndat() { return numeric_limits<Type>::max(); }
	void update(int i, int x) {
		i += size_; dat[i] = x;
		while (i > 1) i >>= 1, dat[i] = min(dat[2 * i], dat[2 * i + 1]);
	}
	Type query(int l, int r) {
		return query_(l, r, 1, 0, size_);
	}
};
int n, ptr, ret, a[200000], b[200000], previ[200001];
int main() {
	scanf("%d", &n); ret = n;
	for (int i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b + n);
	for (int i = 0; i < n; i++) ptr = lower_bound(b, b + n, a[i]) - b, a[i] = ptr + 1;
	for (int i = 1; i <= n; i++) previ[i] = -1;
	RMQ<int> r(n);
	for (int i = 0; i < n; i++) r.update(i, a[i]);
	for (int i = 0; i < n; i++) {
		if (previ[a[i]] != -1) {
			if (r.query(previ[a[i]], i) >= a[i]) ret--;
		}
		previ[a[i]] = i;
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 6964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <numeric>
#include <set>

#define MOD 1000000007
#define INF 2000000000
#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(YY, yy) for(long long yy = 0; yy < YY; ++yy)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<pair<int, pair<int, int> > > vpip;
typedef vector<bool> vb;
typedef priority_queue<int> pqi;

int N;
vi A, B, C;

int main(int argc, char **argv)
{
    ios::sync_with_stdio(); cin.tie(0);
    cin >> N;
    A.assign(N, 0);
    B.assign(N, 0);
    C.assign(N-1, 0);

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

    int bef = -1, total = 0;
    for(int i = 0; i < N; ++i)
    {
        total += B[A[i]];
        if(bef != -1)
        {
            if(bef == A[i] - 1)
            {
                total += C[bef];
            }
            else bef = A[i];
        }
        bef = A[i];
    }
    cout << total << endl;


    return 0;
}

//cikisir



Measured memory_bytes: 256
from collections import Counter

N = int(input())

s_sorted_list = []
for i in range(N):
    s_sorted = ''.join(sorted(input()))
    s_sorted_list.append(s_sorted)

count = Counter(s_sorted_list)
count = count.most_common()

ans = 0
for i in range(len(count)):
    if count[i][1] == 1:
        break
    else:
        ans += count[i][1]*(count[i][1]-1)//2
print(ans)

Measured memory_bytes: 24484
/*********************************************
 *Author*        :ZZZZone
 *reated Time*  : 2017/8/7 12:35:46
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1e5;
int n;
LL a[MaxN + 5]; 

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    while(~scanf("%d", &n)){
    	int cnt4 = 0, cnt2 = 0;
    	for(int i = 1; i <= n; i++){
    		scanf("%lld", &a[i]);
    		if(a[i] % 4 == 0) cnt4++;
    		else if(a[i] % 2 == 0) cnt2++;
		}
		int tot = 2 * cnt4 + 1;
		if(cnt2 > 0) tot += cnt2 - 1;
		if(tot >= n) printf("Yes\n");
		else printf("No\n");
	}
    return 0;
}

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

using namespace std;

int main(){
	//freopen("92bIn.txt","r",stdin);
	//freopen("92bOut.txt","w",stdout);
	
	int n,d,x,val,tot,cnt,totsum;
	totsum=0;
	cin>>n>>d>>x;
	for(int i=0;i<n;i++){
		cin>>val;
		tot=1;
		cnt=1;

		while(tot<=d){
			tot=(cnt*val)+1;
			cnt++;
		}

		totsum=totsum+(cnt-1);
	}
	cout<<totsum+x<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char s[5];
    int i,a=0,b=0;
    scanf("%s",s);
    for(i=0;s[i];i++)
    {
        if(s[i]=='+')
            a++;
        else
            b++;
    }
    printf("%d\n",a-b);
    return 0;
}


Measured memory_bytes: 128