akhauriyash/Code-Regression huggingface dataset:
'use strict';
function main(input) {
  const args = input.split(' '),
        W = parseInt(args[0]),
        H = parseInt(args[1]),
        x = parseInt(args[2]),
        y = parseInt(args[3]);
  const square = W * H / 2;
  if (x+x === W && y+y === H) {
    console.log(square + ' 1');
  } else {
    console.log(square + ' 0');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  string D;
  cin >> D;
  if ( (D[0] == D[1] && (D[1] == D[2])) ||
       (D[1] == D[2] && (D[2] == D[3])) ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int k, s, z, cnt = 0;
    cin >> k >> s;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            z = s - x - y;
            if (z >= 0 && z <= k) cnt++;
        }
    }
    cout << cnt << endl;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

void swap1(int &x, int &y) {
  x ^= y;
  y ^= x;
  x ^= y;
}

void swap2(int &x, int &y) {
  int tmp = x;
  x = y;
  y = tmp;
}

int main() {
  int T, X;
  cin >> T >> X;
  cout << (double)T / X << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
    int a, b, c;
    read(a), read(b), read(c);
    puts(a == b && b == c ? "Yes" : "No");
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

ll A, B, K, cur;

int main(){
    cin >> A >> B >> K;

    cur = min(A + K - 1, B);

    for(int i = A; i <= cur; i++)
        cout << i << endl;

    cur = max(cur+1, B - K + 1);

    for(int i = cur; i <= B; i++)
        cout << i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
        ios::sync_with_stdio(false);
        cin.tie(0);

        int h,w;cin>>h>>w;
        vector<string>s(h);
        rep(i,h)
        {
                cin>>s[i];
        }

        bool flag=true;
        rep(i,h)
        {
                rep(j,w)
                {
                        if (s[i][j] == '#')
                        {
                                if (!((i + 1 < h and s[i + 1][j] == '#') || (i - 1 >= 0 and s[i - 1][j] == '#') || (j + 1 < w and s[i][j+1] == '#')||(j - 1 >= 0 and s[i][j-1] == '#')))
                                {
                                        cout<<"No\n";
                                        return 0;
                                }
                        }
                }
        }
        cout<<"Yes\n";

        return 0;
}

Measured memory_bytes: 256
n = int(input())

if n % 4 == 0 or n % 7 == 0:
  print('Yes')
else:
  canbuy = False
  while True:
    n = n - 7
    if n < 0:
      break
    if n % 4 == 0:
      canbuy = True
      break
  if canbuy:
    print('Yes')
  else:
    print('No')

    

Measured memory_bytes: 2940
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    string[] strings = new string[n];
    string[] stringsOrigi = new string[n];
    int[] nums = new int[n];
    int[] used = new int[n];
    int answer = 0;
    int maxMemo = -1;
    for(int i = 0; i < n; i++)
    {
      var numsa = Console.ReadLine().Split(' ');
      strings[i] = numsa[0];
      stringsOrigi[i] = numsa[0];
      nums[i] = int.Parse(numsa[1]);
    }
    Array.Sort(strings);

    for(int i = 0; i < n; i++)//順位
    {
      maxMemo = -1;
      for(int j = 0; j < n; j++)
      {
        if(strings[i] == stringsOrigi[j] && maxMemo < nums[j]
          && used[j] == 0)
        {
          answer = j+1;
          maxMemo = nums[j];
        }
      }
      used[answer-1] = 1;
      Console.WriteLine(answer);
    }
    
    
	}
}

Measured memory_bytes: 13404
#include<iostream>
using namespace std;
#include<cmath>
#include<algorithm>
int main()
{
    long int a,b,n,high=0,i;
    scanf("%ld %ld %ld",&a,&b,&n);
    i=min(b-1,n);
    
    high=floor(a*i/b)-a*floor(i/b);
    
    
    printf("%ld",high);
    return 0;
}

Measured memory_bytes: 3804
use proconio::input;

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

    let mut t = FenwickTree::from_vec(a);
    for i in 0..q {
        let (f, l, r) = query[i];
//        input! { f: usize };
        if f == 1 {
//            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
//            input! { p: usize, x: usize }
            let (p, x) = (l, r);
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            let v = t.v[i] + v[i];
            t.v[i] = v;
            let p = i + Self::lsb(i + 1);
            if p < n {
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        while i < self.v.len() {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= Self::lsb(i);
        }
        v
    }

    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 34876
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  
  ll dif = abs(a - b);
  
  for (int i = 0; i < n - 1; i++) {
    ll high = i * d - (n - 1 - i) * c;
    ll low = i * c - (n - 1 - i) * d;
    if (low <= dif && dif <= high) {
      cout << "YES\n";
      return 0;
    }
  }
  
  cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


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

Measured memory_bytes: 3088
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

int ca,cb,cab;
int wa,wb;

void run() {
	scanf("%d%d%d",&ca,&cb,&cab); scanf("%d%d",&wa,&wb);

	ll ret=0;
	if(2*cab<=ca+cb) {
		int cur=min(wa,wb);
		ret+=(ll)cur*2*cab; wa-=cur; wb-=cur;
		ret+=(ll)min(2*cab,ca)*wa;
		ret+=(ll)min(2*cab,cb)*wb;
	} else {
		ret+=(ll)ca*wa+(ll)cb*wb;
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
a = map(int, raw_input().split())

ans = 0
used = [False]*N
for i in xrange(N):
    if not used[i]:
        if a[a[i] - 1] == i + 1 and not used[a[i] - 1]:
            ans += 1
            used[a[i] - 1] = True
print ans


Measured memory_bytes: 12648
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = SR(n)
for i in range(n):
    for j in range(len(s[i])):
        while s[i][j] in s[i][:j]:
            s[i][j] = "0"+s[i][j]
ans = set(s[0])
for i in range(1,n):
    ans &= set(s[i])
ans = sorted(list(ans))
if len(ans) == 0:print()
else:
    for i in range(len(ans)):
        ans[i] = ans[i][-1]
    ans.sort()
    for i in range(len(ans)-1):
        print(ans[i],end = "")
    print(ans[-1])
"""

#D
n,m = LI()
ln = [n-1]
lm = [m-1]
a = n-1
b = m-1
while a > 2:
    a -= 2
    ln.append(ln[-1]+a)
while b > 2:
    b -= 2
    lm.append(lm[-1]+b)
la = len(ln)
lb = len(lm)
for i in range(la):
    if i or a == 2:
        ln.append(ln[la-i-1])
for i in range(lb):
    if i or b == 2:
        lm.append(lm[lb-i-1])
x,y = LIR(2)
lx = 0
ly = 0
for i in range(n-1):
    lx += ln[i]*(x[i+1]-x[i])%mod
    lx %= mod
for i in range(m-1):
    ly += lm[i]*(y[i+1]-y[i])%mod
    ly %= mod
ans = lx*ly%mod
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

using namespace std;

int main() {
  long long X;
  cin >> X;
  long long now = 100;
  long long ans = 0;
  while (now < X) {
    now += now / 100;
    ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int c=0;
  for(int i=2;i<n;i++){
    if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C') { c++; i+=2; }
  }
  cout<<c;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> ab(n);
    vector<vector<int>> cd(m);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        ab[i].push_back(a);
        ab[i].push_back(b);
    }
    rep(i, m)
    {
        int c, d;
        cin >> c >> d;
        cd[i].push_back(c);
        cd[i].push_back(d);
    }
    rep(i, n)
    {
        int min_distance = 1000000000;
        int min_j;
        rep(j, m)
        {
            if (chmin(min_distance, abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])))
            {
                min_j = j;
            }
        }
        cout << min_j + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    string a, b, ans;
    cin >> a >> b;
    a = ' ' + a;
    b = ' ' + b;
    vector<vector<int>> dp(a.length(), vector<int>(b.length(),0));
    //map<int, map<int, ii>> tr;
    rep(i, 1, sz(a)) {
        rep(j, 1, sz(b)) {
            if (a[i] == b[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                //tr[i][j] = {i-1,j-1};
            }
            else {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
                //if (dp[i][j-1] > dp[i-1][j]) tr[i][j] = {i,j-1};
                //else tr[i][j] = {i-1,j};
            }
        }
    }
    int x = sz(a) - 1, y = sz(b) - 1;
    while (x >= 1 && y >= 1) {
        if (a[x] == b[y]) {
            ans.pb(a[x]);
            --x;--y;
            continue;
        }
        if (dp[x-1][y] > dp[x][y-1]) {
            --x;
        }
        else --y;
    }
    reverse(all(ans));
    cout << ans << "\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 38456
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	
	string s;
	bool flg = false;
	
	map<int,int> A;
	map<int,int> B;
	while(1){
		getline(cin,s);
		if(s=="#")break;
		if(cin.eof())break;
		
		if(s.size()<=1)flg=true;
		else{
			int a=0;
			rep(i,s.size()){
				if('0'<=s[i]&&s[i]<='9'){
					a*=10;
					a+=(s[i]-'0');
				}else{
					break;
				}
			}
			
			if(!flg)A[a]++;
			else B[a]++;
		}
	}
	
	typedef pair<int,int> pii;
	vector<pii> dat;
	
	map<int,int>::iterator it = A.begin();
	while(it!=A.end()){
		
		map<int,int>::iterator bt = B.find(it->first);
		if(bt!=B.end()){
			dat.push_back(pii(it->first, it->second+bt->second));
		}
		it++;
	}
	
	sort(dat.begin(),dat.end());
	
	rep(i,dat.size()){
		printf("%d %d\n",dat[i].first,dat[i].second);
	}
}

Measured memory_bytes: 1192
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int c = sc.nextInt();
			if((n|c) == 0) break;
			int [] data1 = new int[n];
			for(int i = 0; i < n; i++){
				StringBuilder sb = new StringBuilder();
				for(int j = 0; j < 16; j++){
					sb.append(sc.nextInt());
				}
				data1[i] = Integer.parseInt(sb.toString(), 2);
			}
			int [] data2 = new int[c];
			for(int i = 0; i < c; i++){
				StringBuilder sb = new StringBuilder();
				for(int j = 0; j < 16; j++){
					sb.append(sc.nextInt());
				}
				data2[i] = Integer.parseInt(sb.toString(), 2);
			}
			int [][] dp = new int[2][1 << 16];
			for(int i = 0; i < 2; i++){
				Arrays.fill(dp[i], -1);
			}
			dp[0][0] = 0;
			int max = 0;
			for(int i = 0; i < n; i++){
				int ind = i & 1;
				for(int j = 0; j < (1 << 16); j++){
					if(dp[ind][j] < 0) continue;
					dp[ind ^ 1][j] = Math.max(dp[ind ^ 1][j], dp[ind][j]);
					max = Math.max(max, dp[ind ^ 1][j]);
					for(int k = 0; k < c; k++){
						int temp = data1[i] | j;
						int temp2 = temp & data2[k];
						int count = Integer.bitCount(temp2);
						
						int nextbit = temp & (~data2[k]);
						int value = dp[ind][j] + count;
						dp[ind ^ 1][nextbit] = Math.max(dp[ind ^ 1][nextbit], value);
						max = Math.max(max, dp[ind ^ 1][nextbit]);
					}
				}
				Arrays.fill(dp[ind], -1);
			}
			System.out.println(max);
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 45264
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N, M ,C;
	cin >> N >> M >> C;
	vector<int> B(M);
//	cout << "1" << endl;
	for(int i=0; i<M; i++){
		cin >> B.at(i);
	}
//	cout << "2" << endl;

	vector<vector<int>> A(N, vector<int>(M));
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++){
			cin >> A.at(i).at(j);
		}
	}

	int cnt_solve=0;
	int tmp=0;
	for(int i=0; i<N; i++){
		tmp = C;
		for(int j=0; j<M; j++){
//			cout << "a" << endl;
			tmp+=A.at(i).at(j)*B.at(j);
		}
		if(tmp>0){
			cnt_solve++;
		}
	}

	cout << cnt_solve << endl;

	return 0;
}

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

int main(){

int a,b,c,d;

	cin >> a >> b >> c >> d;
	d==0;
	for(int i=a; i<=b; i++){
	if(c%i==0)d++;
	
	}
	cout << d << "\n";
	
	return 0;
	}

Measured memory_bytes: 1164
#include<stdio.h>
typedef struct
{
    char m;
    int n;
}Card;
int main()
{
    int a,b,d=0,i,j;
    scanf("%d",&a);
    Card x[a],y[a],c={0};
    for(i=0;i<a;i++){
        scanf(" %c%d",&x[i].m,&x[i].n);
        y[i]=x[i];
    }
    for(i=0;i<a-1;i++){
        for(j=a-1;j>i;j--){
            if(x[j].n<x[j-1].n){
                c=x[j-1];x[j-1]=x[j];x[j]=c;
            }
        }
    }
    for(i=0;i<a;i++){
        if(i==a-1)printf("%c%d\n",x[i].m,x[i].n);
        else printf("%c%d ",x[i].m,x[i].n);
    }
    puts("Stable");
    for(i=0;i<a;i++){
        b=i;
        for(j=i;j<a;j++){
            if(y[j].n<y[b].n){
                b=j;
            }
        }
        if(i!=b){
            c=y[i];y[i]=y[b];y[b]=c;
        }
    }
    for(i=0;i<a;i++){
        if(i==a-1)printf("%c%d\n",y[i].m,y[i].n);
        else printf("%c%d ",y[i].m,y[i].n);
    }
    for(i=0;i<a;i++){
        if(x[i].m==y[i].m)d++;
    }
    if(a==d)puts("Stable");
    else puts("Not stable");
    return 0;
}

Measured memory_bytes: 608
#include <stdio.h>

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


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q;
ll s[200005],t[200005],x[200005];
set<pair<ll,int> >S;
vector<pair<ll,pair<ll,ll> > > vec;
ll ans[200005];
int main(){
	scanf("%d%d",&n,&q);
	repn(i,n){
		scanf("%lld%lld%lld",&s[i],&t[i],&x[i]);
		ll L = s[i]-x[i];
		ll R = t[i]-1-x[i];
		vec.pb(mp(x[i],mp(L,R)));
	}
	repn(i,q){
		ll d;
		scanf("%lld",&d);
		S.insert(mp(d,i));
		ans[i] = -1;
	}
	SORT(vec);
	rep(i,vec.size()){
		ll L = vec[i].sc.fi;
		ll R = vec[i].sc.sc;
		if(S.empty()) continue;
		auto it = S.lower_bound(mp(L,-1));
		while(S.size() && it != S.end() && (*it).fi <= R){
			ans[(*it).sc] = vec[i].fi;
			S.erase(it++);
		}
	}
	repn(i,q) printf("%lld\n",ans[i])
	;}

Measured memory_bytes: 26092
#include <iostream>
using namespace std;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int k,x;
	cin >> k >> x;
	if(k*500 >= x){
		println("Yes");
	}else{
		println("No");
	}
	return 0;
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner inputs = new Scanner(System.in);
		String s = inputs.next();
		int end = 3;
		boolean huh = true;
		int len1 = (s.length()-1)/2;
		int len2 = (s.length()+3)/2;
		if(!palin(s.substring(0,len1))||!palin(s.substring(len2-1))||!palin(s)) {
			huh=false;
		}
		if(huh) {
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}
	public static boolean palin(String s) {
		String temp = "";
		for(int i=s.length()-1;i>=0;i--) {
			temp+=s.charAt(i);
		}
		if(temp.equals(s)) {
			return true;
		}
		return false;
	}
}


Measured memory_bytes: 23636
#include <stdio.h>
int main() {
	long n, x, a, p=0,num = 0;
	scanf("%ld%ld", &n, &x);
    for(int i=0;i<n;i++){
      scanf("%ld",&a);
      if(p+a>x){
        num+=p+a-x;
        a=x-p;
      }
      p=a;
    }
  printf("%ld\n",num);
}
/*
 p+a-xは減らす必要のある数，式の変形でa=x-pでaは決まる．
*/

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
a = 0
x = 0

while x == 0:
    for i in range(n):
        if l[i] % 2 == 0:
            x += 1
            l[i] = (l[i]/2)
        else:
            x = -1
    if x == n:
        a += 1
        x = 0

print("{}".format(a))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  for(int i = 0; i < 5; i++){
    cout << s.at(i);
  }
  cout << ' ';
  for(int i = 6; i < 13; i++){
    cout << s.at(i);
  }
  cout << ' ';
  for(int i = 14; i < 19; i++){
    cout << s.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>>x(n, vector<int>(d));
	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	int ans(0);
	rep(i, n) {
		rep(j, n) {
			int sum(0);
			if (i == j)continue;
			rep(k, d) {
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			int root = sqrt(sum);
			if (root * root == sum) {
				ans++;
			}
		}
	}
	cout << ans / 2;
	return 0;

}

Measured memory_bytes: 3708
import java.util.HashMap;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashMap<String, String> weather = new HashMap<String, String>();
        weather.put("Sunny", "Cloudy");
        weather.put("Cloudy", "Rainy");
        weather.put("Rainy", "Sunny");
        String a = sc.next();
        System.out.println((String)weather.get(a));
    }
}

Measured memory_bytes: 19156
x=int(input())
li = list(map(int,input().split()))
i=0
c=0
a=1
for n in li:
  while c<i:
    if li[c]>n:
      break
    c+=1
    if c==i:
      a+=1
  c=0  
  i+=1
print(a)
    

Measured memory_bytes: 2940
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

long long int N,sum=0;

int main(){

    cout << fixed << setprecision(18);
    cin>>N;
    N%=10;
    if(N==3){
        cout<<"bon"<<endl;
    }else if(N==0||N==1||N==6||N==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
    
}



Measured memory_bytes: 3620
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
    using System.Net;

     
    public class Program
    {

        public void Proc() {
            int total = int.Parse(Reader.ReadLine());
            int cake = int.Parse(Reader.ReadLine());
            int donuts = int.Parse(Reader.ReadLine());

            int ans = (total-cake)%donuts;
            Console.WriteLine(ans);
        }



        public class Reader {
            public static bool IsDebug = false;
            private static System.IO.StringReader SReader;
            private static string InitText = @"





1234
150
100






";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            #if DEBUG
            Reader.IsDebug = true;
            #endif
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 11092
%:pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;

#define int long long

int n , p;
int gcd(int x , int y) {
	return (y == 0) ? x : gcd(y , x % y);
}

int lcm(int x, int y) {
	return x * y / gcd(x , y);
}

main(void) {
	cin>>n;
	int a , b, c;
	for(a = 1;a <= 3500;a ++) {
		for(b = 1;b <= 3500;b ++) {
			int p = 4 , q = n;
			int LCM = lcm(q , a);
			int xx1 = p * LCM / q;
			int xx2 = LCM / a;
			xx1 -= xx2;
			if(xx1 < 0) continue;
			q = LCM; p = xx1;
			LCM = lcm(q , b);
			xx1 = p * LCM / q;
			xx2 = LCM / b;
			if(xx1 - xx2 == 1) {
				cout<<a<<" "<<b<<" "<<LCM<<endl;
				return 0;
			}
		}
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;

    ll mi = (1ll<<60);
    for(ll x=1;x*x<=N;x++){
    	if(N%x==0) chmin(mi, x+N/x);
    }
    cout << mi-2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
    int n;
    cin >> n;    
    int a[n];
    int max = 0;
    int ans = 0;
    int key = 0;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < n; i++){
        if(ans<a[i]){
            ans = a[i];
        key = i;
        }
    }
    sort(a, a + SIZE_OF_ARRAY(a), std::greater<>());
    int ans2 = a[1];
    for (int i = 0; i < n; i++){
        if(i!=key)
        cout << ans << endl;
        else
        cout << ans2 << endl;
    }
    return 0;
}


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

using namespace std;
typedef pair<int, int> ii;



int main() {
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    bool dp[k+2];
    dp[0] = 0;
   
    for(int i = 0; i < arr[0]; ++i) {
        dp[i] = 0;
    }

    for(int i = 1; i <= k; ++i) {
        bool canwin = false;
        for(int j = 0; j < n and arr[j] <= i; ++j) {
            if(dp[i - arr[j]] == 0) {
                canwin = true;
            }
        }
        dp[i] = canwin;
    }

    bool First = false;

    for(int j = 0; j < n ; ++j) {
        if(dp[k-arr[j]] == 0) {
            First = true;
        }
    }
    if(First) {
        cout << "First";
    }else {
        cout << "Second";
    }

}

Measured memory_bytes: 384
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0509-input.txt"));

		while (scan.hasNext()) {
			String s = scan.next();
			decode(s);
		}

		scan.close();
		System.exit(0);
	}

	private static void decode(String s) {
		StringBuilder d = new StringBuilder("");
		for (int i = 0; i < s.length(); i++)
			d.append(decodeChar(s.charAt(i)));
		System.out.println(d.toString());
	}

	private static char decodeChar(char c) {
		int a = c - 'A';
		a -= 3;
		if (a < 0)
			a += 26;
		return (char) (a + 'A');
	}
}

Measured memory_bytes: 26352
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input())

    ans = 0
    q = N // K
    for i in range(K):
        dp = np.zeros((3, q + 2), dtype='i8')
        for j in range(q + 1):
            ti = i + j * K
            if ti >= N:
                continue
            rsp = T[ti]
            if rsp == 'r':
                dp[0][j + 1] = max(dp[1][j], dp[2][j])
                dp[1][j + 1] = max(dp[0][j], dp[2][j])
                dp[2][j + 1] = max(dp[0][j] + P, dp[1][j] + P)
            elif rsp == 's':
                dp[0][j + 1] = max(dp[1][j] + R, dp[2][j] + R)
                dp[1][j + 1] = max(dp[0][j], dp[2][j])
                dp[2][j + 1] = max(dp[0][j], dp[1][j])
            elif rsp == 'p':
                dp[0][j + 1] = max(dp[1][j], dp[2][j])
                dp[1][j + 1] = max(dp[0][j] + S, dp[2][j] + S)
                dp[2][j + 1] = max(dp[0][j], dp[1][j])
        ans += np.max(dp)

    print(ans)


if __name__ == '__main__':
    solve()


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


int main() 
{
	int k, a, b, c, ans, l, x, y, z, i, j;
	char s[111];
	
	scanf("%s%d", s, &k);
	l = strlen(s);
	if(k == 1){
		ans = 9 * (l - 1), x = s[0] - 48;
		for(a = 1; a <= 9; a++){
			if(a <= x) ans++;
		}
	}
	else if(k == 2){
		if(l < 2) ans = 0;
		else{
			ans = 9 * 9 * (l - 1) * (l - 2) / 2;
			x = s[0] - 48;
			for(i = 1; i < l && s[i] == 48; i++);
			if(i < l) y = s[i] - 48;
			for(a = 1; a <= x; a++){
				for(b = 1; b <= 9; b++){
					if(a < x) ans += l - 1;
					else if(i < l){
						if(b <= y) ans += l - i;
						else ans += l - i - 1;
					}
				}
			}
		}
	}
	else{
		if(l < 3) ans = 0;
		else{
			ans = 9 * 9 * 9 * (l - 1) * (l - 2) * (l - 3) / 6;
			x = s[0] - 48;
			for(i = 1; i < l && s[i] == 48; i++);
			if(i < l) y = s[i] - 48;
			for(j = i + 1; j < l && s[j] == 48; j++);
			if(j < l) z = s[j] - 48;
			for(a = 1; a <= x; a++){
				for(b = 1; b <= 9; b++){
					for(c = 1; c <= 9; c++){
						if(a < x) ans += (l - 1) * (l - 2) / 2;
						else if(i < l){
							if(i + 1 == l) continue;
							ans += (l - i - 1) * (l - i - 2) / 2;
							if(b < y) ans += l - i - 1;
							else if(b == y && j < l){
								if(c <= z) ans += l - j;
								else ans += l - j - 1;
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n", ans);	
			
	return 0;
}

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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORALL(i, n) for(int i = 0; i < n; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string a, b, c, s[3];
	cin >> s[0] >> s[1] >> s[2];
	sort(s, s + 3);

	do {
		a = s[0], b = s[1], c = s[2];
		if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
			cout << "YES" << endl;
			return 0;
		}
	} while(next_permutation(s, s + 3));
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3560
import numpy as np
N = int(input())
kuku_array = np.zeros((9, 9))
for i in range(1,10):
  for j in range(i,10):
    kuku_array[i-1][j-1] = i*j
if np.any(kuku_array == N) == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 12504
N = int(input())
MOD = 10**9 + 7
A = list(map(int, input().split()))

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

def lcm(x, y):
    return x * y // gcd(x, y)

L = 1
for a in A:
    L = lcm(L, a)

L %= MOD
ans = 0
for a in A:
    ans += L * pow(a, MOD - 2, MOD)
print(ans % MOD)


Measured memory_bytes: 4084
s = input()
t = input()

ans = len(s)
for i in range(len(s)):
    if i + len(t) - 1 >= len(s):break
    dif = 0
    for j in range(len(t)):
        if s[i+j] != t[j]:
            dif += 1
    ans = min(ans, dif)

print(ans)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n>>t;
    int arr[n+1];
    rep(i,0,n)cin>>arr[i+1];

    sort(arr+1,arr+n+1);
    ll sum=0;
    if(n>=t)
    {
    rep(i,1,n-t+1)
    {
        sum+=arr[i];
    }

    }
    cout<<sum;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;

	int ans;
	if ( A > B )
	{
		if ( A > C )
		{
			ans = A * 10 + B + C;
		}
		else
		{
			ans = C * 10 + B + A;
		}
	}
	else
	{
		if ( C > B )
		{
			ans = C * 10 + B + A;
		}
		else
		{
			ans = B * 10 + A + C;
		}
	}

	std::cout << ans << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>
 
typedef long long ll ;
 
#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
 
using namespace std;
const int maxn = 1000*100+5 ;
const ll inf = 9223372036854775807 ;
 
 
int main()
{
	migmig ;
	int n ; 
  cin>> n ; 
  int a[n] , m[n] , ans = 0 ; 
  for(int i= 0 ; i < n ; i ++ ) 
  {
cin>>a[i] ; 
    m[i] = 0 ; 
  }
  for(int i = 0 ; i < n ; i ++ ) 
  {
	if(i == 0 ) m[i] = a[i] ; 
    else m[i] = min(m[i-1] , a[i] ) ; 
    if(a[i] <= m[i] ) ans++ ; 
  }
  cout<<ans ; 
}
//////
////////
///////////

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

int main(void)
{
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    list<tuple<int, double>> degree;
    for(size_t i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        degree.push_back(make_tuple(i+1,abs((t-h*0.006)-a)));
    }
    degree.sort([](tuple<int, double> l, tuple<int, double> r) {
        return get<1>(l) < get<1>(r);
    });
    cout << get<0>(degree.front()) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#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() {
  int R; cin >> R;
  if (R < 1200) cout << "ABC" << endl;
  else if (R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  return 0;
}

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

int main() {
    int n;
    bool ok = true;
    cin >> n;
    for(int i = 0; i < n; i++){
        int buf;
        cin >> buf;
        if(buf%2 == 0){
            if(buf%3 != 0 && buf%5 != 0){
                ok = false;
            }
        }
    }
    
    cout << (ok ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
times = 5.times.map{ gets.chomp.to_i }
times_all = times.permutation(5).to_a
results = []

count = 0
times_all.each do |times|
  for i in 0..times.size-1 do
    count += times[i]
    unless i == times.size-1
      until count % 10 == 0 do
        count += 1
      end
    end
  end
  results.push(count)
  count = 0
end

puts results.min


Measured memory_bytes: 1788
N,D = map(int,input().split())
points = []
for i in range(N):
	x = list(map(int,input().split()))
	points.append(x)

ans = 0
for i in range(N-1):
	for j in range(i+1,N):
		dist = 0
		for d in range(D):
			dist += (points[i][d] - points[j][d]) ** 2
		for x in range(1,dist+1):
			if x*x > dist:
				break
			elif x*x == dist:
				ans += 1
				break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, y;
    cin >> n >> y;

    exrep(i, 0, n) {
        exrep(j, 0, n-i) {
            ll k = n - (i+j);
            if(10000*i + 5000*j + 1000*k == y) {
                cout << i << " " << j << " " << k << endl;
                re0;
            }
        }
    }
    
    cout << -1 << " " << -1 << " " << -1 << endl;
    re0;
}

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

template<class T>
struct lazy_segment_tree{
  int n;
  vector<T> dat,lazy;
  T de,le;

  T f(T a,T b){
    return a+b;
  }
  T g(T& a,T b){
    a += b;
  }
  T h(T& a,T b){
    a += b;
  }

  lazy_segment_tree(){}
  lazy_segment_tree(int sz){
    n = 1;
    while(n<=sz)n<<=1;
    de = 0;
    le = 0;
    dat.resize(2*n-1,de);
    lazy.resize(2*n-1,le);
  }
  lazy_segment_tree(vector<T> const& v){
    int sz = v.size();
    n = 1;
    while(n<=sz)n<<=1;
    de = 0;
    le = 0;
    dat.resize(2*n-1,de);
    lazy.resize(2*n-1,le);
    for(int i=0;i<sz;++i){
      dat[i+n-1] = v[i];
    }
    for(int i=n-2;i>=0;--i){
      dat[i] = f(dat[i*2+1],dat[i*2+2]);
    }
  }

  void eval(int k,int l,int r){
    if(lazy[k]!=le){
      g(dat[k],lazy[k]);
      if(r-l>1){
        h(lazy[2*k+1],lazy[k]/2);
        h(lazy[2*k+2],lazy[k]/2);
      }
      lazy[k] = le;
    }
  }

  void update(int a,int b,T x,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    eval(k,l,r);
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
      h(lazy[k],x*(r-l));
      eval(k,l,r);
    }else{
      update(a,b,x,2*k+1,l,(r+l)/2);
      update(a,b,x,2*k+2,(r+l)/2,r);
      dat[k] = f(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(b<=l||r<=a)return de;
    eval(k,l,r);
    if(a<=l&&r<=b)return dat[k];
    T vl = query(a,b,2*k+1,l,(r+l)/2);
    T vr = query(a,b,2*k+2,(r+l)/2,r);
    return f(vl,vr);
  }

  T operator[](int k){
    return query(k,k+1);
  }

};

void RAQ(){

  int n,q;
  cin>>n>>q;
  lazy_segment_tree<int64_t> seg(n);
  while(q--){
    int com;cin>>com;
    if(com){
      int i;cin>>i;i--;
      cout<<(seg[i])<<endl;
    }else{
      int s,t,x;cin>>s>>t>>x;s--;t--;
      seg.update(s,t+1,x);
    }
  }

}

int main(){
  RAQ();
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	int ans = ((n*(n-1))/2) + ((m*(m-1))/2);
	cout<<ans;
}

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

using namespace std;

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

  int K;
  string s;
  cin >> s >> K;
  int sz = s.size();
  set<string> hash;
  for (int k = 1; k <= K; ++k) {
    for (int i = 0; i+k-1 < sz; ++i) {
      hash.insert(s.substr(i, k));
    }
  }
  for (auto &h : hash) {
    K--;
    if (K == 0) {
      cout << h << endl;
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h> 
using namespace std;
     
int gcd3(int a, int b, int c){
    return gcd(gcd(a, b), c);
}
     
int main(){int a, b, c;
    int K;
    scanf("%d", &K);
    
    int sum = 0;
    for(a = 1; a <= K; a++){
        for(b = 1; b <= K; b++){
            for(c = 1; c <= K; c++){
                sum += gcd3(a, b, c);
            }
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3688