akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextInt()
    println(1 - x)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34324
n = gets.to_i
v = gets.strip.split(" ").map(&:to_f).sort
(n - 1).times do
    item1 = v[0]
    item2 = v[1]
    v.shift(2)
    v.unshift((item1 + item2) / 2)
end
print v.inject(:+)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};



int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];
    vector<ll> ab;
    rep(i,x){
        rep(j,y){
          ab.push_back(a[i] + b[j]);
        }
    }
    sort(all(ab), greater<ll>());
    vector<ll> abc;
    rep(i,min(k, sz(ab))){
        rep(j,z){
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(all(abc), greater<ll>());
    rep(i,k) print(abc[i]);
}


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

typedef pair<double, double> P;

double x[2][123],y[2][123],a[123],b[123],c[123];

set<P> st;

int main(void){
	int n,i,j,ans;
	double p,q;
	while(cin >> n){
		if(!n){
			break;
		}
		ans = 1;
		for(i=0; i<n; ++i){
			cin >> x[0][i] >> y[0][i] >> x[1][i] >> y[1][i];
			a[i] = y[1][i]-y[0][i];
			b[i] = x[0][i]-x[1][i];
			c[i] = (y[1][i]-y[0][i])*x[0][i] + (x[0][i]-x[1][i])*y[0][i];
		}
		for(i=0; i<n; ++i){
			st.insert(P(x[0][i],y[0][i]));
			st.insert(P(x[1][i],y[1][i]));
			for(j=0; j<i; ++j){
				if(a[i]*b[j]==a[j]*b[i]){
					continue;
				}
				p = (c[i]*b[j]-c[j]*b[i])/(a[i]*b[j]-a[j]*b[i]);
				q = (c[i]*a[j]-c[j]*a[i])/(b[i]*a[j]-b[j]*a[i]);
				if(-100.0<=p && p<=100.0 && -100.0<=q && q<=100.0){
					st.insert(P(p,q));
				}
			}
			ans += (st.size()-1);
			st.clear();
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <string.h>

int main()
{
	char inp[96];
	int  len;
	int  i;
	/**--init --**/

	for (;;) {
		/**--input--**/
		gets(inp);
		len = strlen(inp);
		if (len==0) {
			break;
		}

		for (i=len-1 ; i>=0 ; i--) {
			printf("%c",inp[i]);
		}
		printf("\n");
		break;
	}
	return 0;
}

Measured memory_bytes: 524
var 
    std: String;
begin
    ReadLn(std);
    
    if std = 'H H' then
      Writeln('H')
    else if std = 'H D' then
      Writeln('D')
    else if std = 'D H' then
      Writeln('D')
    else if std = 'D D' then
      Writeln('H');
      
end.

Measured memory_bytes: 128
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    d=int(readline())
    c=list(map(int, readline().rstrip().split()))
    s=[0]*d
    for i in range(d):
        s[i]=list(map(int, readline().rstrip().split()))

    last=[-1]*26
    for i in range(d):
        maxx=-1
        memo=0
        for j in range(26):
            ccc=(i-last[j])*c[j]
            if (s[i][j]-ccc) > maxx:
                maxx=(s[i][j]-ccc)
                memo=j
        print(memo+1)
        last[memo]=i
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16536
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from heapq import heapify, heappush, heappop
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    total = 0
    L, R = [], []
    for _ in range(N):
        k, l, r = map(int, input().split())
        if l >= r:
            # kより前に入れたい
            L.append((k, l, r))
            total += l
        else:
            # kより後ろに入れたい
            R.append((N - k, r, l))
            total += r

    # Lにとって前から，Rにとって後ろから
    L.sort()
    R.sort()

    queue = []
    for i in range(len(L)):
        k, ai, bi = L[i]
        heappush(queue, ai - bi)
        # 前から入れていき，効果が薄いもの(ai - bi)は消す
        while len(queue) > k:
            value = heappop(queue)
            total -= value
            
    queue = []
    for i in range(len(R)):
        k, ai, bi = R[i]
        heappush(queue, ai - bi)
        # 後ろから入れていき，効果が薄いもの(ai - bi)は消す
        while len(queue) > k:
            value = heappop(queue)
            total -= value

    print(total)


if __name__ == '__main__':
    t = int(input())
    while t > 0:
        t -= 1
        main()

Measured memory_bytes: 43116
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

#define mp(k, v) make_pair(k, v)

using namespace std;

int main ( void )
{
	string in;
	
	char hyo[] = { 'w', ' ', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r' };
	map<char, char> m;
	
	m.insert(mp('T', 'a'));
	m.insert(mp('L', 'i'));
	m.insert(mp('U', 'u'));
	m.insert(mp('R', 'e'));
	m.insert(mp('D', 'o'));
	
	while (cin >> in)
	{
		string out = "";
		for (int i = 0, len = in.size(); i < len; i+=2)
		{
			if ((in[i] == '0') && (in[i+1] == 'U'))
			{
				out += "nn";
			}
			else
			{
				if (in[i] != '1')
				{
					out += hyo[in[i] - '0'];
				}
				out += m[in[i+1]];
			}
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void)
{
	int n,i,j;
	char s;
	scanf("%d\n",&n);
	char array_b[n*3],array_s1[n*3],array_s2[n*3];
	for (i = 0;i < n * 3;i++) {
		scanf("%c",&array_b[i]);
		array_s1[i] = array_b[i];
		array_s2[i] = array_s1[i];
	}

  /* bubble_sort */
	for (j = 0;j < n;j++) {
		for (i = 1;i < n * 3 - 2;i+=3) {
			if (array_b[i+3] < array_b[i]) {
				/* change letter */
				s = array_b[i+2];
				array_b[i+2] = array_b[i-1];
				array_b[i-1] = s;
				/* change nummber */
				s = array_b[i+3];
				array_b[i+3] = array_b[i];
				array_b[i] = s;
			}
		}
	}
	
	for (i = 0;i < n * 3 - 1;i++) {
		if (i == (n * 3 - 2))
			printf("%c\n",array_b[i]);
		else  printf("%c",array_b[i]);
	}
	printf("Stable\n");

  /* select_sort-v3 */
	for (j = 1;j < n * 3 - 2 ;j+=3) {

		for (i = j + 3;i < n * 3 - 2;i+=3) {
			if(array_s1[i+3] >= array_s1[i]) {
				array_s1[i+2] = array_s1[i-1];
				array_s1[i+3] = array_s1[i];
			}
		}

		if (array_s2[j] > array_s1[n*3-2]) {
			for (i = j + 3;i < n * 3 - 2;i+=3)
				if (array_s2[i] == array_s1[n*3-2])
					break;
			/* change letter */
			s = array_s2[j-1];
			array_s2[j-1] = array_s1[n*3-3];
			array_s2[i-1] = s;
			/* change number */
			s = array_s2[j];
			array_s2[j] = array_s1[n*3-2];
			array_s2[i] = s;
			for (i = j;i < n * 3;i+=3) {
				array_s1[i-1] = array_s2[i-1];
				array_s1[i] = array_s2[i];
			}
		} else {
			for (i = j + 3;i < n * 3 ;i+=3) {
				array_s1[i-1] = array_s2[i-1];
				array_s1[i] = array_s2[i];
			}
		}

	}
	
	for (i = 0;i < n * 3 - 1;i++) {
		if (i == n * 3 - 2)
			printf("%c\n",array_s2[i]);
		else printf("%c",array_s2[i]);
	}

  /* compare */
	for (i = 0;i < n * 3;i++) {
		if (array_s2[i] != array_b[i] ) {
			printf("Not stable\n");
			return 0;
		}
	}
	printf("Stable\n");
	return 0;
}


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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int l;

void solve() {
  int tl = 0; bool flag = false;
  rep(i,12) {
    int m, n; cin>>m>>n;
    if (flag) continue;
    tl += (m-n);
    if (tl >= l) {
      cout<<i+1<<endl;
      flag = true;
    }
  }
  if (flag) return;
  cout<<"NA"<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>l, l) {
    solve();
  }
  return 0;
}

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

int gcd(int a, int b) { 
    if(b==0)
        return a; 
    return gcd(b, a % b);  
      
}
int main(){
    int x;
    cin>>x;
    int g=gcd(x,360);
    cout<<360/g<<endl;
}

Measured memory_bytes: 3628
s=input()
t=input()
i=0
index=-1
ans=0
while i<len(t):
  if t[i] not in s:
    break
  elif t[i] not in s[index+1:]:
    ans+=len(s)-index+s.index(t[i])
    index=s.index(t[i])
    i+=1
  else:
    ans+=s[index+1:].index(t[i])+1
    index+=s[index+1:].index(t[i])+1
    i+=1
print(ans if i==len(t) else -1)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<string>

typedef long long ll;

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    int ans = 1e9;
    int len = s.length();
    for (int i = 0; i <= len-2; i++){
        if(s[i]!=s[i+1]){
            ans = min(ans, max(i + 1, len -1 - i));
        }
    }
    //易错!!!如果ans还是1e9的话,答案应该是s.length()!!!我只想着"因为要去最小值所以一开始要初始化一个很大的值"了...
    //其实一开始给ans初始化s.length()就行啦~~
    if(ans==(int)1e9){
        ans = len;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
use std::vec::Vec;
use std::collections::HashSet;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<i64> = read_vec();
    if v[0] == v[1] {
      println!("{}", v[2]);
    }
    else if v[1] == v[2]{
      println!("{}", v[0]);
    }
    else {
      println!("{}", v[1]);
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> s(n+1,0);
  REP(i,n){
    int a;
    cin >> a;
    s[i+1] = s[i] + a;
  }

  map<int, ll> mp;
  REP(i,n+1)mp[s[i]%m]++;

  ll ans=0;
  for(auto &v: mp){
    ans += v.second * (v.second-1) / 2;
  }
  cout << ans << endl;

}



Measured memory_bytes: 4992
#define FASTIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//#define BZ
//#define PBDS
//#define POINT

#ifndef BZ
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("no-stack-protector")
#pragma GCC target ("tune=native")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize ("conserve-stack")
//#pragma GCC optimize ("no-stack-limit")
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using str = string;
using pll = pair<ll, ll>;

#ifdef POINT
using point = complex<ll>;
#define x real
#define y imag
#endif

#ifdef PBDS
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//using namespace __gnu_pbds::detail;
template <class T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#endif

#define INF 0x7fffffffffffffffLL
#define BASE 1000000007LL // 3 * 10**9 + 19 // 998244353 - rev == pow(n + m, BASE - 2)
#define MAX(type) std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()

#define LOG(v) cout << #v << " " << v << "\n";

#define pb push_back
#define eb emplace_back
//#define all(c) c.begin(), c.end()
//#define rall(c) c.rbegin(), c.rend()
#define F first
#define S second
#define forEach(c) for (auto &it : c)
#define loop while (true)
#define mp make_pair
#define mt make_tuple

template<class T>
void chMax(T &a, T b) {
	if (a < b) a = b;
}

template<class T>
void chMin(T &a, T b) {
	if (b < a) a = b;
}

inline ll divUp(ll a, ll b) {
	return (a + b - 1)/b;
}

void solve() {
	ll n;
	cin >> n;
	ll ans = INF;
	for (ll d = 1; d * d <= n; d++) {
		if (n % d) continue;
		chMin(ans, d + n / d);
	}
	cout << ans - 2 << "\n";
}

//#define LOCAL

int main() {
	FASTIO
#ifdef LOCAL
	auto start = std::chrono::system_clock::now();
#endif
	solve();
#ifdef LOCAL
	auto end = std::chrono::system_clock::now();
	std::chrono::duration<ld> elapsed_seconds = end - start;
	cerr << "\ntime: " << elapsed_seconds.count() << " s\n";
#endif
	return 0;
}


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

int main() {
  int n, m, l;
  cin>>n>>m>>l;
  long long cost[n][n];
  long long inf = 300 * 1e9;
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      cost[i][j] = inf;
    }
    cost[i][i] = 0;
  }
  for (int i=0; i<m; i++) {
    int a, b, c;
    cin>>a>>b>>c;
    --a;
    --b;
    cost[a][b] = c;
    cost[b][a] = c;
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (cost[i][k] != inf && cost[k][j] != inf) {
          cost[i][j] = min(cost[i][k] + cost[k][j], cost[i][j]);
        }
      }
    }
  }
  int edge[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        edge[i][j] = 0;
      } else if (cost[i][j] <= l) {
        edge[i][j] = 1;
      } else {
        edge[i][j] = 0;
      }
    }
  }
  int num[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      if (i == j) {
        num[i][j] = 0;
      } else if (edge[i][j] == 1) {
        num[i][j] = 1;
      } else {
        num[i][j] = n;
      }
    }
  }
  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (num[i][k] != n && num[k][k] != n) {
          num[i][j] = min(num[i][k] + num[k][j], num[i][j]);
        }
      }
    }
  }
  int q;
  cin>>q;
  for (int i=0; i<q; i++) {
    int s, t;
    cin>>s>>t;
    --s;
    --t;
    if (num[s][t] == n) {
      cout<<-1<<endl;
    } else {
      cout<<num[s][t]-1<<endl;
    }
  }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    double n,p;
    cin>>n>>p;
    int64_t ans=round(pow(p,1/n));
    //cout<<ans<<endl;
    while((int64_t)p % (int64_t)round(pow(ans,n)) !=0){
        ans--;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(a+b+1,c)+b<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int[] W = new int[N];
    	int Wsum = 0;
    	for(int i=0; i<N; i++) {
    		W[i] = sc.nextInt();
    		Wsum += W[i];
    	}
    	int left = 0;
    	int right = Wsum;
    	int min = Integer.MAX_VALUE;
    	for(int i=0; i<N-1; i++) {
    		left += W[i];
    		right -= W[i];
    		if(Math.abs(left - right) < min) {
    			min = Math.abs(left - right);
    		}
    	}
    	System.out.println(min);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


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

int main()
{
int a,b,sum, sub,pro;
cin>>a>>b;
sum=a+b;
sub=a-b;
pro=a*b;
if(a==0||b==0){
  cout<<sum;
}
else if (pro>=sum&& pro>=sub){
    cout<<pro;
}
else if (sum>=pro&& sum>=sub){
    cout<<sum;
}
else if (sub>=pro&& sub>=sum){
    cout<<sub;
}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  map<string, ll> cnt;
  string S;
  rep(i, N){
    cin >> S;
    cnt[S]++;
  }

  cout << "AC x " << cnt["AC"] << "\n";
  cout << "WA x " << cnt["WA"] << "\n";
  cout << "TLE x " << cnt["TLE"] << "\n";
  cout << "RE x " << cnt["RE"] << "\n";
  
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> x(N), y(M);
    for (int i = 0; i < N; i++)cin >> x[i].first >> x[i].second;
	for (int i = 0; i < M; i++)cin >> y[i].first >> y[i].second;
  
    for (int i = 0; i < N; i++){
        int index = 0;
        int ans = abs(x[i].first - y[0].first) + abs(x[i].second - y[0].second);
        for (int j = 1; j < M; j++){
            if ((abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second)) < ans){
                ans = abs(x[i].first - y[j].first) + abs(x[i].second - y[j].second);
                index = j;
            }
        }
        cout << index + 1 << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	static int z = 0;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		Long X = sc.nextLong();
		for(int a = -118; a <= 120; a++){
			for(int b = -118; b <= 120; b++){
				if(Math.pow(a, 5) - Math.pow(b, 5) == X){
					pw.println(a + " " + b);
					z = 1;
					break;
					/* System.exit(0); */
				}
				if(z == 1) break;
			}
			if(z==1) break;
		}
		pw.close();
	}	

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

		public double nextDouble(String x) 
		{

			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}


	}
}

Measured memory_bytes: 36536
n,m = map(int,input().split())
s = input()
s = s[::-1]
ans = []
cur = 0
c = 0
#while cur < n and c < 100:
while cur < n:
    d = n - cur
    r = min(m,d)
    cnt = 0
    for i in range(r):
        x = r - i
        if s[cur + x] == '0':
            ans.append(x)
            cur += x
            #print(x)
            break
        else:
            cnt += 1
    if cnt == r:
        print(-1)
        exit()
    #c += 1
    #print(cur,r)


print(*ans[::-1])

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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

struct edge{
    int to, cost;
    edge(int to, int cost): to(to), cost(cost) {}
};

struct State{
    int v, m, c;
    State(int v, int m, int c): v(v), m(m), c(c){}
    bool operator<(const State& right ) const {
        return c == right.c ? m < right.m : c > right.c;
    }
};

vector<int> dijkstra(vector<vector<edge>>& E, int start=0){
    int N = E.size();
    vector<int> d(N, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    d[start] = 0;
    que.push(P(0, start));
    while(que.size()){
        P p = que.top(); que.pop();
        if(d[p.second] < p.first) continue;
        for(edge e: E[p.second]){
            int nc = p.first + e.cost;
            if(d[e.to] > nc){
                d[e.to] = nc;
                que.push(P(nc, e.to));
            }
        }
    }
    return d;
}

int main(){
    while(1){
        int N, M, L, K, A, H;
        cin >> N >> M >> L >> K >> A >> H;
        if(N == 0) break;

        vector<bool> cure(N, false);
        for(int i=0;i<L;i++){
            int l;
            cin >> l;
            cure[l] = true;
        }

        vector<vector<edge>> E(N);
        for(int i=0;i<K;i++){
            int x, y, t;
            cin >> x >> y >> t;
            E[x].emplace_back(y, t);
            E[y].emplace_back(x, t);
        }

        vec minDist = dijkstra(E, H);
        int minCost[101][101];
        memset(minCost, -1, sizeof(minCost));

        priority_queue<State> que;
        que.emplace(A, M, 0);
        minCost[A][M] = 0;

        int ans = INF;
        while(que.size()){
            State s = que.top(); que.pop();
            if(minCost[s.v][s.m] < s.c) continue;
            if(s.c >= ans) break;
            if(cure[s.v] && s.m < minDist[s.v]){
                int rest = min(M-s.m, minDist[s.v]-s.m);
                s.c += rest;
                s.m += rest;
            }
            if(minDist[s.v] <= s.m){
                ans = min(ans, s.c+minDist[s.v]);
                continue;
            }
            for(edge& e: E[s.v]){
                int nc = s.c + e.cost, nm = s.m - e.cost;
                if(nm < 0) continue;
                if(minCost[e.to][nm] == -1 || minCost[e.to][nm] > nc){
                    minCost[e.to][nm] = nc;
                    que.emplace(e.to, nm, nc);
                }
            }
        }
        if(ans == INF) cout << "Help!" << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
_,x,y=$<.map{|e|e.chop.chars};p x.zip(y).map{|a,b|a==b}.chunk{|e|e}.reduce(3){|s,(k,v)|n=v.size;s*(k ?2**~-n: 2*3**(n/2-1))%(10**9+7)}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll h[n];
	rep(i,0,n){
		cin>>h[i];
	}
	ll flag,cnt=0;
	rep(i,0,n){
		flag=0;
		rep(j,0,i){
			if(h[i]<h[j]){
				flag=1;
				break;
			}
		}
		if(!flag){
			cnt++;
		}
	}
	cout<<cnt;
	
	
	return 0;
}

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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (W >= x + r&&H>=y+r&&0<=x&&0<=y){
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3068
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    int[] y = new int[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt();
      y[i]=sc.nextInt();
    }
    double[][] d = new double[n][n];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)d[i][j]=Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    int p = 1;
    for(int i=2;i<=n-1;i++)p*=i;
    double sum = 0;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)sum+=(double)p*d[i][j];
    sum/= p*n;
    System.out.println(sum);
  }
}

Measured memory_bytes: 22608
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int r;

    cin >> r;

    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
a_list = list(map(int, input().split()))

sum = 0
i = 0
while len(a_list) > 0:
    number = a_list.pop(a_list.index(max(a_list)))
    if i % 2 == 0:
        sum += number
    else:
        sum -= number
    i += 1
print(sum)

Measured memory_bytes: 3060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		long ans = 0;
		int minus = 0;
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			ans += Math.abs(A[i]);
			if(A[i] < 0)
				minus++;
			min = Math.min(min, Math.abs(A[i]));
		}
		if(minus % 2 == 1)
			ans -= min*2;
		System.out.println(ans);
	}

}

Measured memory_bytes: 51904
def 解():
    iN = int(input())

    #解法pdfを見て作ったその2

    iK = int((2 * iN) ** 0.5)
    if 2 * iN != iK * (iK +1 ) :
        print("No")
    else:
        print("Yes")
        print(iK+1)
        oAns = []
        iStart = 1
        for i in range(iK):
            oRes = [iK]
            oRes.extend(list(range(iStart,iStart+i+1)))
            iLast = oRes[-1]
            for k in range(i+1,iK):
                iLast += k
                oRes.append(iLast)
            oAns.append(" ".join([str(_) for _ in oRes]))
            iStart += i +1
        oRes = [iK]
        iStart = 0
        for i in range(0,iK):
            iStart += i +1
            oRes.append(iStart)
        oAns.append(" ".join([str(_) for _ in oRes]))
        print("\n".join(oAns))
解()


Measured memory_bytes: 7668
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0;i<N;i++) cin >> x.at(i);

  int sum=0;
  for(int i=0;i<N;i++){
    if(x.at(i)<abs(K-x.at(i))) sum+=2*x.at(i);
    else sum+=2*abs(K-x.at(i));
  }

  cout << sum << endl;
  
  return 0;
}


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

int main(){
    while(1){
        int p[102] = {0};
        int a[2];
        int i;
        while(1){
            if(!(cin >> a[0] >> a[1])) return 0;
            if(a[0] == 0 && a[1] == 0) break;
            for(i=0; i<2; ++i) ++p[a[i]-1];
        }
        for(i=2; i<102; ++i)
            if(p[i] % 2 != 0) break;
        if(i == 102 && p[0] % 2 != 0) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

vector<vector<int>> G;
vector<int> idx,pos,idxl,visited;


void dfs(int t, int p){
  visited[t] = true;
  idxl[t] = pos.size();
  for(auto v : G[t]){
    if(p != t && !visited[v]){
      dfs(v,t);
      idx[v] = pos.size();
      pos.push_back(v);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,q,a,b;
  cin >> n >> q;
  G = vector<vector<int>>(n);
  idx = vector<int>(n);
  visited = vector<int>(n, false);
  vector<int> imos(n+1,0);
  idxl = vector<int>(n);
  idx[0] = n-1;

  for(int i=0; i<n-1; i++){
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0, -1);
  pos.push_back(0);
  for(int i=0; i<q; i++){
    int p,x;
    cin >> p >> x;
    p--;
    imos[idxl[p]] += x;
    imos[idx[p]+1] -= x;
  }
  for(int i=0; i<n-1; i++){
    imos[i+1] = imos[i+1] + imos[i];
  }
  for(int i=0; i<n; i++){
    cout << imos[idx[i]];
    cout << ((i==n-1) ? "\n" : " ");
  }

  return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
	
using namespace std;

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int p[100000],q[100000];
void Calc(int n,pii pos[],ll ans[],int start[]){
	sort(pos,pos+n);
	int c=0,last=-1;
	REP(i,n){
		if(last!=pos[i].first){
			p[c]=last=pos[i].first;
			q[c++]=0;
		}
		q[c-1]++;
	}
	ll lc=q[0],rc=n-lc,cost=0;
	FOR(i,1,c)
		cost+=ll(q[i])*(p[i]-p[0]);
	int k=0;
	for(int i=n-1;i>=0;i--){
		while(k<c-1){
			int t=k+1;
			ll plus=lc*(p[t]-p[k]);
			ll minus=rc*(p[t]-p[k]);
			if(cost*2-abs(pos[i].first-p[k])
				>(cost+plus-minus)*2-abs(pos[i].first-p[t])){
					k++;
					lc+=q[t];
					rc-=q[t];
					cost+=plus-minus;
				}
			else
				break;
		}
		int j=pos[i].second;
		ans[j]=cost*2-abs(pos[i].first-p[k]);
		start[j]=p[k];
	}
}

pii xs[100000],ys[100000];
ll xAns[100000],yAns[100000];
int xSt[100000],ySt[100000];

typedef pair<ll,pii> Answer;

int main(){
	read(),read();
	int n=read();
	REP(i,n){
		xs[i]=MP(read(),i);
		ys[i]=MP(read(),i);
	}
	Calc(n,xs,xAns,xSt);
	Calc(n,ys,yAns,ySt);
	Answer ans=MP(LLONG_MAX,MP(0,0));
	REP(i,n){
		Answer a=MP(xAns[i]+yAns[i],MP(xSt[i],ySt[i]));
		ans=min(ans,a);
	}
	printf("%lld\n",ans.first);
	printf("%d %d\n",ans.second.first,ans.second.second);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> flowers(n);
    int ans = 0;
    int active = 0;
    for (int i = 0; i < n; i++){
        cin >> flowers.at(i);
    }

    for (int i = 0; i < n; i++){
        if(active >= flowers.at(i)){
            active = flowers.at(i);
        }else{
            ans += flowers.at(i) - active;
            active = flowers.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#

import sys
input=sys.stdin.readline

def main():
    H,W,K=map(int,input().split())
    mas=[input().strip("\n") for i in range(H)]
    mincut=H*W
    for bit in range(2**(H-1)):
        sep=[]
        for s in range(H-1):
            if (bit>>s)&1:
                sep.append(s)
        cutcnt=len(sep)
        cnt=[0]*(len(sep)+1)
        for j in range(W):
            ci=0
            cntt=cnt[:]
            for i in range(H):
                if mas[i][j]=="1":
                    cnt[ci]+=1
                if i in sep:
                    ci+=1
            if max(cnt)>K:
                for i in range(len(sep)+1):
                    cnt[i]-=cntt[i]
                cutcnt+=1
        if max(cnt)>K:
            cutcnt=10000000000
        if cutcnt<mincut:
            mincut=cutcnt
    print(mincut)
                
    
    
if __name__=="__main__":
    main()


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;


int main(){
    int N; cin >> N;
    vi A(N);
    vector<ll> s(N+1, 0);
    for(int i=0; i<N; i++){
        cin >> A[i];
        s[i+1]=s[i]+A[i];
    }
    ll res=LINF;
    for(int i=1; i<N-2; i++){
        auto it1=lower_bound(all(s), s[i+1]/2);
        auto it2=lower_bound(all(s), s[i+1]+(s[N]-s[i+1])/2);
        ll P1=*it1, P2= it1 == s.begin()?LINF:*(--it1);
        ll Q1=s[i+1]-P1, Q2=s[i+1]-P2;
        ll R1=*it2-s[i+1], R2= it2 == s.begin()?LINF:*(--it2)-s[i+1];
        ll S1=s[N]-R1-s[i+1], S2=s[N]-R2-s[i+1];
        ll maxi=max(P1, max(Q1, max(R1, S1)));
        ll mini=min(P1, min(Q1, min(R1, S1)));
        res=min(res, maxi-mini);
        maxi=max(P1, max(Q1, max(R2, S2)));
        mini=min(P1, min(Q1, min(R2, S2)));
        res=min(res, maxi-mini);
        maxi=max(P2, max(Q2, max(R1, S1)));
        mini=min(P2, min(Q2, min(R1, S1)));
        res=min(res, maxi-mini);
        maxi=max(P2, max(Q2, max(R2, S2)));
        mini=min(P2, min(Q2, min(R2, S2)));
        //cout << P1 << " " << Q1 << " " << R1 << " " << S1 << endl;
        //cout << P2 << " " << Q2 << " " << R2 << " " << S2 << endl;
        res=min(res, maxi-mini);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5620
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    std::string s;
    int result = 0;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+')
            result++;
        else
            result--;
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int i,n;
    int a[100];
    scanf("%d", &n);
    for(i = 0;i < n;i++)
        scanf("%d", &a[i]);
 
    for(i = n - 1; i >= 0; i--) {
        printf("%d", a[i]);
        if(i != 0)
            	printf(" ");
    }
    printf("\n");
    return 0;
}


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

int solve(int custo,int total,int tempo){

        int tempo2=0,total2=0,i=1;

        while (tempo2<tempo){
                tempo2=i*custo;
                i++;
                if (tempo2<tempo){
                total2+=total;
                }
        }

return total2;



}

int main(){

int a,b,t;
cin >> a >> b >> t;
a=a*10;
t=t*10+5;


cout << solve(a,b,t)<<endl;


return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int n;
	while(cin>>n){
		int ans = 1;
		for(int i=1;i<=n;i++){
			ans += i;
		}
		cout<< ans<< endl;
	}
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();
	return 0;
}

 

Measured memory_bytes: 1160
INF = 10**16

# ソートしてから入れる
def ClosestDFS(Points):
    l = len(Points)
    if l <= 1: return INF, Points
    d1, nearPoints1 = ClosestDFS(Points[:l//2])
    d2, nearPoints2 = ClosestDFS(Points[l//2:])
    retPoints = []
    ind = 0
    for p1x, p1y in nearPoints1:
        while ind != len(nearPoints2) and nearPoints2[ind][1] < p1y:
            retPoints.append(nearPoints2[ind])
            ind += 1
        retPoints.append((p1x, p1y))
    while ind != len(nearPoints2):
        retPoints.append(nearPoints2[ind])
        ind += 1
    
    d = min(d1, d2)
    B = []
    border_x = Points[l//2][0]
    for px, py in retPoints:
        if abs(border_x-px) > d: continue
        for bx, by in reversed(B):
            if py - by > d: break
            d = min(d, ((px-bx)**2+(py-by)**2)**0.5)
        B.append((px, py))
    return d, retPoints

def ClosestPair(Points):
    Points.sort()
    d, _ = ClosestDFS(Points)
    return d

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    Points = [list(map(float, input().split())) for _ in range(N)]
    print("{:.8f}".format(ClosestPair(Points)))

if __name__ == "__main__":
    main()


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	string s;
	cin >> n >> k >> s;

	string hoge = "";
	hoge = s[k - 1];
	std::transform(hoge.begin(), hoge.end(), hoge.begin(), ::tolower);

	if (k == 1) {
		cout << hoge;
		for (int i = 1; i < n; i++) {
			cout << s[i];
		}
		cout << endl;
		return 0;
	}

	for (int i = 0; i < k - 1; i++) {
		cout << s[i];
	}
	
	cout << hoge;

	for (int i = k; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }

  return x;
  
}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }

  return x;
 
}

Node treeSearch(Node u, int k){

  while(u!=NIL && 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!=NIL) return treeMinimum(x->right);

  y=x->parent;

  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
		      
  return y;
  
}

void transplant(Node u,Node v){

  if(u->parent==NIL) root=v;
  else if(u==u->parent->left) u->parent->left=v;
  else u->parent->right=v;

  if(v!=NIL) v->parent=u->parent;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL){
    transplant(z,z->right);
  }else if(z->right==NIL){
    transplant(z,z->left);
  }else{
    y=treeMinimum(z->right);
    if(y->parent!=z){
      transplant(y,y->right);
      y->right=z->left;
      y->left->parent=y;
    }
  }

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; // 親を設定

    if (z->key < x->key){
      x = x->left; // 左の子へ移動
    }else{ 
      x = x->right; // 右の子へ移動
    }
    
  }//while
  
  z->parent = y;

  if(y == NIL){ // T が空の場合
    root = z;
  }else if (z->key < y->key){
    y->left = z; // z を y の左の子にする
  } else {
    y->right = z; // z を y の右の子にする
  }

}

void inorder(Node u){
  
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
  
}

void preorder(Node u){

  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) 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;
}



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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, k;
	cin >> n >> k;
	ll c1 = 0, c2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i%k == 0) ++c1;
		if (k%2 == 0 && i%k == k/2) ++c2;
	}
	ll answer = c1*c1*c1 + c2*c2*c2;
	cout << answer << endl;
}


Measured memory_bytes: 256
def solve():
  n, l = map(int,input().split())
  ans = 0
  pre = 0
  trend = 1
  acc = 0
  for i in range(n):
    length = int(input())
    time = l - length
    if length > pre and trend >= 0:
      acc += time
    elif length < pre and trend <= 0:
      acc += time
    else:
      if ans < acc:
        ans = acc
      acc = time + (l - pre)
      trend = length - pre
    pre = length
  else:
    ans = max(ans, acc)
  print(ans)
solve()


Measured memory_bytes: 5620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADuplexPrinting solver = new ADuplexPrinting();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADuplexPrinting {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            w.println((s.nextInt() + 1) / 2);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23380
let () =
  Scanf.scanf "%d %d" @@ fun h w ->

  let c = Array.init 10 (fun _ -> Array.init 10 (fun _ -> Scanf.scanf " %d" ((+) 0))) in
  for k = 0 to 9 do
    for i = 0 to 9 do
      for j = 0 to 9 do
        c.(i).(j) <- min c.(i).(j) (c.(i).(k) + c.(k).(j))
  done done done;

  Array.init (h*w) (fun _ -> Scanf.scanf " %d" ((+) 0))
  |> Array.fold_left (fun s e ->
      if e = -1 then s else s + c.(e).(1)) 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 4736
import sys
a = sys.stdin.read().lower()
c = {}
for i in range(26):
    c[chr(ord('a')+i)] = 0
for i in a:
    if c.get(i) is None:
        continue
    else:
        c[i] += 1
for i in range(26):
    print(chr(ord('a')+i) + ' : ' + str(c[chr(ord('a')+i)]))


Measured memory_bytes: 5564
#include<iostream>
#include<string>
using namespace std;
int main(){
long d,n,i,j,k,p,q,r;
string s[100];
cin>>d;
for(k=0;k<d;k++){
cin>>n;
for(i=0;i<n;i++){
s[i].erase();
s[i].resize(n,' ');
}
for(i=n-1;i>=0; i--)s[i][0]='#';
for(j=0;j<n/2;j+=2){
for(i=j;    i<n-j;  i++)s[j]    [i]    ='#';
if(2*j>=n-2)break;
for(i=j;    i<n-j;  i++)s[i]    [n-1-j]='#';
for(i=n-1-j;i>=j+2; i--)s[n-1-j][i]    ='#';
if(2*j>=n-4)break;
for(i=n-1-j;i>=j+2; i--)s[i]    [j+2]  ='#';
}
if(k>0)cout<<endl;
for(i=0;i<n;i++)cout<<s[i]<<endl;
}
return 0;
}

Measured memory_bytes: 1228