akhauriyash/Code-Regression huggingface dataset:
mod = 10**9 + 7

def iip(listed = False):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod

#####################################################ライブラリ集ここまで

def main():
    n = iip()
    ret = 0
    ret += (n // 500) * 1000
    n = n % 500
    ret += (n // 5) * 5
    print(ret)


if __name__ == "__main__":
    main()

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

int main(){
   int h,w;
   cin >> h >> w;
   vector<vector<char>>pic(h,vector<char>(w));
   rep(i,h)rep(j,w) cin >> pic[i][j];

   rep(i,w+2) cout << '#';
   cout << endl;
   for(int i=0;i<h;i++){
       cout << '#';
       for(int j=0;j<w;j++){
           cout << pic[i][j];
       }
        cout << '#';
       cout << endl;
   }
   rep(i,w+2) cout << '#';
   cout << endl;
   return 0;
}

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

class Program{

  static int ans = 0;

  static int Main() {

    string nyu =  Console.ReadLine();
    char[] nya = nyu.ToCharArray();

    for (int i = 0; i < 4; i ++) {
      if (nya[i] == '+') {
        ans ++;
      } else {
        ans --;
      }
    }

    Console.WriteLine("{0}", ans);

    return 0;
  }

}


Measured memory_bytes: 13140
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
  int N,M;
  vector<long> H;
  pair<int,int> PATH;
  vector< pair<int,int> > PATHES;
  vector<bool> Good;
  cin>> N>>M;
  long H_;
  for(int i=0;i<N;i++){
    cin>>H_;
    H.push_back(H_);
    Good.push_back(true);
  }
  int A,B;
  for(int i=0;i<M;i++){
    cin>>A>>B;
    PATH=make_pair(A-1,B-1);
    PATHES.push_back(PATH);
  }
  int lesser;
  for(int i=0;i<M;i++){
    if(H[PATHES[i].first]<H[PATHES[i].second]){
      Good[PATHES[i].first]=false;
    }else if(H[PATHES[i].first]>H[PATHES[i].second]){
      Good[PATHES[i].second]=false;

    }else{
      Good[PATHES[i].first]=false;
      Good[PATHES[i].second]=false;
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(Good[i]){
      ans++;
    }
  }
  cout<<ans;






}

Measured memory_bytes: 5632
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
map<int, int> m;
int N, K, Num[200005], Nidx, result;

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++)
    {
        int num;
        scanf("%d", &num);
        m[num]++;
    }
    map<int, int>::iterator it;
    for(it = m.begin(); it != m.end(); it++)
    {
        Num[Nidx++] = it->second;
    }
    sort(Num, Num + Nidx);
    int size;
    size = m.size();
    for(int i = 0; i < size - K; i++)
    {
        result += Num[i];
    }
    printf("%d", result);
}

Measured memory_bytes: 10368
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], a = tmp[1], b = tmp[2];
    int ans;
    foreach (i; 1 .. n+1) {
        string s = i.to!string;
        int m;
        foreach (x; s) {
            m += (x - '0');
        }
        if (a <= m && m <= b) ans += i;
    }
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 380
use proconio::*;
use std::cmp::*;
use std::vec::Vec;
use std::cmp::Ordering;


/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less | Ordering::Equal => {
                    low = mid + 1;
                }
                Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    input! {
        n: usize,
        mut L: [i32; n],
    }
    L.sort();
    let mut res = 0;
    for a in 0..n{
        for b in a + 1..n{
            let ma = L[a] + L[b];
            let mi = L[b] - L[a];
            let left = L.upper_bound(&mi);
            let right = L.lower_bound(&ma);
            let mut cnt = right - left;
            if mi < L[a] && L[a] < ma {
                cnt -= 1;
            }
            if mi < L[b] && L[b] < ma {
                cnt -= 1;
            }
            res += cnt;
        }
    }
    println!("{}", res / 3);
}

Measured memory_bytes: 2164
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	pp := make(Pairs, n)

	for i := 0; i < n; i++ {
		a := getNextInt64(scanner)
		pp[i] = &Pair{
			a: a,
			b: 0,
		}
	}
	for i := 0; i < n; i++ {
		pp[i].b = getNextInt64(scanner)
	}
	sort.Sort(pp)

	var inc int64
	for i := 0; i < n; i++ {
		if pp[i].a > pp[i].b {
			inc += pp[i].a - pp[i].b
			continue
		}
		inc -= (pp[i].b - pp[i].a) >> 1
	}

	if inc > 0 {
		fmt.Fprintln(writer, "No")
	} else {
		fmt.Fprintln(writer, "Yes")
	}

	writer.Flush()
}

// Pair ...
type Pair struct {
	a, b int64
}

// Pairs ...
type Pairs []*Pair

func (a Pairs) Len() int           { return len(a) }
func (a Pairs) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Pairs) Less(i, j int) bool { return a[i].a-a[i].b > a[j].a-a[j].b }


Measured memory_bytes: 1408
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)

def lcm(a, b):
    return a*b//gcd(a,b)
#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = [a for a in A]
    T = 1
    L = 1
    C = [0]*N
    for i in range(N):
        for _ in range(30):
            if B[i]%2 == 0:
                B[i] //= 2
                C[i] += 1
            else:
                break
    p = C[0]
    for i in range(N-1):
        if p != C[i+1]:
            print(0)
            return
    q = pow(2,p)
    t = 1
    for i in range(N):
        t = lcm(t,A[i]//2)
    if t > M:
        print(0)
        return

    print((M-t)//(t*2) + 1)

if __name__ == '__main__':
    main()



Measured memory_bytes: 14244
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   for(ll i=k;i<n;i++){
       
       if(arr[i]>arr[i-k])
            cout<<"Yes\n";
       else cout<<"No\n";        
       
   }
   
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 5216
n = gets.to_i
a = gets.split.map(&:to_i)

a_max = 0
x = 0
a_max = a.max
a_min = a.min

p 2*n-1
if a_max.abs >= a_min.abs
  x = a.index(a_max)
  n.times{ |t| puts "#{x+1} #{t+1}" }
  (n-1).times{ |t| puts "#{t+1} #{t+2}" }
else
  x = a.index(a_min)
  n.times{ |t| puts "#{x+1} #{t+1}" }
  n.downto(2){ |t| puts "#{t} #{t-1}" }
end



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

const int N = 2e3 + 10;

int n;
int dis[N][N];
int cnt[N];

vector<int> g[N];

void dij(int s) {
    int d[N];
    memset(d, 63, sizeof d);
    priority_queue<int> q;
    q.push(s);
    d[s] = 0;
    while (!q.empty()) {
        int u = q.top(); 
        q.pop();
        for (int v : g[u]) {
            if (d[v] > d[u] + 1) {
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        dis[s][i] = d[i];
        ++cnt[d[i]];
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int u, v;
    cin >> n >> u >> v;
    for (int i = 1; i <= n - 1; i++) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[u].push_back(v);
    g[v].push_back(u);
    for (int i = 1; i <= n; i++) {
        dij(i);
    }
    for (int k = 1; k <= n - 1; k++) {
        cout << (cnt[k] >> 1) << '\n';
    }
}   

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define precise(x) cout<<fixed<<setprecision(12)<<x
#define test cout<<"#";

const ll INF = 1e18L + 5;

ll solve(ll k, vector<ll> &v, ll ans[], ll visit[])
{
	if(k==0)
		return 0;
	if(visit[k])
		return ans[k];
	ans[k] = 1;
	for(auto u:v)
	{
		if(u<=k)
			ans[k] &=solve(k-u, v, ans, visit);
	}
	ans[k] = 1-ans[k];
	visit[k] = 1;
	return ans[k];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[k+1];
	ll visit[k+1]={0};
	cout<<(solve(k, v, ans, visit)==1?"First":"Second");	
}

Measured memory_bytes: 9600
#include <stdio.h>
 
int main() {
  int n;
  int b, f, r, v;
  int i, j, k;
 
  int tenants[4][3][10] = {{{}}};
 
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    tenants[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", tenants[i][j][k]);
      }
      printf("\n");
    }
    if(i != 3) printf("####################\n");
  }
 
  return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#define inf 1e9
using namespace std;
int solve(vector<int> ar, int n, int k)
{
    vector<int> dp(n+1);
    dp[1] = 0;
    for(int i = 2 ; i <= n; i++)
    {
        dp[i] = inf;
        for(int j = i - 1; j >= 1 && (i - j) <= k; j--)
        {
            dp[i] = min(dp[i], abs(ar[i] - ar[j]) + dp[j]);
        }
    }
    return dp[n];
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> ar(n+1);
    for(int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    cout << solve(ar, n, k);
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int a, b, c, k, x, y, i, ans;
    scanf("%d %d", &a, &b);
    if(a==b) ans = a + b;
    else if(a>b) ans = a + a - 1;
    else ans = b + b - 1;
    printf("%d", ans);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n, t, e;
	int x;
	int i, j;
	int reverse;
	int flag;
	
	/*砂時計の数・理想的な時間・許容範囲を入力*/
	scanf("%d %d %d", &n, &t, &e);
	
	/*砂時計*/
	/*for (i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}*/
	
	
	/*全ての砂時計で調べる*/
	for (i = 0; i < n; i++){
		/*  i + 1 個目の測れる時間を入力*/
		scanf("%d", &x);
		
		/*時刻の許容範囲内を調べる*/
		for (j = -e; j <= e; j++){
			reverse = 1;/*ひっくり返した数の初期化*/
			flag = 0;
			while (t + j >= x * reverse){/*誤差よりも大きくなったら抜ける*/
				if (t + j == x * reverse){
					flag = 1;
					break;
				}
				reverse++;
			}
			
			if (flag == 1){
				break;
			}
		}
		
		if (flag == 1){
			break;
		}
	}
	
	if (flag == 1){
		printf("%d\n", i + 1);
	}
	else {
		printf("-1\n");
	}
	
	return (0);
}

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

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

int main()
{
    int x;
    cin >> x;
    int cnt = 0;

    while (true)
    {
        x = x - 3;
        if (x < 0)
            break;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int N= 200100 , shift = 100100;
int n , k , x[N] , ans = 1<<30;

ll ret;
int bit[N];
void add(int i,int x){ for(;i<N;i+=i&-i)bit[i]+=x; }
ll get(int i){ for(ret=0;i;i-=i&-i)ret+=bit[i]; return ret; }


bool ok(int M){
ll all = 1ll* n * (n+1) / 2ll;
ll cnt = 0 , sum =0 ;
memset(bit,0,sizeof bit);
add(shift,1);
for(int i=1;i<=n;i++){
    sum += ( x[i] <= M );
    cnt += get( sum+sum-i+shift-1 );
    add(sum+sum-i+shift,1);
}
return cnt+cnt > all;
}

int main(){

scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",x+i);

int low=1,high=1e9 +5;
while( low < high ){
    int mid = low+high>>1;
    if( ok(mid) )high=mid;
    else low=mid+1;
}
printf("%d\n",high);
return 0;
}


Measured memory_bytes: 1408
using System;

namespace abc139_a
{
    static class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var n = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == t[i])
                {
                    n++;
                }
            }

            Console.WriteLine($"{n}");
        }
    }
}


Measured memory_bytes: 13268
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int W, H;
  while (cin >> W >> H, W) {
    vs v(H);
    rep(i, H) cin >> v[i];
    vvi dp(H, vi(W));
    int b = 0, w = 0;
    rep(i, H) rep(j, W) {
      dp[i][j] = 2 * (v[i][j] == 'B') + (v[i][j] == 'W');
      b -= v[i][j] == 'B';
      w -= v[i][j] == 'W';
    }
    rep(_, W * H) rep(i, H) rep(j, W) {
      if (v[i][j] != '.') continue;
      if (i > 0) dp[i][j] |= dp[i - 1][j];
      if (j > 0) dp[i][j] |= dp[i][j - 1];
      if (i < H - 1) dp[i][j] |= dp[i + 1][j];
      if (j < W - 1) dp[i][j] |= dp[i][j + 1];
    }
    rep(i, H) rep(j, W) {
      b += dp[i][j] == 2;
      w += dp[i][j] == 1;
    }
    cout << b << ' ' << w << endl;
  }
}

Measured memory_bytes: 3124
//Do what you can't.
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    char a=in.readString().charAt(0);
    char b=in.readString().charAt(0);
    char c=in.readString().charAt(0);
    w.println(Character.toUpperCase(a)+""+Character.toUpperCase(b)+""+Character.toUpperCase(c));

    w.close();
    }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAXV = 101;
static const long long INF = 1LL << 32;

int v, e;
long long A[MAXV][MAXV];

int main() {
	int i, j, k, s, t, d;
	
	cin >> v >> e;

	//initWarshallFloyd
	for (i = 0; i < v; i++) {
		for (j = 0; j < v; j++) {
			A[i][j] = INF;
		}
		A[i][i] = 0;
	}

	//make A^0[i][j]
	for (i = 0; i < e; i++) {
		cin >> s >> t >> d;
		A[s][t] = d;
	}

	//warshallFloyd
	for (k = 0; k < v; k++) {
		for (i = 0; i < v; i++) {
			if (A[i][k] == INF)continue;
			for (j = 0; j < v; j++) {
				if (A[k][j] == INF)continue;
				A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
			}
		}
	}

	//check
	for (i = 0; i < v; i++) {
		if (A[i][i] < 0) {
				cout << "NEGATIVE CYCLE" << endl;
				return 0;
		}
	}

	//print
	for (i = 0; i < v; i++) {
		for (j = 0; j < v - 1; j++) {
			if (A[i][j] == INF)cout << "INF ";
			else cout << A[i][j] << " ";
		}
		if (A[i][j] == INF)cout << "INF" << endl;
		else cout << A[i][v - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3180
#include<iostream>

using namespace std;

int main()
{
    int a,b,c,d,e,f;
    cin>>a;
    cin>>b;
    cin>>c;
    d=a+b;
    e=b+c;
    f=a+c;

    if((a>b&&a>c)||(c==b&&c<a)||(a==b&&a>c))
    {

        cout<<e<<endl;
    }
    else if((b>c&&b>a)||(a==c&&a<b)||(b==c&&b>a))
    {
        cout<<f<<endl;
    }
    else if((c>a&&c>b)||(a==b&&a<c)||(a==c&&c>b))
    {
        cout<<a+b<<endl;
    }
    else if(a==b&&a==c)
    {
        cout<<a+b<<endl;
    }


    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	string s;
	int f[256] = {0};
	cin >> s;
	for(int i=0 ; i < s.size() ; i++ ){
		f[ s[i] ]++;
	}
	cout << min( min(f['K'],f['U']) , min(f['P'],f['C']) ) << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
 
using namespace std;
 
struct Point { double x,y; };
typedef pair<double,double> Segment;
const int MAX_N = 2010;
const int IINF = INT_MAX;
int N;
double sx[MAX_N],sy[MAX_N],ex[MAX_N],ey[MAX_N];
 
inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }
inline bool inside(double a,double b,double c) { return LTE(a,c) && LTE(c,b); }
inline double getDist(double x,double y) { return sqrt(x*x+y*y); }
 
int main(){
  scanf("%d",&N);
  vector<Segment> segs(N);
  rep(i,N) {
    scanf("%lf %lf %lf %lf",sx+i,sy+i,ex+i,ey+i);
    vector<Point> vec(4);
    vec[0] = (Point){sx[i],sy[i]};
    vec[1] = (Point){sx[i],ey[i]};
    vec[2] = (Point){ex[i],sy[i]};
    vec[3] = (Point){ex[i],ey[i]};
    segs[i] = Segment(IINF,-IINF);
    rep(j,4){
      double arg = atan2(vec[j].y,vec[j].x) * 180 / M_PI;
      if( LT(arg,0.0) ) arg += 360;
      if( sx[i] > 0 && sy[i] < 0 && ey[i] >= 0 ) {
        if( LTE(0.0,arg) && LTE(arg,91.0) ) arg += 360;
      } 
      segs[i].first  = min(segs[i].first ,arg);
      segs[i].second = max(segs[i].second,arg);
    }
  }
 
  sort(segs.begin(),segs.end());
  rep(i,N) segs.push_back(Segment(segs[i].first+360,segs[i].second+360));
  int ans = N;
  rep(i,N){
    int cost = 0;
    double L,R;
    REP(j,i,i+N){
      cost++;
      L = segs[j].first, R = segs[j].second;
      while( j+1 < i+N && ( inside(L,R,segs[j+1].first) || inside(L,R,segs[j+1].second) ) ){
        j++;
        L = max(L,segs[j].first);
        R = min(R,segs[j].second);
      }
    }
    ans = min(ans,cost);
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1488
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
ll a[N];


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	ll cnt=0;
	 for(int i=1;i<=n;++i){
	 	cin>>a[i];
	 	cnt=cnt^a[i];
	 }
	 for(int i=1;i<=n;++i){
	 	ll tmp=cnt^a[i];
	 	cout<<tmp<<" ";
	 }



    return 0;
}


Measured memory_bytes: 5048
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_c

n = int(input())
strings = []
for _ in range(n):
    strings.append(input())

ans = 0
head_b = tail_a = both = 0
for s in strings:
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
    elif s[0] == 'B':
        head_b += 1
    elif s[-1] == 'A':
        tail_a += 1

if both == 0:
    ans += min(head_b, tail_a)
elif head_b + tail_a == 0:
    ans += max(both - 1, 0)
else:
    ans += both + min(head_b, tail_a)
print(ans)


Measured memory_bytes: 44248
#include<map>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a,b,j,m;
int n=0;
int main(){
	scanf("%c%c%c%c",&a,&b,&j,&m);
	if(a=='+')n+=1;
	else if(a=='-')n-=1;
	if(b=='+')n+=1;
	else if(b=='-')n-=1;
	if(j=='+')n+=1;
	else if(j=='-')n-=1;
	if(m=='+')n+=1;
	else if(m=='-')n-=1;
	printf("%d",n);
}

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

typedef long long ll;
ll min (ll a,ll b);

int main(){
    ll k = 0;
    ll n = 0;
    ll *a;
    
    ll buf = 0;
    cin >> k >> n;
    a = new ll[n];
    ll ans = 0;
    cin >> a[0];
    for(ll i = 1; i < n; i++){
        cin >> a[i];
        buf = a[i] - a[i - 1];
        if(ans <= buf){
            ans = buf;
        }
    }   
    buf = k - a[n-1] + a[0];
    if(ans <= buf){
        ans = buf;
    }

    cout << k - ans << endl;
    return 0;

}

ll min(ll a,ll b){
    if(a >= b) return b;
    else return a;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<30;
const ll mod = 1000000007;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n, m; cin >> n >> m;
  vvi jobs(m);

  rep(i,n) {
    int a, b; cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }

  priority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5632
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
fun main(args:Array<String>?): Unit {
    while (true) {
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val message = readLine()!!.trim().toCharArray()
        val operation = List(n) {
            val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
            Pair(a, b)
        }
        for ((a, b) in operation.asReversed()) {
            message.swap(a, b)
        }
        println(message.joinToString(""))
    }
}

fun CharArray.swap(a: Int, b: Int): Unit {
    val aChar = 'a' + (this[a - 1] - 'a' + b - a) % 26
    val bChar = 'a' + (this[b - 1] - 'a' + b - a) % 26
    this[a - 1] = bChar
    this[b - 1] = aChar
}


Measured memory_bytes: 31692
#include<iostream>
#include<cstdio>
#include<queue>
int main() {
    int n,m,x;
    scanf("%d%d",&n,&m);
    std::priority_queue<int> q;
    long long ans=0;
    for(int i=1;i<=n;i++) {
        scanf("%d",&x);
        ans+=x;
        q.push(x);
    }
    while(!q.empty()&&m--) {
        int x=q.top();q.pop();
        int y=x/2;
        ans-=x-y;
        if(y) q.push(y);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D=0;
  str N;
  cin>>A;
  cout<<48-A<<endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    }
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        cs: chars,
    }
    let mut num0 = 0;
    let mut num1 = 0;
    for c in cs {
        match c {
            '0' => num0 += 1,
            '1' => num1 += 1,
            _ => panic!(""),
        }
    }
    let ans = (num0 + num1) - (cmp::max(num0, num1) - cmp::min(num0, num1));
    println!("{}", ans);
}

Measured memory_bytes: 4352
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = k; i < n; i++) {
        const bool ans = a[i] > a[i - k];
        cout << (ans ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 4780
#include <iostream> 
#include <vector>
using namespace std;
const int MAX = 1299710;
int prime[MAX];

int cal(int n){
  int l = 0;
  int f = 0;
  for(l = n;!prime[l];l++){
  }
  for(f = n;!prime[f];f--){
  }
  return l - f;
  
}
int main(){
  prime[1] = 0;
  prime[2] = 1;
  fill(prime,prime+MAX,1);
  for(int i = 2;i < MAX;i++){
    if(prime[i]){
      for(int j = i+i;j < MAX;j+=i){
	prime[j] = 0;
      }
    }
  }
  /*  for(int i = 1;i < 100;i++){
    if(prime[i])cout << i << endl;
    }*/
  int n;
  while(cin >> n,n != 0){
    cout << cal(n) << endl;
  }

  return 0;
}

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

using namespace std;

int memo[100][100][2][2];

int w, h;

int rec(int i, int j, int vec, int f)
{
	if ((i < 0 || i >= w) || (j < 0 || j >= h)) return 0;

	if (i == w - 1 && j == h - 1) return 1;

	if (memo[i][j][vec][f] >= 0) return memo[i][j][vec][f];

	int res;

	if (vec == 0) { // ??????????????§?????´???
		if (f) { // ????????£???
			res = rec(i + 1, j, 0, 0);
		} else {
			res = rec(i + 1, j, 0, 0) + rec(i, j + 1, 1, 1);
		}
	} else { // ??????????????§?????´???
		if (f) { // ????????£???
			res = rec(i, j + 1, 1, 0);
		} else {
			res = rec(i + 1, j, 0, 1) + rec(i, j + 1, 1, 0);
		}
	}

	return memo[i][j][vec][f] = res % 100000;
}

int main()
{
	while (cin >> w >> h, w || h) {
		memset(memo, -1, sizeof(memo));

		cout << (rec(1, 0, 0, 0) + rec(0, 1, 1, 0)) % 100000 << endl;
	}
}

Measured memory_bytes: 1336
#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>;

const ll INF = 1e18;

int main(){
  int n;
  cin >> n;
  vector<string> w(n);
  rep(i,n) cin >> w[i];

  for(int i = 1; i<n; i++){
    if(*w[i].begin()!=*w[i-1].rbegin()){
      cout << "No" << endl;
      return 0;
    }
  }

  sort(w.begin(),w.end());

  for(int i = 1; i<n; i++){
    if(w[i]==w[i-1]){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3604
N,T = map(int,input().split(" "))
whole = []
for i in range(N):
  whole.append(list(map(int,input().split(" "))))
flag = 0
j = 0
while j < N:
  if whole[j][1] <= T:
    if flag == 0:
      flag = whole[j][0]
    else:
      if flag >= whole[j][0]:
        flag = whole[j][0]
  j = j + 1
if flag == 0:
    print("TLE")
else:
    print(flag)
         

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

void run() {
    int n; get n;
    int t; get t;
    int a; get a;

    int ans = 0;
    double ansAbs = 0;

    rep(i, 1, n + 1) {
    	int x; get x;
    	double d = t - x * 0.006;
    	double abs = fabs(a - d);
    	if ((abs < ansAbs) || (ans == 0)) {
    		ans = i;
    		ansAbs = abs;
    	}
    }

    put ans;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


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

int main(){
    int n,k,x,y; cin>>n>>k>>x>>y;
    if(n<=k) cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[]= new int[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
		}
		Arrays.parallelSort(A);
		int count =1;
		for (int i=N-1;i>0;i--) {
			if (A[i]!=A[i-1]) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35956
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int a,b;
    cin>>a>>b;
    
    int c=0,d=0;
    
    REP(i,b){
        c += a*pow(10,i);
    }
    REP(i,a){
        d += b*pow(10,i);
    }
    string cs = to_string(c);
    string ds = to_string(d);
    if(cs<ds){
        cout<<cs<<endl;
    } else {
        cout<<ds<<endl;
    }

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#整数の入力
N = int(input())
#スペース区切りの整数の入力リスト
P_list = list(map(int, input().split()))

counter = 0
for i in range(N-2):
  if((P_list[i]<P_list[i+1]<P_list[i+2])or(P_list[i+2]<P_list[i+1]<P_list[i])):
    counter = counter + 1
    
    
print(counter)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
string s;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
string t;
int ans;
int main()
{
    cin>>s;
    int ss=s.size();
    t="-";
    rep(i,ss)
    {
        if(s.substr(i,1)!=t)
        {
            ans++;
            t=s.substr(i,1);
        }
        else
        {
            if(i!=ss-1)ans++;
            t=s.substr(i,2);
            i++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())

upper_num = 1
upper_count = 0
for i in range(1,N+1,1):
    count = 0
    a, b = divmod(i,2)
    while b == 0:
        count += 1
        a, b = divmod(a,2)
#         print("{}:{}".format(i,count))
    if count > upper_count:
        upper_count = count
        upper_num = i
print(upper_num)

Measured memory_bytes: 3060
#include <iostream>
#include <map>

using namespace std;

#define P pair<int, int>

int main() {
    int n, m, a, h, p, q;
    while (true) {
        multimap<int, P> lines;
        cin >> n >> m >> a;
        if (n == 0) {
            break;
        }
        for (int i=0; i<m; i++) {
            cin >> h >> p >> q;
            lines.insert(pair<int, P>(h, P(p, q)));
        }
        for (multimap<int, P>::reverse_iterator iter=lines.rbegin(); iter!=lines.rend(); iter++) {
            if (a == iter->second.first) {
                a = iter->second.second;
            }
            else if (a == iter->second.second) {
                a = iter->second.first;
            }
        }
        cout << a << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    string s,u,v;
    t = 1;
    while(t--) {
     cin >> s >> u >> v;
     cout << s[0] << u[1] << v[2] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public void solve(){
        Scanner sc = new Scanner(System.in);
         
        int n = sc.nextInt();
         
        for(int i=0;i<n;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int b = sc.nextInt();
            int p = sc.nextInt();
             
            int kin = x*b + y*p;
             
            if(b>=5 && p>=2){
                kin = (x*b + y*p)*4/5;
            }else{
                if(b<5){
                b=5;
                }
                if(p<2){
                p=2;
                }
                int wari = (x*b + y*p)*4/5;
                 
                if(kin>wari){
                    kin = wari;
                }
            }
            System.out.println(kin);
        }
    }
     
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23364
a,b,c,x,y=map(int,input().split())
case=[]
c=c*2
case.append(a*x+b*y)
if x>=y:
    case.append(c*x)
    case.append(((x-y)*a)+(c*y))
else:
    case.append(y*c)
    case.append(((y-x)*b)+(c*x))
print(min(case))


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
ll x;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x;
  ll ans = 0;
  if(0 < x % 11) {
    if(11 && x % 11 <= 6) {
      ans += 1;
      x -= x % 11;
    } else {
      ans += 2;
      x -= x % 11;
    }
  }

  ans += (x / 11) * 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define ll long long
#define ull unsigned long long
#define traverse(c,it) for(auto it=c.begin();it!=c.end();it++)
#define lowerb(v,a) lower_bound(v.begin(),v.end(),a)
#define lowerbarr(v,n,a) lower_bound(v,v+n,a)
#define upperb(v,a) upper_bound(v.begin(),v.end(),a)
#define upperbarr(v,n,a) upper_bound(v,v+n,a)
#define maxval(v) max_element(v.begin(),v.end())
#define maxarr(v,n) max_element(v,v+n)
#define minval(v) min_element(v.begin(),v.end())
#define minarr(v,n) min_element(v,v+n)
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define mem0(v) memset(v,0,sizeof(v))
#define memf(v) memset(v,false,sizeof(v))
#define memt(v) memset(v,true,sizeof(v))
#define mem(v,a) memset(v,a,sizeof(v))
#define npos string::npos
#define MAX 1000000
#define MOD 1000000007
                   /**************SIEVE****************/

bool prime[MAX+1];
vector<ll> v;
void sieve(){ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.
   
    memset(prime, true, sizeof(prime)); 
  
    for (long p=2; p*p<=MAX; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (long i=p*p; i<=MAX; i += p) 
                prime[i] = false; 
        } 
    } 
  for(int i=0;i<=MAX;i++)if(prime[i])v.pb(i);
  
   
    
   
} 
 
                                        /**************gcd****************/

ll gcd(ll a,ll b) 
{ if(a>b)swap(a,b);
    if (a == 0) 
        return b; 
 return gcd(b%a, a); 
}
 
 
 
                                         /**************POWER****************/
 ull binpow(ll a, ll b) {
    if (b == 0)
        return 1;
    ll res = binpow(a, b / 2)%MOD;
    if (b % 2)
        return ((ull)res * (ull)res * (ull)a)%MOD;
    else
        return ((ull)res * (ull)res)%MOD;
}
   

 
 
 
 
                                     /**************MAIn****************/


int main()
{   tezi
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("put.txt","w",stdout);
  #endif

  int T=1;
  //cin>>T;
  while(T--)
  {string s;
    cin>>s;
    if(s[s.size()-1]!='s')
      s+='s';
    else s+="es";
    cout<<s;
    
  
 
    
  
}
 
 cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}  
 
 
 
 
 
  
 
 

Measured memory_bytes: 3852
n_a, n_b, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
xycs = m.times.map{STDIN.gets.split.map(&:to_i)}

ans = a.min + b.min

xycs.each do |xyc|
    x = xyc[0] - 1
    y = xyc[1] - 1
    t = a[x] + b[y] - xyc[2]
    ans = t if ans > t
end

p ans

Measured memory_bytes: 18972
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n];
    ll ans=1e9;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int y=-100; y<=100; y++) {
        ll cost=0;
        for(int i=0; i<n; i++) cost += (a[i]-y) * (a[i]-y);
        if(cost<ans) ans = cost;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec 22 21:00:16 JST 2019
 **/

signed main() {
    Int a = in(), b = in();
    cout << 6 - a - b << endl;
}


Measured memory_bytes: 256