akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long LLINF = LL(99999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    GET(N);
    int m4 = 0, m2 = 0, m1 = 0;
    for(int i = 0;i < N;i++){
        GET(dummy);
        switch (dummy%4) {
        case 0:
            m4++;
            break;
        case 2:
            m2++;
            break;
        default:
            m1++;
            break;
        }
    }
    if(m2%2==1)m1++;
    if((m1-1<=m4 && m4)||(m1<=0))cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
use std::io::stdin;

fn is_ascii_uppercase(a: char) -> bool {
    match a as u8 {
        x if 65 <= x && x <= 90 => true,
        _ => false,
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let s = s.trim();
    let l = s.chars().count();

    let f1 = || if let Some(0) = s.find('A') { true } else { false };
    let f2 = || s.chars().take(l - 1).skip(2).filter(|&a| a == 'C').count() == 1;
    let f3 = || s.chars().skip(1).filter(|&a| is_ascii_uppercase(a) && (a != 'C')).count() == 0;

    println!("{}", if f1() && f2() && f3() { "AC" } else { "WA" });
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

int main(void){
    int A = 0,B = 0,C = 0;
    cin >> A >> B >> C;
    if((A += B + C) >= 22) cout << "bust";
    else cout << "win";
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    A.sort()
    n = max(A)

    i = 0
    while i < N - 2 and 2 * A[i] < n:
        i += 1

    if i in (0, N - 1):
        r = A[i]
    elif abs(2 * A[i] - n) < abs(2 * A[i - 1] - n):
        r = A[i]
    else:
        r = A[i - 1]

    print(n, r)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20044
#include <bits/stdc++.h>
using namespace std;
#define N 2005
#define max(x,y) ((x)>(y)?(x):(y))
int n,x,y,ans,a[N];
int main()
{
    scanf("%d %d %d",&n,&x,&y);for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    if(n==1) printf("%d\n",abs(a[n]-y));else printf("%d\n",max(abs(a[n]-y),abs(a[n]-a[n-1])));
}

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

using namespace std;

typedef long long ll;

int N;
int A[200000];
vector<pair<ll,ll>> v;

ll count(ll l,ll r){
    ll n = r-l;
    return n*(n+1)/2;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    int s = 0;
    int l=0,r=0;
    while(r<N){
        if((s^A[r]) == (s|A[r])){
            s ^= A[r++];
            continue;
        }
        v.push_back(make_pair(l,r));
        while((s^A[r]) != (s|A[r])){
            s ^= A[l++];
        }
        s ^= A[r++];
    }
    v.push_back(make_pair(l,r));
    ll ans = 0;
    ll p = 0;
    for(int i=0;i<v.size();i++){
        ans += count(v[i].first,v[i].second);
        if(p > v[i].first){
            ans -= count(v[i].first,p);
        }
        p = v[i].second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            in.nextLine();
            String[] ss = new String[n];

            for (int i = 0; i < n; ++i) {
                ss[i] = in.nextLine();
            }

            int[] min_alphabet_count = new int[26];
            for (int i = 0; i < 26; ++i) {
                min_alphabet_count[i] = Integer.MAX_VALUE;
            }

            for (int i = 0; i < ss.length; ++i) {
                String str = ss[i];
                for (int j = 0; j < 26; ++j) {
                    int c = count(str, (char) ('a' + j));
                    if (c < min_alphabet_count[j]) {
                        min_alphabet_count[j] = c;
                    }
                }
            }

            for (int i = 0; i < min_alphabet_count.length; ++i) {
                int cnt = min_alphabet_count[i];
                String str = String.valueOf((char) ('a' + i));
                for (int j = 0; j < cnt; ++j) {
                    out.print(str);
                }
            }
            out.println();
        }

        //count the number of times a char occurs in string
        public int count(String str, char ch) {
            int cnt = 0;
            for (int i = 0; i < str.length(); ++i) {
                if (str.charAt(i) == ch) cnt++;
            }
            return cnt;
        }

    }
}



Measured memory_bytes: 23764
n = int(input())
lis = list(map(int,input().split()))
count = 0
zero = 0
for i in range(n):
  if lis[i] == 0:
    zero += 1
  elif lis[i] < 0:
    lis[i] = lis[i] * -1
    count += 1
if zero >= 1:
  print(sum(lis))
elif count % 2 == 0:
  print(sum(lis))
else:
  print(sum(lis) - (min(lis)*2))

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

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



Measured memory_bytes: 3164
#include <stdio.h>

int main()
{
  int n,i,j,u,k;
  int v[100],G[100][100];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[j]);
      G[u-1][v[j]-1] = 1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",G[i][j]);
      if(j!=n-1) printf(" ");
      else printf("\n");
    }
  }

  return 0;
}


  
  



Measured memory_bytes: 2076
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % MOD;
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll X; cin >> X;

	for (int x = X; x >= 0; x--) {
		for (int n = x; n >= 0; n--) {
			for (int p = 10; p >= 2; p--) {
				ll y = pow(n,p);
				if (y == x) {
					cout << y << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 8064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main() {
    ll a;
    long double b;
    long double ans;
    cin >> a >> b;
    ans = a*b;
    cout << (long long)(ans) << endl;



}

Measured memory_bytes: 3728
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from collections import*\n"
"input=open(0).readline\n"
"n=int(input())\n"
"e=[[]for _ in range(n)]\n"
"for _ in range(n-1):\n"
"    a,b=map(int,input().split())\n"
"    e[a-1].append(b-1)\n"
"    e[b-1].append(a-1)\n"
"f=[0]*n\n"
"v=[1]+[0]*~-n\n"
"q=deque([(0,0)])\n"
"while q:\n"
"    t,c=q.pop()\n"
"    v[t]=1\n"
"    f[t]=c\n"
"    for i in e[t]:\n"
"        if not v[i]:\n"
"            q.append((i,c+1))\n"
"s=[0]*n\n"
"v=[0]*~-n+[1]\n"
"q=deque([(n-1,0)])\n"
"while q:\n"
"    t,c=q.pop()\n"
"    v[t]=1\n"
"    s[t]=c\n"
"    for i in e[t]:\n"
"        if not v[i]:\n"
"            q.append((i,c+1))\n"
"a=b=0\n"
"for i,j in zip(f,s):\n"
"    if i<=j:\n"
"        a+=1\n"
"    else:\n"
"        b+=1\n"
"if a>b:\n"
"    print('Fennec')\n"
"else:\n"
"    print('Snuke')\n"
"\"";
  system(s);
  return 0;
}            

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

using namespace std;
typedef long long ll;

int main() {
  int N, C;
  cin >> N >> C;
  
  vector<vector<int>> dis(C, vector<int>(C));
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < C; j++) {
      cin >> dis[i][j];
    }
  }
  
  vector<vector<int>> cs(N, vector<int>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> cs[i][j];
    }
  }
  
  vector<vector<int>> res(3, vector<int>(C));
  for (int c = 0; c < C; c++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        res[((i + j) % 3)][c] += dis[cs[i][j] - 1][c];
      }
    }
  }
  
  int ans = INT_MAX;
  for (int c1 = 0; c1 < C; c1++) {
    for (int c2 = 0; c2 < C; c2++) {
      if (c1 == c2) {
        continue;
      }
      for (int c3 = 0; c3 < C; c3++) {
        if (c1 == c3 || c2 == c3) {
          continue;
        }
        int r = res[0][c1] + res[1][c2] + res[2][c3];
        ans = min(ans, r);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
s = input()
n = len(s)

ret = [0]*n

for i in range(n-1):
	if s[i:i+2] == "RL":
		for j in range(i,-1,-1):
			if s[j] == "R":
				ret[i + (i+j)%2] += 1
			else:
				break
		for j in range(i+1,n):
			if s[j] == "L":
				ret[i + (i+j)%2] += 1
			else:
				break

print(" ".join(map(str,ret)))

Measured memory_bytes: 10484
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    String W = stdin.next().toUpperCase();
    int n = 0;
    while (true) {
      String T = stdin.next();
      if (T.equals("END_OF_TEXT")) {
        break;
      } else if (T.toUpperCase().equals(W)) {
        n++;
      }
    }

    System.out.println(n);
  }

}

Measured memory_bytes: 18076
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

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

    vector<int> a(N);

    REP(i, N) { cin >> a[i]; }

    vector<int> diff(N - 1);
    REP(i, N - 1) { diff[i] = abs(a[i] - a[i + 1]); }

    int sum = abs(a[0]) + abs(a[N - 1]);
    REP(i, N - 1) { sum += diff[i]; }

    // i == 1
    cout << sum - abs(a[0]) - diff[0] + abs(a[1]) << endl;

    for (int i = 1; i < N - 1; i++) cout << sum - diff[i - 1] - diff[i] + abs(a[i + 1] - a[i - 1]) << endl;

    // i == N
    cout << sum - abs(a[N - 1]) - diff[N - 2] + abs(a[N - 2]) << endl;

    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct Point{ double x; double y; };

void printPoint(Point p){
    printf("%.5lf %.5lf\n", p.x, p.y);
}

void koch(int d, Point p1, Point p2){
    if(d == 0) return;
    // s, u, tをそれぞれ計算
    Point s, t, u;
    s.x = (2*p1.x + p2.x) / 3; s.y = (2*p1.y + p2.y) / 3;
    t.x = (p1.x + 2*p2.x) / 3; t.y = (p1.y + 2*p2.y) / 3;
    u.x = (t.x-s.x)*cos(60*M_PI/180) - (t.y-s.y)*sin(60*M_PI/180) + s.x;
    u.y = (t.x-s.x)*sin(60*M_PI/180) + (t.y-s.y)*cos(60*M_PI/180) + s.y;
    // 出力
    koch(d-1, p1, s);
    printPoint(s);
    koch(d-1, s, u);
    printPoint(u);
    koch(d-1, u, t);
    printPoint(t);
    koch(d-1, t, p2);
}


int main()
{
    int n; cin >> n;
    Point p1, p2;
    p1.x = 0; p1.y = 0;
    p2.x = 100; p2.y = 0;
    printPoint(p1);
    koch(n, p1, p2);
    printPoint(p2);
}


Measured memory_bytes: 3144
#include<iostream>
using namespace std;
#include<iomanip>
#include<cmath>

int main()
{
    int i, n;
    int x[100], y[100];
    double d1 = 0, d2 = 0, d3 = 0, d_inf = 0;

    cin >> n;
    for(i = 0; i < n; i++){ cin >> x[i]; }
    for(i = 0; i < n; i++){
        cin >> y[i];
        d1 = d1 + abs(x[i] - y[i]);
        d2 = d2 + pow(1.0 * (x[i] - y[i]), 2.0);
        d3 = d3 + pow(1.0 * abs(x[i] - y[i]), 3.0);
        if(d_inf < abs(x[i] - y[i])) d_inf = abs(x[i] - y[i]);
    }

    cout << fixed << setprecision(10) << endl;
    cout << d1 << endl << sqrt(d2) << endl;
    cout << pow(d3, 1.0 / 3) << endl << d_inf << endl;

    return 0;
}

Measured memory_bytes: 1304
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int result = 0;
        int[] pricelist = new int[N];
        for (int i = 0; i < N; i++) {
            pricelist[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(pricelist);
        for (int i = 0; i < K; i++) {
            result = result + pricelist[i];
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 37992
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn func(a: f64, b: f64, x: f64, m: f64) -> bool {
    let p = (2.0 * x / m.tan()).sqrt();
    if a >= p {
        return b >= p * m.tan();
    }
    let h = (x - a * a * m.tan() / 2.0) / a * m.cos();

    return h / m.cos() + a * m.tan() <= b;
}


fn main() {
    let line: Vec<f64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let a = line[0];
    let b = line[1];
    let x = line[2] / a;

    let mut l = 0.0;
    let mut r = 90.0;
    while r - l > 1e-8 {
        let m = (r+l)/2.0;

        if func(a,b,x,m * PI / 180.0) {
            l = m;
        } else {
            r = m;
        }
    }

    println!("{:.8}", l);
}


Measured memory_bytes: 4352
<?php
$x=trim(fgets(STDIN));
$a=-200;
while($a<200){
  $b=-200;
  while($b<200){
    $n=(int)(pow($a,5)-pow($b,5));
    if($n==$x){
      echo "$a $b";
      exit;
    }
    ++$b;
  }
  ++$a;
}

Measured memory_bytes: 16164
#include<bits/stdc++.h>
#define D(x) cout << #x << "=" << x <<endl;
using namespace std; 

//int _; 

int k;
string s; 

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> k >> s;
	if(k >= s.size())
		cout << s << endl;
	else
		cout << s.substr(0,k) << "...\n";
	return 0;
}

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

int main(){
  int w,h,n; cin>>w>>h>>n;
  set<int> st_x;
  set<int> st_y;
  
  for (int i=0; i<n; i++){
    int x,y,a; cin>>x>>y>>a;
    x-=1;
    y-=1;
    
    if (a==1){
      for (int j=0; j<=x; j++){
        st_x.insert(j);
      }
    }
    else if (a==2){
      for (int j=x+1; j<w; j++){
        st_x.insert(j);
      }
    }
    else if (a==3){
      for (int j=0; j<=y; j++){
        st_y.insert(j);
      }
    }
    else {
      for (int j=y+1; j<h; j++){
        st_y.insert(j);
      }
    }
  }
  
  int ans=0;
  for (int i=0; i<w; i++){
    for (int j=0; j<h; j++){
      if (st_x.count(i) | st_y.count(j)){
      }
      else {
        ans+=1;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int time = sc.nextInt();

		int h = time / 3600;
		int m = (time - (h * 3600)) / 60;
		int s = time - (h * 3600) - (m * 60);

		System.out.println(h + ":" + m + ":" + s);	
	}
}



Measured memory_bytes: 26292
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    vector<int> tim(5);
    for(int i=0; i<5; i++) {
        cin >> tim[i];
    }
    sort(tim.begin(), tim.end());

    int ans = INF;
    do {
        int cur = 0;
        for(int i=0; i<5; i++) {
            cur += tim[i];
            while(i < 4 and cur % 10 != 0) cur++;
        }
        ans = min(ans, cur);
    }while(next_permutation(tim.begin(), tim.end()));

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

def in_sec(a, b, c):
    return min(a, b) <= c <= max(a, b)

q = input()

for loop in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())
    #(y1 - y0)(x - x0) = (x1 - x0)(y - y0)
    a1, b1, c1 = [y1 - y0, x0 - x1, x0 * (y1 - y0) - y0 * (x1 - x0)]
    a2, b2, c2 = [y3 - y2, x2 - x3, x2 * (y3 - y2) - y2 * (x3 - x2)]
    det = a1 * b2 - b1 * a2

    print float(c1 * b2 - c2 * b1) / det, float(c2 * a1 - c1 * a2) / det



Measured memory_bytes: 5064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,m;
	cin >> n >> m;
	
	std::vector<int> a(n);
	rep(i,n) cin >> a[i];
	int sum = 0;
	rep(i,n) sum += a[i];

	int b = (sum+4*m-1) / 4 / m;
	int ct = 0;
	rep(i,n) {
		if(a[i] >= b){
			ct++;
		}
	}

	if(ct >= m){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

  return 0;
}


Measured memory_bytes: 256
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 100100;
int n;
int a[maxn];
vector<pii> vec;

inline void sub(int &x, int y) {
	vec.pb(mp(x, y));
	x -= y;
}
void out() {
	rep(i, 0, vec.size() - 1) printf("%d %d\n", vec[i].fi, vec[i].se);
}
void work() {
	n = read();
	rep(i, 1, n) a[i] = read();
	sort(a + 1, a + n + 1);
	if (a[1] <= 0 && a[n] >= 0) {
		int x = a[1];
		int j = n;
		rrep(i, n - 1, 2) {
			if (a[i] < 0) break;
			sub(x, a[i]); j = i;
		}
		a[1] = x;
		x = a[n];
		rep(i, 1, j - 1) sub(x, a[i]);
		printf("%d\n", x);
		out();
		return;
	}
	if (a[1] > 0) {
		int x = a[1];
		rep(i, 2, n - 1) sub(x, a[i]);
		sub(a[n], x);
		printf("%d\n", a[n]);
		out();
		return;
	}
	if (a[n] < 0) {
		int x = a[n];
		rep(i, 1, n - 1) sub(x, a[i]);
		printf("%d\n", x);
		out();
		return;
	}
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif

	work();

	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


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

int mod = 1000000007;

int main()
{
    int64_t X;
    cin >> X;
    int64_t yen = 100;
    int64_t year = 0;
    while (yen < X)

    {
        yen += yen / 100;
        year++;
    }

    cout << year;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // Happy Candle、それぞれの地点からスタートしたものを保持
    // (現在地、スタート)のpairのset、右に移動した距離のmultiset
    int H, W;
    cin >> H >> W;
    map<int, int> pieces;
    multiset<int> rmove;
    rep(i, W) {
        pieces[i] = i;
        rmove.insert(0);
    }
    rep(i, H) {
        int a, b;
        cin >> a >> b;
        a--;
        auto it = pieces.lower_bound(a);
        int limit = -1;
        while (it != pieces.end() && it->first <= b) {
            limit = max(limit, it->second);
            int move = it->first - it->second;
            pieces.erase(it++);
            rmove.erase(rmove.find(move));
        }
        if (limit != -1 && b < W) {
            pieces[b] = limit;
            rmove.insert(b-limit);
        }
        if (!rmove.empty()) {
            cout << i + 1 + *rmove.begin() << '\n';
        } else cout << -1 << '\n';
    }
    return 0;
}

// 09



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


using namespace std;

const long long int mod = (1e9)+7;

int main(){
    int h,w; cin >> h >> w;

    int arr[h][w];

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

        for(int j=0;j<w;j++){
            if(a[j] == '.')
                arr[i][j] = 0;
            else
                arr[i][j] = 1;
        }
    }

    long long int dp[h][w]={};

    if(arr[0][0] == 0)
        dp[0][0] = 1;
   
    for(int i=1;i<h;i++){
        if(!arr[i][0]) dp[i][0] = dp[i-1][0];
        else dp[i][0] = 0;
    }
    for(int i=1;i<w;i++){
        if(!arr[0][i]) dp[0][i] = dp[0][i-1];
        else dp[0][i] = 0;
    }

    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(arr[i][j]==0) 
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
    }

    cout << dp[h-1][w-1] % mod << endl;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, k, l[50];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l, l + n);
	int ans=0;
	for (int i = 0; i < k; i++) {
		ans += l[n-i-1];
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int a, b;
    cin >> a >> b;
   if ( 0 < a && a < 10 && b > 0 && b < 10)
       cout << a * b << endl;
   else
       cout << - 1;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stdio.h>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    INIT;

    int n, a, b;
    cin >> n >> a >> b;
    int X[n] = {};
    X[a - 1]++;
    X[b - 1]++;

    int f = 1, a_n = a - 1, b_n = b - 1, cnt = 0;
    char j;
    while(1){
        if(f == 1){
            if(X[a_n + 1] != 0){
                if(a_n - 1 < 0){
                    j = 'B';
                    break;
                }else{
                    X[a_n] = 0;
                    a_n--;
                    X[a_n] = 1;
                }
            }else{
                X[a_n] = 0;
                a_n++;
                X[a_n] = 1;
            }
        }else{
            if(X[b_n - 1] != 0){
                if(b_n + 1 >= n){
                    j = 'A';
                    break;
                }else{
                    X[b_n] = 0;
                    b_n++;
                    X[b_n] = 1;
                }
            }else{
                X[b_n] = 0;
                b_n--;
                X[b_n] = 1;
            }
        }
        cnt++;
        if(cnt > n * 2){
            j = 'D';
            break;
        }
        f = 1 - f;
    }
    if(j == 'A') cout << "Alice" << endl;
    else if(j == 'B') cout << "Borys" << endl;
    else if(j == 'D') cout << "Draw" << endl;

    return 0;
}

Measured memory_bytes: 256
#[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 s = get!(String).chars().collect::<Vec<_>>();
    let n = s.len();

    let mut vec = Vec::new();
    vec.push(0);
    for i in 0..n-1 {
        if s[i] != s[i+1] {
            vec.push(i+1);
        }
    }
    vec.push(n);

    let top = if s[0] == '<' {
        1
    } else {
        0
    };

    let mut sum = 0;
    let mut before_diff = 0;
    for (i, diff) in vec.iter().zip(vec.iter().skip(1)).map(|(e1,e2)| e2-e1).enumerate() {
        sum += (diff-1)*diff/2;
        if i % 2 == top {
            sum += max!(before_diff, diff);
        }
        before_diff = diff;
    }
    if s[n-1] == '<' {
        sum += before_diff;
    }
    println!("{}", sum);
}


Measured memory_bytes: 13684
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	int N,K,n;
	cin>>N>>K;
	map<pair<string,string>,int>m;
	for(;N--;){
		cin>>n;
		vector<string>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
			for(int j=0;j<i;j++){
				auto p=make_pair(v[i],v[j]);
				if(p.first>p.second)swap(p.first,p.second);
				m[p]++;
			}
		}
	}
	vector<pair<string,string>>v;
	for(auto &e:m)if(e.second>=K)v.push_back(e.first);
	sort(v.begin(),v.end());
	cout<<v.size()<<endl;
	for(auto &e:v)cout<<e.first<<' '<<e.second<<endl;
}

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

using namespace std;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

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

	ll n;
	cin >> n;

	vl dp(n + 1);
	dp[0] = 2;
	dp[1] = 1;

	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    
    
    if H==0 and W==0:
        break
    else:
        if W%2==0:
            
            if H%2==0:
                for i in range(H//2):
                    print("#."*(W//2))
                    print(".#"*(W//2))
                print("")
            else:
                for i in range(H//2):
                    print("#."*(W//2))
                    print(".#"*(W//2))
                print("#."*(W//2))
                print("")
        else:
            
            if H%2==0:
                for i in range(H//2):
                    print("#."*(W//2)+"#")
                    print(".#"*(W//2)+".")
                print("")
            else:
                for i in range(H//2):
                    print("#."*(W//2)+"#")
                    print(".#"*(W//2)+".")
                print("#."*(W//2)+"#")
                print("")
                    
        
            
        



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

using namespace std;
using ll = long long;


int main()
{
	ll q, h, s, d, n; cin >> q >> h >> s >> d >> n;
	s = min({s, h * 2, q * 4});
	cout << min(s * n, (n / 2) * d + (n % 2) * s) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
const int maxn = 5e5 + 1;
const int maxq = 5e5 + 1;
 
struct TQuery{
    int l, r, id;
    inline bool operator <(const TQuery &other){
        return r < other.r;
    }
};
 
int n, m, a[maxn], bit[maxn], res[maxq];
TQuery q[maxq];
map<int, int> pre; // vi tri xuat hien truoc do cua a[i]
 
inline void update(int x, const int &val){
    for(; x <= n; x += x & -x) bit[x] += val;
}
 
inline int get(int x){
    int sum = 0;
    for(; x; x -= x & -x) sum += bit[x];
    return sum;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= m; i++) cin >> q[i].l >> q[i].r, q[i].id = i;
    sort(q + 1, q + m + 1);
    for(int i = 1, x = 1; i <= m; i++){
        for(; x <= q[i].r; x++){
            update(x, 1); int cur = a[x]; // tang vi tri x len 1
            if(pre[cur]) update(pre[cur], get(pre[cur] - 1) - get(pre[cur])); // neu a[x] da xuat hien thi xoa cho truoc do di
            pre[cur] = x; // cap nhat lai pre
        }
        res[q[i].id] = get(q[i].r) - get(q[i].l - 1); // lay tong tu l -> r
    }
    for(int i = 1; i <= m; i++) cout << res[i] << '\n';
    return 0;
} 

Measured memory_bytes: 38976
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char s[5];
  scanf("%s",s);
  for(int i=0;i<3;i++) {
    if(s[i]=='1')s[i]='9';
    else if(s[i]=='9')s[i]='1';
  }
  puts(s);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl

int main(){
	int n; cin>>n;
	vector<char> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i =0; i < n - 1; i++){
		if(a[i] != a[i + 1]){
			ans++;
		}
	}
	cout<<(ans + 1 == 3 ? "Three\n" : "Four\n");
}


Measured memory_bytes: 256
#include <iostream>

 

 

 

using namespace std;

 

 

 

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
       cout << "a > b" << endl;
    else if (a == b)
       cout << "a == b" <<endl;
    else
       cout << "a < b" << endl;
     
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <iomanip>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
#define fsp(c) fixed << setprecision(c)

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

double cutl(int i,double n,double r) {
  if (i<=0||n<=i) return 0;
  return r*sqrt(1-((double)i-n/2)*((double)i-n/2)*4/n/n);
}

int main(){
  int n,m=0,o,a,b;
  cin >> n;
  REP(i,n){
    cin >> a >> b;
    if (a>m) {
      m=a;
      o=b;
    }
  }
  cout << m+o;
  return 0;
}

Measured memory_bytes: 256
while (n, x = gets.split.map(&:to_i)) != [0, 0]

  count = 0
  for a in 1..n-2
    for b in a+1..n-1
      for c in b+1..n
        count += 1 if a+b+c == x
      end
    end
  end

  puts count

end



Measured memory_bytes: 6856
if __name__ == '__main__':
    N, M = map(int, input().split())
    X = sorted([int(i) for i in input().split()])
    diff = [None for i in range(M-1)]

    for i in range(len(diff)):
        diff[i] = X[i+1] - X[i]

    print(sum(sorted(diff, reverse=True)[N-1:]))


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

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] S = Input.ScanStrArray();
          Console.WriteLine(S[0][S[0].Length-1]==S[1][0] && S[2][0]==S[1][S[1].Length-1] ? "YES" : "NO");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
int main(void){
    int n;
    int i;
    int tcnt=0;
    int hcnt=0;
    char s1[101],s2[101];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s %s",s1,s2);
        if(strcmp(s1,s2)>0)
            tcnt+=3;
        else if(strcmp(s1,s2)==0){
            tcnt++; hcnt++;
        }
        else
            hcnt+=3;
    }
    printf("%d %d\n",tcnt,hcnt);
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int>vis;

int main()
{
  int n;
  cin>>n;
  string a;
  cin>>a;
  int flag=1;
  char tm=a[a.size()-1];
  vis[a]=1;
  n--;
  while(n--)
  {
      string b;
      cin>>b;
      if(b[0]!=tm||vis[b]){flag=0;}
      vis[b]=1;
      tm=b[b.size()-1];
  }
  if(flag){cout<<"Yes"<<endl;}
  else {cout<<"No"<<endl;}
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int dp0 = 0;
	int dp1 = 0;
	int dp2 = 0;

	rep(i, N) {
		int kari1 = max(dp0, dp1) + getint();
		int kari2 = max(dp1, dp2) + getint();
		dp1 = max(dp2, dp0) + getint();
		dp2 = kari1;
		dp0 = kari2;
	}

	printf("%d", max(dp0, max(dp1, dp2)));

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N;
	cin>>N;
	vector<ll> a;
	rep(i,N){
		ll x;
		cin>>x;
		x -= i+1;
		a.pb(x);
	}
	sort(all(a));
	ll m = a[N/2];
	ll ans = 0;
	rep(i,N) ans += abs(a[i]-m);
	cout<<ans<<endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][][] room = new int[4][3][10];
        for (int i = 0; i < n; i++) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
            room[a[0] - 1][a[1] - 1][a[2] - 1] += a[3];
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 10; k++) {
                    System.out.print(" " + room[i][j][k]);
                }
                System.out.println();
            }
            if (i != 3) {
                System.out.println("####################");
            }
        }
    }
}

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test

void solve() {
    int n, W;
    cin >> n >> W;
    vector<vector<int>> dp(n, vector<int>(W + 1));
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    if (w[0] <= W) {
        dp[0][w[0]] = v[0];
    }
    for (int i = 1; i < n; ++i) {
        int val = v[i];
        int wt = w[i];
        if (wt > W) {
            dp[i] = dp[i - 1];
        }
        else {
            for (int j = 0; j < wt; ++j) {
                dp[i][j] = dp[i - 1][j];
            }
            dp[i][wt] = max(dp[i - 1][wt], val);
            for (int j = wt + 1; j <= W; ++j) {
                dp[i][j] = max(dp[i - 1][j], val + dp[i - 1][j - wt]);
            }
        }
    }
    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end());
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 82232