akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        string[] input = Console.ReadLine().Split().Select(i =>i).ToArray();
        bool honest = true;
        for(int a = 0; a < input.Length; a++)
        {
            if (input[a]=="D") honest = !honest;
        }

        Console.WriteLine(honest?"H":"D");

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 3612
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    x: i64,
    k: u128,
    d: u128,
    }

    let mut ans = 0;
    let absx = x.abs();

      if absx as u128 > (k as u128 * d as u128){
        ans = absx as u128 - k as u128 * d as u128;
      }else{
        let amari = absx as u128 % d;
        let shou = absx as u128 / d;

        let nokori = k - shou;

        if nokori % 2 == 1 {
          ans = d - amari;
        }else {
          ans = amari;
        }
      }

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


Measured memory_bytes: 2120
n = int(input())
c = str(input())
l = 0
r = n-1
answer = 0
while l < r:
    if c[l] == "W" and c[r] == "R":
        answer += 1
        l += 1
        r -= 1
    elif c[l] == "W" and c[r] == "W":
        r -= 1
    elif c[l] == "R" and c[r] == "R":
        l += 1
    else:
        l += 1
        r -= 1
print(answer)

Measured memory_bytes: 9516
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

#define m 256
const double eps=1e-8;

int main(){
	while(1){
		int n, input[m+1];
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=1; i<=n; ++i) scanf(" %d", &input[i]);
		
		int as=-1, aa=-1, ac=-1;
		double minh=10000000;
		
		for(int s=0; s<=15; ++s){
			for(int a=0; a<=15; ++a){
				for(int c=0; c<=15; ++c){
					int r[m+1], o[m+1];
					int occur[m+1];
					
					memset(occur, 0, sizeof(occur));
					
					r[0]=s;
					for(int i=1; i<=n; ++i){
						r[i]=(a*r[i-1]+c)%m;
						o[i]=(input[i]+r[i])%m;
						occur[o[i]]++;
						//printf("o[%d]=%d\n", i, o[i]);
					}
						
					double h=0;
					for(int i=0; i<m; ++i){
						if(occur[i]==0) continue;
						else{
							double tmp=(double)occur[i]/n;
							//printf("tmp=%lf", tmp);
							h-= tmp*log(tmp);	
						}
					}
					//printf("s=%d, a=%d, c=%d, h=%lf\n", s, a, c, h);
					
					if(h+eps<minh){
						minh=h;	
						as=s;
						aa=a;
						ac=c;
					}

				}
			}
		}		
		
		printf("%d %d %d\n", as, aa, ac);
	}
}	

Measured memory_bytes: 1228
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

const int INF = 1<<25;
int dx[] = {-1,0,1,-1,0,1,-1,0,1};
int dy[] = {-1,-1,-1,0,0,0,1,1,1};
struct Pos{
    int x, y;
    Pos(int x=0, int y=0) {
        this->x = x;
        this->y = y;
    }
};
Pos p[9];
int N;
Pos ary[1000000];

int func(bool flg, Pos l, Pos r) {
    int res = 0;
    REP(i, N) {
        if (flg) { // right foot
            if (ary[i].x<l.x) {
                l = ary[i];
                flg = !flg;
                res++;
            } else {
                if (r.x==ary[i].x && r.y==ary[i].y) flg != flg;
                r = ary[i];
            }
        } else { // left foot
            if (ary[i].x>r.x) {
                r = ary[i];
                flg = !flg;
                res++;
            } else {
                if (l.x==ary[i].x && l.y==ary[i].y) flg != flg;
                l = ary[i];
            }
        }
        flg = !flg;
    }
    return res;
}

int solve() {
    string str;
    getline(cin, str);
    if (str=="#") return -1;

    N = str.length();
    REP(i, N) {
        ary[i] = p[str[i]-'1'];
    }
    int ans = INF;
    REP(i, 9) REP(j, 9) {
        ans = min(ans, min(func(false, p[i], p[j]), func(true, p[i], p[j])));
    }
    return ans;
}

int main() {
    REP(i, 9) {
        p[i] = Pos(dx[i], dy[i]);
    }

    int ans;
    while((ans = solve())>=0) {
        printf("%d\n", ans);
    }
    return 0;
}

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

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

    int point[n];
    vector<pair<int, int> > phase(n);

    for(int i = 0; i < n; i++){
        int s, l, p;
        cin >> s >> l >> p;
        point[i] = p;
        phase[i].first = s;
        phase[i].second = l;
    }

    int x;
    cin >> x;
    int length[x];

    for(int i = 0; i < x; i++){
        cin >> length[i];
    }

    int dp[400];
    for(int m = 0; m <= 400; m++){
        dp[m] = -1;
    }
    dp[0] = 0;

    for(int m = 0; m <= 400; m++){
        for(int i = 0; i < n; i++){
            for(int l = phase[i].first; l <= phase[i].second; l++){
                if(m - l < 0){
                    continue;
                }
                dp[m] = max(dp[m], dp[m-l]+point[i]);
            }
        }
    }


    for(int i = 0; i < x; i++){
        if(dp[length[i]] == -1){
            printf("-1\n");
            return 0;
        }
        
    }

    for(int i = 0; i < x; i++){
        printf("%d\n", dp[length[i]]);
        
    }

    

    return 0;
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	string s, t;
	cin >> s >> t;
	vi sk(26, 0);
	vi tk(26, 0);
	int pos = 1;
	for (int i = 0; i < s.size(); i++) {
		if (sk[s[i] - 'a'] == 0) {
			sk[s[i] - 'a'] = pos;
			pos++;
		}
		s[i] = (sk[s[i] - 'a']-'1');
	}
	pos = 1;
	for (int i = 0; i < t.size(); i++) {
		if (tk[t[i] - 'a'] == 0) {
			tk[t[i] - 'a'] = pos;
			pos++;
		}
		t[i] = (tk[t[i] - 'a'] - '1');
	}
	if (s == t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 776
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    int k;
    cin >> k;
    int a, b, c, sum = 0;
    for(a = 1; a <= k; a++){
        for(b = 1; b <= k; b++){
            for(c = 1; c <= k; c++){
                sum += __gcd(__gcd(a, b), c);
            }
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,m;
	while(1){
		cin >> n >>m;
		vector<int> a(n),b(m);
		if(n==0 && m==0) break;
		cinf(n,a); cinf(m,b);
		int suma=0; int sumb=0;
		for (int i = 0; i < n; ++i)
			suma+=a[i];
		for(int i=0;i<m;i++)
			sumb+=b[i];
		int ansa=150; int ansb=150;
		if(suma>sumb){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(suma-sumb == (a[i]-b[j])*2 && b[j]+a[i]<ansa+ansb){
						ansa=a[i]; ansb=b[j];
                    }
				}
			}
		}
		else if(suma == sumb){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(a[i]==b[j] && ansa>a[i]){
						ansa = a[i]; ansb = b[j];
				    }
				}
			}
		}
		else {
			for(int j=0;j<m;j++){
				for(int i=0;i<n;i++){
					if(sumb-suma ==(b[j]-a[i])*2 && b[j]+a[i]<ansa+ansb){
						ansa=a[i]; ansb=b[j];
                    }
				}
			}

		}
		if(ansa==150) cout << -1 << endl;
		else cout << ansa <<" "<< ansb << endl;
		}
}


Measured memory_bytes: 3016
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main(){
  int i,n,fib[45]={1,1};
  scanf("%d",&n);
  for(i=2;i<n+1;i++){
    fib[i]=fib[i-1]+fib[i-2];
  }
  printf("%d\n",fib[i-1]);
}



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

class Program
{
    static void Main()
    {
        var n = NextInt();
        var t = 1L;
        var a = 1L;

        foreach (var i in Enumerable.Range(0, n))
        {
            var ti = NextInt();
            var ai = NextInt();

            var k = Math.Max(1 + (t - 1) / ti, 1 + (a - 1) / ai);
            t = ti * k;
            a = ai * k;
        }
        Console.WriteLine(t + a);
    }

    static int NextInt()
    {
        return int.Parse(NextString());
    }

    static string NextString()
    {
        var result = new List<char>();
        while (true)
        {
            int next = Console.Read();
            if (next < 0)
            {
                break;
            }
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
            {
                result.Add(nextChar);
            }
            else if (nextChar != '\r')
            {
                break;
            }
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>

template <typename C>
void print_container(const C &c, const std::string &name)
{
  std::cout << name << ": ";
  std::for_each(c.cbegin(), c.cend(),
                [](auto &x) { std::cout << x << ", "; });
  std::cout << std::endl;
}

std::vector<int> n_ary(uint64_t decimal, uint64_t base)
{
  uint64_t s = decimal;
  std::vector<int> ret;
  while(s >= base) {
    int r = s % base;
    s /= base;
    ret.push_back(r);
  }
  ret.push_back(s);

  std::reverse(ret.begin(), ret.end());
  return ret;
}

char i2c(int i)
{
  return char('a' + i);
}


int main()
{
  uint64_t N;
  std::cin >> N;

  const uint64_t n = 26;
  uint64_t i=1; // i-place number(i=3, aaa-zzz)
  while(N - std::pow(n, i) > 0) {
    N -= std::pow(n, i);
    i++;
  }

  // let N 0 origin
  N--;

  auto ary26 = n_ary(N, n);
  // print_container(ary26, "ary26");

  // i=3, ary26 = {1, 2} => s = abc
  std::string s;
  for(auto k: ary26) {
    s = s + i2c(k);
  }

  std::cout << std::setw(i) << std::setfill('a')
            << s << std::endl;

  return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	cout<<"ABC"<<N<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def get_primes(max=None, count=None):
    """
    素数列挙
    昇順にソートされています
    https://qiita.com/Ishotihadus/items/73e107271275611f05f2
    :param int max:
    :param int count:
    """
    assert max or count
    if count:
        raise NotImplementedError()
    if max <= 1:
        return []

    primes = [2]
    sieve = [False for _ in range(max + 1)]
    p = 3
    while p <= max:
        primes.append(p)
        sieve[p] = True
        if p <= math.sqrt(max):
            for i in range(p * (p | 1), max + 1, p * 2):
                sieve[i] = True
        while p <= max and sieve[p]:
            p += 2

    return primes


N = int(sys.stdin.buffer.readline())

is_prime = [False] * 55555 * 5
for p in get_primes(55555 * 5):
    is_prime[p] = True


def test(ans):
    for choices in itertools.combinations(ans, r=5):
        if is_prime[sum(choices)]:
            return False
    return True


# あーーー時間かかった
ans = []
for p in get_primes(55555):
    if p % 5 == 1:
        ans.append(p)

ans = ans[:N]
print(*ans)

# while True:
#     import random
#     ans = {2}
#     while len(ans) < 55:
#         ans.add(random.choice(primes))
#     print(ans)
#     if test(ans):
#         print(ans)
#         exit()


Measured memory_bytes: 8884
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
 
int main() {
    int N,M;
    cin >> N >> M;
    int sizeM = 2*M;
    int array[sizeM];
    for(int i=0;i<2*M;i++){
        cin >> array[i];
    }
    for(int j=0;j<N;j++){
        int count = 0;
        for(int l=0;l<2*M;l++){
            if(array[l]==j+1){
                count++;
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 256
unittest
{
	assert( [ "2 50", "6 10" ].parse.expand.solve == 2 );
	assert( [ "3 100", "14 22 40" ].parse.expand.solve == 0 );
	assert( [ "5 1000000000", "6 6 2 6 2" ].parse.expand.solve == 166666667 );
	
	assert( [ "2 1000000000", "2 4" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nm[ 1 ], as );
}

auto solve( long m, long[] as )
{
	// aの半分の最小公倍数（＝最小のX候補）を計算
	auto x = 1L;
	foreach( a; as )
	{
		if( a % 2 ) return 0;		// aが奇数だったらpを何にしてもXが整数にならないので0確定
		x = lcm( x, a / 2 );
		if( m < x ) return 0;		// mより大きかったら0確定
	}
	
	// aの半分の最小公倍数が半公倍数じゃなかったら0確定
	foreach( a; as )
	{
		if( ( x - a / 2 ) % a ) return 0;
	}
	
	// 0 < i && x * i <= m && i % 2 == 1 のときに半公倍数になる
	return ( m / x + 1 ) / 2;
}

// 最小公倍数
auto lcm( long x, long y )
{
	return x * y / x.gcd( y );
}


Measured memory_bytes: 6600
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, c{}; cin >> N; int P[N], Q[N]; for (int &p: P) cin >> p; for (int i{}; i < N; ++i) Q[i] = i + 1;
  for (int i{}; i < N; ++i) c += P[i] != Q[i];
  puts(c < 3 ? "YES" : "NO");}

Measured memory_bytes: 3604
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

score hand
  | elem 4 counts = "four card"
  | counts == [2,3] = "full house"
  | hand == [1,10,11,12,13] || map (subtract $ head hand) (tail hand) == [1,2,3,4] = "straight"
  | elem 3 counts = "three card"
  | counts == [1,2,2] = "two pair"
  | elem 2 counts = "one pair"
  | otherwise = "null"
  where counts = sort . map length . group $ hand

main = do
    ls <- map (sort . map readInt . wordsBy (==',')) . lines <$> getContents
    forM_ ls $ putStrLn . score

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
int h,n;
int a[1010],b[1010];
int dp[30010];
int hh;
int main(){
	memset(dp,0x3f,sizeof dp);
	cin>>h>>n;
	hh=h+10000;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	dp[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=a[i];j<=hh;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	int ans=dp[h];
	for(int i=h+1;i<=hh;i++)ans=min(ans,dp[i]);
	cout<<ans<<endl;
//	for(int i=1;i<=hh;i++)cout<<dp[i]<<' ';
//	cout<<endl;
	return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+5;
using namespace std;
ll n,m;
ll x,y;
int main()
{
    scanf("%lld%lld%lld%lld",&n,&m,&x,&y);
    if(n==2&&m==28) printf("1\n");
    else if((n==1||n==3||n==5||n==7||n==8||n==10||n==12)&&m==31) printf("1\n");
    else if((n==4||n==6||n==9||n==11)&&m==30) printf("1\n");
    else printf("0\n");
    return 0;
}

/**

**/



Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
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_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    sn = s_input()
    n = int(sn)

    compare_num = int(sn[0]) * 100 + int(sn[0]) * 10 + int(sn[0])
    
    if n == compare_num:
        print(n)
    elif n > compare_num:
        tmp = int(sn[0]) + 1
        print(tmp * 100 + tmp * 10 + tmp)
    else:
        print(compare_num)

if __name__ == '__main__':
    main()


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

int main()
{
  int count=0;
  string s;
  bool a=false;
  cin>>s;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A')a=true;
    if(s[i]=='Z' && a){
      count++;
      a=false;
    }
  }
  if(count==0)cout<<-1<<endl;
  else {
    for(int i=0;i<count;i++)cout<<"AZ";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    ll a,b,c;
    cin >> a >> b >> c;
    if(c <= a+b+1){
        cout << c+b << endl;
    }else{
        cout << b + (a+b+1) << endl;
    }
}




Measured memory_bytes: 256
def main():

    c = [list(map(int, input().split())) for _ in range(3)]
    if (c[0][0]-c[1][0]) != (c[0][1]-c[1][1]) or (c[0][0]-c[1][0]) != (c[0][2]-c[1][2]) or (c[0][1]-c[1][1]) != (c[0][2]-c[1][2]):
        print('No')
        return

    if (c[1][0]-c[2][0]) != (c[1][1]-c[2][1]) or (c[1][0]-c[2][0]) != (c[1][2]-c[2][2]) or (c[1][1]-c[2][1]) != (c[1][2]-c[2][2]):
        print('No')
        return

    if (c[0][0]-c[2][0]) != (c[0][1]-c[2][1]) or (c[0][0]-c[2][0]) != (c[0][2]-c[2][2]) or (c[0][1]-c[2][1]) != (c[0][2]-c[2][2]):
        print('No')
        return

    if (c[0][0]-c[0][1]) != (c[1][0]-c[1][1]) or (c[0][0]-c[0][1]) != (c[2][0]-c[2][1]) or (c[1][0]-c[1][1]) != (c[2][0]-c[2][1]):
        print('No')
        return

    if (c[0][0]-c[0][2]) != (c[1][0]-c[1][2]) or (c[0][0]-c[0][2]) != (c[2][0]-c[2][2]) or (c[1][0]-c[1][2]) != (c[2][0]-c[2][2]):
        print('No')
        return

    if (c[0][1]-c[0][2]) != (c[1][1]-c[1][2]) or (c[0][1]-c[0][2]) != (c[2][1]-c[2][2]) or (c[1][1]-c[1][2]) != (c[2][1]-c[2][2]):
        print('No')
        return

    print('Yes')

main()


Measured memory_bytes: 3192
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   double x1,y1,x2,y2;
   cin>>x1>>y1>>x2>>y2;
   double dis=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
   printf("%.8lf\n",dis);
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3264
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(n) for(ll i=0; i<n; i++)
#define INF LLONG_MAX/2

vector<ll> dp0(10000000); //繰り下がりなし
vector<ll> dp1(10000000); //繰り下がりなあり
ll n;

void state()
{
  for (ll i = 0; i < n; i++)
  {
    cout << dp0[i] << " ";
  }
  cout << endl;
  for (ll i = 0; i < n; i++)
  {
    cout << dp1[i] << " ";
  }
  cout << endl;  
}

int main()
{
  vector<int> v;
  string s;
  cin >> s;
  n = s.length();
  for (ll i = 0; i < n; i++)
  {
    v.push_back(s[i]-'0');
  }

  dp0[0] = 0;
  dp1[0] = 1;


  for (ll i = 0; i < n; i++)
  {
    ll cur = v[i];
/*  
    if(cur==0) dp0[i+1] = dp0[i] + cur;
    else dp0[i+1] = min(dp1[i]+10-cur, dp0[i]+cur);

    if(cur==9) dp1[i+1] = dp0[i]+9-cur;
    else dp1[i+1] = min(dp1[i]+9-cur, dp0[i]+cur+1);

*/
    dp0[i+1] = min(dp1[i]+10-cur, dp0[i]+cur);
    dp1[i+1] = min(dp1[i]+9-cur, dp0[i]+cur+1);

  }
//  state();
  
  cout << dp0[n] << endl;
  
  return 0;
}

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

int main()
{
  string S;
  cin >> S;
  int ans = 0;
  if (S.at(0) == '0')
  {
    for (int i = 0; i < S.size(); i++)
    {
      if (i % 2 == 0)
      {
        if (S.at(i) == '1')
          ans++;
      }
      else
      {
        if (S.at(i) == '0')
          ans++;
      }
    }
  }
  else
  {
    for (int i = 0; i < S.size(); i++)
    {
      if (i % 2 == 0)
      {
        if (i % 2 == 0)
        {
          if (S.at(i) == '0')
            ans++;
        }
      }
      else
      {
        if (S.at(i) == '1')
          ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
  char c;
  scanf("%c",&c);
  switch(c)
  {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':printf("vowel\n"); break;
    default : printf("consonant\n"); break;
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int n,temp=0;
  cin >> n;
  std::vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  // int max = *max_element(h.begin(), h.end());
  for (int i = 0; i < 10000; i++) {
    temp = 0;
    // cout << i << endl;
    for (int j = 0; j < n; j++) {
      if (h[j] == 0 && temp == 0){
        // do nothing
      } else if(h[j] == 0 && temp == 1) {
        break;
      }  else {
        h[j] = h[j] - 1;
        temp = 1;
      }
    }
    if (temp == 0){
      cout << i << endl;
      return 0;
    }
  }
}


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

int pos[21][21];

int main(){
  int n;
  while(cin>>n && n){
    memset(pos,0,sizeof(pos));
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      pos[x][y]=1;
    }
    int m;
    cin>>m;
    int posx=10;
    int posy=10;
    int gem=0;
    for(int i=0;i<m;i++){
      char c;
      int d;
      cin>>c>>d;
      switch(c){
      case 'N':
	for(int j=1;j<=d;j++){
	  if(pos[posx][++posy]){
	    gem++;
	    pos[posx][posy]=0;
	  }
	}
	break;

      case 'E':
	for(int j=1;j<=d;j++){
	  if(pos[++posx][posy]){
	    gem++;
	    pos[posx][posy]=0;
	  }
	}
	break;

      case 'W':
	for(int j=1;j<=d;j++){
	  if(pos[--posx][posy]){
	    gem++;
	    pos[posx][posy]=0;
	  }
	}
	break;

      case 'S':
	for(int j=1;j<=d;j++){
	  if(pos[posx][--posy]){
	    gem++;
	    pos[posx][posy]=0;
	  }
	}
	break;
      }
    }
    if(gem == n)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, k, d, t;
Int mx[108000];
vector<P> sushi;
Int good[108000];

int main(){
  fill(mx, mx + 108000, -1);
  cin >> n >> k;
  for(Int i = 0;i < n;i++){
    cin >> t >> d;
    sushi.push_back(P(d, t));
  }
  sort(sushi.rbegin(), sushi.rend());

  for(int i = n-1;i >= 0;i--){
    mx[sushi[i].second] = i;
  }

  for(int i = 1;i <= n;i++){
    if(mx[i] == -1)continue;
    good[mx[i]] = true;
  }

  Int sum = 0, typeCnt = 0;
  for(int i = 0;i < k;i++){
    sum += sushi[i].first;
    if(good[i])typeCnt++;
  }
  Int res = sum + typeCnt * typeCnt;
  
  Int r = k-1, l = k;
  while(r >= 0 && l < n){
    while(r >= 0 && good[r])r--;
    while(l < n && !good[l])l++;
    if(r < 0 || l >= n)break;
    sum += -sushi[r].first + sushi[l].first;
    typeCnt++;
    r--;
    l++;
    res = max(res, sum + typeCnt * typeCnt);
  }

  cout << res << endl; 
  return 0;
}

Measured memory_bytes: 4340
N, M = map(int, input().split())  #頂点, 辺
g = [[] for _ in range(N)]  #iはjと繋がっている
for _ in range(M):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

#1度通った頂点をTrueにする
is_checked = [False] * N

def dfs(i):
    cnt = 0
    is_checked[i] = True
    if not(False in is_checked):
        return 1
    else:
        for j in g[i]:
            if not(is_checked[j]):
                cnt += dfs(j)
                is_checked[j] = False
        return cnt
            
ans = dfs(0)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;


    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    cout << (intl)ceil((double)(m - 1) / (n - 1)) << endl;
    return 0;
}

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

int main() {
	int t, n, x;	//scanf("%d %d %d", &n, &x, &t);
	string num;		cin>>num;
	
	x = 0;
	for(auto c: num) x += (c - '0');
	
	if(x % 9 == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3696
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val x = Scanner.nextInt

	pw.println(if (x >= 30) "Yes" else "No")
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54556
import collections
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
points=['No' for i in range(n)]
c = collections.Counter(a)

zone=k-q


for v in c:
    
    if zone+c.get(v)>=1:
        points[v-1]='Yes'
if zone>=1:
    for h in points:
        print('Yes')
else:
    for h in points:
        print(h)

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18
#define PI 3.14159265359

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < ii > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	ll ans = 0;
	cin >> n;
	ll n1 = n;
	bool all9=1;
	while(n1>=10){
		if(n1%10!=9){
			all9=0;
		}
		n1/=10;
	}
	if(all9){
		while(n>=10){
			ans+=9;
			n/=10;
		}
		cout << ans+n;
	}
	else{
		while(n>=10){
			ans+=9;
			n/=10;
		}
		cout << ans+n-1;
	}
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

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

	return gcd(b, a%b);
}

int main() {

	IOS

	int n;
	cin >> n;

	ll sum = 0;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				sum += gcd(i, gcd(j, k));

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3652
n, m = gets.split.map(&:to_i)
edges = Array.new(n) { Array.new }
m.times do
  a, b = gets.split.map(&:to_i).map(&:pred)
  edges[a] << b
  edges[b] << a
end

# [current]
queue = [0]
ans = Array.new(n)
until queue.empty?
  current = queue.shift
  edges[current].each do |to|
    next if to == 0
    unless ans[to]
      ans[to] = current
      queue << to
    end
  end
end

ans.shift
puts "Yes"
ans.each { |n| puts n + 1 }


Measured memory_bytes: 32908
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  int ans = 0;
  rep(i, S.size()) {
    if(S[i] != T[i]) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, r;
    cin >> n >> r;
    cout << r+(10-min(10, n))*100 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>
using namespace std;
typedef long long ll;


int main(){
        ll X, Y, Z, K;
        cin >> X >> Y >> Z >> K;
        vector<ll> A(X), B(Y), C(Z);
        for(int i=0; i<X; i++){
                cin >> A[i];
        }
        for(int i=0; i<Y; i++){
                cin >> B[i];
        }
        for(int i=0; i<Z; i++){
                cin >> C[i];
        }
        sort(A.rbegin(), A.rend());
        sort(B.rbegin(), B.rend());
        sort(C.rbegin(), C.rend());
        vector<ll> D(X*Y);
        for(int i=0; i<X; i++){
                for(int k=0; k<Y; k++){
                        D[i*Y+k] = A[i] + B[k];
                }
        }
        sort(D.rbegin(), D.rend());
        int num;
        if(X*Y > K) num = K;
        else num = X*Y;
        vector<ll> ans(num*Z);
        for(int i=0; i<num; i++){
                for(int k=0; k<Z; k++){
                        ans[i*Z+k] = D[i] + C[k];
                }
        }
        sort(ans.rbegin(), ans.rend());
        for(int i=0; i<K; i++){
                cout << ans[i] << endl;
        }




}


Measured memory_bytes: 31616
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long M = 1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;

    ll ans = 0;
    ll under = 0;
    ll top = 0;
    for(ll i = 0; i < k; i++){
        under += i;
        top += n - i;
    }
    for(ll i = k; i <= n+1; i++){
        ans += (top - under + 1);
        under += i;
        top += n - i;
    }

//    ans = comb(n, k);

    p(ans%M);
}

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


int main() {

    int n;

    cin >> n;
    int s[n];
    int sum = 0;

    for (int i = 0; i<n; ++i) {
        cin >> s[i];
        sum+=s[i];
    }

    sort (s, s + n);

    int i = 0;

    if (sum % 10 == 0) {
        while (i < n) {
            if (s[i] % 10 != 0) break;
            ++i;
        }

        if (i != n) sum-=s[i]; else sum = 0;
    }

    cout << sum << '\n';

    return 0;
}



Measured memory_bytes: 256
//DP Contest
//K-Stones
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 

  //Similar to a game of nim
  //its a fair game
  //SO i will look at transitions in a complemented fashion

//A reservoir of K-stones is present, from which stones are drawn 

  //bool dp[i]=TRUE if First person is the winner when i stones are remaining

  int32_t main()
  {
  	/*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    IOS
    int n,k;
    cin>>n>>k;
    vector<int> v(n,0);
    for(auto& x: v)
    	cin>>x;
    //bottom up building the dp
     vector<bool> dp(k+1,false);
     for(int i=0;i<=k;i++)  //i is the number of stones
     {
        for(auto x:v)
        {
        	if(i>=x && !dp[i-x])
        		dp[i]=true;
        }
     }  
     if(dp[k])
     	cout<<"First";
     else
     	cout<<"Second";
     return 0;
   }



Measured memory_bytes: 256
import collections
N=int(input())
a=list(map(int,input().split()))
b=collections.Counter(a)
c=list(set(a))
count=0
for i in range(0,len(c)):
    if b[c[i]]>=c[i]:
        count+=b[c[i]]-c[i]
    else:
        count+=b[c[i]]
print(count)

Measured memory_bytes: 20592
from bisect import bisect_left, bisect_right

class Set(): #BinaryIndexedTree
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): #k個以下のときはINFを返す
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def get(self, idx):
        return self.sum(idx) - self.sum(idx - 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = [int(input()) for _ in range(D)]

M = int(input())
Q = [tuple(map(int, input().split())) for _ in range(M)]

res = 0
last = [0 for _ in range(26)]
used = [Set(list(range(D))) for i in range(26)]

for d in range(D):
    res += S[d][T[d] - 1]
    last[T[d] - 1] = d + 1
    used[T[d] - 1].insert(d)
    for j in range(26):
        res -= C[j] * ((d + 1) - last[j])

for i in range(M):
    d, q = Q[i]
    if T[d - 1] == q:
        print(res)
        continue
    res -= S[d - 1][T[d - 1] - 1]
    res += S[d - 1][q - 1]
    k = used[T[d - 1] - 1].sum(d - 1)
    l = used[T[d - 1] - 1].get(k - 1) if k != 1 else -1
    r = used[T[d - 1] - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    res -= (d - 1 - l) * C[T[d - 1] - 1] * (r - d + 1)
    used[T[d - 1] - 1].delete(d - 1)
    used[q - 1].insert(d - 1)
    k = used[q - 1].sum(d - 1)
    l = used[q - 1].get(k - 1) if k != 1 else -1
    r = used[q - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    res += (d - 1 - l) * C[q - 1] * (r - d + 1)
    T[d - 1] = q
    print(res)

Measured memory_bytes: 95896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
//絶対値
ll ze(ll x,ll y){
    return max(x,y)-min(x,y);
};
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans =mod;
    for(int i = 0; i < n-2; i++){
        int tmp = (s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        if(ans > ze(tmp,753)) ans = ze(tmp,753); 
    }
    cout << ans << endl;
}

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

int main ( )
{
       int n,i,odd=0;
       float p;
        scanf ("%d",&n);
        for (i=1; i<=n; i++)
        {
                if (i%2!=0)
                         odd++;
         }
         p=odd/(float)n;
         printf ("%f\n",p);
         return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
 
// 素集合データ構造というデータ構造ですj
struct UnionFind {
  std::vector<int> parent; // あるデータの親
  std::vector<int> sizes;  // あるデータが属する木のサイズ
 
  // コンストラクタ
  // データ一つ一つを木とし、親は自分自身に初期化する
  UnionFind(int n)
    : parent(n)
    , sizes(n, 1)
  {
    for (int i = 0; i < n; ++i) {
      parent[i] = i;
    }
  }
 
  // データxが属する木の根ノードを取得
  // findだがunion-find木の仕組み的に内部で破壊的更新を伴う
  int find(int x) {
    // 親と自分が同じであることが
    // 自分がルートノードであるということ
    if( x == parent[x] ) {
      return x;
    }

    // 経路を圧縮するため調べた辺を根に直接繋ぎ直す
    parent[x] = find(parent[x]);
    return parent[x];
  }
 
  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // それぞれのデータの根ノードを取得
    int root_x = find(x);
    int root_y = find(y);
 
    // x, yが同じ木に属するならマージしない
    if (root_x == root_y) return;
 
    // xの木がyの木より大きくなるようにする
    if (sizes[root_x] < sizes[root_y]) {
      std::swap(root_x, root_y);
    }
 
    // xがyの親になるようにマージする
    parent[root_y] = root_x;
    sizes[root_x] += sizes[root_y];
  }
 
  // 2つのデータx, yが同じ木に属するかどうか
  bool same(int x, int y) {
    return (find(x) == find(y));
  }
 
  // データxの属する木のサイズを返す
  int size(int x) {
    return sizes[find(x)];
  }
};
 
// 頂点a, bを繋ぐコストcostの無向辺
struct Edge {
  int a, b, cost;
 
  // コストで順序を決める(ソートのときに使われる)
  bool operator<(const Edge &o) const {
    return cost < o.cost;
  }
};
 
// 頂点数と辺集合の組として定義したグラフ
struct Graph {
  int n;           // 頂点数
  std::vector<Edge> edges; // 辺集合
 
  // クラスカル法で無向最小全域木を求め、コストの和を返す
  int kruskal() {
    // costの小さい辺から繫いでいくので、昇順にソートしておく
    sort(edges.begin(), edges.end());
 
    // UnionFindで同じ集合にいることを確認できます
    // これを使って「繋がってるノード」をすべて1つの集合にいることにします
    // 最初の状態では「どれも繋がっていません」が
    // エッジで繋いだ2つのノードは、同じ集合にいることにしてしまいます
    // 辺を追加するときに、すでにつながっているノード同士を繋ぐということが閉路ができる条件なので
    // 閉路を作らないようにつながっていないノードを繋ぐということを繰り返す
    UnionFind uf(n);
    int min_cost = 0;
    for (size_t i = 0; i < edges.size(); ++i) {
      Edge e = edges[i];
      if (!uf.same(e.a, e.b)) {
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }
 
    return min_cost;
  }
};
 
int main() {
  int N;
  std::cin >> N;
  std::pair<int, int> x[N], y[N];
  for (size_t i = 0; i < N; ++i) {
    std::cin >> x[i].first >> y[i].first;
    x[i].second = y[i].second = i;
  }
 
  // 式 min( |a-c|, |b-d| ) を検討してみると
  // - "x軸側で一番近い"街
  // - "y軸側で一番近い"街
  // の2つだけがそれぞれの街に存在することがわかります。
  //
  // ということは言い換えると
  // - x軸側について街を並べた並び
  // - y軸側について街を並べた並び
  // の2つだけを検討したら十分なことがわかります
  sort(x, x + N);
  sort(y, y + N);

  // グラフ構造を引っ張る
  Graph g;
  g.n = N;  // Nノードあります

  // 辺を作っていく
  for (size_t i = 0; i < N - 1; ++i) {
    Edge e;
    e.a = x[i].second;
    e.b = x[i+1].second;
    e.cost = x[i+1].first - x[i].first;
    g.edges.push_back(e);

    e.a = y[i].second;
    e.b = y[i+1].second;
    e.cost = y[i+1].first - y[i].first;
    g.edges.push_back(e);
  }
 
  std::cout << g.kruskal() << std::endl;
  return 0;
}

Measured memory_bytes: 6516
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

class CommonIO {
public:
  CommonIO() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
  }
  ~CommonIO() {}

  template <class T>
  void scan(T &v) {
      std::cin >> v;
  }
  template <class T, class... Rest>
  void scan(T &v, Rest&... rest) {
      scan(v);
      scan(rest...);
  }

  template <class T>
  void print(T v) {
    std::cout << v;
  }
  template <class T>
  void print(std::vector<T> &v) {
    if (v.size() == 0) return;
    print(*v.begin());
    for (auto it = ++v.begin(); it != v.end(); ++it) {
        print(' ');
        print(*it);
    }
  }
  template <class T>
  void print(std::vector< std::vector<T> > &grid) {
    if (grid.size() == 0) return;
    print(*grid.begin());
    for (auto it = ++grid.begin(); it != grid.end(); ++it) {
      print('\n');
      print(*it);
    }
  }
  template <class T, class... Rest>
    void print(T v, Rest... rest) {
    print(v);
    print(' ');
    print(rest...);
  }

  template <class T>
    void printl(T v) {
    print(v);
    std::cout << '\n';
  }
  template <class T, class... Rest>
    void printl(T v, Rest... rest) {
    print(v);
    print(' ');
    printl(rest...);
  }
  #define original_output(obj) std::ostream& operator<<(std::ostream& stream, const decltype(obj)& obj)
} io;


int cnt = 0;

template <typename T>
void insertionSort(vector<T> &a, int g) {
  int n = a.size();
  for (int i=g; i<n; ++i) {
    T v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
        a[j+g] = a[j];
        j -= g;
        cnt++;
    }
    a[j+g] = v;
  }
}

template <typename T>
void shellSort(vector<T> &a) {
  int n = a.size();
  cnt = 0;

  vector<int> g(1, 1);
  for (int i=4; i<n; i=i*3+1) {
    g.push_back(i);
  }
  reverse(ALL(g));
  
  for(auto gap : g) {
    insertionSort(a, gap);
  }
  io.printl(g.size());
  io.printl(g);
  io.printl(cnt);
}

int main() {
  int n; io.scan(n);
  vector<int> a(n);
  REP(i, n) io.scan(a[i]);

  shellSort(a);
  REP(i, n) {
    io.printl(a[i]);
  }

  return 0;
}



Measured memory_bytes: 6796
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;

using namespace std;

int main(){
    int l;  cin >> l;
    string a, b, c;    cin >> a >> b >> c;
    int cnt = 0;
    for(int i=0; i<l; i++){
        if(a[i] == b[i]){
            if(b[i] != c[i])    cnt++;
        }else{
            if(a[i] == c[i])    cnt++;
            else if(b[i] == c[i])    cnt++;
            else    cnt += 2;
        }
    }
    print(cnt);
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	cout<<s.length()-abs(count(s.begin(),s.end(),'0')-count(s.begin(),s.end(),'1'))<<endl;

	return 0;
}


Measured memory_bytes: 512