akhauriyash/Code-Regression huggingface dataset:
H,W = map(int,input().split())
a = [0]*H
for i in range(H):
    a[i]=list(map(int, input().split()))

ans_array = []
ans_cnt = 0
for i in range(H):
    for j in range(W):
        if a[i][j]%2 == 0:
            continue
        else:
            if i !=H-1: 
                if j==W-1:
                    ans_array.append([i,j,i+1,j])
                    # print("1")
                    ans_cnt += 1
                    a[i+1][j]+=1

                else:
                    if a[i][j+1]%2==0:
                        ans_array.append([i,j,i+1,j])
                        # print("2")
                        ans_cnt += 1
                        a[i+1][j]+=1
                    else: 
                        ans_array.append([i,j,i,j+1])
                        # print("3")
                        ans_cnt += 1
                        a[i][j+1]+=1
            else:
                if j==W-1:
                    continue
                else:
                    ans_array.append([i,j,i,j+1])
                    # print("4")
                    ans_cnt += 1
                    a[i][j+1]+=1
                    
                        


print(ans_cnt)
for i in range(len(ans_array)):
    print(ans_array[i][0]+1,ans_array[i][1]+1,ans_array[i][2]+1,ans_array[i][3]+1)



                    
                    

                


Measured memory_bytes: 69212
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val list = StdIn.readLine.split(" ").map(_.toInt)

    val w = list(0)
    val h = list(1)
    val x = list(2)
    val y = list(3)
    val r = list(4)

    if((x+r) > w || (x-r) < 0 || (y+r) > h || (y-r) < 0) println("No")
    else println("Yes")
  }
}

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

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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		int n=sc.nextInt();
		int[]ans=new int[n];
		for(int i=0;i<n-1;i++)
			ans[sc.nextInt()-1]++;
		for(int i:ans)pw.println(i);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 54248
const NUM_OF_AB :usize = 26;
const A_INDEX   :usize = 97;

struct Category {
    //depth    :u32,
    children    :Vec<Category>,
    list        :Vec<String>,
    active_bmp  :u32,
}
impl Category {
    //fn new(depth :u32) -> Category
    fn new() -> Category
    {
        Category {
            //depth:    depth,
            children:   Vec::new(),
            list:       Vec::new(),
            active_bmp: 0,
        }
    }

    fn prepare(&mut self)
    {
        for _ in 0..NUM_OF_AB {
            self.children.push(Category::new());
        }
    }

    fn is_active(&self, key1 :usize, _key2 :usize) -> bool
    {
        let mut ret = false;
        if  (self.active_bmp & (1<<key1)) != 0  {
            //if  (self.children[key1].active_bmp & (1<<key2)) != 0  {
                ret = true;
            //}
        }
        ret
    }

    fn activate(&mut self, key1 :usize, _key2 :usize)
    {
        if  (self.active_bmp & (1<<key1)) == 0  {
            self.children[key1].prepare();
            self.active_bmp |= {1<<key1};
        }
        //println!("len = {}", self.children[key1].children[key2].list.len());
    }

    fn search(&self, word :&String) -> bool
    {
        let mut ret = false;
        for i in 0..self.list.len() {
            if  *word == self.list[i]  {
                ret = true;
                break;
            }
        }
        ret
    }

    fn push(&mut self, word :String)
    {
        self.list.push(word);
    }

    fn num_of_nodes(&self) -> u32
    {
        let mut total :u32 = 0;
        for frst in 0..NUM_OF_AB {
            for scnd in 0..NUM_OF_AB {
                if  self.is_active(frst, scnd)  {
                    total += {self.children[frst].children[scnd].list.len() as u32};
                }
            }
        }
        total
    }
}

fn index_get(c :char) -> usize
{
    let code = c as usize;
    if  code > A_INDEX  {
        code - A_INDEX
    } else {
        0
    }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    let mut prize :Category = Category::new();
    prize.prepare();

    let num_of_prizes :usize = s.trim().parse::<usize>().ok().unwrap();

    for _ in 0..num_of_prizes {
        let mut s1 = String::new();
        std::io::stdin().read_line(&mut s1).ok();

        let mut si = s1.chars();
        let frst = index_get(si.next().unwrap());
        let scnd =
            match  si.next()  {
                None    => 0,
                Some(c) => index_get(c),
            };
        if  !prize.is_active(frst, scnd)  {
            prize.activate(frst, scnd);
        }
        if  !prize.children[frst].children[scnd].search(&s1)  {
            prize.children[frst].children[scnd].push(s1);
        }
    }

    println!("{}", prize.num_of_nodes());
}


Measured memory_bytes: 16460
def resolve():
	n,m = map(int,input().split())
	sc = [tuple(map(int,input().split())) for _ in range(m)]
	for i in range((10**(n-1) if n!=1 else 0),10**n):
		c = 1
		for j in sc:
			if str(i)[j[0]-1] != str(j[1]):
				c = 0
				break
		if c: break
	print(i if c else -1)
    
resolve()

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;

const ull MOD = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    auto A = vc(int, N+1);
    auto B = vc(int, N);
    fa(i, A) cin >> i;
    fa(i, B) cin >> i;
    ull ans = 0;
    int temp;
    for (int i = 0; i < N; i++)
    {
        temp = min(A[i], B[i]);
        B[i] -= temp;
        ans += temp;
        temp = min(A[i+1], B[i]);
        A[i+1] -= temp;
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXVAL = 1e5;

int main() {
  ll n,W;
  cin>>n>>W;
  vector<ll> w(n+1),v(n+1);
  for(ll i = 0; i<n ; i++) {
    cin>>w[i+1]>>v[i+1];
  }
  //dp[n][v] is the min weight for sum of values v
  //dp[n][v] = min(dp[n-1][v],w[n] + dp[n-1][v-v[n]])

  ll a,b,valsum = 0;
  vector<vector<ll>>dp(n+1,vector<ll> (MAXVAL + 1,INT_MAX));
  dp[0][0] = 0;
  for(ll i = 1; i<=n;i++) {
    valsum += v[i];
    for(ll val = 0; val <= valsum ; val++) {
      a = INT_MAX,b = INT_MAX;
      if(val >= v[i] && dp[i-1][val - v[i]] != INT_MAX) {
        a = w[i] + dp[i-1][val-v[i]];
      } 
      b = dp[i-1][val];
      dp[i][val] = min(a,b);
      //printf("dp[%lld][%lld] = %lld\n",i,val,dp[i][val]);
    }
  }
  for(int val = valsum ; val >= 0; val-- ) {
    if(dp[n][val] <= W) {
      printf("%d\n",val);
      break;
    }
  }
}

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

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

int main(){
    int N;cin >> N;
    int g = 0;
    rep(i,N){
        int a;
        cin >> a;
        g = gcd(a,g);
    }
    cout << g << endl;
    return 0;
}

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

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

    int keta = 0;
    int k = n;
    int sum = 0;
    for(int i = 0; i < 10; i++){
        if(k / 10 == 0 && k % 10 == 0){
            break;
        }

            keta = k % 10;
            k -= keta;
            sum += keta;
            k /= 10;
            //cout << k << "  " << sum << endl;
    }

    //cout << sum << endl;

    if(n % sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, x, y; cin >> n >> x;
    int cnt = 1, cur = 0;
    for(int i = 0; i < n; i++) {
        cin >> y;
        cur += y;
        if(cur <= x) cnt++;
    }    
    cout << cnt;
}

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

int main() 
{
    int N;
    cin >> N;
    
    map<int, int>mp;
    for (int i = 1; i < N; i++) {
        int A = 0;
        cin >> A;
        mp[A-1] += 1;
    }
    
    for (int i = 0; i < N; i++) {
        cout << mp[i] << endl;
    }
    
}

Measured memory_bytes: 12972
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <set>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cmath>
#include <sstream>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main() {
	int n, k, ans = 0;
	cin >> n >> k;
	while (n) {
		ans++;
		n /= k;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1e5 + 5;
ll n;

void solve(){
	cin>>n;
	string s;
	cin>>s;
	ll k = s.size();		
	if(k<=n) {
		cout<<s;
	}
	else{
		// string t = s.substr(0, n);
		cout<<s.substr(0, n)<<"...";
	}
}
 
int main(){
	fast;
	ll testcase;
	testcase = 1;
	// cin>>testcase;
	while(testcase--) {
		solve();
	}
}

Measured memory_bytes: 3644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

char bits[1000000];
LL primes[100000], n_primes; 
int cnt[1000000];

void sieve(){
	int i, j;
	memset(bits, 1, 1000000);
	bits[0] = bits[1] = 0;
	for (i = 0; i < sqrt(1000000.0)+1; i++)
		if (bits[i])
			for (j = i * i; j < 1000000; j += i)
				bits[j] = 0;
	for (i = j = 0; i < 1000000; i++)	
		if (bits[i]) primes[j++] = i;
	n_primes = j;
}

int main(){
	sieve();
	FOR(i,1,1000000){
		cnt[i] = cnt[i-1];
		if(bits[i])cnt[i]++;
	}
	int n;
	while(cin>>n)cout << cnt[n] << endl;
	return 0;
}

Measured memory_bytes: 6668
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

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

    int m = n;
    if(n%2 == 1) m--;

    vector<pair<int,int>> p;
    int cnt = 0;

    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            if(m + 1 - j == i){
                continue;
            }
            p.push_back(make_pair(i,j));
            cnt++;
        }
    }

    cout << cnt << endl;
    for(auto i : p){
        cout << i.first << " " << i.second << '\n';
    }

    return 0;
}

Measured memory_bytes: 384
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] hs = ReadIntArray();

	int curr = ((int) 1e+9) + 1;

	for (int i = n - 1; i >= 0; i--)
	{
	    int h = hs[i];
	    if (h > curr + 1)
	    {
		WriteLine("No");
		return;
	    }
	    else if (h == curr + 1)
	    {
		hs[i]--;
	    }
	    curr = hs[i];
	}
	WriteLine("Yes");
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
char A[MC];
int c[26];

int main(){
	scanf("%s" , A);
	int n = 0;
	for(; A[n] != 0 ; ++n){
		++c[A[n]-'a'];
	}
	LL ans = (LL)n * (n-1) / 2;
	repp(i,0,26) ans -= (LL)c[i] * (c[i]-1) / 2;
	printf("%lld\n" , ans + 1);
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> A(n,0),B(n,0),C(n-1,0);
    for(int i=0;i<n;i++)cin>>A[i];
    for(int i=0;i<n;i++)cin>>B[i];
    for(int i=0;i<n-1;i++)cin>>C[i];
    int sat=0;
    sat+=B[A[0]-1];
    for(int i=1;i<n;i++)
    {
     sat+=B[A[i]-1];
     if(A[i]-A[i-1]==1)
     sat+=C[A[i-1]-1];
    }
    cout<<sat;
    return 0;
}


Measured memory_bytes: 256
# D - Moving Piece

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
assert len(p) == len(c) == n

visited = [False] * n
scc = []
for i in range(n):
    if not visited[i]:
        scc.append([])
        j = i
        while not visited[j]:
            visited[j] = True
            scc[-1].append(j)
            j = p[j] - 1

n_scc = len(scc)
subsum = [[0] for i in range(n_scc)]
for i in range(n_scc):
    for j in scc[i]:
        subsum[i].append(subsum[i][-1] + c[j])
    for j in scc[i]:
        subsum[i].append(subsum[i][-1] + c[j])

def lister(k):
    for i in range(n_scc):
        l = len(scc[i])
        loop_score = max(0, subsum[i][l])
        for kk in range(1, min(k, l) + 1):
            base = loop_score * ((k - kk) // l)
            for j in range(kk, l + kk + 1):
                yield base + subsum[i][j] - subsum[i][j - kk]

print(max(lister(k)))


Measured memory_bytes: 74944
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
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 argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    map<ll, ll> m;

    int a;
    rep(i, n) {
        cin >> a;
        if (m.count(a) != 0) {
            m.erase(a);
        }
        else {
            m[a] = 1;
        }
    }

    cout << m.size();



    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> cal(string s)
{
	vector<int> vec(26);
	for(int i=0;i<s.length();i++)
	{
		vec[s[i]-'a']++;
	}
	return vec;
}
bool same(vector<int> vec,vector<int> b)
{
	for(int i=0;i<=25;i++) if(vec[i]!=b[i]) return false;
	return true;
}
int main()
{
	int n;cin>>n;string s;
	map< vector<int> ,int > mp;ll ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		vector<int> cmp=cal(s);
		if(mp.count(cmp))
		{
			//mp[cm]
			ans+=mp[cmp];
			mp[cmp]++;
		}
		else mp[cmp]=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 18944
#include<stdio.h>
int main(void){
	int i,b,f,r,v,j,k,count;
	int room[4][3][10]={0};
	scanf("%d",&count);
	for(i=0;i<count;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		room[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++)
				printf(" %d",room[i][j][k]);
			printf("\n");
		}
		if(i!=3) printf("####################\n") ;
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int h, m, s;

int main()
{
  while(~scanf(" %d %d %d", &h, &m, &s) && h >= 0){
    int rec = 120 * 60 - (60 * 60 * h + 60 * m + s);
    printf("%02d:%02d:%02d\n", rec / 3600, (rec - (rec / 3600) * 3600) / 60, (rec % 60));
    rec *= 3;
    printf("%02d:%02d:%02d\n", rec / 3600, (rec - (rec / 3600) * 3600) / 60, (rec % 60));
  }

  return 0;
}

Measured memory_bytes: 1200
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    //cout << A << '\n'<< B << '\n' << C << '\n' << D << endl ; 
    B *= 100; B += D;
    
    ll X = A*B; X /= 100;
    cout << X << nl;
	
	return 0;
}
 




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

namespace ConsoleApplication1
{
    class DrawingLots
    {
        char[][] map;
        int[] lines;

        int line, startPos, target, depth;

        public DrawingLots(int n, int m, int t, int d)
        {
            line = n;
            startPos = m;
            target = t;
            depth = d;
        }

        public void MakeMap(string[] source)
        {
            map = new char[depth][];

            for (int i = 0; i < depth; i++)
            {
                string temp = "0" + source[i] + "0";

                map[i] = temp.ToCharArray();
            }
        }

        public string Solve()
        {
            if (isTarget()) return "0";

            for (int i = 0; i < depth; i++)
            {
                for (int j = 1; j < line; j++)
                {
                    if (map[i][j] == '1') continue;

                    if (map[i][j - 1] == '0' && map[i][j + 1] == '0')
                    {
                        map[i][j] = '1';

                        if (isTarget()) return string.Format("{0} {1}", i + 1, j);

                        map[i][j] = '0';
                    }
                }
            }
            return "1";
        }

        private bool isTarget()
        {
            lines = Enumerable.Range(0, line + 1).ToArray();

            for (int i = 0; i < depth; i++)
            {
                for (int j = 1; j < line; j++)
                {
                    if (map[i][j] == '1')
                    {
                        int temp = lines[j];
                        lines[j] = lines[j + 1];
                        lines[j + 1] = temp;
                    }
                }
            }
            return lines[target] == startPos;
        }
    }

    class Program
    {
        static void Main()
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int m = int.Parse(Console.ReadLine());
                int t = int.Parse(Console.ReadLine());
                int d = int.Parse(Console.ReadLine());

                DrawingLots DL = new DrawingLots(n, m, t, d);

                string[] source = new string[d];

                for (int i = 0; i < d; i++)
                {
                    source[i] = Console.ReadLine();
                }

                DL.MakeMap(source);

                sb.AppendLine(DL.Solve());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9624
N,A,B=map(int,input().split())
sum = 0
for N in range(1,N+1):
  a=N%10
  b=(N//10)%10
  c=(N//100)%10
  d=(N//1000)%10
  e=(N//10000)%10
  S=a+b+c+d+e
  
  if A <= S and S <= B:
    sum += (a+b*10+c*100+d*1000+e*10000)
    
print(sum)

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll n;
    cin >> n;

    ll h[n];

    rep(i,n)
    {
    	cin >> h[i];
    }
    ll maxi = 0;

    ll ans = 0;
    rep(i,n)
    {
    	if(h[i]>=maxi)
    		ans++;
    	maxi = max(maxi,h[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
x0,y0,x1,y1 = map(float,input().split())
n = int(input())
vx1,vy1 = x1-x0,y1-y0

for i in range(n):
    x2,y2 = map(float,input().split())
    vx2,vy2 = x2-x0,y2-y0
    sqr = vx1**2 + vy1**2
    in_p = vx1*vx2 + vy1*vy2
    xt,yt = in_p*vx1/sqr + x0,in_p*vy1/sqr + y0
    print("{0:.10f} {1:.10f}".format(xt,yt))

Measured memory_bytes: 7672
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll firstTerm=(4*a*b);
    ll secondTerm=(c-a-b)*(c-a-b);
    if((c-a-b)<=0){
        cout<<"No\n";
    }else if(firstTerm<secondTerm){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N,M;
    ll K;
    cin >> N >> M >> K;
    bool ans = false;
    rep(i,N + 1){
        rep(j,M + 1){
            if(j * (N - i) + i * (M - j) == K)ans = true;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};
function max(list){return list.reduce(function(a,b){ return Math.max(a,b) }) }
function min(list){return list.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(list){return list.reduce(function(a,b){ return a+b }) }
function sortex(list, index){list.sort((a, b) => a[index] - b[index])}
function all(list){return list.reduce(function(a,b){ return a && b }) }
function any(list){return list.reduce(function(a,b){ return a || b }) }
function equal(arr, brr){
    if (arr.length !== brr.length){ throw new Error("length not match") }
    let crr = new Array(arr.length)
    for (let i = 0; i < arr.length; i++){ crr[i] = (arr[i] === brr[i]) }
    return all(crr)
}
/*START*/

function isneg(x){if(x[0]=="-"){return true}else{return false}}
function neg(x){if(isneg(x)){return x.slice(1, x.length)}else{return "-"+x}}

function zerot(x){
    let rx = Array.from(x).reverse()    
    while(rx[rx.length - 1] === "0"){
        rx.pop()
        if (rx.length === 0){
            rx = ["0"]
            break;
        }
    }
    return rx.reverse().join("")
}

function zerocut(x){
    if (isneg(x)){
        let ans = neg(zerot(neg(x)))
        if (ans === "-0"){ return "0" }
        return ans
    }else{
        return zerot(x)
    }
}

function bigsmal(x, y){
    if (isneg(x) || isneg(y)){ throw new Error("negative input") }
    if (x.length > y.length){
        return [x, y]
    }else if(x.length < y.length){
        return [y, x]
    }else{
        return [x, y].sort().reverse()
    }
}


function bigsmall(x, y){
    if (!isneg(x) && isneg(y)){
        return [x,y]
    }else if (isneg(x) && !isneg(y)){
        return [y,x]
    }else if (!isneg(x) && !isneg(y)){
        return bigsmal(x, y)
    }else if (isneg(x) && isneg(y)){
        let tmp = bigsmal(neg(x), neg(y)).reverse()
        return Array.from(tmp, i => neg(i))   
    }
}


let n = input()
if (equal(bigsmall("999", n), ["999", n])){
    print("ABC")
}else{
    print("ABD")
}

/*END*/
console.log(stdout.join("\n"));
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7624
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}



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 = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if (a == b) {
            System.out.println("Draw");
        } else if ((a > b && b != 1) || a == 1) {
            System.out.println("Alice");
        } else {
            System.out.println("Bob");
        }
    }
}

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

using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int ans;
	for(int i=1;i<s.size();i++){
	    if(s[i-1]==s[i])    ans++;
	}
	ans=min(n-1,ans+2*k);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define hell 1000000007
#define PI acos(-1.0)
#define S second
#define F first
#define lli long long int
#define li long int
#define ld long double
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define run(j, n) for(auto ii=j;ii!=n;ii++)
#define out(j, n) for(auto ii=j;ii!=n;ii++) cout<<(*ii)<<" ";




int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);


int n;cin>>n;
lli ar[n];for(int i=0;i<n;i++) cin>>ar[i];
sort(ar, ar+n, greater<lli>());
int k=0;
if(n==1)
{
  cout<<0;return 0;
} 
lli ans = ar[k];k++;
for(int i=2;i<n;i++)
{
  if(i+1<n)
  {
    ans+=2*ar[k];k++;i++;
  }
  else
  {
    ans+=ar[k];
  }

}
cout<<ans;

return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define mem(i,j) memset(i,j,sizeof(i))
#define pl (p<<1)
#define pr (p<<1)|1
#define int long long
using namespace std;
inline int read(){
	char ch=' ';int res=0,f=1;
	while(!isdigit(ch)){ch=getchar();if(ch=='-')f=-1;}
	while(isdigit(ch)){res=res*10+ch-'0';ch=getchar();}
	return res*f;
}
int _min(int x,int y){return x<y?x:y;}
int _max(int x,int y){return x>y?x:y;}
const int N=2e5+5;
int n,a[N];
bool judge(int x){
	for(register int i=0;i<n-1;i++) {
	 	if((a[n+i]>x&&a[n+i+1]>x)||(a[n-i]>x&&a[n-i-1]>x)) return 0;
	 	else if((a[n+i]<=x&&a[n+i+1]<=x)||(a[n-i]<=x&&a[n-i-1]<=x)) return 1;
	 }
	 return a[1]<=x;
}
#undef int
int main() {
	n=read();
	for(register int i=1;i<2*n;i++)a[i]=read();
	int l=1,r=2*n-1,ans;
	while(l<r){
		int mid=(l+r)>>1;
		if(judge(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}

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

int h,w,n;

bool in(int x,int y){
	if(x<0 || x>=w || y<0 || y>=h) return false;
	return true;
}

void print(vector<string> M){
	for(int i=0;i<M.size();i++)
		cout<<M[i]<<endl;
	cout<<endl;
}

bool do_clear(vector<string> &M){
//	print(M);
	bool update=false;

	vector<vector<bool> > ok(h,vector<bool>(w,false));

	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if(M[y][x]=='.') continue;
			char now=M[y][x];
			int ty=y,tx=x,num=0;
			while(in(tx,ty) && M[ty][tx]==now){
				num++;
				tx++;
			}
			tx--;
			if(num>=n){
				for(int i=0;i<num;i++){
					ok[y][tx-i]=true;
				}
			}

			ty=y;tx=x;num=0;
			while(in(tx,ty) && M[ty][tx]==now){
				num++;
				ty++;
			}
			ty--;
			if(num>=n){
				for(int i=0;i<num;i++){
					ok[ty-i][tx]=true;
				}
			}
		}
	}

	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if(ok[y][x]){
				M[y][x]='.';
				update=true;
			}
		}
	}
	return update;
}

bool calc(vector<string> M,int x,int y){

	swap(M[y][x],M[y][x+1]);
	
	bool update=true;
	while(update){
		update=false;
		for(int y=h-1;y>=0;y--){
			for(int x=0;x<w;x++){
				int ty=y+1;
				if(M[y][x]=='.') continue;
				while(in(x,ty) && M[ty][x]=='.') ty++;
				ty--;
				if(y==ty) continue;
				update=true;
//				print(M);
//				cout<<y<<" "<<ty<<endl;
				M[ty][x]=M[y][x];
				M[y][x]='.';
			}
		}
		
		update=do_clear(M);
	}

	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if(M[y][x]!='.') return false;
		}
	}
	return true;
}


int main()
{
	while(cin>>h>>w>>n && h!=0){
		vector<string> M;
		for(int i=0;i<h;i++){
			string s;
			cin>>s;
			M.push_back(s);
		}
		bool ok=false;
		for(int y=0;y<h;y++){
			if(ok) break;
			for(int x=0;x<w-1;x++){
				if(M[y][x]!=M[y][x+1])
					if(calc(M,x,y)){ok=true;break;}
			}
		}
		if(ok) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
    using namespace std;
     
    #define       pb(a)             push_back((a))
    #define       mp(a,b)           make_pair((a),(b))
    #define       REP(a,b)          for(ll i=(a);i<(b);i++)
    #define       REP2(a,b)         for(ll j=(a);j<(b);j++)
    #define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
    #define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
    #define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
    #define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
    #define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
    #define       all(v)            (v).begin(),(v).end()
    #define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
    #define       INF               INT_MAX
    #define       sz(x)             x.size()
    #define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define       F                 first
    #define       S                 second
    #define       MOD               1000000007
     
    using         ll     = long long;
    using         vi     = vector<int>;
    using         vvi    = vector<vi>;
    using         vll    = vector<ll>;
    using         vvll   = vector<vll>;
    using         vb     = vector<bool>;
    using         vd     = vector<double>;
    using         vs     = vector<string>;
    using         pii    = pair<int, int>;
    using         pll    = pair<ll, ll>;
    using         pdd    = pair<double, double>;
    using         vpii   = vector<pii>;
    using         vvpii  = vector<vpii>;
    using         vpll   = vector<pll>;
    using         vvpll  = vector<vpll>;
    using         vpdd   = vector<pdd>;
    using         vvpdd  = vector<vpdd>;
     
     
    ll gcd(ll a,ll b){
    	if(b==0)return a;
    	return gcd(b,a%b);
    }
    ll lcm(ll a,ll b){
     
    	return a*b/gcd(a,b);
    }
     
    ll ceeel(ll n,ll a){
    	if(n%a==0) return n/a;
    	return n/a +1;
    }
    ll power(ll x, ll y){
    	ll ans=1;
    	REP(0,y){
    		ans*=x;
    	}
    	return ans;
    }

ll getfirst(ll n){
	ll temp = 0;
	while(n){
		temp = n%10;
		n/=10;
	}
	return temp ;
}
ll getlast(ll n){
	return n%10;
}
ll fact(ll n) 
{ 
    if (n <= 1) 
        return 1; 
    return n*fact(n-1); 
} 
  
ll nPr(ll n, ll r) 
{ 
    return fact(n)/fact(n-r); 
} 
     
    void solve(){
    	ll n; cin >> n;
    	map < pair<ll,ll> , ll > mp;
    	REP(1,n+1){
    		ll l,f; 
    		l = getlast(i);
    		f = getfirst(i);
    		if(l!=0 and f!=0){
    			mp[mp(f,l)]++;
    		}
    	}
    	ll ans = 0 ;
    	// cout<<sz(mp)<<endl;
    	Trvs(mp){
    		ans += ((*it).S * mp[mp((*it).F.S,(*it).F.F)]);
    	}
    	cout<<ans<<endl;
}
     
    	
     
     
    int main(){
     
    	flash
    	
   
    	
    	//ll t;cin>>t;while(t--)
    	solve();
     
     
    	return 0;
    }

Measured memory_bytes: 256
using Yorukatsu048.Questions;
using Yorukatsu048.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu048.Questions
{
    /// <summary>
    /// ABC158 B
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nab = inputStream.ReadLongArray();
            var n = nab[0];
            var blue = nab[1];
            var red = nab[2];

            var rep = n / (blue + red);
            var mod = n % (blue + red);

            yield return rep * blue + Math.Min(blue, mod);
        }
    }
}


namespace Yorukatsu048
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu048.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu048.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

class Str
{
public:

	string str;

	Str(){}
	Str(string c)
	{
		str = c;
	}

	bool operator=(const Str & a)const
	{
		return str == a.str;
	}

	bool operator<(const Str & a)const
	{
		if(str.length() == a.str.length())
		{
			return str < a.str;
		}
		return str.length() < a.str.length();
	}
};

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

	vec num(3, 0);
	ll ans = 1;
	for (int i = 0; i < N; ++i)
	{
		int A;
		cin >> A;

		int k = -1;
		int cnt = 0;
		for (int j = 0; j < 3; ++j)
		{
			if (num[j] == A) 
			{ 
				cnt++;
				k = j;
			}
		}

		if (cnt == 0)
		{
			cout << 0 << endl;
			return 0;
		}
		ans *= cnt;
		ans %= MOD;
		num[k]++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int n = Integer.parseInt(str);
        for (int i = 0; i < n; i++) {
            str = br.readLine();
            String[] coordinate = str.split(" ", 8);
            double x1 = Double.parseDouble(coordinate[0]);
            double y1 = Double.parseDouble(coordinate[1]);
            double x2 = Double.parseDouble(coordinate[2]);
            double y2 = Double.parseDouble(coordinate[3]);
            double x3 = Double.parseDouble(coordinate[4]);
            double y3 = Double.parseDouble(coordinate[5]);
            double x4 = Double.parseDouble(coordinate[6]);
            double y4 = Double.parseDouble(coordinate[7]);
            double a = (y1 - y2) * (x3 - x4) - (y3 - y4) * (x1 - x2);
            if (Math.floor(Math.abs(a * Math.pow(100000,2))) == 0.0) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 24488
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
  string cmd; // command
  int digit; // digit to insert
  priority_queue<int> Q;
  while (cin >> cmd && cmd != "end") {
    if (cmd == "insert") {
      cin >> digit;
      Q.push(digit);
    } else if (cmd == "extract") {
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}

Measured memory_bytes: 5716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

int main(){
    int n;
    cin >> n;
    string S,hozon[105];
    bool flag = true;

    for(int i = 0; i < n; i++){
        char temp;
        cin >> S;
        if(i != 0 && temp != S[0]){ 
            flag = false;
        }
        for(int j = 0; j < i; j++){
            if(S == hozon[j]){
                flag = false;
            }
        }
        hozon[i] = S;
        temp = S[S.length()-1];
    }

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

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
 int i,j;
 
 for(i = 1; i <= 9; ++i) {
  for(j = 1; j <= 9; ++j) {
   cout << i << "x" << j << "=" << i * j << endl;
  }
 }

 return 0;
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    divisors.sort()
    return divisors

ans=make_divisors(n)
print(ans[len(ans)//2-1]+ans[len(ans)//2]-2)

Measured memory_bytes: 3264