akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
  int ma,md;
  int da,dd;
  int r;
  scanf("%d", &ma);
  scanf("%d", &da);
  scanf("%d", &md);
  scanf("%d", &dd);
  if(ma==md){
    r=0;
  }
  else{
    r=1;
  }
  printf("%d\n",r);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#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()

typedef long long lint;

using namespace std;

int main(){
  int X,Y;
  cin>>X>>Y;
  if(Y%2==0 and X*2<=Y and Y<=X*4)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str

def can_make(steps, t, init):
    cur = {init}
    for s in steps:
        nex = set()
        for c in cur:
            nex.add(c + s)
            nex.add(c - s)
        cur = nex
    if t in cur:
        return True
    return False


def solve(s: str, x: int, y: int):
    steps = [[], []]
    flg = 0
    tmp = 0
    for c in s:
        if c == 'T':
            steps[flg].append(tmp)
            flg = (flg + 1) % 2
            tmp = 0
        else:
            tmp += 1
    steps[flg].append(tmp)
    #print(steps)
    init_x = steps[0][0] if len(steps[0]) > 0 else 0
    if can_make(steps[0][1:], x, init_x) and can_make(steps[1], y, 0):
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(s, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;
  return 0;
}

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

int main(){

    ll n,m;
    cin >> n >> m;

    cout << n*(n-1)/2 + m * (m-1)/2;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,k;cin>>n>>k;
  vi h(n);
  rep(i,n) cin>>h.at(i);
  int ans=0;
  rep(i,n) if(h.at(i)>=k) ans++;
  cout<<ans<<endl;
}

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

int main(int argc, char *argv[])
{
    int a, b, c;
    int ans;

    scanf("%d %d %d", &a, &b, &c);


    if (a * c <= b) {
        ans = c;
    } else {
        ans = b / a;
    }

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

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  ll a, b;
  scanf("%lld %lld", &a, &b);
  ll x, y;
  for (int i = 1; i < N; ++i) {
    scanf("%lld %lld", &x, &y);
    ll m = max((a + x - 1) / x, (b + y - 1) / y);
    a = x * m;
    b = y * m;
  }
  ll ans = a + b;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    bool f = true;
    map<char, char> m;
    map<char, char> m2;
    for (long long i = 0; i < t.size(); i++) {
        if(!m.count(t[i])) {
            m[t[i]] = s[i];
        } else {
            f &= m[t[i]] == s[i];
        }
    }
    for (long long i = 0; i < s.size(); i++) {
        if(!m2.count(s[i])) {
            m2[s[i]] = t[i];
        } else {
            f &= m2[s[i]] == t[i];
        }
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;

#define _ sync_with_stdio(false)
typedef long long ll;
const int MAXN=100000+10;
const long long INF=0x7fffffffffffffff;

int main(){
	long long n,m;
	cin>>n>>m;
	long long MIN=INF;
	for(int i=1;i<n;i++){
		long long x=i*m;
		long long y=(m/2)*(n-i);
		long long z=((m+1)/2)*(n-i);
		MIN=min(MIN,max(x,max(y,z))-min(x,min(y,z)));
		if(i>=1&&i<n-1){
			x=i*m;
			y=((n-i)/2)*m;
			z=((n-i+1)/2)*m;
			MIN=min(MIN,max(x,max(y,z))-min(x,min(y,z)));	
		}
	}
	for(int i=1;i<m;i++){
		long long x=i*n;
		long long y=(n/2)*(m-i);
		long long z=((n+1)/2)*(m-i);
		MIN=min(MIN,max(x,max(y,z))-min(x,min(y,z)));
		if(i>=1&&i<m-1){
			x=i*n;
			y=((m-i)/2)*n;
			z=((m-i+1)/2)*n;
			MIN=min(MIN,max(x,max(y,z))-min(x,min(y,z)));	
		}
	}
	cout<<MIN<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main()
{
    const int INF = 1 << 30;
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    for (int i = 0; i < h; i++) { cin >> a[i]; }

    queue<pair<int, int>> q;
    vector<vector<int>> d(h, vector<int>(w, INF));

    for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) {
            if (a[x][y] == '#') {
                q.push(make_pair(x, y));
                d[x][y] = 0;
            }
        }
    }

    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, 1, 0, -1};

    while (!q.empty()) {
        auto nowpos = q.front();
        q.pop();
        int nowx = nowpos.first;
        int nowy = nowpos.second;
        for (int i = 0; i < 4; i++) {
            int newx = nowx + dx[i], newy = nowy + dy[i];
            if (newx < 0 || newx >= h || newy < 0 || newy >= w) continue;
            if (a[newx][newy] == '#') continue;
            if (d[newx][newy] != INF) continue;
            a[newx][newy] = '#';
            q.push(make_pair(newx, newy));
            d[newx][newy] = d[nowx][nowy] + 1;
        }
    }
    int ans = 0;
    for (int x = 0; x < h; x++) {
        for (int y = 0; y < w; y++) { ans = max(ans, d[x][y]); }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13568
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(n == 1){
            System.out.println(m);
            return;
        }
        int ans = 1;
        int max = (int)Math.sqrt(m)+1;
        for(int i = 1; i <= max; i++){
            if(m % i == 0){
                if(i >= n){
                    ans = Math.max(ans,m/i);
                }
                if(m/i >= n){
                    ans = Math.max(ans,i);
                }
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
    
    public double[] nextDoubleArray(int n) {
        double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = nextDouble();
        return a;
    } 
}


Measured memory_bytes: 21332
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std ;

int main()
{
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;   
    }else if(d == 24){
        cout << "Christmas Eve" << endl;
    }else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#define PI 3.14159265358979323846264338327950L
#define ll long long
using namespace std;

int main(){
    int k;
    cin >> k;
    int ans = -1;
    bool r = true;
    int n = 0;
    for(int i=1; i<=(10e7)&&r; i++){
        n = (n*10+7)%k;
        if(n == 0){
            ans = i;
            r = false;
        }
    }
    cout << ans;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int>a(N);
  int ans=0;
  for(int i=0;i<=M-1;++i){
    int k;
    cin>>k;
    for(int j=0;j<=k-1;++j){
      int s;
      cin>>s;
      s--;
      a[s] |= 1<<i;
    }
  }
  int p=0;
  for(int i=0;i<=M-1;++i){
    int x;
    cin>>x;
    p |= x<<i;
  }
  for(int s=0;s<(1<<N);s++){
    int t=0;
    for(int i=0;i<N;i++){
      if(s>>i & 1){
        t ^= a[i];
      }
    }
    if(t==p){
      ans++;
    }
  }    
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] LRd = ria();
        int L = LRd[0];
        int R = LRd[1];
        int d = LRd[2];

		Console.WriteLine(R / d - (L - 1) / d);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 27492
//09
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int t[16][17];
    for(int y=0;y<n;y++){
      for(int x=0;x<n+1;x++){
	cin>>t[y][x];
      }
    }
    int dp[1<<16]={};
    fill(dp+1,dp+(1<<16),1<<30);
    for(int i=0;i<1<<n;i++){
      for(int j=0;j<n;j++){
	if((i&1<<j)==0){
	  int mt=t[j][0];
	  for(int k=0;k<n;k++){
	    if(i&(1<<k)){
	      mt=min(mt,t[j][k+1]);
	    }
	  }
	  dp[i|1<<j]=min(dp[i|1<<j],mt+dp[i]);
	}
      }
    }
    cout<<dp[(1<<n)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1424
N,M=map(int,input().split())
list1=[["w",1]for i in range(N+1)]
list1[0]=[0,0]
list1[1]=["r",1]
#print(list1)
for j in range(M):
    x,y=map(int,input().split())
    list1[x][1]-=1
    list1[y][1]+=1
    if list1[x][0]=="r":
        list1[y][0]="r"
        if list1[x][1]==0:
            list1[x][0]="w"
cnt=0
for k in range(1,N+1):
    if list1[k][0]=="r":
        cnt+=1
print(cnt)

Measured memory_bytes: 13172
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int n, a[200100], p, q; ll k;
vector<int> v;
bool vis[200100] = {};
int s[200100];

void dfs(int x, int cnt) {
  if (vis[x]) {
    p = s[x];
    q = cnt - p;
    return;
  } else {
    vis[x] = true;
    s[x] = cnt;
    dfs(a[x], cnt + 1);
    return;
  }
  return;
}

ll fac[400100];

int main(void) {

  ll n, m, k;
  cin >> n >> m >> k;

  fac[0] = 1;
  for (ll i = 1; i <= n+5; i++) {
    fac[i] = fac[i - 1]*i % MOD;
  }

  ll ans = 0;

  for (ll t = 0; t <= n; t++) {
    if (n - t > k) continue;
    //cout << t << endl;
    ll x = 0;
    x = fac[n-1]*powMod(fac[n-t]*fac[t-1]%MOD, MOD-2, MOD)%MOD;
    //cout << x << endl;
    x *= m;
    x %= MOD;
    x *= powMod(m-1, t-1, MOD);
    ans += x;
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5184
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int num = 1;
		for (int i = 0; i < N; i++) {
			if (num < K) {
				num = num * 2;
			} else {
				num = num + K;
			}
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 21716
import sys
import numpy as np


def main():
    MOD = int(1e9 + 7)

    n, k = map(int, input().split())
    can = [[int(c) for c in input().split()] for _ in range(n)]
    can = np.matrix(can, 'O')
    
    # for i in range(n):
    #     for j, e in enumerate(int(c) for c in input().split()):
    #         can[i, j] = e

    b = np.eye(n, n, 0, 'O')
    while k:
        b = [b, b*can % MOD][k & 1]
        can = can*can % MOD
        k >>= 1

    print(b.sum() % MOD)

    # answer = np.eye(n, dtype=int)
    # while k:
    #     if k % 2:
    #         answer = np.dot(answer, can) % MOD
    #     can = np.dot(can, can) % MOD
    #     k //= 2

    # total = 0
    # for i in range(n):
    #     for j in range(n):
    #         total += answer[i,j]
    #         if total >= MOD:
    #             total -= MOD

    # print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14552
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    int count=0;
    string s, t;
    cin>>s>>t;
    
    rep(i, 3) if(s[i] == t[i]) count ++;
       
    cout<<count<<endl;
    return 0;
}



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

using namespace std;

int main() {

	int a, b, x;
	scanf("%d %d %d", &a, &b, &x);

	if(x < a) {
		printf("NO\n");
	} else {
		if(x - a > b) {
			printf("NO\n");
		} else {
			printf("YES\n");
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			int[] a = new int[4];
			int[] b = new int[4];
			int hit = 0;
			int brow = 0;
			
			for(int i=0; i<4; i++){
				a[i] = scanner.nextInt();
			}
			for(int i=0; i<4; i++){
				b[i] = scanner.nextInt();
			}
			
			for(int i=0; i<4; i++){
				if(a[i] == b[i]){
					hit++;
				}
				for(int j=0; j<4; j++){
					if(i!=j && a[i]==b[j]){
						brow++;
					}
				}
			}
			System.out.println(hit + " " + brow);
			
		}
	}
}

Measured memory_bytes: 18108
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const string S4[4] = {"abcc", "abdd", "ccab", "ddab"};
const string S5[5] = {"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
const string S6[6] = {"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
const string S7[7] = {".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};

char s[1010][1010];
void solve(int x) {
    int n = x;
    x = x % 4 + 4;
    for (int i = 0 ; i < n - x ; i += 4) {
        for (int j = 0 ; j < 4 ; j++) {
            for (int k = 0 ; k < 4 ; k++) {
                s[i+j][i+k] = S4[j][k];
            }
        }
    }
    int bs = n - x;
    if (x == 4) {
        for (int j = 0 ; j < 4 ; j++) {
            for (int k = 0 ; k < 4 ; k++) {
                s[bs+j][bs+k] = S4[j][k];
            }
        }
    }
    else if (x == 5) {
        for (int j = 0 ; j < 5 ; j++) {
            for (int k = 0 ; k < 5 ; k++) {
                s[bs+j][bs+k] = S5[j][k];
            }
        }
    }
    else if (x == 6) {
        for (int j = 0 ; j < 6 ; j++) {
            for (int k = 0 ; k < 6 ; k++) {
                s[bs+j][bs+k] = S6[j][k];
            }
        }
    }
    else {
        for (int j = 0 ; j < 7 ; j++) {
            for (int k = 0 ; k < 7 ; k++) {
                s[bs+j][bs+k] = S7[j][k];
            }
        }
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < n ; j++) {
            if (s[i][j] == 0) {
                cout << '.';
            }
            else {
                cout << s[i][j];
            }
        }
        cout << '\n';
    }
}
int main() {
    int n;
    cin >> n;
    if (n <= 2) {
        cout << -1 << endl;
    }
    else if (n <= 3) {
        cout << "a..\n"
             << "a..\n"
             << ".bb\n";
    }
    else {
        solve(n);
    }
}

Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 300001
#define MAX_D 61
#define INF   1000000000
#define p     1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A[MAX_N];
ll a[MAX_D*2][MAX_N];

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

    ll N;
    cin >> N;
    for(ll i = 0; i < N; i++) cin >> A[i];

    for(ll i = 0; i < MAX_D; i++) {
      a[2*i][0]   = ((((A[0]>>i)&1) ^ 0)<<i) % p;
      a[2*i+1][0] = ((((A[0]>>i)&1) ^ 1)<<i) % p;
      
      for(ll j = 1; j < N; j++) {
	a[2*i][j]   = a[2*i][j-1]   + ((((A[j]>>i)&1) ^ 0)<<i) % p;
	a[2*i+1][j] = a[2*i+1][j-1] + ((((A[j]>>i)&1) ^ 1)<<i) % p;
	a[2*i][j] %= p;
	a[2*i+1][j] %= p;
      }
    }

    ll ans = 0;
    for(ll i = 0; i < N-1; i++) {
      for(ll j = 0; j < MAX_D; j++) {
	ll k = ((A[i]>>j)&1);
	ll inc = a[2*j + k][N-1] - a[2*j + k][i];
	if(inc < 0) inc += p;
	ans += inc;
	ans %= p;
      }
    }
    cout << ans << endl;
    
    return 0;
}
    


Measured memory_bytes: 288512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
vector<int> v(13);
vector<int> now;
int ans = 0;
 
void g() {
    int val = 25;
    for(int i = 0; i < now.size(); i++) {
        for(int j = i + 1; j < now.size(); j++) {
            int delta = abs(now[i] - now[j]);
            chmin(val, min(delta, 24 - delta));
        }
    }
    chmax(ans, val);
}
 
void f(int index) {
    if(index == 13) {
        g();
        return;
    }
    if(v[index] == 0) f(index + 1);
    if(v[index] == 1) {
        now.push_back(index);
        f(index + 1);
        now.pop_back();
        now.push_back(24 - index);
        f(index + 1);
        now.pop_back();
    }
    if(v[index] == 2) {
        now.push_back(index);
        now.push_back(24 - index);
        f(index + 1);
        now.pop_back();
        now.pop_back();
    }
}
 
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v[0]++;
    for(int i = 1; i <= N; i++) {
        int D;
        cin >> D;
        if(v[D] == 2) {
            cout << 0 << endl;
            return 0;
        }
        v[D]++;
    }
    f(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import Control.Monad
import Data.List

main :: IO ()
main = getLine >> replicateM 3 getLine >>= print . solve

solve :: [String] -> Int
solve [as, bs, cs] = foldl' ff 0 $ zip3 as bs cs
    where
        ff acc (a, b, c) = acc + 3 - x
            where
                x = head . sortBy (flip compare) . map length . group $ sort [a, b, c]

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n, l;
    cin >> n >> l;
    int minV = INF;
    int sum = n * (n + 1) / 2;
    int base = (l + l + n - 1) * n / 2;
    int answer = 0;
    for (int i = 1; i < n + 1; i++) {
        int x = (n - 1) * (l - 1) + sum - i;
        if (abs(base - x) < minV) {
            minV = abs(base - x);
            answer = x;
        }
    }
    cout << answer << "\n";
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
    if(n==0){cout<<0<<endl;return 0;}
	string ans;
	bool a=true;
	if(n<0)a=false;
	n=abs(n);
	while(n!=1){
        int m=n%2;
		string t=to_string(m);
        ans.PB(t[0]);
		n/=2;
		if(!a){
			if(m)n++;
			a=true;
		}
		else a=false;
	}
	ans.PB('1');
    if(!a)ans.PB('1');
	reverse(all(ans));
	cout<<ans<<endl;
}

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

using namespace std;

typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000 //2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T,vector<T>,greater<T>>;
template<class T> vector<T> vect(int len,T elem){ return vector<T>(len,elem); }

template<class T,class U>
ostream& operator << (ostream& os,const pair<T,U>& p){
  os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
  is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
  for(int i=0;i<vec.size();i++){
    os << vec[i];
    if(i+1<vec.size())os << ' ';
  }
  return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
  for(int i=0;i<vec.size();i++)is >> vec[i];
  return is;
}
void fastio(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout<<fixed<<setprecision(20);
}
namespace Util{
  template<class T>
  vector<pair<T,int>> runLength(vector<T> v){
    vector<pair<T,int>> res;
    for(int i=0;i<v.size();i++){
      if(res.empty()||res.back().first!=v[i])res.push_back(make_pair(v[i],1));
      else res.back().second++;
    }
    return res;
  }
  template<class T>
  void compress(vector<T> &v){
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
  }
}

void solve(){
  string s;
  cin >> s;
  int ans = 0;
  bool flag = false;
  reverse(all(s));
  vector<vector<int>> dp(s.size()+1,vector<int>(2,INF));
  dp[0][0] = 0;
  for(int i=0;i<s.size();i++){
    int d = (int)(s[i]-'0');
    for(int j=0;j<2;j++){
      dp[i+1][0] = min(min(min(dp[i][1]+2+d,dp[i][0]+d),dp[i][0]+11-d),dp[i][1]+11-d);
      dp[i+1][1] = min(dp[i][1]+9-d,dp[i][0]+9-d);
    }
  }
  // for(int i=0;i<dp.size();i++)cout << dp[i] << endl;
  cout << dp[s.size()][0] << endl;
  return ;
}
 
signed main(){
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 55964
from collections import defaultdict
from math import gcd


def main():
    mod = 10 ** 9 + 7
    worst_iwashi_count = 0
    ans = 1
    d = defaultdict(int)
    N = int(input())
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            worst_iwashi_count += 1
        elif a == 0:
            d[(0, -1)] += 1
        elif b == 0:
            d[(1, 0)] += 1
        else:
            g = gcd(abs(a), abs(b))
            if a * b > 0:
                d[(abs(a // g), abs(b // g))] += 1
            else:
                d[(abs(a // g), -abs(b // g))] += 1
    done_set = set()
    for a, b in list(d):
        if (a, b) in done_set:
            continue
        x = d[(a, b)]
        done_set.add((a, b))
        if b >= 0:
            y = d[(b, -a)]
            done_set.add((b, -a))
        else:
            y = d[(-b, a)]
            done_set.add((-b, a))
        ans *= 2 ** x + 2 ** y - 1
        ans %= mod
    ans += worst_iwashi_count - 1
    print(ans % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 176704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,k,i;
    cin>>n>>k;
    vector<ll> a(n);
    ll sum = 0;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<k-1;i++) sum+=a[i];
    ll pos =  0, loc = -1, mx = -1;
    for(i=k-1;i<n;i++)
    {
        sum+=a[i];
        if(sum > mx) {mx=sum;loc=i;}
        sum-=a[pos];
        pos++;
    }
    double ans = 0;
    for(i=loc;i>=loc-(k-1);i--)
    {
        ans+=((a[i]+1)/2.0);
    }
    printf("%.8f", ans);
}

Measured memory_bytes: 1792
n,m = gets.split.map(&:to_i)

h = Hash.new

n.times do 
    a, b = gets.split.map(&:to_i)
    
    unless h[a]
        h[a] = Array.new
    end

    h[a].push(b)
end

ans = 0
jobs = Array.new(0)
for day in 1..m
    if h[day] 
        h[day].each do |b|
            idx = jobs.bsearch_index { |x| x >= b }
            if jobs.size > 0 && idx
                jobs.insert(idx, b)
            else
                jobs.push(b)
            end
        end
    end

    val = jobs.pop
    ans += val if val
end

puts ans


Measured memory_bytes: 15100
import java.util.Scanner;
public class Main {
private static Scanner s = new Scanner(System.in);
static int[] a = new int[100001];
public static void main(String[] args) {
	int n = s.nextInt();

	StringBuilder sb = new StringBuilder();

	for(int i = 0;i < n;i++) {
		a[i] = s.nextInt();
	}
	int j = partition(a,0,n-1);
	for(int i = 0;i < n-1;i++) {
		if(i == j) {
			sb.append("[" + a[i] + "] ");
		}else {
		sb.append(a[i]+" ");
		}
	}
	System.out.println(sb.toString() + a[n-1]);
}

public static int partition(int[] a,int p,int r) {
int x = a[r];
int i = p-1;

for(int j = p;j < r;j++) {
	if(a[j] <= x) {
		i++;
		int tmp;
		tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}
}
	int tmp;
	tmp = a[i+1];
	a[i+1] = a[r];
	a[r] = tmp;

return i+1;
}
}


Measured memory_bytes: 68400
def max(a,b) a>b ? a:b end

def distance(x1, y1, x2, y2)
  dx, dy = x1 - x2, y1 - y2
  Math.sqrt(dx**2 + dy**2)
end

# 時間t, 熱源位置(x,y)で焼ける肉の個数を返す
# t + 0.0000000001 の 0.0000000001 はtan,cosの計算による誤差をカバー(だと思う)
def yaketa_niku(t, x, y)
  res = 0
  N.times do |i|
    if t + 0.0000000001 >= C[i] * distance(x, y, X[i], Y[i])
      res += 1
    end
  end
  res
end

# [二円の交点] http://godfoot.world.coocan.jp/circle-circle.htm
def circle_cross_point(t, xyc1, xyc2)
  x1, y1, x2, y2 = xyc1[0], xyc1[1], xyc2[0], xyc2[1]
  d = distance(x1, y1, x2, y2)
  r1, r2 = t/xyc1[2], t/xyc2[2]

  return if d > r1 + r2 || d < (r1 - r2).abs
  
  tmp = (r1**2 + d**2 - r2**2)/(2*r1*d)
  return unless -1 <= tmp && tmp <= 1
  
  sita = Math.atan2(y2-y1, x2-x1)
  alf = Math.acos(tmp)

  nx1 = x1 + r1 * Math.cos(sita + alf)
  ny1 = y1 + r1 * Math.sin(sita + alf)
  nx2 = x1 + r1 * Math.cos(sita - alf)
  ny2 = y1 + r1 * Math.sin(sita - alf)
  [[nx1,ny1], [nx2,ny2]].uniq
end

# ci*(熱源からの距離) <= t
# (熱源からの距離) <= t/ci
# 時間tの時、肉が焼ける円(中心は肉の座標、半径はt/ci)があり、
# 2つの円を選んだ時の交点の座標を熱源の候補位置を計算する
# 計算した熱源の位置を使って肉が時間内に焼けた個数の最大値を計算し返す
def f(t)
  heater_pos = XY
  test=[]
  XYC_comb.each do |xyc1, xyc2|
    tmp = circle_cross_point(t, xyc1, xyc2)
    heater_pos += tmp if tmp
  end
  res = 0
  heater_pos.each do |x, y|
    res = max(res, yaketa_niku(t, x, y))
  end
  res
end

#時間で二分探索
def main()
  l = 0.0
  r = 400000.0
  100.times do
    m = (l+r)/2.0
    if f(m) < K
      l = m
    else
      r = m
    end
    break if r-l < 10**(-7)
  end
  puts sprintf("%.10f", l)
end

N, K = gets.split.map(&:to_i)
XYC = N.times.map{gets.split.map(&:to_f)}

=begin
N=60
K=30
aaa=Array.new(N)
N.times do |i|
  aaa[i] = [-1000 + 30*i, -1000 + 30*i, rand(1..100)].map(&:to_f)
end
XYC=aaa
=end

X, Y, C = XYC.transpose
XY = [X, Y].transpose
XYC_comb = XYC.combination(2).to_a

main


Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n, k;
    cin >> n >> k;
    int h;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (h >= k) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
S = input()

if(S[0] == 'A' and S[1] == 'A' and S[2] == 'A'):
  print('No')
elif(S[0] == 'B' and S[1] == 'B' and S[2] == 'B'):
  print('No')
else:
  print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s;
  cin >> s;

  ll alpha[26] = {};

  rep(i, ll(s.size())) {
    alpha[s[i]-'a']++;
  }

  rep(i, 26) {
    if (alpha[i] == 0) {
      cout << char('a' + i) << endl;
      break;
    }
    if (i == 25) cout << "None" << endl;
  }

  return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> v(h, vector<char>(w));
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            cin >> v[i][j];
        }
    }
    int res = 0;
    for(int maskH=0;maskH<(1<<h);maskH++) {
        for(int maskW=0;maskW<(1<<w);maskW++) {
            int cnt = 0;
            for(int i=0;i<h;i++) {
                for(int j=0;j<w;j++) {
                    if(maskH & (1<<i) || maskW & (1<<j)) continue;
                    if(v[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) res++;
        }
    }
    cout << res << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
string to_string(string s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif
#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define two pair<int,int>
#define mod(x,m) ((x%m+m)%m)
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define int long long int
#define fori(x,n) for(int i = x; i < n; i++)
#define forj(y,m) for(int j = y; j < m; j++)
#define fork(z,p) for(int k = z; k < p; k++)
#define speedforces std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

int dp[3005][3005];

int fun(int i,int j,vector<int> &v){
  if(i > j || j < 1 || i > v.size()) return 0;
  if(i == j) return dp[i][i] = v[i];
  if(dp[i][j] != -1) return dp[i][j];
  dp[i][j] = min(fun(i+2,j,v),fun(i+1,j-1,v))+v[i] ;
  return dp[i][j] = max(dp[i][j],min(fun(i+1,j-1,v),fun(i,j-2,v))+v[j]);
}

signed main(){
  //input_from_file;
  speedforces;
  int n; cin>>n;
  vector<int> v(n+1);
  memset(dp,-1,sizeof dp);
  int sum = 0;
  fori(1,n+1) cin>>v[i] , sum += v[i];
  cout<<2*fun(1,n,v)-sum<<endl;
}


Measured memory_bytes: 71416
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int solve(int n, int p[])
{
	int result[101][101];
	for(int i = 0; i < n + 1; i++){
		for(int j = 0; j < n + 1; j++){
			if(i == j) result[i][j] = 0;
			else result[i][j] = 1000000;
		}
	}
	for(int i = 2; i < n + 1; i++){
		for(int j = 1; j < n - i + 2; j++){
			for(int k = j; k < j + i - 1; k++){
				result[j][j + i - 1] = min(result[j][j + i - 1], result[j][k] + result[k + 1][j + i - 1] + p[j - 1] * p[k] * p[j + i - 1]);
			}
		}
	}
	// i : 掛け合わせる行列の個数
	// j : 掛け合わせる行列のうち一番左のもの
	// k : 左から何番目で分けるか
	return result[1][n];
}

int main()
{
	int n;
	cin >> n;
	int p[101];
	for(int i = 1; i < n + 1; i++){
		cin >> p[i - 1] >> p[i];
	}
	cout << solve(n, p) << endl;
	return 0;
}

Measured memory_bytes: 1200
N, M, L = map(int, raw_input().split())
nm = [map(int, raw_input().split()) for n in range(N)]
ml = [map(int, raw_input().split()) for m in range(M)]

for n in range(N):
    col = [0] * L
    for l in range(L):
        for m in range(M):
            col[l] += nm[n][m] * ml[m][l]
    print ' '.join(map(str, col))

Measured memory_bytes: 6876
from bisect import bisect_left,bisect_right

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

A.sort()
B.sort()
C.sort()

#bisect_left:keyを挿入できる最小のindex
#bisect_right:keyを挿入できる最大のindex
ans = 0
for i in range(N):
    b_l,b_r = bisect_left(A,B[i]),N-bisect_right(C,B[i])
    ans += (b_l)*(b_r)
print(ans)


Measured memory_bytes: 23360
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll l,r;
  cin>>l>>r;
  vector<ll>v;
  for(ll i=l;i<=r&&(i-l)<2019*2;i++){
    v.push_back(i%2019);
  }
  sort(v.begin(),v.end());
  ll n=v.size();
  ll ans=2019;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      ans=min(ans,v[i]*v[j]%2019);
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++) cin >> S.at(i);
    set<string> Sset;
    int count = 0;
    for(string s : S){
        if(Sset.find(s) == Sset.end()){
            Sset.insert(s);
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 25124
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,a,b) = get!(usize, usize, usize);
    if (b-a)%2 == 0 {
        println!("{}", (b-a)/2);
        return;
    }

    println!("{}", min!((b+a-1)/2, n-(a+b-1)/2));
}


Measured memory_bytes: 8572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    ll l = 0;
    ll r = 1e9 + 5;
    while(r - l > 1){
        ll tmp = (r + l) / 2;
        ll s = 0;
        REP(i, N){
            ll hoge = ceil((double)A[i] / (double)tmp);
            s += hoge - 1;
        }
        if (s <= K) r = tmp;
        else l = tmp;
    }
    cout << r << endl;

    return 0;
}



Measured memory_bytes: 4440
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	int m=2*d+1;
	int cnt=1;
	int a=m;
	while(1){
		if(m>=n){
			break;
		}
		m+=a;
		cnt++;
	}
	cout<<cnt;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	
	int n;
	double x1,x2,x3,x4,y1,y2,y3,y4,ab,cd;
	
	cin>>n;
		
	for(int i=0;i<n;i++){
		
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(x1==x2 && x3==x4){
			cout<<"YES"<<endl;
		}else if(x1==x2 || x3==x4){
			cout<<"NO"<<endl;
		}else{
			ab=(y1-y2)/(x1-x2);
			cd=(y3-y4)/(x3-x4);

			if(ab==cd){
				cout<<"YES"<<endl;
			}else{
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

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

		 BufferedReader br = new BufferedReader(new
		 InputStreamReader(System.in));
		//BufferedReader br = new BufferedReader(new FileReader("sample.txt"));
		
		String[] str=br.readLine().split(" ");
		double x1=Double.parseDouble(str[0]);
		double y1=Double.parseDouble(str[1]);
		double x2=Double.parseDouble(str[2]);
		double y2=Double.parseDouble(str[3]);
		double a=Math.pow((x1-x2),2)+(y1-y2)*(y1-y2);
		double dis=Math.sqrt(a);		
		System.out.printf("%1$.5f%n",dis);
	
	
	}}

Measured memory_bytes: 16944