akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);
 
const int MAX_N=1e5;
 
 
int main(){
    string S;
    cin>>S;
    bool f=1;
    REP(i,SZ(S)/2){
        if(S[i]!=S[SZ(S)-1-i])f=0;
    }
    if(f){
        cout<<0<<endl;
        return 0;
    }
    string S2="";
    REP(i,SZ(S)){
        if(S[i]!='x'){
            S2+=S[i];
        }
    }
    int N=SZ(S2);
    f=1;
    REP(i,N/2){
        if(S2[i]!=S2[N-1-i])f=0;
    }
    if(!f){
        cout<<-1<<endl;
        return 0;
    }
    
    int cnt=0;
    int  pos1=0,pos2=0;
    if(N%2==0){
        REP(i,SZ(S)){
            if(S[i]!='x'){
                cnt++;
                if(cnt==N/2){
                    pos1=i;
                }else if(cnt==N/2+1){
                    pos2=i+1;
                }
            }
        }
    }else{
        REP(i,SZ(S)){
            if(S[i]!='x'){
                cnt++;
                if(cnt==N/2+1){
                    pos1=i;
                    pos2=i+1;
                }
            }
        }
    }
    string str1="",str2="";
    str1=S.substr(0,pos1);
    str2=S.substr(pos2);
    reverse(str2.begin(),str2.end());
    //cout<<str1<<endl;
    //cout<<str2<<endl;
    int res=0;
    pos1=0;pos2=0;
    while(pos1<SZ(str1)&&pos2<SZ(str2)){
        if(str1[pos1]!=str2[pos2]){
            res++;
            if(str1[pos1]=='x'){
                pos1++;
            }else{
                pos2++;
            }
        }else{
            pos1++;pos2++;
        }
    }
    //cout<<res<<" "<<pos1<<" "<<pos2<<endl;
    cout<<res+(SZ(str1)-pos1)+(SZ(str2)-pos2)<<endl;
    return 0;
    return 0;
}

Measured memory_bytes: 640
a, b, r = gets.split(" ").map(&:to_f)
radian = r * Math::PI / 180.0
c = Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(radian))
puts "%.5f"%(0.5 * a * b * Math.sin(radian))
puts "%.5f"%(a + b + c)
puts "%.5f"%(b * Math.sin(radian))

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  int d;
  d = a+b+c;
  
  if (d%2 == 0 && a==d/2 || 
      d%2 == 0 && b==d/2 || 
      d%2 == 0 && c ==d/2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0;i < N;++i) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int i = 1;i < N;++i) {
		S[0] += S[i];
	}
	cout << S[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=110;
char s[N];int n;
bool check(int l,int r)
{
	for(int i=1;i<=(r-l+1)/2;i++)
		if(s[i+l-1]!=s[r-i+1])return false;
	return true;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	if(check(1,n)&&check(1,(n-1)/2)&&check((n+3)/2,n))puts("Yes");
	else puts("No");
	return 0;
}


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

int main(void){
  int n, x;
  std::cin >> n >> x;

  std::vector<int> v;
  for(int i=1; i<=2*n-1; i++){
    v.push_back(i);
  }


  if(x<2 || 2*n-2<x){
    std::cout << "No" << std::endl;
  }else{
    std::cout << "Yes" << std::endl;
    int slide = n-x;
    for(int i=0; i<2*n-1; i++){
      std::cout << v[(i+2*n-1-slide)%(2*n-1)] << std::endl;
    }
  }
  
  return 0;
}

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

int main()
{
  int a[1000005], i;
  
  for (i = 0; i < 5; i++)
  {
    cin >> a[i];
    if (a[i] == 0)
    {
      cout << i+1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int a[100005];
 
int main(){
    int n,i;cin>>n;
    for(i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+n+1,greater<int>());
    for(i=1;i<=n;++i){
        if(a[i+1]<i+1 && a[i]>=i){
            int j=0;
            while(a[j+i+1]==i) j++;
            if((a[i]-i)%2==0 && j%2==0) puts("Second");
            else puts("First");
        }
    }
}

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


void solve(long long T, long long X){
    cout << fixed;
    cout << setprecision(10);
    cout << ((double)T / (double)X) << endl;
}

int main(){
    long long T;
    scanf("%lld",&T);
    long long X;
    scanf("%lld",&X);
    solve(T, X);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    long ans=0;
    //bool ans=false;
    int N,K;
    
    cin>>N>>K;
    
    vector<long> H;
    for(int i=0;i<N;i++){
        long a;
        cin>>a;
        H.push_back(a);
    }

    sort(H.begin(),H.end(),std::greater<long>());

    for(int i=K;i<N;i++){
        ans+=H[i];
    }

    cout<<ans<<endl;

   /* if(ans){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
*/
    return 0;
}

Measured memory_bytes: 2420
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# 2個ある要素を1つだけ選び，他を2要素より外側から
# 取るときだけ重複する

# nCk
## 0!~n!をmodしつつ求める
def fact_all(n,M=mod):
    f = [1]*(n+1)
    ans = 1
    for i in range(1,n+1):
        ans = (ans*i)%M
        f[i] = ans
    return f

## inv(0!)~inv(n!)をmodしつつ求める
def fact_inv_all(fact_all,M=mod):
    N = len(fact_all)
    finv = [0]*N
    finv[-1] = pow(fact_all[-1],M-2,M)
    for i in range(N-1)[::-1]:
        finv[i] = finv[i+1]*(i+1)%M
    return finv

## nCkをmodしつつ返す
def nCk(n,k,fact_list,inv_list,M=mod):
    return (((fact_list[n]*inv_list[k])%M)*inv_list[n-k])%M

n = I()
a = LI()

place = [-1]*(n+1)
for i in range(n+1):
    if place[a[i]] != -1:
        p1 = place[a[i]]
        p2 = i
        break
    else:
        place[a[i]] = i

fl = fact_all(n+1)
il = fact_inv_all(fl)

for i in range(1,n+2):
    ans = nCk(n+1,i,fl,il)
    if p1+n-p2 >= i-1:
        ans -= nCk(p1+n-p2,i-1,fl,il)
        ans %= mod
    print(ans)

Measured memory_bytes: 57452
n = int(input())
L = []
for i in range(n):
  x, l = map(int, input().split())
  L.append([x-l,x+l])
L.sort(key=lambda x: x[1])
ans = 1
a = L[0][1]
for i in range(1,n):
  if a <= L[i][0]:
    ans += 1
    a = L[i][1]
print(ans)

Measured memory_bytes: 64728
#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	int nl[12];
	int freq[12];
	int flag[12][12];
	int homura;
	int zannen;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &nl[i]);
		}
		
		homura = 0;
		
		while (1) {
			
			zannen = 0;
			
			for (i = 0; i < 12; i++){
				for (j = 0; j < 12; j++){
					flag[i][j] = 0;
				}
				freq[i] = 1;
			}
		
			for (i = 0; i < n; i++){
				for(j = n - 1; j >= 0; j--){
					 if (i != j && nl[i] == nl[j]){
					 	if (flag[j][i] == 0){
					 		freq[i]++;
							freq[j]++;
							flag[i][j] = 1;
					 	}
					 }
				}
			}
			
			for (i = 0; i < n; i++){
				if (freq[i] == 0){
					freq[i] = 1;
				}
			}
			
			for (i = 0; i < n; i++){
				if (nl[i] != freq[i]){
					zannen = 1;
					break;
				}
			}
			
			if (zannen == 0){
				break;
			}
			
			else {
				homura++;
				for (i = 0; i < n; i++){
					nl[i] = freq[i];
				}
			}
		}
		
		printf("%d\n", homura);
		
		for(i = 0; i < n; i++){
			if (i != 0){
				printf(" ");
			}
			printf("%d",nl[i]);
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 0
#include"stdio.h"
#include"stdlib.h"
int main()
{
    long long k,i=100,j=0;
    scanf("%lld",&k);
    while(i<k)
    {
        i=i+i/100;
        j++;
        //printf("1\n");
    }
    printf("%d",j);


    return 0;
}


Measured memory_bytes: 1736
#include<stdio.h>
#include<string.h>
#define N 20
#define ll long long
int n,q,m,a[N];
int rec(int i,int sum){
  if(sum == m)return 1;
  if(i >= n)return 0;
  return rec( i+1, sum) || rec( i+1, sum + a[i]);
}
int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&a[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++) {
    scanf("%d",&m);
    if( rec(0,0) )printf("yes\n");
    else printf("no\n");
  }

  return 0;
}


Measured memory_bytes: 2108
import functools
import math

K = int(input())

def gcd_2(*vals):
    return functools.reduce(math.gcd, vals)

ans=0
for x in range(1,K+1):
    for y in range(1,K+1):
        for z in range(1,K+1):
            ans += gcd_2(x,y,z)

print(ans)


Measured memory_bytes: 69524
n=[]
line=''
while line != [0,0]:
    line=list(map(int,input().split()))
    n.append(line)
for i in range(len(n)-1):
    print('%d %d'%(n[i][0] if n[i][0]<=n[i][1] else n[i][1],n[i][0] if n[i][0]>=n[i][1] else n[i][1]))

Measured memory_bytes: 8192
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    l = i_list()
    dic = {}
    for i in l:
        dic[i] = dic.get(i,0) + 1
    t = 0
    for i,k in dic.items():
        t += k-1
    if t%2==0:
        print(len(dic))
    else:
        print(len(dic)-1)


if __name__=="__main__":
    main()


Measured memory_bytes: 21968
function Main(input) {
  input = input.split("\n");
  var h = parseInt(input[0].split(" ")[0]);
  var w = parseInt(input[0].split(" ")[1]);
  var n = parseInt(input[1]);
  tmp = input[2].split(" ");
  a=new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
  }
  var ans ="";
  d = new Array();
  for(i=0;i<n;i++){
    for(j=0;j<a[i];j++){
      d.push(i+1);
    }
  }
  for(i=0;i<h;i++){
    if(i%2!=1){
      for(j=0;j<w;j++){
        if(j%w!=w-1){
        ans+=d[i*w+j]+" ";
        }else{
        ans+=d[i*w+j]+"\n";
        }
      }
    }else{
      for(j=0;j<w;j++){
        if(j%w!=w-1){
        ans+=d[(i+1)*w-j-1]+" ";
        }else{
          ans+=d[(i+1)*w-j-1]+"\n";
        }
      }
    }
  }
  ans=ans.substr(0,ans.length-1);
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3592
n = gets.to_i
array = gets.split.map(&:to_i)

max = array.max
half = max / 2
gap = Float::INFINITY
b = 0
array.each do |e|
  if (half - e).abs < gap && max != e
    b = e
    gap = (half - e).abs
  end
end

puts [max, b].join(' ')


Measured memory_bytes: 8452
#include <stdio.h>

int main(void)
{
	int x,y,a[3000],b[3000],i,j;
	
	x = y = 1;
	i = 0;
	
	while(x+y != 0){
		scanf("%d %d",&x,&y);
		if(x < y){
			a[i] = x;
			b[i] = y;
		}
		else if(x > y){
			a[i] = y;
			b[i] = x;
		}
		else if(x == y){
			a[i] = x;
			b[i] = y;
		}
		else if(x == 0 && y == 0)break;
		++i;
	}
	for(j = 0;j < i-1;++j){
		printf("%d %d\n",a[j],b[j]);
	}
	
	return(0);
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    int x = X-A;
    cout << x-(B*(x/B)) << endl;
    return 0;
}


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

int main() {
  long n, a, b;
  cin >> n >> a >> b;
  long ans = 0;
  
  long t = a + b;
  
  if (n % t <= a){
    cout << ((n / t) * a) + (n % t) << endl;
  }
  else{
    cout << ((n / t) * a) + a << endl;
  }
}
  



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll cnt[10][10]={};
	int n;
	cin>>n;
	for(int i=1; i<=n; i++){
		if(i%10==0) continue;
		vector<int> v;
		int x=i;
		while(x){
			v.push_back(x%10);
			x/=10;
		}
		cnt[v.back()][v[0]]++;
	}
	ll ans=0;
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			ans+=cnt[i][j]*cnt[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N, K = Scanner.map_int()
    A = Scanner.map_int()
    A = [a - 1 for a in A]
    X = 1
    visited = [0 for _ in range(N)]
    p = 0
    while visited[p] == 0:
        visited[p] = X
        X += 1
        p = A[p]
        if X - 1 == K:
            print(p + 1)
            return
    Y = (visited[p] - 1)
    Z = X - Y - 1
    t = (K - Y) // Z
    K -= t * Z
    print(visited.index(K + 1) + 1)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 34744
<?php
	$n = trim(fgets(STDIN));
	$p = array(0, 0);
	for ($i = 0; $i < $n; $i++) {
		$card = explode(" ", trim(fgets(STDIN)));
		if ($card[0] > $card[1]) $p[0] += 3;
		elseif ($card[0] < $card[1]) $p[1] += 3;
		else {
			$p[0]++;
			$p[1]++;
		}
	}
	echo $p[0] . " " . $p[1] . "\n";

Measured memory_bytes: 6588
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    cout << ((n + 1) / 2) - 1 << endl;





}

Measured memory_bytes: 256
N,D = map(int,input().split())
nums = []
for i in range(N):
    nums.append(list(map(int,input().split())))
count = 0
for j in range(len(nums)):
    for k in range(len(nums)):
        ans = 0
        if j==k:
            continue
        for (x,y) in zip(nums[j],nums[k]):
            ans+=abs(x-y)**2
        ans = ans**(1/2)
        if int(ans)==ans:
            count+=1
print(count//2)

Measured memory_bytes: 3188
#042_C
n, k = map(int, input().split())
d = set(map(int, input().split()))
d_ = list({i for i in range(0, 10)} - d)
inf = 10 ** 7

def dfs(frm, cur):
    if frm == cur == 0:
        return inf
    if cur >= n:
        return cur
    
    x = 10 ** 7
    for k in d_:
        x = min(x, dfs(cur, cur * 10 + k))
        
    return x

print(dfs(-1, 0))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {

  int a_enter_h,a_enter_m,a_enter_s,a_leave_h,a_leave_m,a_leave_s;
  int b_enter_h,b_enter_m,b_enter_s,b_leave_h,b_leave_m,b_leave_s;
  int c_enter_h,c_enter_m,c_enter_s,c_leave_h,c_leave_m,c_leave_s;

  int a,b,c;

  int a_h,a_m,a_s;
  int b_h,b_m,b_s;
  int c_h,c_m,c_s;

  cin >> a_enter_h; cin >> a_enter_m; cin >> a_enter_s; cin >> a_leave_h; cin >> a_leave_m; cin >> a_leave_s;
  cin >> b_enter_h; cin >> b_enter_m; cin >> b_enter_s; cin >> b_leave_h; cin >> b_leave_m; cin >> b_leave_s;
  cin >> c_enter_h; cin >> c_enter_m; cin >> c_enter_s; cin >> c_leave_h; cin >> c_leave_m; cin >> c_leave_s;

  a=(3600*a_leave_h+60*a_leave_m+a_leave_s)-(3600*a_enter_h+60*a_enter_m+a_enter_s);
  b=(3600*b_leave_h+60*b_leave_m+b_leave_s)-(3600*b_enter_h+60*b_enter_m+b_enter_s);
  c=(3600*c_leave_h+60*c_leave_m+c_leave_s)-(3600*c_enter_h+60*c_enter_m+c_enter_s);

  a_h=a/3600;
  a_m=(a%3600)/60;
  a_s=a%60;

  b_h=b/3600;
  b_m=(b%3600)/60;
  b_s=b%60;

  c_h=c/3600;
  c_m=(c%3600)/60;
  c_s=c%60;

  cout << a_h << " " << a_m << " " << a_s << endl;
  cout << b_h << " " << b_m << " " << b_s << endl;
  cout << c_h << " " << c_m << " " << c_s << endl;

  return 0;

}

Measured memory_bytes: 0
import scala.math.{abs, max, min}

object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, d = sc.nextInt

    if (b < c || d < a) {
      println(0)
    } else {
      println(abs(max(a, c) - min(b, d)))
    }
  }
}


Measured memory_bytes: 27312
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        string str = to_string(i);
        if (str.size() % 2 == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000000ll
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll x,k,d;
    cin>>x>>k>>d;

    x = abs(x);
    ll ans;
    if(x/d - k >=0){
        cout<<abs(x - k*d)<<endl;
        return 0;
    }else{
        ans = x - (x/d)*d;
        if((k - (x/d))%2 != 0){
            ans = abs(ans - d);
            cout<<ans<<endl;
            return 0;
        }else{
            cout<<ans<<endl;
            return 0;
        }
    }

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  string s;
  bool ans = true;
  cin >> s;
  if(s.at(2)!=s.at(3)) ans=false;
  if(s.at(4)!=s.at(5)) ans=false;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    string s;
    cin>>s;
    lli ans = 0,count = 0;;
    rep(i,0,3)
    {
        if(s[i] == 'R')
        {
            count++;
        }
        else
        {
            ans = max(ans,count);
            count = 0;
        }
    }
    ans = max(ans,count);
    cout<<ans;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

Measured memory_bytes: 3648
type SortDataType=Longint;
function SortCmp(const x,y:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
var
	N,i,j,k:Longint;
	A:Array[1..2000]of int64;
	id:Array[1..2000]of Longint;
	dp:Array[1..2001,1..2001]of int64;
	ans:int64;
function SortCmp(const x,y:SortDataType):Boolean;
begin
	SortCmp:=A[x]>A[y];
end;
procedure chmax(var a:int64;b:int64);
begin
	if a<b then a:=b;
end;
begin
	read(N);
	for i:=1 to N do begin
		id[i]:=i;
		read(A[i]);
	end;
	Sort(id,N);
	for i:=1 to N do for j:=1 to i do begin
		k:=N+1-(i-j);
		chmax(dp[j+1,k],dp[j,k]+A[id[i]]*abs(id[i]-j));
		chmax(dp[j,k-1],dp[j,k]+A[id[i]]*abs(id[i]-(k-1)));
	end;
	for i:=1 to N+1 do chmax(ans,dp[i,i]);
	writeln(ans);
end.


Measured memory_bytes: 22884
#include <stdio.h>

int main()
{
    long long int a;
    int b;
    scanf("%lld%d", &a, &b);
    long long int avr, total;
    total = a + b;
    avr = total/2;

    if(total%2 == 1) {
        printf("%lld\n", avr + 1);
    }
    else {
        printf("%lld\n", avr);
    }

    return 0;
}


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

const int N = 1010;

char s[N], t[N];

int main(){
    scanf("%s%s", s, t);
    int n = strlen(s), m = strlen(t);
    int ans = INT_MAX;
    for (int i = 0; i <= n - m; ++ i){
        int cnt = 0;
        for (int j = i; j < i + m; ++ j){
            cnt += s[j] != t[j - i];
        }
        ans = std::min(ans, cnt);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin >> n;
  int h[n];
  pair<int,int> p[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
    p[i]=make_pair(h[i],i);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    ans+=h[p[i].second];
    for(int j=p[i].second-1;j>=0;j--){
      if(h[j]==0){
        break;
      }
      h[j]-=h[p[i].second];
    }
    for(int j=p[i].second+1;j<n;j++){
      if(h[j]==0){
        break;
      }
      h[j]-=h[p[i].second];
    }
    h[p[i].second]=0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        Scanner  sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans=0,te=0;
        TreeMap<String,Integer> ts=new TreeMap<>();
        while(t-->0)
        {
            int n=sc.nextInt();
            for(int i=0;i<n;i++)
            ts.merge(sc.next(),1,Integer::sum);
        }
        int max=Collections.max(ts.values());
        for(String s:ts.keySet())
        {
            if(ts.get(s)==max) pw.println(s);
        }
           pw.close();
    }
}
  

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

int solve(int N, int L, int R) {
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    
    int ret;
    int ma = 1;
    for (int i = L-1; i < R; i++) {
        if (ma <= a[i] - a[i+1]) {
            ret = i+1;
            ma = a[i] - a[i+1];
        }   
    }
    return ret;
}

int main(void){
    // Your code here!
    int N, L, R;
    vector<int> ans;
    while (1) {
        cin >> N >> L >> R;
        if (!N && !L && !R) break;
        ans.push_back(solve(N, L, R));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}



Measured memory_bytes: 3096
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple2_first (x, _) = x
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let find_sec a =
  let acc = ListL.fold_left
      (List.combine (0++^ List.length a) a) ~init:[] ~f:(fun pred (i, w) ->
          match pred with
          | [] -> (w, 1, i)::pred
          | (v, n, i) :: rest when v = w -> (v, n+1, i)::rest
          | _ :: _ -> (w,1, i)::pred) in
  try ListL.find acc ~f:(fun (_, n,_) -> n >= 3)
  with Not_found -> (0, 0, 0)

let rec create n=
  if n = 0 then []
  else 0::create (pred n)

let print arr =
  Array.iter (fun v ->
      Printf.printf "%d " v ) arr;
  Printf.printf "\n"

let print_mat mat =
  Array.iter print mat

let () =
  let rec solve ()=
    let n = scan "%d" id in
    if n = 0 then ()
    else
      let mat = scan_matrix n 5 0 int_of_string in
      ListL.map (0 ++ (succ n)) ~f:(fun _ ->
          let v = ArrayL.mapi mat ~f:(fun i a ->
              let l = Array.to_list a in
              let (w, n, k) = find_sec l in
              if w > 0 then
                ListL.map (0 ++^ n) ~f:(fun j ->
                    mat.(i).(k+j) <- 0;w) |> List.fold_left (+) 0
              else 0) |> Array.fold_left (+) 0 in
          ListL.iter (0++^5) ~f:(fun j ->
              let a =
                let l = ListL.filter
                    (ListL.map (0 ++^ n) ~f:(fun i -> mat.(i).(j))) ~f:((<>) 0) in
                create (n - List.length l) @ l
                |> Array.of_list in
              ListL.iter (0 ++^ n) ~f:(fun i ->
                  mat.(i).(j) <- a.(i)));
          v)
      |> List.fold_left (+) 0
      |> Printf.printf "%d\n";
      solve () in
  solve ()



Measured memory_bytes: 4596
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll N, A;
    cin >> N >> A;
    cout << (N * N - A) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll X,Y;
    cin>>X>>Y;
    ll i=0;
    do{
        i++;
        X*=2;
    }while(Y>=X);
    cout<<i<<endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int N; cin >> N;
  priority_queue <double, vector<double>, greater<double> > que;
  for (int i = 0; i < N; i++){
    double V; cin >> V;
    que.push(V);
  }

  while (!que.empty()){
    double Q1 = que.top(); que.pop();
    double Q2 = que.top(); que.pop();

    que.push((Q1 + Q2) / 2);

    if (que.size() == 1){
      cout << setprecision(16) << que.top() << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
// typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ull d[100010],dp[100][100];
ull x[100010],y[100010];

struct edge{ull to,cost;};
typedef pair<ull,ull> P;
vector<edge> g[100010];

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P> > que;
  fill(d,d+n,INF);
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();que.pop();
    ull v = p.second;
    if(d[v] < p.first)continue;
    rep(i,0,g[v].sz){
      edge e = g[v][i];
      if(d[e.to] > d[v]+e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main(){
  cin >> n;
  rep(i,1,n){
    ull a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    g[a].pb((edge){b,c});
    g[b].pb((edge){a,c});
  }
  cin >> m >> l;
  rep(i,0,m)cin >> x[i] >> y[i];
  dijkstra(l-1);
  rep(i,0,m){
    print(d[x[i]-1]+d[y[i]-1]);
  }
  return 0;
}


Measured memory_bytes: 12784
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  int H, W;
  string S[50];
  cin >> H >> W;
  for( int i=0; i<H; i++ ) cin >> S[i];
  for( int y=0; y<H; y++ ){
    for( int x=0; x<W; x++ ){
      if( S[y][x] == '#' ) continue;
      int n = 0;
      for( int yy=max(0,y-1); yy<min(H,y+2); yy++ ){
        for( int xx=max(0,x-1); xx<min(W,x+2); xx++ ){
          if( S[yy][xx] == '#' ) n++;
        }
      }
      S[y][x] = '0' + n;
    }
  }
  for( int i=0; i<H; i++ ) cout << S[i] << endl;
}

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

bool solve(VI& v) {
    VI vs = v;
    sort(vs.begin(), vs.end());
    if (v == vs) {
        return true;
    }
    REP (i, v.size() - 1) {
        for (int j = i + 1; j < v.size(); ++j) {
            swap(v[i], v[j]);
            if (v == vs) {
                return true;
            }
            swap(v[i], v[j]);
        }
    }
    return false;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    VI v(n);
    REP (i, n) {
        cin >> v[i];
    }
    if (solve(v)) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
/*
	atcoder ARC094
	E Tozan and Gezan
*/
#include <bits/stdc++.h>
typedef long long ll;
const int N = 2e5 + 5;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int n, a[N], b[N];
inline bool equal() {
	for (int i = 1; i <= n; ++i) 
		if (a[i] != b[i]) return false;
	return true;
}

inline ll play() {
	int min = 1000000010;
	ll s0 = 0;
	for (int i = 1; i <= n; ++i) s0 += a[i];
	for (int i = 1; i <= n; ++i)
		if (a[i] > b[i]) down(min, b[i]);
	return s0 - min;
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> n;
    for (int i = 1; i <= n; ++i) std::cin >> a[i] >> b[i];
    if (equal()) return std::cout << 0 << '\n', 0;
    std::cout << play() << '\n';
	return 0;
}


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

int main(void){
    
    unsigned long H,W;
    cin >> H >> W;
    
    if(H%2 == 1 && W%2 == 1){
        if(H == 1 || W == 1){
            cout << 1 << endl;
        }
        else{
            cout<< H*W/2 + 1 <<endl;
        }
        
    }
    else{
        if(H == 1 || W == 1){
            cout << 1 << endl;
        }
        else{
            cout<< H*W/2 <<endl;
        }
        
    }
   
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define MP make_pair
#define PB emplace_back
#define all(x) (x).begin(), (x).end()
#define tc(t) int t;cin>>t;while(t--)

const int INF = 1e18L;
const double eps = 1e-9;
const int mod = 1e9 + 7;

int32_t main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    IOS;
    int n, k, ans = 0;
    cin >> n >> k;
    for (int i = k; i <= n + 1; i++)
    {
        int mn, mx;
        mn = (i * (i - 1) / 2) % mod;
        mx = ((n * (n + 1) / 2) % mod - ((n - i) * (n - i + 1) / 2) % mod + mod) % mod;
        ans = (ans + mx - mn + 1 + mod) % mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

bool G[10][10];

int main(){
    int n, m; cin >> n >> m;
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a][b] = G[b][a] = true;
    }

    vector<int> ord(n);
    rep(i, n) ord[i] = i;

    int res = 0;
    do{
        if(ord[0] != 0) break;
        bool ok = true;
        for(int i = 0; i + 1 < n; i++){
            int from = ord[i];
            int to = ord[i+1];
            if(!G[from][to]) ok = false;
        }
        if(ok) res++;
    }while(next_permutation(ord.begin(), ord.end()));
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
# まあできるだけ小さい単位で割ったほうが嬉しいので、素因数分解して因数で割ったほうがうれしい
# ただし以前つかったやつは使えないので、x^1, x^2, x^3... に限定されてしまう
# -> 冪数を増やしていく感じでいけそう

n = int(input())


def div_primes(x):
    ret = {}
    for i in range(2, int(x**0.5) + 1):
        tmp = 0
        while x % i == 0:
            tmp += 1
            x /= i
        if tmp > 0:
            ret[i] = tmp

    if x > 1:
        ret[x] = 1
    return ret


primes = div_primes(n)
ans = 0
for k, v in primes.items():
    j = 1
    while v - j >= 0:
        v -= j
        j += 1
        ans += 1
print(ans)

Measured memory_bytes: 9436
////#include <stdio.h>
////long long int n,a,b[100001],c[100001],num[100001]={},d[4001]={};
////	  int i,j,x=0;
////	  int sum=0;
////	   int main(){
////	  while(1){
////	  scanf("%lld",&n);
////	  if(n==0) break;
////	  for(i=0;i<n;i++){
////		  scanf("%lld %lld %lld",&a,&b[i],&c[i]);
////		  d[a] += b[i]*c[i];
////                            num[i]=a;
////	  }
////	  for(i=0;i<n;i++){
////		  if(d[num[i]]>=1000000){
////                                 for(j=1;j<i;j++){
////                                     if(num[j]==num[i]){
////                                             x=1;
////                                              break;
////                                    }} if(x==0){
////			  printf("%lld\n",a);
////			  sum++;
////			}  
////		  }
////	  }
////	  if(sum==0){
////		  printf("NA\n");
////	  }
////	  sum = 0;
////	  for(i=1;i<=4000;i++){
////		  d[i]=0;
////	  }
////	  }
////	  return 0;
////  }
////
//#include <stdio.h>
//int main(void){
//	int n,i,j,x,y,z,f,a[4000];
//	long long t,b[4000];
//	for(;scanf("%d",&n),n;f||puts("NA"))
//		for(f=i=0;n--;){
//			scanf("%d%d%d",&x,&y,&z);
//			t=z;
//			for(j=i;--j>=0&&a[j]-x;);
//			if(j<0){a[j=i]=x;b[i++]=y*t;}
//			else if(b[j]>=0)b[j]+=y*t;
//			if(b[j]>=1000000)
//				b[j]=f=-printf("%d\n",a[j]);
//		}
//		return 0;
//}
#include <stdio.h>
int main(){
	int n, m,i;
	long long int x,y,z;
	long long int sum[4001];
	int q, a[4000];
	while(1){
		scanf("%d ", &n);
		if(n==0) break; 
		m=0;
		q=0;
		for(i=1;i<4001;i++){
			sum[i]=0;
		}
		while(n--){
			scanf("%lld %lld %lld ", &x, &y, &z);
			sum[x] += y *z;
			a[q] = x;
			q++;
		}        
		for(i=0;i<q;i++)
			if(1000000 <= sum[a[i]]){
				printf("%d\n", a[i]);
				m = 1;
				sum[a[i]] = 0;
			}
			if(m==0) printf("NA\n");
	}
	return 0;
} 

Measured memory_bytes: 656
#include<iostream>

using namespace std;

int main()
{
  int a,b,c;
  int count=0;
  cin>>a>>b>>c;
  if(a==b)
    count++;
  if(b==c)
    count++;
  if(c==a)
    count++;
  if(count==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
    

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

int main(){
  int n,m;
  cin >> n;
  vector<string> blue(n);
  rep(i,n) cin >> blue.at(i);
  cin >> m;
  vector<string> red(m);
  rep(i,m) cin >> red.at(i);
  
  int max = -1000;
  int score;
  rep(i,n){
    score = 0;
    rep(j,n){
      if(blue.at(i) == blue.at(j)) score++;
    }
    rep(j,m){
      if(blue.at(i) == red.at(j)) score--;
    }
    if(score > max) max = score;
  }
  rep(i,m){
    score = 0;
    rep(j,n){
      if(red.at(i) == blue.at(j)) score++;
    }
    rep(j,m){
      if(red.at(i) == red.at(j)) score--;
    }
    if(score > max) max = score;
  }
  if (max < 0) max = 0; 
  cout << max << endl;
}

Measured memory_bytes: 256
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,k=IL()
c=[1]
for i in range(2,min(a,b)+1):
    if a%i==0 and b%i==0:
        c.append(i)
print(c[-k])

Measured memory_bytes: 3060