akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())


// 最大公約数を求める(ユークリッドの互除法).
ll gcd (ll x, ll y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

// 最小公倍数を求める(lcm(a,b) = a*b / gcd(a,b)). overflowに気をつけよう
ll lcm (ll x, ll y) {
  ll t = gcd(x,y);
  return (x / t) * y;
}


int main() {
  int n,m;
  cin >> n >> m;
  string s,t;
  cin >> s;
  cin >> t;

  if (s[0] != t[0]) {
    cout << -1 << endl;
    return 0;
  }
  ll res = lcm(n,m);

  int s1 = n / res, s2 = m/res;
  int mmax = min(s1,s2);

  map<int, char> mp;

  for (int i = 0; i < n; ++i) {
    mp[i*(res/n) + 1] = s[i];
  }

  for (int i = 0; i < m; ++i) {
    if (mp[i*(res/m) + 1]) {
      if (mp[i*(res/m) + 1] != t[i]) {
        cout << -1 << endl;
        return 0;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 8192
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

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

		Integer[] v = new Integer[]{ sc.nextInt(), sc.nextInt(), sc.nextInt() };
		Arrays.sort(v, Comparator.naturalOrder());

			System.out.printf("%d %d\n", v[0], v[2]);
		sc.close();
	}
}


Measured memory_bytes: 26464
n = int(input())
l = []
for i in range(n):
    i = list(map(int,input().split()))
    l.append(i)
tmp = 0

for j in reversed(range(n)):
    l[j][0] += tmp
    if l[j][0]%l[j][1] != 0:
        tmp += l[j][1] - l[j][0]%l[j][1]

print(tmp)

Measured memory_bytes: 60568
use proconio::input;
use std::cmp;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let op = cmp::max;
    let mut rmq = RMQ::new(300010, 0, op);

    let mut ans = 0;
    for &na in &a {
        let l = if na >= k { na - k } else { 0 };
        let r = cmp::min(na + k, 300000);
        let tmp = rmq.query(l, r + 1, 0, 0, rmq.get_n()) + 1;
        ans = cmp::max(ans, tmp);
        rmq.update(na, tmp);
    }

    println!("{}", ans);
}

struct RMQ {
    n: usize,
    dat: Vec<usize>,
    e : usize,
    op: fn(usize, usize) -> usize,
}

impl RMQ {
    fn new(_n: usize, e: usize, op: fn(usize, usize) -> usize) -> Self {
        let mut n = 1;
        while n < _n {
            n *= 2;
        }

        RMQ {
            n: n,
            dat: vec![e; 2 * n - 1],
            e: e,
            op: op,
        }
    }

    fn update(&mut self, mut k: usize, a: usize) {
        //kを0-indexedに
        k += self.n - 1;
        self.dat[k] = a;
        while k > 0 {
            k = (k - 1) / 2;
            self.dat[k] = (self.op)(self.dat[k * 2 + 1], self.dat[k * 2 + 2]);
        }
    }

    /// queryは[a, b)の最大値を返す
    ///外から呼ぶときはquery(a, b, 0, 0, n)と呼ぶ
    fn query(&self, a: usize, b: usize, k: usize, l: usize, r: usize) -> usize {
        if r <= a || b <= l {
            return self.e;
        }
        if a <= l && r <= b {
            return self.dat[k];
        } else {
            let vl = self.query(a, b, k * 2 + 1, l, (l + r) / 2);
            let vr = self.query(a, b, k * 2 + 2, (l + r) / 2, r);
            return (self.op)(vl, vr);
        }
    }

    ///queryを呼ぶときに使う
    fn get_n(&self) -> usize {
        self.n
    }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/24  Problem: ABC 122 B / Link: http://abc122.contest.atcoder.jp/tasks/abc122_b  ----- */


int main() {
	cin.tie(0);

	ios_base::sync_with_stdio(false);

	string s; cin >> s;
	LL ans = 0LL;
	FOR(i, 0, SZ(s)) {
		FOR(j, 1, SZ(s) + 1) {
			string t = s.substr(i, j);
			DD(de(t));
			LL ret = 0;
			for (auto c : t) {
				if (c == 'A' || c == 'T' || c == 'G' || c == 'C')ret++;
				else break;
			}
			ans = max(ans, ret);
		}
	}


	cout << (ans) << "\n";

	return 0;
}


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

int main(void) {
    int N, K;
    cin >> N >> K;
    map<int, bool> person;

    for (int i = 0; i < N; i++)
        person[i] = false;

    vector<int> d(K);
    for (int i = 0; i < K; i++) {
        cin >> d.at(i);
        for (int j = 0; j < d.at(i); j++) {
            int num = 0;
            cin >> num;
            person.at(num - 1) = true;
        }
    }
    int count = 0;
    for (int i = 0; i < N; i++)
        if (person.at(i) == false)
            count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>
#include<vector>
#include<stack>
#include <cstdlib>


using namespace std;

int main() {
	int n, k;
	int d;
	int cnt=0;
	int tmp;
	map<int,int> have;
	cin >>n>> k;
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> tmp;
			have[tmp]++;
		}
	}
	for (int i = 1; i <= n;i++) {
		if (have[i]==0) {
			cnt++;
		}
	}
	cout << cnt;

	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;
    long long r = N % K;
    long long ans = std::min(r, abs(r - K));
    cout << ans << endl;
    return 0;
}


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

int main() {
	
	int n; cin >> n;
	vector<string> s(n);
	ll ans = 0;
	ll BAcnt = 0;
	ll XAcnt = 0;
	ll BXcnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i][0] == 'B' && s[i].back() == 'A') {
			BAcnt++;
		}
		else if (s[i].back() == 'A') {
			XAcnt++;
		}
		else if(s[i][0] == 'B') {
			BXcnt++;
		}
		for (int j = 1; j < s[i].size(); j++) {
			if (s[i][j - 1] == 'A' && s[i][j] == 'B') {
				ans++;
			}
		}	
	}
	if (BAcnt == 0) {
		ans += min(XAcnt, BXcnt);
	}
	else { // 0 < BAcnt
		if (XAcnt < BXcnt) {
			ans += XAcnt;
			BXcnt -= XAcnt;
			ans += BAcnt - 1;
			ans += 1;
		}
		else if (BXcnt < XAcnt) {
			ans += BXcnt;
			BXcnt -= BXcnt;
			ans += BAcnt - 1;
			ans += 1;
		}
		else if (XAcnt == 0 && BXcnt == 0) {
			ans += BAcnt - 1;
		}
		else { // XAcnt == BXcnt
			ans += XAcnt;
			ans += BAcnt;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int m = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			String grade;

			if (m == -1 && f == -1 && r == -1) {
				break;
			} else if (m == -1 || f == -1) {
				grade = "F";
			} else if (m + f < 30) {
				grade = "F";
			} else if (m + f < 50) {
				if (r >= 50) {
					grade = "C";
				} else {
					grade = "D";
				}
			} else if (m + f < 65) {
				grade = "C";
			} else if (m + f < 80) {
				grade = "B";
			} else {
				grade = "A";
			}

			System.out.println(grade);
		}
	}
}



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

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> L(N);
    rep(i, 0, N) cin >> L[i];
    sort(L.begin(), L.end(), greater<ll>());
    ll ans = accumulate(L.begin(), L.begin()+K, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }


// mint
template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) const { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> P, M; P.reserve(N); M.reserve(N);
  int z = 0;
  for(int i = 0; i < N; ++i) {
    int A; std::cin >> A;
    if(A > 0) P.push_back(A);
    else if(A < 0) M.push_back(-A);
    else ++z;
  }
  if(z+K > N) fin(0); // always zero
  if(P.size() == 0) { // no plus
    if(K%2==1) { // odd number of non-plus integers
      if(z > 0) fin(0); // can be zero
      std::sort(M.begin(), M.end()); // smallest in abs
      mint ans(-1);
      for(int i = 0; i < K; ++i) ans *= mint(M[i]);
      fin(ans.v_);
    }
    std::sort(M.rbegin(), M.rend()); // biggest in abs
    mint ans(1);
    for(int i = 0; i < K; ++i) ans *= mint(M[i]);
    fin(ans.v_);
  }
  if(K == M.size() + P.size() && M.size()%2==1) { // cannot be plus
    if(z > 0) fin(0);
    mint ans(-1);
    for(int i = 0; i < M.size(); ++i) ans *= mint(M[i]);
    for(int i = 0; i < P.size(); ++i) ans *= mint(P[i]);
    fin(ans.v_);
  }
  // can be plus
  mint ans = 1;
  std::vector<int64_t> PP; PP.reserve(N);
  std::sort(P.rbegin(), P.rend());
  if(K%2==0) {
    for(int k = 0; k < P.size()-1; k += 2) {
      PP.push_back((int64_t)P[k]*P[k+1]);
    }
  } else {
    --K;
    ans = P[0];
    for(int k = 1; k < P.size()-1; k += 2) {
      PP.push_back((int64_t)P[k]*P[k+1]);
    }
  }
  if(M.size() > 1) {
    std::sort(M.rbegin(), M.rend());
    for(int k = 0; k < M.size()-1; k += 2) {
      PP.push_back((int64_t)M[k]*M[k+1]);
    }
  }
  std::sort(PP.rbegin(), PP.rend());
  for(int i = 0; i < K/2; ++i) ans *= mint(PP[i]);
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  
  // 全てのタイル数
  int all_tail = N * N;
  
  // 全てのタイル数から白色を引くと黒色
  cout << all_tail -A << endl; 
}

Measured memory_bytes: 256
fun main() {
    val s = next()
    val t = next()
    var res = 0
    (s.indices).forEach {
        if (s[it] != t[it]) {
            res++
        }
    }
    println(res)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}


Measured memory_bytes: 41656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s = new Scanner(System.in).next();
		// + が入る可能性のある個所
		int n = s.length() - 1;
		long sum = 0;
		StringBuilder parts = new StringBuilder();
		for (int i = 0; i < (1<<n); i++) {
			for(int j = 0; j < n; j++) {
				parts.append(s.charAt(j));
				// フラグが立っている場合はそこに + が挟まれるため、
				// 文字列を数値に変換の上加算する
				if ((1 & i>>j) == 1) {
					sum = sum + Long.parseLong(parts.toString());
					parts.setLength(0);
				}
			}
			// 文字列sの最後の1文字を追加して加算する
			parts.append(s.charAt(n));
			sum = sum + Long.parseLong(parts.toString());
			parts.setLength(0);
		}
		System.out.println(sum);
	}
}


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

public class Main {


	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static int nextInt() throws IOException {
		return Integer.parseInt(br.readLine());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(br.readLine());
	}

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

	public static int[] sortArr(int arr[]) throws IOException {
		ArrayList<Integer> a = new ArrayList<Integer>();
		for (int i : arr)
			a.add(i);

		Collections.sort(a);

		for (int i = 0; i < a.size(); i++)
			arr[i] = a.get(i);
		return arr;
	}

	public static int[] desortArr(int arr[]) throws IOException {
		ArrayList<Integer> a = new ArrayList<Integer>();
		for (int i : arr)
			a.add(i);

		Collections.sort(a, Collections.reverseOrder());

		for (int i = 0; i < a.size(); i++)
			arr[i] = a.get(i);
		return arr;
	}

	public static int[] nextArr() throws IOException {
		String elements[] = br.readLine().split(" ");
		int arr[] = new int[elements.length];
		for (int j = 0; j < elements.length; j++)
			arr[j] = Integer.parseInt(elements[j]);
		return arr;
	}

	public static void printArr(int arr[]) {
		for (int i = 0; i < arr.length; i++)
			System.out.print(arr[i] + " ");
	}

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

		int T = 1;
		
		while (T-- > 0) {

			int n = nextInt();
			
			int arr[] = nextArr();

			int aux[] = new int[100003];

			long sum = 0;
			for (int i = 0; i < arr.length; i++) {
				sum += arr[i];
				aux[arr[i]]++;

			}

			int q = nextInt();

			for (int i = 0; i < q; i++) {
				int input[] = nextArr();
				int c = input[0];
				int d = input[1];
				long m = (long) d * aux[c];
				long o = (long) c * aux[c];
				
				sum += m - o;
				
				aux[d] += aux[c];
				aux[c] = 0;
				
				System.out.println(sum);
			}

		}
	}


}


Measured memory_bytes: 64580
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>
#include <climits>


using namespace std;

using ll=long long;

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

void OUT(bool isTrue, string t="YES", string f="NO"){
    cout<<(isTrue?t:f)<<endl;
}
void out(bool isTrue, string t="yes", string f="yes"){
    cout<<(isTrue?t:f)<<endl;
}

template <typename T>
string printItr(T b, T e, string delim=" ")
{
    stringstream ss;
    ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}

void bulk(){}
template <class Head, class... Tail>
void bulk(Head& head, Tail&... tail){
    cin>>head;
    bulk(tail...);
}


#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()
#define cint(...) \
    int __VA_ARGS__;\
    bulk(__VA_ARGS__);

int main(void){
    cint(n,l);
    vs a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    rep(i,n)cout<<a[i];
}

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

int main(){
  int n,nu=0;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      nu+=d[i]*d[j];
    }
  }
  cout<<nu<<endl;
}
      
    

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

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[2] = {' ', '\n'};

int main() {
  int i, j, k, n, m, f, r;
  char g;

  while(true) {
    cin>>m>>f>>r;
    if (m==-1&&f==-1&&r==-1) break;
    if (m==-1||f==-1) g = 'F';
    else if (m + f >= 80) g = 'A';
    else if (m + f >= 65) g = 'B';
    else if (m + f >= 50 || (m + f >= 30 && r >= 50)) g = 'C';
    else if (m + f >= 30) g = 'D';
    else g = 'F';
    cout << g << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();

            if (ss[0] == "H")
                Console.WriteLine(ss[1]);
            else
                Console.WriteLine(ss[1] == "H" ? "D" : "H");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

int solve(ll x){
	// cout<<"x="<<x<<"\n";
	if(x == 0)
		return 0;
	ll dup = x;
	int cnt = 0;
	while(dup > 0){
		if(dup&1)
			++cnt;
		dup >>= 1;	
	}

	return 1+solve(x%cnt);
}

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

	ll n;
	cin>>n;
	string s;
	cin>>s;

	ll k = 0;
	for(int i=0;i<n;i++)
		if(s[i]=='1')
			++k;

	ll powup[n];
	powup[0] = 1%(k+1);
	for(int i=1;i<n;i++)
		powup[i] = (powup[i-1]*2)%(k+1);

	ll ans[n];
	ll x = 0;
	for(int i=0;i<n;i++){
		if(s[i] == '1')
			x = (x+powup[n-1-i])%(k+1);
	}

	// cout<<"x="<<x<<"\n";

	for(int i=0;i<n;i++)
		if(s[i] == '0'){
			// cout<<"i="<<i<<"\n";
			ans[i] = 1+solve((x+powup[n-1-i])%(k+1));
		}

	if(k == 1){
		for(int i=0;i<n;i++)
			if(s[i] == '1'){
				ans[i] = 0;
				break;
			}
	}
	else if(k>1){
		powup[0] = 1%(k-1);
		for(int i=1;i<n;i++)
			powup[i] = (powup[i-1]*2)%(k-1);
		x = 0;
		for(int i=0;i<n;i++){
			if(s[i] == '1')
				x = (x+powup[n-1-i])%(k-1);
		}

		for(int i=0;i<n;i++)
			if(s[i] == '1'){
				// cout<<"i="<<i<<"\n";
				ans[i] = 1+solve((x+k-1-powup[n-1-i])%(k-1));
			}
	}

	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	cout<<"\n";
}

Measured memory_bytes: 6924
n , m  = map(int, input().split())
l_1 = [] #左から1桁目の数字のりすと
l_2 = [] #左から2桁目の数字のりすと
l_3 = [] #左から3桁目の数字のりすと
nocounter = 0
 
if m == 0:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  else:
    print(100)
else:
  for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
      l_1.append(b)
    elif a == 2:
      l_2.append(b)
    else:
      l_3.append(b)
  if len(l_1) > 0:
    pv = l_1[0]
    for j in range(len(l_1)):
      if not pv  == l_1[j]:
        nocounter += 1
      if l_1[j] == 0 and n > 1:
        nocounter += 1
  if len(l_2) > 0:
    pv = l_2[0]
    for j in range(len(l_2)):
      if not pv  == l_2[j]:
        nocounter += 1
  if len(l_3) > 0:
    pv = l_3[0]
    for j in range(len(l_3)):
      if not pv  == l_3[j]:
        nocounter += 1
  if nocounter > 0:
    print(-1)
  else:
    if n == 1:
      print(l_1[0])
    elif n == 2 and len(l_2)*len(l_1) > 0:
      print(10*l_1[0] + l_2[0])
    elif n == 2 and len(l_1) == 0:
      print(10 + l_2[0])
    elif n == 2 and len(l_2) == 0:
      print(10*l_1[0])
    elif len(l_1)*len(l_2)*len(l_3) > 0:
      print(100*l_1[0] + 10*l_2[0] + l_3[0])
    elif len(l_1) == 0 and len(l_2) == 0:
      print(100 + l_3[0])
    elif len(l_1) == 0 and len(l_3) == 0:
      print(100 + 10*l_2[0])
    elif len(l_1) == 0:
      print(100 + 10*l_2[0] + l_3[0])
    elif len(l_2) == 0 and len(l_3) == 0:
      print(100*l_1[0])
    elif len(l_2) == 0 :
      print(100*l_1[0] + l_3[0])
    else:
      print(100*l_1[0] + 10*l_2[0])

Measured memory_bytes: 3192
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日  8/20 20:26:38 2017
 *Ended  Time*  : 日  8/20 20:42:13 2017
 *********************************************/

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

int main()
{
    while(~scanf("%d", &n)){
        scanf("%s" ,a[1]);
        scanf("%s" ,a[2]);
        LL ans = 1;
        for(int i = 0; i < n; i++){
            if(i == 0){
                if(a[1][i] == a[2][i]) ans = 3;
                else ans = 6, i++;
                continue;
            }
            if(a[1][i] == a[2][i]){
                if(a[1][i - 1] == a[2][i - 1]) ans = ans * 2 % pt;
            }
            else if(a[1][i] != a[2][i]){
                if(a[1][i - 1] == a[2][i - 1]) ans = ans * 2 % pt;
                else if(a[1][i - 1] != a[2][i - 1]) ans = ans * 3 % pt;
                i++;
            }
        }
        printf("%lld\n", ans % pt);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack> 
#include <string>
#include <set>
#include <map>
#include <vector>
using namespace std;
int main(void){
	int n;
	while(cin>>n){
		int a[10];
		int cnt=0;
		memset(a,0,sizeof(a));
		while(n){
			a[cnt++]=n%10;
			n/=10;
		}
		if(a[0]==a[1]&&a[1]==a[2]){
			cout<<"Yes"<<endl;
		}else if(a[1]==a[2]&&a[3]==a[2]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

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

using namespace std;
long long int a,ans;

void dfs(long long int x,int s,int t, int u){
  
  if(x>a){
    return;
  
  }
  if(s>0&&t>0&&u>0){
    ans++;
  }
  if(x <= 1000000000){
    dfs(10*x+3,s+1,t,u);
    dfs(10*x+5,s,t+1,u);
    dfs(10*x+7,s,t,u+1);
  }
 
}
int main(void){
  cin >> a;
  dfs(0,0,0,0);
  
  cout << ans << endl;
}


Measured memory_bytes: 256
from bisect import bisect

def solve():
	mod = 10**9+7
	n,k,*a = map(int,open(0).read().split())
	b = []
	ans = 0
	for j,x in enumerate(a):
		i = bisect(b,x)
		ans += (j-i)*k
		ans %= mod
		b.insert(i,x)
	bef = max(a)
	j=0
	for i,cur in enumerate(b[::-1]):
		if cur!=bef:
			j = i
			bef = cur
		ans += k*(k-1)*j//2
		ans %= mod
	print(ans%mod)

if __name__=="__main__":
	solve()

Measured memory_bytes: 3188
import java.io.*;
public class Main{
  public static void main(String[] args){
    try{
      BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 	  int N, M;
      String[] s = bf.readLine().split(" ");
      N = Integer.parseInt(s[0]);
      M = Integer.parseInt(s[1]);
      int p = 1 << M;
      int X = (M*1900+(N-M)*100)*p;
      System.out.println(X);
    } catch(IOException e){}
  }
}
    

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

int main(){
    bool flag=false;
    string x,y;
    cin >> x >> y;
    string z=x+y;
    int a;
    a=stoi(z);
    for(int i=1;i*i<=a;i++){
        if(a==i*i) flag=true;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int n;

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

signed main()
{
	cin >> n;
	
	for (int a = 1; a <= 3500; a++) {
		for (int b = 1; b <= 3500; b++) {
			int si = 4 * a * b - n * b - n * a;
			int bo = n * a * b;
			if (si < 0) continue;
			int g = gcd(si, bo);
			si /= g;
			bo /= g;
			if (si == 1) {
				cout << a << " " << b << " " << bo << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s,t,cnt[105],cn;
char x;
int main(){
	getline(cin,s);
	cnt[0]=s;
	for(int i=1;i<=s.size();i++){
		cn=cnt[i-1].substr(0,cnt[i-1].size()-1);
		x=cnt[i-1][s.size()-1];
		cnt[i]=x+cn;
	}	
	getline(cin,t);
	for(int i=0;i<=s.size();i++){
		if(cnt[i]==t){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

int *leftArray;
int *rightArray;

long cnt;

void merge(int *array, int left, int center, int right) {
    int pl, pr, pa;

    for(pa = left, pl = 0; pa <= center; pa++, pl++) {
        leftArray[pl] = array[pa];
    }

    for(pa = center + 1, pr = 0; pa <= right; pa++, pr++) {
        rightArray[pr] = array[pa];
    }

    int lLen = pl;
    int rLen = pr;
    int lSize = center - left + 1;
    for(pl = 0, pr = 0, pa = left; pl < lLen && pr < rLen; pa++) {
        if(leftArray[pl] > rightArray[pr]) {
            array[pa] = rightArray[pr++];
            cnt += lSize - pl;
        } else {
            array[pa] = leftArray[pl++];
        }
    }

    while(pl < lLen) {
        array[pa++] = leftArray[pl++];
    }

    while(pr < rLen) {
        array[pa++] = rightArray[pr++];
    }
}

void _mergeSort(int *array, int left, int right) {
    if(left < right) {
        int center = (left + right) / 2;

        _mergeSort(array, left, center);
        _mergeSort(array, center + 1, right);

        merge(array, left, center, right);
    }
}   

bool mergeSort(int *array, int n) {
    if((leftArray = malloc(n * sizeof(int))) == NULL) {
        return false;
    }
    if((rightArray = malloc(n * sizeof(int))) == NULL) {
        free(leftArray);
        return false;
    }

    _mergeSort(array, 0, n - 1);

    free(leftArray);
    free(rightArray);
    return true;
}

int main(void) {
    int n;

    scanf("%d", &n);
    int *array = malloc(n * sizeof(int));

    for(int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    mergeSort(array, n);

    printf("%ld\n", cnt);

    free(array);
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	string s;cin>>s;
	set<char>se;
	rep(i,s.length()){
		se.insert(s[i]);
	}
	if(se.size()==1){
		cout<<0<<endl;
		return 0;
	}
	int ans =INF;
	for(char wa :se){
		int cnt =0;
		string t,w=s;
		while(1){
			cnt++;
			rep(i,w.length()-1){
				if(w[i]==wa){
					t.push_back(w[i]);
				}
				else
				{
					t.push_back(w[i+1]);
				}
			}
			bool f=true;
			rep(i,t.length()){
				if(t[i]!=wa){
					f=false;
				}
			}
			if(f){
				break;
			}
			w=t;
			t="";
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
h = [int(x) for x in input().split()]
DP = [10000]*N
DP[0] = 0
DP[1] = abs(h[0] - h[1])
for i in range(2,N):
    DP[i] = min(DP[i-2] + abs(h[i]-h[i-2]),DP[i-1] + abs(h[i]-h[i-1]))
print(DP[N-1])

Measured memory_bytes: 13924
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    char s[105]; scanf("%s",s);
    char c[10] = {"keyence"};
    int n = strlen(s);
    int m = strlen(c);
    rep(i,m+1){
        char tc[10]={0};
        strncpy(tc,s,i);
        strncpy(tc+i,s+i+(n-m),m-i);
        if(strcmp(tc,c)==0){
            puts("YES");
            return 0;
        }
    }

    puts("NO");
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    string A, B, C;
    while (cin >> A >> B >> C) {
        int N = A.size();

        A += "#";
        B += "#";
        C += "#";
        reverse(all(A));
        reverse(all(B));
        reverse(all(C));

        // dp[i][j] = i?????????????¬????????????°????????????(j = 1) or ??°??????????????????(j = 0) ???????????´????????°
        VV dp(N + 1, V(2, 0));
        dp[0][0] = 1;
        rep2(i, 1, N + 1) {
            rep(j, 2) {
                rep(a, 10) {
                    if (A[i] != '?' && a != A[i] - '0') continue;
                    if (i == N && a == 0) continue;
                    rep(b, 10) {
                        if (B[i] != '?' && b != B[i] - '0') continue;
                        if (i == N && b == 0) continue;
                        rep(c, 10) {
                            if (C[i] != '?' && c != C[i] - '0') continue;
                            if (i == N && c == 0) continue;

                            if ((a + b + j) % 10 == c) {
                                (dp[i][(a + b + j) / 10] += dp[i - 1][j]) %= mod;
                            }
                        }
                    }
                }
            }
        }

        cout << dp[N][0] << endl;
    }
}

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

int main () {
	double l;
	cin >> l;

	double length = l / 3;

	l -= length;

	double breadth = l / 2;

	double height = l - breadth;

	cout << setprecision(8) << (height * breadth * length) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    int ans=0;
    vector<int> edge[2000];
    int lis[100][2];
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        lis[i][0]=a;lis[i][1]=b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> Q;
    for(int i=0;i<M;i++){
        int itta[100]={0};
        itta[1]=1;
        Q.push(1);
        while(!Q.empty()){
            int pa;
            pa=Q.front();Q.pop();
            for(int j=0;j<edge[pa].size();j++){
                if(itta[edge[pa][j]]==0){
                    if(pa==lis[i][0]&&edge[pa][j]==lis[i][1])continue;
                    if(pa==lis[i][1]&&edge[pa][j]==lis[i][0])continue;
                    itta[edge[pa][j]]=1;
                    Q.push(edge[pa][j]);

                }
            }
        }
        for(int j=1;j<=N;j++){
            if(itta[j]==0){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
open Scanf
open Printf

let ($) f x = f x
let scanIntlist n = let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; List.rev !list
    
let string2charlist s = let rec proc i res =
                          try proc (i+1) $ s.[i]::res
                          with Invalid_argument _ -> res
  in List.rev $ proc 0 []
       
let minInt l = let rec proc l res = match l with
      [] -> res
    | x::xs -> if x < res then proc xs x else proc xs res
  in if l == [] then raise $ Failure "null list" else proc l max_int

let maxInt l = let rec proc l res = match l with
      [] -> res
    | x::xs -> if x > res then proc xs x else proc xs res
  in if l == [] then raise $ Failure "null list" else proc l min_int

let rec listSum = function
    [] -> 0
  | x::xs -> x+listSum xs;;

let rec quick_sort = function
    ([] | [_]) as l -> l
  | pivot :: rest ->
     let rec partition left right = function
	 [] -> (quick_sort left) @ (pivot :: quick_sort right)
       | y :: ys -> if pivot < y then partition left (y :: right) ys
                    else partition (y :: left) right ys
     in partition [] [] rest


let calc a b c x y = let p1 = a*x + b*y in
  let p2 = if x < y then c*2*x + b*(y-x) else c*2*y + a*(x-y) in
  let p3 = if x < y then c*2*y else c*2*x in
  minInt [p1;p2;p3];;

scanf "%d %d %d %d %d" $ fun a b c x y -> print_int $ calc a b c x y;;


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

int gcd(int x, int y, int z){
  int d,e;
  d=1;
  e=1;
  while(e<=x && e<=y && e<=z){
    if(x%e==0 && y%e==0 && z%e==0)
    d=e;
    e++;
  }
  return d;
}

int main() {
  int n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      for(int k = 1; k <= n; k++){
        ans += gcd(i, j, k);
      }
    }
  }
  cout << ans *1ll;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static int MAX = 100000;
    public static int[] A = new int[MAX];
    public static int n;

    public static int partition(int p, int r) {
        int x = A[r];
        int i = p - 1;
        int t;
        for(int j = p; j < r; j++) {
            if(A[j] <= x)
            {
                i++;
                t = A[i];
                A[i] = A[j];
                A[j] = t;
            }
        }
        t = A[i + 1];
        A[i+1] = A[r];
        A[r] = t;
        return i+1;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        int q = partition(0,n-1);
        for(int i = 0; i < n; i++) {
            if(i != 0) System.out.print(" ");
            if(i == q) System.out.print("[");
            System.out.print(A[i]);
            if(i == q) System.out.print("]");
        }
        System.out.println();
    }
    
}



Measured memory_bytes: 73312
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

ll n, a, b;
vector<ll>h(101010);

int fl(ll s, ll t) {
	if (s%t == 0)return s / t;
	else return s / t + 1;
}



bool check(ll p) {
	ll res=0;
	rep(i, 0, n) {
		ll temp = h[i] - b * p;
		if(temp>0){
			res += fl(temp,a-b);
		}
	}
	if (res <= p)return 1;
	else return 0;

}


int main() {
	cin >> n >> a >> b;

	rep(i, 0, n)cin >> h[i];


	ll ok, ng;
	ng = 0, ok = 1010101010;
	while (ng + 1 != ok) {
		ll middle = (ng + ok) / 2;
		if (check(middle))ok = middle;
		else ng = middle;
	}

	cout << ng + 1 << endl;

	return 0;
}

Measured memory_bytes: 1024
fn main() {
    let stdin = std::io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let k: i32 = iter.next().unwrap().parse().unwrap();
    let s: i32 = iter.next().unwrap().parse().unwrap();

    let mut cnt = 0;
    for x in 0..k+1 {
        for y in 0..k+1 {
            let z = s - x - y;
            if z >= 0 && z <= k {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
class UnionFind
  attr_accessor :parent

  def initialize(size)
    @parent = Array.new(size, -1)
  end

  def root(x)
    if @parent[x] < 0
      x
    else
      @parent[x] = root(@parent[x])
    end
  end

  def same_parent?(x, y)
    root(x) == root(y)
  end

  def merge(x, y)
    x_root = root(x)
    y_root = root(y)

    return false if x_root == y_root

    if @parent[x_root] > @parent[y_root]
      x_root, y_root = y_root, x_root
    end

    @parent[x_root] += @parent[y_root]
    @parent[y_root] = x_root

    true
  end

  def size(x)
    -@parent[root(x)]
  end
end

n, m, k = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n)
union = UnionFind.new(n)
n.times do |i|
  arr[i] = {}
end
m.times do
  a, b = gets.chomp.split(' ').map { |i| i.to_i - 1 }
  union.merge(a, b)
  arr[a][b] = true
  arr[b][a] = true
end
k.times do
  a, b = gets.chomp.split(' ').map { |i| i.to_i - 1 }
  if union.same_parent?(a, b)
    arr[a][b] = true
    arr[b][a] = true
  end
end
res = []
n.times do |i|
  res << union.size(i) - arr[i].size - 1
end
puts res.join(' ')

Measured memory_bytes: 41272
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

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

ll N, M;

const int MAXN = 10;
vector<ll> S[MAXN];
ll P[MAXN];

ll solve(ll depth)
{
    if (depth == N) { return 1; }



}

int main()
{
    cin >> N >> M;

    rep(i, M)
    {
        ll k;
        cin >> k;

        S[i].assign(k, 0);

        rep(j, k) { cin >> S[i][j]; --S[i][j]; }
    }

    rep(i, M)
    {
        cin >> P[i];
    }

    ll ans = 0;

    for (ll i=0,n=(1<<N);i<n;++i)
    {
        bool ok = true;

        for (ll j=0;j<M;++j)
        {
            ll num = 0;

            for (ll k=0;k<S[j].size();++k)
            {
                if (i & (1 << S[j][k])) { ++num; }
            }

            if ((num & 1) != P[j]) { ok = false; }
        }

        if (ok) { ++ans; }
    }

    cout << ans << endl;

    return 0;
}


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

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n, T;
      n=Integer.parseInt(sc.next());
      T=Integer.parseInt(sc.next());
      int[] c = new int[n];
      int[] t = new int[n];

      for(int i=0; i<n; i++){
        c[i]=Integer.parseInt(sc.next());
        t[i]=Integer.parseInt(sc.next());
      }

      int ans=1001;
      for(int i=0; i<n; i++){
        if(t[i]<=T){
          if(c[i]<ans){
            ans=c[i];
          }
        }
      }

      if(ans==1001){
        System.out.println("TLE");
      }else{
        System.out.println(ans);
      }
      
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 23124
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
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; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
int main(void){
    ll N;cin>>N;
    ll c1=0,c2=0;
    REPS(i,N){
        if(i%2==0)c2++;
        else c1++;
    }
    cout<<c1*1.0/(c1+c2)<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    set<int> s;
    REP(i, 3) {
        int a;
        cin >> a;
        s.insert(a);
    }

    cout << s.size() << endl;

    return 0;
}



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

void init(int array[300][2]){
	for(int i=0;i<300;i++){
		for(int j=0;j<2;j++){
			array[i][j]=0;
		}
	}
}

int main(){
	while(1){
		int N;
		int max_width=0,max_height=0;
		int min_width=0,min_height=0;
		int array[300][2];
		init(array);
		cin >> N;
		if(N==0)break;
		for(int i=1;i<N;i++){
			int n,d;
			cin >> n >> d;
			if(d==0){
				array[i][0]=array[n][0]-1;
				array[i][1]=array[n][1];
			}else if(d==1){
				array[i][1]=array[n][1]+1;
				array[i][0]=array[n][0];
			}else if(d==2){
				array[i][0]=array[n][0]+1;
				array[i][1]=array[n][1];
			}else{
				array[i][1]=array[n][1]-1;
				array[i][0]=array[n][0];			
			}
			max_width=max(array[i][0],max_width);
			max_height=max(array[i][1],max_height);
			min_width=min(array[i][0],min_width);
			min_height=min(array[i][1],min_height);	
		}
		
		cout << max_width - min_width +1<<" "<<max_height - min_height +1<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 1160
n=int(input())
T,A=map(int, input().split())
H=list(map(int, input().split()))
V=[]
for i in range(n):
    V.append((T-H[i]*0.006)-A)
    
for i in range(n):
    V[i]=abs(V[i])
print(V.index(min(V))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
3000ならmapいれて対するものの和をとるとか
1 2 3

1 
2
3
12
13
23
123
4回ずつ

1 2 3 4
1 
2
3
4
12
13
14
23
24
34
123
124
134
234
1234
1+3+3+1
8回ずつ2^3

DPかな
最初1回
次、2回
新登場のやつも2回
次4回
新登場も4回

3 4
2 2 4
   [2 2 4]
  0 1 2   3 4 5
0 1 2 4 4
1 0 0 0 0 
2 0 1 2 4
3 0 0 0 0
4 0 0 0 1
まずi-1を2倍する。
つぎに[i][j+a]+=[i-1][j]する
*/
vector<vector<ll>> DP(3030,vector<ll>(3030,0));
int main(){
  DP[0][0]=1;
  ll N,S,MOD=998244353;
  cin>>N>>S;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    for(ll j=0; j<=S; j++) DP[i+1][j]=(DP[i][j]*2)%MOD;
    for(ll j=0; j<=S-a; j++) (DP[i+1][j+a]+=DP[i][j])%=MOD;
  }
  cout<<DP[N][S]<<endl;
}

Measured memory_bytes: 74872
n = int(input())
a = list(map(int, input().split()))
print(2 * n - 2)
if abs(min(a)) <= abs(max(a)):
    x = a.index(max(a)) + 1
    for y in range(1, n + 1):
        if not x == y:
            print(x, y)
    for x in range(1, n):
        y = x + 1
        print(x, y)
else:
    x = a.index(min(a)) + 1
    for y in range(1, n + 1):
        if not x == y:
            print(x, y)
    for x in range(n, 1, -1):
        y = x - 1
        print(x, y)

Measured memory_bytes: 9236
#include<stdio.h>

int main(void){
int i,a,b;
for(i=0;;i++){
  scanf("%d %d",&a,&b);
  if(a==0 && b==0)break;
  if(a<=b){
    printf("%d %d\n",a,b);
  }
  if(a>b){
    printf("%d %d\n",b,a);
  }
}
return 0;
}



Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;



int main(void) {
  ll N;
  cin >> N;
  ll i, j;
  
  ll cnt=0;
  vector<ll> g[111];
  for(i=1; i<=N; i++) {
    for(j=i+1; j<=N; j++) {
      if(N%2==0 && i+j==N+1) continue;
      if(N%2==1 && i+j==N)   continue;
      
      g[i].push_back(j);
      cnt++;
    }
  }
  
  pt(cnt);
  for(i=1; i<=N; i++) {
    for(j=0; j<g[i].size(); j++) {
      pt(i<<" "<<g[i][j]);
    }
  }
  
  
}


Measured memory_bytes: 384
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
mochi = []
for _ in range(N):
    mochi.append(I())
s_mochi = set(mochi)
print(len(s_mochi))


Measured memory_bytes: 38256
n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
table.sort(t)
local function solve()
  if t[1] + 1 < t[n] then
    return false
  end
  if t[1] == t[n] then
    if t[n] == n - 1 then return true end
  end
  local major = 0
  for i = 1, n do
    if t[i] == t[n] then
      major = n + 1 - i
      break
    end
  end
  local minor = n - major
  local minhats = minor + 1
  local maxhats = minor + major // 2
  return minhats <= t[n] and t[n] <= maxhats
end

print(solve() and "Yes" or "No")


Measured memory_bytes: 2424
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[200005];
llint dp[200005][3][2];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 2; k++){
				dp[i][j][k] = -inf;
			}
		}
	}
	dp[0][0][0] = 0;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 2; k++){
				if(k == 0) chmax(dp[i+1][j][1], dp[i][j][k] + a[i+1]);
				
				llint nj = j;
				if(k == 0) nj++;
				if(nj < 3) chmax(dp[i+1][nj][0], dp[i][j][k]);
			}
		}
	}
	
	llint ans;
	if(n % 2) ans = max(dp[n][1][0], dp[n][2][1]);
	else ans = max(dp[n][0][0], dp[n][1][1]);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 14564
//Aizu - 0016 : Treasure Hunt
#include<stdio.h>
#include<math.h>

#define PAI acos(-1.0)

int main()
{
	int d,t,ang=0;
	double x=0,y=0;

	while(scanf("%d,%d",&d,&t)&&(!(d==0&&t==0)))
	{
		x+=d*sin(PAI*ang/180.0);
		y+=d*cos(PAI*ang/180.0);
		ang+=t;
	}

	printf("%d\n%d\n",(int)x,(int)y);

	return 0;
}

Measured memory_bytes: 1032