akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    int pre = 0;
    bool f = false;
    for(int i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            int tmp = 1;
            s[i] = 'B';
            s[i + 1] = 'C';
            s[i + 2] = 'A';
            if(!f){
                for(int j = i - 1; j >= 0; j--){
                    if(s[j] != 'A') break;
                    else{
                        tmp++;
                        s[j] = 'B';
                        s[j + 1] = 'C';
                        s[j + 2] = 'A';
                    }
                }
                ans += tmp;
                pre = tmp;
            }else{
                ans += pre;
            }
            f = true;
            i++;
        }else{
            if(f){
                if(s[i] == 'A') pre++;
                else{
                    f = false; pre = 0;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll N,M,a,b;
  cin>>N>>M;
  rep(i,M){
    cin>>a>>b;
    graph[a-1][b-1]=true;
    graph[b-1][a-1]=true;
  }
  bool visited[8];
  for(ll i=0;i<=N;i++){
    visited[i]=false;
  }
  visited[0]=true;
  ll Z=0;
  cout<<dfs(Z,N,visited)<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	v := []int{
		1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51,
	}
	K := ReadInt()
	fmt.Println(v[K-1])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF = 1000000007;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  int n;
  string s;
  cin>>n>>s;
  if(n % 2 != 0){
    cout<<"No"<<endl;
    return 0;
  }
  string a = s.substr(0,(n / 2));
  string b = s.substr(n/2,(n / 2));
  if(a==b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
    int n, m = 1;
    cin >> n;
    for(int i = 1; i < n; ++i) {
        if(n <= i+1 + i*(i+1)/2) {
            m = i+1;
            break;
        }
    }
    int i = m-1;
    while(i+1) {
        cout << m << '\n';
        n -= m;
        while(!(n-i >= 0)) {
            i--;
        }
        m = i;
        i--;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

bool isPrime(ll n) {
  if(n == 1)return false;
  for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

// TODO: write
int main() {
  int q;cin>>q;
  vector<int> isOk(1e5+100,-1);
  
  vector<int> a(1e5+100,0);
  for(int i = 2;i <= (1e5+100);++i){
    a[i] = a[i-1];

    isOk[i] = isPrime(i);
    int tmp = (i+1)/2;
    if(isOk[i]){
      if(isOk[tmp] == -1){
        isOk[tmp] = isPrime(tmp);
      }
      if(isOk[tmp]){
        a[i]++;
      }
    }
  }
  
  rep(i,q){
    int l,r;cin>>l>>r;
    print(a[r]-a[l-1]);
  }

  return 0;
}


Measured memory_bytes: 1408
from collections import defaultdict
import bisect
n,m = map(int,input().split())
s = list(map(int,input().split()))
t = list(map(int,input().split()))
mod = 10**9+7
p = max(n,m)
if n>m:
  t.extend((0,)*(n-m))
else:
  s.extend((0,)*(m-n))
dp = [[1 for i in range(p+1)] for j in range(p+1)]
for i in range(1,p+1):
  for j in range(1,p+1):
    x = s[i-1]
    y = t[j-1]
    if x == y:
      dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod
    else:
      dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%mod
print(dp[-1][-1])

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

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

 const int nmmax=50;
 char A[nmmax][nmmax],B[nmmax][nmmax];


 for(int y=0;y<N;++y){
 for(int x=0;x<N;++x){
 cin >> A[y][x];
 }
 }

 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 cin >> B[y][x];
 }
 }

 bool exist=false;

 for(int ly=0;ly<N;++ly){
 for(int lx=0;lx<N;++lx){
 if(ly+M-1>=N or lx+M-1>=N) continue;

 bool match=true;
 for(int y=0;y<M;++y){
 for(int x=0;x<M;++x){
 if(A[ly+y][lx+x]!=B[y][x]) match=false;
 }
 }
 if(match) exist=true;
 }
 }

 if(exist)
 cout << "Yes" << endl;
 else
 cout << "No" << endl;

 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
using ll = long long;
using ld = long double;

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

    int result = 0;
    for ( int i = 0; i < 4; ++i )
    {
        switch ( S[ i ] )
        {
            case '+': ++result; break;
            case '-': --result; break;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#include<complex>
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s,ans;
		cin >> s;
		ans = s[0];
		for (int j = 1; j < s.length(); j++) {
			if (isalpha(s[j])) {
				if (find(ans.begin(), ans.end(), s[j]) != ans.end())continue;

				if (s[j - 2] == '-'&&s[j - 1] == '>') {
					ans += s[j];
				}
				else if (s[j - 2] == '<'&&s[j - 1] == '-') {
					ans = s[j] + ans;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int H, W;
vector<vector<int>> c(10, vector<int>(10));
vector<vector<int>> a(200, vector<int>(200));




int main() {
	cin >> H >> W;
	for(int i=0; i<10; i++){
		for(int j=0; j<10; j++){
			cin >> c.at(i).at(j);
		}
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> a.at(i).at(j);
		}
	}
	for(int x=0; x<10; x++){
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(x)+c.at(x).at(j));
			}
		}
	}
	long long sum=0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(a.at(i).at(j) == -1){
				continue;
			}else{
				sum += c.at(a.at(i).at(j)).at(1);
			}
		}
	}
	cout << sum << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using ld = long double;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

int main(void){
	int64 A, B, C;
	cin >> A >> B >> C;
	cout << A*B/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define MOD 998244353
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

int main() {

    int n;cin >> n;
    map<int, int> s;
    int max_d = 0;
    rep(i,n){
        int d; cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << endl;
            return 0;
        } else if (i != 0 && d == 0) {
            cout << 0 << endl;
            return 0;
        }
        max_d = max(max_d, d);
        s[d]++;
    }

    ll ans = 1;
    for (int i=1; i<max_d; i++) {
        if (s[i+1] == 0) {
            cout << 0 << endl;
            return 0;
        }
        rep(j, s[i+1]) {
            ans *= s[i];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		String t=sc.nextLine();
		int n=s.length();
		int m=t.length();
		int dp[][]=new int[n+1][m+1];
		for(int i=0;i<=n;i++ ){
		    for(int  j=0;j<=m;j++){
		        if(i==0||j==0)
		        dp[i][j]=0;
		       else if(s.charAt(i-1)==t.charAt(j-1))
		        dp[i][j]=dp[i-1][j-1]+1;
		        else
		        dp[i][j]=Math.max(dp[i-1][j],dp[i][j-1]);
		       //  System.out.print(dp[i][j]+" ");
		    }
		  //   System.out.println(" ");
		}
		    int idx=dp[n][m];
		    int  t1=idx;
		   // System.out.println(t1);
		    char lcs[]=new char[idx+1];
		    lcs[idx]=' ';
		    int  i=n;
		    
		    int j=m;
		    while(i>0&&j>0){
		        if(s.charAt(i-1)==t.charAt(j-1)){
		             lcs[idx-1]=s.charAt(i-1);
		            i--;
		            j--;
		            idx--;
		           
		            
		        }
		        else if(dp[i-1][j]>dp[i][j-1])
		        i--;
		        else
		        j--;
		    }
		    for(int k=0;k<=t1;k++){
		        System.out.print(lcs[k]);
		    }
		
	}
}


Measured memory_bytes: 81220
using System;
using System.Linq;
class c
{
    static void Main()
    {
        Console.ReadLine();
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int odd = a.Count(f => f % 2 == 1);
        Console.WriteLine(odd % 2 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 20576
N,K = map(int,input().split())
A = list(map(int,input().split()))

if N == K:
    print(1)
    exit()
index = A.index(1)
left = index
right = N - index - 1
count = 0
tmp = left % (K-1)
count += (left//(K-1)) + (tmp > 0)
if tmp > 0:
    right -= K - 1 - tmp 
count += (right//(K-1)) + (right%(K-1) > 0)

print(count)

Measured memory_bytes: 14008
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::Write;

fn calc(l: usize, r: usize, v: usize, mut ans: &mut Vec<Vec<usize>>) {
    if l == r {
        return;
    }
    let m = (l + r) / 2;
    for i in l..(m + 1) {
        for j in (m + 1)..(r + 1) {
            ans[i][j] = v;
        }
    }
    calc(l, m, v + 1, &mut ans);
    calc(m + 1, r, v + 1, &mut ans);
}

fn run() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    input! {
        n: usize,
    }
    let mut ans = vec![vec![0; n + 1]; n + 1];
    calc(1, n, 1, &mut ans);
    for i in 1..n {
        for j in (i + 1)..(n + 1) {
            if j > i + 1 {
                write!(out, " ").unwrap();
            }
            write!(out, "{}", ans[i][j]).unwrap();
        }
        writeln!(out, "").unwrap();
    }
}

fn main() {
    run();
}


Measured memory_bytes: 6652
n, y = map(int, input().split())
result = 0

for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        z = 10000*i + 5000*j + 1000*k
        if z == y and k >= 0:
            result += 1
            print(i, j, k)
            exit()

if result == 0:
    print('-1 -1 -1')

Measured memory_bytes: 3060
const main = (input) => {
  input = input.split('\n');
  const HW = input[0].split(' ');
  const hw = input[1].split(' ');
  console.log(HW[0]*HW[1] - hw[0]*HW[1] - HW[0]*hw[1] + hw[0]*hw[1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
n = int(input())
 
sum = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            sum += gcd(i,j,k)
 
print(sum)

Measured memory_bytes: 69772
let k = cin.n
var (a,b) = cin.pair

while(a <= b) {
  if a%k == 0 {
    print("OK")
    a = 9999
    break
  }
  a += 1
}

if a != 9999 {
  print("NG")
}

import Foundation
#if os(Linux)
    import Glibc
#else
    import Darwin.C
#endif

enum cin {
    // 123
    static var n: Int { Int(readLine()!)! }
    // 12 23
    static var pair: (Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!) }
    // 12 23 34
    static var triple: (Int, Int, Int) { let line = readLine()!.components(separatedBy: " "); return (Int(line[0])!, Int(line[1])!, Int(line[2])!) }
    // AtCoder
    static var line: String { readLine()! }
    // At Coder
    static var arrayStr: [String] { line.components(separatedBy: " ") }
    // 1 2 3 4
    static var array: [Int] { line.components(separatedBy: " ").map { Int($0)! } }
    // 1
    // 2
    // 3
    static func v_array(count: Int) -> [Int] { (0..<count).map { _ in n } }
}

extension Int {
    // 123 -> [1, 2, 3]
    var digits: [Int] { Array(String(self)).map { Int(String($0))! } }
}

extension Array where Element == Int {
    // [2, 1, 3, 2] -> 8
    var sum: Int { self.reduce(0, +) }
    // [2, 1, 3, 2] -> [1, 2, 2, 3]
    var orderBy: [Int] { sorted() }
    // [2, 1, 3, 2] -> [3, 2, 2, 1]
    var orderByDesc: [Int] { sorted(by: { $0 > $1 }) }
    // [2, 1, 3, 2] -> [2, 1, 3]
    var distinct: [Int] { Array(Set(self)) }
}

extension String {
    // e.g. cin.line.regex(match: "^(dream|dreamer|erase|eraser)*$")
    func regex(match pattern: String) -> Bool {
        let regex = try! NSRegularExpression(pattern: pattern)
        return regex.firstMatch(in: self, range: NSRange(location: 0, length: self.count)) != nil
    }
    // "ABC"[1] -> "B"
    subscript(i: Int) -> Character {
        get {
            self[index(at: i)]
        }
        set(char) {
            var characters = Array(self)
            characters[i] = char
            self = String(characters)
        }
    }
    func index(at offset: Int) -> String.Index { index(startIndex, offsetBy: offset) }
    // "ABC".swapAt(0, 1) -> "BAC"
    mutating func swapAt(_ index1: Int, _ index2: Int) {
        var characters = Array(self)
        characters.swapAt(index1, index2)
        self = String(characters)
    }
}

Measured memory_bytes: 14108
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cmath>
#include <functional>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	cout << A * B << " " <<  (A + B) * 2 << endl;
	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if( min(b,d) >= max(a,c) ){
        printf("%d\n",min(b,d) - max(a,c));
    }else{
        puts("0");
    }
    return 0;
}


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

int main()
{
  ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  
  if((a[0] == a[1] && a[0] != a[2]) || (a[1] == a[2] && a[0] != a[1]))
    cout << "Yes\n";
  else
    cout << "No\n";
    
  
  return 0;
}

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

typedef struct pp{
    char name[100];
    int time;
}P;

int head, tail;
P Q[LEN];

/*
void init(){
    head = tail = 0;
}

int isfull(){
    return head == (tail+1)%LEN;
}

int isempty(){
    return head == tail;
}
*/

void enqueue(P x){
    /*if(isfull){
        printf("Error : Over flow.\n");
        exit(0);
    }*/
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P dequeue(){
    /*if(isempty){
        printf("Error : Under flow\n");
        exit(0);
    }*/
    P x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int main(){
    int n, q, c, elaps=0;
    cin >> n >> q;
    for(int i=1; i<=n; i++) scanf("%s %d", Q[i].name, &Q[i].time);

    head = 1; tail=n+1;
    P a;
    while(head!=tail){
        a = dequeue();
        /*printf("%s %d\n", a.name, elaps);*/
        if(a.time>q){
            elaps += q;
            a.time -= q;
            enqueue(a);
        }
        else{
            elaps += a.time;
            printf("%s %d\n", a.name, elaps);
        }
    }
    return 0;
}


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

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < n;++i){
        cin >> b.at(i);
    }
    for(i = 0;i < n;++i){
        cin >> c.at(i);
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    long long ans = 0,numbera,numberc;
    for(i = 0;i < n;++i){
        numbera = lower_bound(a.begin(),a.end(),b.at(i))-a.begin();
        numberc = n-(upper_bound(c.begin(),c.end(),b.at(i))-c.begin());
        ans += numbera*numberc;
    }
    cout << ans << endl;
    return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {

             var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();   
             int a=abc[0];
              int b= abc[1];
             int c= abc[2];
            if (a < b && b < c)
            {

                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }

            


        }
    }
}

Measured memory_bytes: 9300
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x-r<0 || x+r>W || y-r<0 || y+r>H) {
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    Vl v(n);
    int a; cin >> a;
    int ans = 0;
    rep(i, 1, n){
        int b; cin >> b;
        if(b == a){
            ans++;
            a = 0;
        }else{
            a = b;
        }
    }
    cout << ans << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        System.out.printf("%d %d %.5f", d, r, f);
        sc.close();
    }
}


Measured memory_bytes: 26348
#include<stdio.h>

int main(){

	int i,n;
	short top,north,south,east,west,bottom,temp;
	char direction[8];

	while(1){
		top=1;
		north=2;
		west=3;
		east=4;
		south=5;
		bottom=6;

		scanf("%d",&n);
		if(n==0){
			break;
		}

		for(i=0;i<n;i++){
			scanf("%s",direction);

		    if(direction[0]=='n'){
		    	temp=top;
		    	top=south;
		    	south=bottom;
		    	bottom=north;
		    	north=temp;
		    }
		    else if(direction[0]=='s'){
		    	temp=top;
		    	top=north;
		    	north=bottom;
		    	bottom=south;
		    	south=temp;
		    }
		    else if(direction[0]=='w'){
		    	temp=top;
		    	top=east;
		    	east=bottom;
		    	bottom=west;
		    	west=temp;
		    }
		    else if(direction[0]=='e'){
		    	temp=top;
		    	top=west;
		    	west=bottom;
		    	bottom=east;
		    	east=temp;
		    }
		}
		printf("%d\n",top);
	}

	return(0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  getline(cin,s);
  char a;
  char b;
  cout << s.at(0);
  for(int i = 0;i<s.size();i++){
    if(s.at(i) == ' '){
      cout << s.at(i+1);
    }
  }
  
  
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;
const int MAX_N = 10005;
const int MAX_D = 105;

string s;
int d;
ll dp[MAX_N][MAX_D][2];

int main()
{
	ios::sync_with_stdio(false);
	cin >> s >> d;
	int n = (int)s.length();

	dp[0][0][1] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < d; j++)
			for (int x = 0; x < 10; x++)
			{
				int nextJ = (j + x) % d;
				dp[i + 1][nextJ][0] = (dp[i + 1][nextJ][0] + dp[i][j][0]) % MOD;
				if (x == s[i] - '0')
					dp[i + 1][nextJ][1] = (dp[i + 1][nextJ][1] + dp[i][j][1]) % MOD;
				if (x < s[i] - '0')
					dp[i + 1][nextJ][0] = (dp[i + 1][nextJ][0] + dp[i][j][1]) % MOD;
			}

	cout << ((dp[n][0][0] + dp[n][0][1] - 1 + MOD) % MOD) << endl;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> l(Q), r(Q);
    for (int i = 0; i < Q; i++)
        cin >> l[i] >> r[i];

    vector<int> sum(N + 1, 0);
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == 'A' && S[i] == 'C')
            sum[i + 1] = sum[i] + 1;
        else
            sum[i + 1] = sum[i];
    }

    for (int i = 0; i < Q; i++) {
        int ans = sum[r[i]] - sum[l[i]];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
//-------------------------------------------------------------------
int MAX_V = 701;
vvi G = vv(MAX_V, 0, 0, int);
vector<int> used(MAX_V, 0);
std::vector<int> mo(MAX_V, 0);

int l, r;
void dfs(int now, int mode){
  used[now] = 1;
  mo[now] = mode;
  if(mode==1) l++;
  else r++;
  for(int i=0;i<G[now].size();i++){
    if(mo[G[now][i]]==mode){
      std::cout << -1 << '\n';
      exit(0);
    }
    if(used[G[now][i]]!=0) continue;
    dfs(G[now][i], -mode);
  }
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  int N, M, a, b;
  std::cin >> N >> M;
  vvi p = vv(N+1, N+1, 1, int);
  for(int i=0;i<M;i++){
    std::cin >> a >> b;
    p[a][b] = p[b][a] = 0;
  }
  for(int i=1;i<=N;i++){
    for(int j=1;j<i;j++){
      if(p[i][j]==1){
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
  }


  vvi candi = vv(0, 2, 0, int);
  for(int i=1;i<=N;i++){
    if(used[i]==0) {
      l = r = 0;
      dfs(i, 1);
      candi.push_back(std::vector<int> {l, r});
      //std::cout << l << " " << r << '\n';
    }
  }
  vvi dp = vv(candi.size()+1, N+1, 0, int);
  dp[0][0] = 1;
  for(int i=1;i<=candi.size();i++){
    for(int j=0;j<=N;j++){
      if(dp[i-1][j]==1){
        if(j+candi[i-1][0]<=N)dp[i][j+candi[i-1][0]] = 1;
        if(j+candi[i-1][1]<=N)dp[i][j+candi[i-1][1]] = 1;
      }
    }
  }
  int ans = 1000000007;
  for(int i=0;i<=N;i++){
    if(dp[candi.size()][i]!=1) continue;
    int t = i;
    int t2 = N - i;
    ans = min(ans, (t*(t-1))/2+(t2*(t2-1))/2);
  }
  std::cout << ans << '\n';
  return 0;
}


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

int main() {
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

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

namespace _20200426_ABC164C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);
            int N = int.Parse(input[0]);

            input = ReadStringList(N);

            var a = input.Distinct();

            Console.WriteLine(a.Count());
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }
    }
}


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

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<vector<int>> A(N, vector<int>(N));
	rep(i, 0, N)rep(j, 0, N)cin >> A[i][j];

	rep(i, 0, N)rep(j, i + 1, N)rep(k, 0, N) {
		if (i == j || j == k || i == k)continue;
		if (A[i][j] > A[i][k] + A[k][j]) {
			cout << -1 << endl;
			return 0;
		}
	}

	int ans = 0;
	rep(i, 0, N)rep(j, i + 1, N)ans += A[i][j];
	rep(i, 0, N)rep(j, i + 1, N)rep(k, 0, N) {
		if (i == j || j == k || i == k)continue;
		if (A[i][j] == A[i][k] + A[k][j]) {
			ans -= A[i][j];
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#define N1 (1000+1)
using namespace std;
int find(int);
void unite(int,int);
bool same(int,int);
int tree[N1*N1];
string str[N1];
int main(){
  int W,H,N,x,y,findy,findx;
  int dx[4]={0,1,0,-1};
  int dy[4]={-1,0,1,0};
  cin >> W >> H;
  for(int i=0;i<H;i++) cin >> str[i];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      tree[i*W+j]=i*W+j;      
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(str[i][j]=='t') findy=i,findx=j;
      if(str[i][j]!='#'){
	for(int k=0;k<4;k++)
	  if(0<=i+dy[k]&&i+dy[k]<H&&0<=j+dx[k]&&j+dx[k]<W)
	    if(str[i+dy[k]][j+dx[k]]!='#')
	      unite(i*W+j,(i+dy[k])*W+(j+dx[k]));
      }
    }
  }
  cin >> N;
  int flag=0;
  if(same(0,findy*W+findx)){
    flag=1;
    cout << 0 << endl;
  }
  int cnt=0;
  while(N--&&flag==0){
    cnt++;
    cin >> x >> y;
    str[y][x]='.';
    for(int i=0;i<4;i++)
      if(0<=y+dy[i]&&y+dy[i]<H&&0<=x+dx[i]&&x+dx[i]<W&&str[y+dy[i]][x+dx[i]]!='#')
	unite(y*W+x,(y+dy[i])*W+(x+dx[i]));
    if(same(0,findy*W+findx)){
      flag=1;
      cout << cnt << endl;
      break;
    }
  }
  if(flag==0) cout << -1 << endl;
  return 0;
}
int st[N1*N1];
int find(int x){
  int cnt=0;
  while(x!=tree[x]){
    x=tree[x];
    st[cnt]=x;
    cnt++;
  }
  while(cnt>0){
    cnt--;
    tree[st[cnt]]=x;
  }
  return x;
}
void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y) return ;
  if(x<y) swap(x,y);
  tree[x]=y;
}
bool same(int x,int y){
  if(find(x)==find(y)) return true;
  return false;
}

Measured memory_bytes: 8036
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <stack>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <iterator>

using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> point;
typedef pair<int, int> pointI;

#define PI 3.1415926535897932384626433832795

const ll mod=1000000007LL;

bool msort(const point &l, const point &r) {
    return l.first<r.first;
}

int main() {
    iostream::sync_with_stdio(false);
    int n; cin>>n;
    vector<pair<ll, int> > input(n); for (int i=0; i<n; i++) cin>>input[i].first, input[i].second=i;

    sort(input.begin(), input.end(), msort);

    int ans=0;
    for (int i=0; i<n; i++)
        if (i%2!=input[i].second%2) ans++;

    //cout<<ans<<endl;
    if (ans%2==1) ans=ans/2+1;
    else ans/=2;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(b - a ==	c - b) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
// Author: Wenxing Mei
//   File: b.cpp
//   Date: 2019-03-10 23:37
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define per(i, b, a) for (int i = (int)b - 1; i >= (int)a; --i)
#define repv(ele, cont) for (auto &ele : cont)
#define all(x) x.begin(), x.end()
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<ll> vll;
// END OF TEMPLATE

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#endif
    int N, M, C;
    cin >> N >> M >> C;
    vi B(M);
    rep(i, 0, M) cin >> B[i];
    vi A(M);
    int res = 0;
    rep(i, 0, N) {
        int sum = C;
        rep(j, 0, M) {
            cin >> A[j];
            sum += A[j] * B[j];
        }
        if (sum > 0) ++res;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll n;
map<ll,ll> ma;
ll ans=0;
ll t=0;

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());
  
  cin>>n;
  for(ll i=0;i<n;i++){
    ma[t]++;
    ll z;cin>>z;
    t+=z;
    ans+=ma[t];
  }
  P(ans);
  return 0;
}


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

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

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define pb push
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2000005)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
typedef pair<ll, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pair<int, int> > piii;
typedef pair<char, int> pci;
typedef pair<int, bool> pib;
ll MOD = 1000000007;

int main() {
    FAST;
    ll a, b, k;
    cin >> a >> b >> k;
    ll x = min(k, a);
    a -= x;
    k -= x;
     x = min(k, b);
    b -= x;
    cout << a << " " << b << fim;
}


Measured memory_bytes: 256
//1171201016　稲村佑哉
//久々のC++での演習だったが、ゲーム形式で楽しく復習できた。
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,ans,r,D,x;
bool a[100];

pair<LL, LL>d;
int main() {
	cin >> r>>D>>x;
	for (int i = 0; i < 10; i++) {
		x = x*r - D;
		cout << x << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define endl "\n"
#define int ll
#define ll long long
#define pb emplace_back
#define fi first
#define se second
#define pll pair<ll, ll>
#define ull unsigned long long
#define ld long double

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repa(i,a,b) for(ll i=(a);i<=(b);i++)
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int , null_type, less<int> , rb_tree_tag, tree_order_statistics_node_update>
/*
 Ordered set docs:
 order_of_key (k) : Number of items strictly smaller than k .
 find_by_order(k) : K-th element in a set (counting from zero).
*/
#define blc boost::lexical_cast<long long>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
const int MOD = 1e9+7;
const ll INF = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}

ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}

ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}

ll powerLL(ll x, ll n, ll mod) 
{ 
    ll result = 1; 
    while (n) { if (n & 1) result = (result%mod * x%mod) % mod; n = n / 2; x = (x%mod * x%mod) % mod; } return result; 
} 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int N = 1e3+5;
ll dp[N][N];

void solve()
{
    ll m, n;
    cin>>m>>n;
    char grid[m][n];
    for(ll i = 0; i<m; i++)
    	for(ll j = 0; j<n; j++)
    		cin >> grid[i][j];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(ll i = 1; i<n; i++)
    {
    	if(grid[0][i] == '.')
    		dp[0][i] = 1;
    	else
    		break;
    }
    for(ll i = 1; i<m; i++)
    {
    	if(grid[i][0] == '.')
    		dp[i][0] = 1;
    	else
    		break;
    }
    for(ll i = 1; i<m; i++)
    {
    	for(ll j = 1; j<n; j++)
    	{
    		if(grid[i][j] == '#')
    			dp[i][j] = 0;
    		else
    			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
    	}
    }
    cout << dp[m-1][n-1] <<endl;
}
int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0; 
}

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

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    string ans;
    ans = (a < c && c < b) || (b < c && c < a) ? "Yes" : "No";
    cout << ans << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N;
	int cnt[200001] = {};
	const int day = 86400;
	const int span = 10801;
	const int MAX = 200000;
	cin >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		(sum += A) %= day;
		cnt[sum]++;
		(sum += B) %= day;
	}
	for (int i = day; i <= MAX; i++) cnt[i] = cnt[i-day];
	int num = 0;
	for (int i = 0; i < span; i++) {
		num += cnt[i];
	}
	int maxv = num;
	for (int i = span; i <= MAX; i++) {
		num -= cnt[i-span];
		num += cnt[i];
		chmax(maxv, num);
	}
	cout << maxv << endl;
	return (0);
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[16];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1476
# bin/env/pypy3
import sys
import collections
n = int(sys.stdin.readline())
a = list(map(int,sys.stdin.readline().split()))
c = collections.Counter(a)
#print(n,a,c)
memo_e = {}
s = sum(v*(v-1)//2 for v in c.values() if v > 1)
for e in a:
    if not e in memo_e:
        #c[e] -= 1
        if 1 < c[e]:
            memo_e[e] = s - (c[e]*(c[e]-1)//2 - (c[e]-1)*(c[e]-2)//2)
        else:
            memo_e[e] = s
    print(memo_e[e])

Measured memory_bytes: 101068
#include <stdio.h>

int main(void)
{
	int W, H,x,y,r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if (r <= x && x <= W-r && r <= y && y <= H-r) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define f1 first
#define s2 second
using namespace std;
 
int n,a,b;
long double cost,sa,ans;
vector<pair<int,int>>v;
vector<int>v1;
double dist(pair<int,int> p1,pair<int,int> p2){
	return sqrt((abs(p1.f1-p2.f1)*abs(p1.f1-p2.f1)+abs(p1.s2-p2.s2)*abs(p1.s2-p2.s2)));
}

int main(){	
	//freopen("a.gir","r",stdin);
 	//freopen("a.cik","w",stdout);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		v.push_back({a,b});
	}
	for(int i=0;i<n;i++){
		v1.push_back(i);
	}
	do{
		for(int i=1;i<n;i++){
			ans+=dist(v[v1[i]],v[v1[i-1]]);
		}
		sa++;
	}while(next_permutation(v1.begin(), v1.end()));
	printf("%0.10Lf\n",ans/sa );
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		String[] num = str.split(" ",2);
		System.out.println(gcd(Integer.parseInt(num[0]),Integer.parseInt(num[1])));
	}
	private static int gcd(int x, int y)
	{
		int tmp = -1;
		if(x < y)
		{
			tmp = x;
			x = y;
			y = tmp;
		}
		while(tmp != 0)
		{
			tmp = x % y;
			x = y;
			y = tmp;
		}
		return x;
	}
}


Measured memory_bytes: 26100
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
 
const int maxn = 55;
int A[maxn], sum[maxn]={0};
int n,k;//n块羊肉   k次操作 
vector<int> vt;

int main(){
//	freopen("d.txt","r",stdin);
	scanf("%d%d", &n, &k);
	for(int i=0;i<n;i++){
		scanf("%d", &A[i]);
		sum[i] += A[i];//0~i累积的和 
	}
	int r = min(n,k);
	int MAX = 0;
	for(int x=0;x<=r;x++){
		for(int y=0;x+y<=r;y++){
			int remain = min(k-x-y,x+y);//放回去的次数
			vt.clear();
			int sum = 0;
			for(int i=0;i<x;i++){//左边x个
				vt.push_back(A[i]);
				sum += A[i];
			} 
			for(int j=0,i=n-1;j<y;j++,i--){//右边y个
				vt.push_back(A[i]);
				sum += A[i];
			}
			sort(vt.begin(),vt.end());
			for(int j=0;j<remain;j++){//放回去 
				if(vt[j]<0){
					sum -= vt[j];
				}else{
					break;
				}
			}
			MAX = max(MAX,sum); 
		}
	} 
	printf("%d\n", MAX);
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, PLL> PP;
typedef unsigned int ui;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 1000100
int tab[maxn], m, mod;
ll n;
ll wyst[maxn];

inline int nt(int x) {
	if (x == n) return 1;
	return x + 1;
}
vector <int> v;

int main()
{
	boost;
	cin >> n;
	ll sum = 0;
	FOR(i, 1, n) {
		cin >> tab[i];
		sum += tab[i];
	}
	ll LO = 0;
	LO = n * (n + 1) / 2;
	if (sum % LO != 0) OUT("NO");
	LO = (sum / LO);

	FOR(i, 1, n) {
		int x = nt(i);
		ll wal = tab[x] - tab[i];
		wal -= LO;
		wal = - wal;
		if (wal < 0) OUT("NO");
		if (wal % n != 0) OUT("NO");
		wal /= n;
		wyst[x] = wal;
	}
	//FOR(i, 1, n) cout << wyst[i] << ' ';
	
	ll sumall = 0;
	FOR(i, 1, n) sumall += wyst[i];
	if (sumall != LO) OUT("NO");
	cout << "YES";
}

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

int main()
{
  //**整数の入力
  int A,B;
  cin >> A >> B;

  //**配列に代入
  vector<int> a = {(A+B), (A-B), (A*B)};
  
  //**小さい順にする
  sort(a.begin(), a.end());
 
  cout << a.at(2) << endl;
  return 0;
}

  

Measured memory_bytes: 256
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,ma,mb = map(int,ipt().split())
    dp = [[10**18]*(n*10+1) for _ in [0]*(n*10+1)]
    dp[0][0] = 0
    for _ in range(n):
        a,b,c = map(int,ipt().split())
        for i in range(n*10+1-a):
            dpi = dp[n*10-i-a]
            dpni = dp[n*10-i]
            for j in range(n*10+1-b):
                if dpni[n*10-j] > dpi[n*10-j-b]+c:
                    dpni[n*10-j] = dpi[n*10-j-b]+c
    mi = 10**18
    for i in range(1,n*10//max(ma,mb)+1):
        m = dp[ma*i][mb*i]
        if m < mi:
            mi = m
    if mi == 10**18:
        print(-1)
    else:
        print(mi)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 40556
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {

		Scanner sc = new Scanner(System.in);
		int a = 0,b = 0;

		a = sc.nextInt();
		b = sc.nextInt();

		if((1 <= a && a <= 9) && (1 <= b && b <= 9)) {
			System.out.println(a * b);
		}else {
			System.out.println("-1");
		}
	}
}


Measured memory_bytes: 21844
n,a,b=map(int,input().split())
def func(x):
    count=0
    while True:
        count+=x%10
        x//=10
        if x==0:
            break
    return count
ans=0
for i in range(n+1):
    if func(i)>=a and func(i)<=b:
        ans+=i
print(ans) 


Measured memory_bytes: 9068
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256