akhauriyash/Code-Regression huggingface dataset:
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	h := stdin.ReadInt()
	n := stdin.ReadInt()
	a := []int{}
	b := []int{}
	for i := 0; i < n; i++ {
		a = append(a, stdin.ReadInt())
		b = append(b, stdin.ReadInt())
	}

	dp := [][]int{}
	inf := int(math.MaxInt32)
	for i := 0; i < n+1; i++ {
		row := []int{}
		for j := 0; j < h+1; j++ {
			row = append(row, inf)
		}
		row[0] = 0
		dp = append(dp, row)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < h+1; j++ {
			dp[i+1][j] = Min(dp[i+1][j], dp[i][j])
			dp[i+1][Min(h, j+a[i])] = Min(dp[i+1][Min(h, j+a[i])], dp[i+1][j]+b[i])
		}
	}
	stdout.Println(dp[n][h])
}

func Min(a ...int) int {
	v := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < v {
			v = a[i]
		}
	}
	return v
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


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

using namespace std;

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

	vector<long long> A(N);
	vector<long long> absA(N);
	vector<int> s(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		absA[i] = abs(A[i]);

		if (A[i] > 0)
		{
			s[i] = 0;
		}
		else if (A[i] < 0)
		{
			s[i] = 1;
		}
		else
		{
			s[i] = 2;
		}
	}

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

	long long ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += absA[i];
	}

	for (int i = 0; i < N - 1; i++)
	{
		if (s[i] == 0)
		{
			continue;
		}

		if (s[i + 1] == 2)
		{
			s[i + 1] = 0;
		}
		else
		{
			s[i] = 0;
			s[i + 1] = 1 - s[i + 1];
		}
	}

	if (s[N - 1])
	{
		ans -= absA[0] * 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define int long long
#define inf 1e9
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[3939];
signed main(){
	int n,cnt=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cnt+=a[i];
	cout<<cnt-n<<endl;
}

Measured memory_bytes: 256
/* d */
#include <bits/stdc++.h>
#define N 5000

using namespace std;

int n;
int R[2][N], G[2][N], B[2][N];
char s[N];

int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i) {
        R[0][i] = R[0][i - 1] + (s[i] == 'R');
        G[0][i] = G[0][i - 1] + (s[i] == 'G');
        B[0][i] = B[0][i - 1] + (s[i] == 'B');
    }
    for (int i = n; i >= 1; --i) {
        R[1][i] = R[1][i + 1] + (s[i] == 'R');
        G[1][i] = G[1][i + 1] + (s[i] == 'G');
        B[1][i] = B[1][i + 1] + (s[i] == 'B');
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R') {
            ans += G[0][i - 1] * B[1][i + 1];
            ans += G[1][i + 1] * B[0][i - 1];
        } else if (s[i] == 'G') {
            ans += R[0][i - 1] * B[1][i + 1];
            ans += R[1][i + 1] * B[0][i - 1];
        } else if (s[i] == 'B') {
            ans += R[0][i - 1] * G[1][i + 1];
            ans += R[1][i + 1] * G[0][i - 1];
        }
    }
    for (int len = 1; len <= n; ++len) {
        for (int i = 1; i <= n; ++i) {
            if (i - len < 1)
                continue;
            if (i + len > n)
                continue;
            ans -= (s[i - len] != s[i] && s[i + len] != s[i] && s[i - len] != s[i + len]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) if((i)) puts("YES");else puts("NO");
#define YesNo(i) if((i)) puts("Yes");else puts("No");
#define yesno(i) if((i)) puts("yes");else puts("no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1,val=-1;cin>>n;
  lvector A(n,0);rep(i,n) cin>>A[i];
  if(n>2) {
    ll pos=0;
    while(pos+1<n) {
      if(A[pos]<A[pos+1]) {
        if(val==-1) val=1;
        else if(val==0) {val=-1;ans++;}
      }
      else if(A[pos]>A[pos+1]) {
        if(val==-1) val=0;
        else if(val==1) {val=-1;ans++;}
      }
      pos++;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) write(string(b, '0' + (char)a));
    else write(string(a, '0' + (char)b));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
	REP(i, k) {
		if (i % 2 == 0) {
			if (a % 2)a--;
			a /= 2;
			b += a;
		}
		else {
			if (b % 2)b--;
			b /= 2;
			a += b;
		}
	}
	printf("%d %d", a, b);
	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

type Vec = MV.MVector (PrimState IO)

solve :: Vec Int -> Vec Bool -> Int -> Int -> IO (Int, Int)
solve mva mvb i count = do
    next <- MV.unsafeRead mva i
    if next == 1
        then return (next, count)
        else do
            b <- MV.unsafeRead mvb next
            if b
                then return (next, count)
                else do
                    MV.unsafeWrite mvb next True
                    solve mva mvb next (count + 1)
main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    mva <- MV.unsafeNew n :: IO (Vec Int)
    mvb <- MV.replicate n False :: IO (Vec Bool)
    forM_ [0..(n - 1)] $ \i -> do
        a <- fst . fromJust . B.readInt <$> B.getLine
        MV.write mva i (a - 1)
    (stop, count) <- solve mva mvb 0 1
    print $ if stop == 1 then count else -1


Measured memory_bytes: 1916
ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    A = list(map(int,input().split()))
    ans = float("inf")
    for i in range(n):
        for j in range(i+1,n):
            res = abs(A[i]-A[j])
            ans = min(ans, res)
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 5656
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
 static void Main(string[] args)
 {
  string N = Console.ReadLine();
  List<string> S = Console.ReadLine().Trim().Split(' ').ToList();
  string u = "Three";
  if (S.Contains("Y")) { u = "Four"; }
  Console.WriteLine("{0}", u);
 }
}


Measured memory_bytes: 11220
use std::io::Read;

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 { return a }
    gcd(b, a%b)
}

fn main() {
    let mut buf = String::new();
    let mut stdin = std::io::stdin();
    stdin.read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    let d = if a>b {
        gcd(a, b)
    } else {
        gcd(b, a)
    };
    let ans = a*b/d;
    println!("{}", ans);
}


Measured memory_bytes: 4352
//20190820
//https://atcoder.jp/contests/abc104/tasks/abc104_d
import java.util.Scanner;

class Main {
    static final long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int len = s.length();
        long[][] dp = new long[len][4];

        // 初期化処理
        if (s.charAt(0) == 'A') {
            dp[0][0] = 1;
            dp[0][1] = 1;
        } else if (s.charAt(0) == '?') {
            dp[0][0] = 3;
            dp[0][1] = 1;
        } else {
            dp[0][0] = 1;
        }
        for (int i = 1; i < len; i++) {
            char c = s.charAt(i);
            for (int j = 0; j < 4; j++) {
                // コピーする
                dp[i][j] = dp[i - 1][j];
                dp[i][j] %= mod;
            }
            // 追加する
            if (c == 'A') {
                dp[i][1] += dp[i - 1][0];

            } else if (c == 'B') {
                dp[i][2] += dp[i - 1][1];

            } else if (c == 'C') {
                dp[i][3] += dp[i - 1][2];

            } else if (c == '?') {
                for (int k = 0; k < 4; k++) {
                    dp[i][k] *= 3;
                    dp[i][k] %= mod;
                }
                dp[i][1] += dp[i - 1][0];
                dp[i][2] += dp[i - 1][1];
                dp[i][3] += dp[i - 1][2];
            }
            for (int j = 0; j < 4; j++) {
                dp[i][j] %= mod;
            }
        }

        System.out.println(dp[len - 1][3]);
        sc.close();
    }
}


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

struct Point {
  int x, y;
};

Point operator+(const Point& p1, const Point& p2) {
  return Point{p1.x+p2.x, p1.y+p2.y};
}
Point operator-(const Point& p1, const Point& p2) {
  return Point{p1.x-p2.x, p1.y-p2.y};
}

Point rotate(Point v) {
  return Point{-v.y, v.x};
}

int main () {
  Point v1, v2;
  cin >> v1.x >> v1.y >> v2.x >> v2.y;

  Point v3 = v2 + rotate(v2 - v1);
  Point v4 = v3 + rotate(v3 - v2);

  printf("%d %d %d %d\n", v3.x, v3.y, v4.x, v4.y);

  return 0;
}


Measured memory_bytes: 256
a = Array.new(3,0)
b = Array.new(3,0)
c = Array.new(3).map{Array.new(3,0)}
correct_flag = true

3.times do |i|
    c[i] = gets.split.map(&:to_i)
end

b[0] = (c[0][0] + c[1][0]) / 2
b[1] = ((c[0][0] + c[1][0]) / 2) - c[0][0] + c[0][1]
b[2] = ((c[0][0] + c[1][0]) / 2) - c[1][0] + c[1][2]

a[0] = c[0][0] - (c[0][0] + c[1][0]) / 2
a[1] = c[1][0] - (c[0][0] + c[1][0]) / 2
a[2] = c[2][0] - (c[0][0] + c[1][0]) / 2

for i in 0..2
    for j in 0..2
        if c[i][j] != (a[i] + b[j])
            correct_flag = false
        end
    end
end

if correct_flag
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
#include <cstdio>
#define V_MAX 200000
#define E_MAX 200000
struct edg
{
	int v; edg * e;
} ES[E_MAX * 2], * ER = ES, * EA[V_MAX + 1];
inline void edg_ins(int u, int v)
{
	*ER = (edg) {v, EA[u]}, EA[u] = ER++;
	*ER = (edg) {u, EA[v]}, EA[v] = ER++;
}
int V, E, u, v, k, d[V_MAX + 1][2], Ql, Qr, Q[V_MAX + 1];
char s[V_MAX + 2];
int main()
{
	scanf("%d %d", &V, &E);
	scanf(" %s", s + 1);
	while (E--)
		scanf("%d %d", &u, &v), edg_ins(u, v), ++d[u][s[v] - 'A'], ++d[v][s[u] - 'A'];
	for (u = 1; u <= V; ++u)
		if (!d[u][0] || !d[u][1])
			Q[++Qr] = u;
	while (Ql < Qr)
	{
		u = Q[++Ql], k = s[u] - 'A', --V;
		for (edg * e = EA[u]; e; e = e->e)
			if (!--d[e->v][k] && d[e->v][k ^ 1])
				Q[++Qr] = e->v;
	}
	puts(V ? "Yes" : "No");
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef pair< int , int > P;



int main(){
    double l;
    cin>>l;
    cout << fixed << setprecision(10);
    cout<<(l/3)*(l/3)*(l/3);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int H = 0;
  long long int W = 0;
  long long int A = 0;
  cin >> H >> W;
  if(H == 1 || W == 1) {
    	A = 1;
    } else{
  		if(H % 2 == 1 && W % 2 == 1) {
      		/**/if((H + W) % 2 == 0) {
      			A = ((H * W + 1) / 2);
      		} else{
      			A = ((H * W - 1) / 2);
      		}//
  		} else {
  			A = (H * W / 2);
  		}
    }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    if (S.find('7') != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll n;

  cin >> n;

  ll ans = n - 1;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, i + n / i - 2);
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int k = sc.nextInt();

		System.out.println((k / 2) * ((k + 1) / 2));

	}
}

Measured memory_bytes: 27048
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node {
	int p, l, r;
};
struct Node T[MAX];
int n;

void preParse(int u)
{
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u)
{
	if (u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void postParse(int u)
{
	if (u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}
int main()
{
	int i, v, l, r, root;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		T[i].p = NIL;
	}
	for (i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}
	for (i = 0; i < n; i++) if (T[i].p == NIL) root = i;//find root
	printf("Preorder\n");
	preParse(root);
	printf("\nInorder\n");
	inParse(root);
	printf("\nPostorder\n");
	postParse(root);
	printf("\n");
	return 0;
	

}


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

using namespace std;

int main(){
        string s, t;
        cin>>s>>t;
        sort(s.begin(), s.end());
        sort(t.rbegin(), t.rend());
        string ans="Yes";
        if(s>=t){
                ans="No";
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol a, b, c, k;
  cin >> a >> b >> c >> k;
  rep(i, k){
    c *= 2;
  }
  rep(i, k){
    if(a < b && b < c){
      cout << "Yes\n";
      return 0;
    }
    b *= 2;
    c /= 2;
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
using namespace std;
int n,a[201],b[201],c[201],d[201];
int g[201][201];
vector<int> G[201];
int match[201];
bool used[201];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
int bipartite_match(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<n;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}
int main(){
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i] >> b[i];
  for(int i=0;i<n;i++)cin >> c[i] >> d[i];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i] < c[j] && b[i] < d[j]) {
	g[i][j]=1;
	add_edge(i,j+n);
      }
    }
  }

  cout << bipartite_match()  << endl;
  // for(int i=0;i<n;i++)cout << i << " " << match[i] << endl;
  return 0;
}


Measured memory_bytes: 384
def main() -> None:
    n = int(input())
    menu = [[int(x) for x in input().split()] for _ in range(n)]

    for i, _ in enumerate(menu):
        menu[i] += [sum(menu[i])]

    menu.sort(key=lambda x: x[len(x) - 1], reverse=True)

    cnt = 0
    for i in range(n):
        if i % 2 == 0:
            cnt += menu[i][0]
        else:
            cnt -= menu[i][1]

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 25952
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <iomanip>
#define ll long long

using namespace std;

int main(void){
    ll n;
    cin >> n;
    vector<vector<ll>> count(10, vector<ll>(10));
    for(ll i = 0; i < 10; i++)
        for(ll j = 0; j < 10; j++)
            count[i][j] = 0;
    for(ll i = 1; i <= n; i++){
        ll a = i; ll b = i%10;
        while(a >= 10)
            a /= 10;
        count[a][b]++;
    }
    ll ans = 0;
    for(ll i = 1; i <= 9; i++)
        for(ll j = 1; j <= 9; j++)
            ans += count[i][j]*count[j][i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int n; cin>>n;
    cout<<n*(n+1)/2-n<<endl;
    return 0;
}

Measured memory_bytes: 3500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 115
	// https://atcoder.jp/contests/abc115/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] trees = new int[n];
		int minDiff = Integer.MAX_VALUE;
		
		for (int i = 0; i < n; i++) {
			trees[i] = sc.nextInt();
		}
		
		Arrays.sort(trees);

		for (int i = 0; i + k - 1 < n; i++) {
			minDiff = Math.min(minDiff, trees[i + k -1] - trees[i]);
		}
		
		System.out.println(minDiff);
	}
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);

    if (n % 2 == 0) {
        std::cout << n * (n-1) / 2 - (n/2) << std::endl;
        rep(i, n) {
            for (int j = i+1; j < n; j++) {
                if (i + j + 2 == n + 1) continue;
                std::cout << i+1 << " " << j+1 << std::endl;
            }
        }
    } else {
        std::cout << n * (n-1) / 2 - (n/2) << std::endl;
        rep(i, n) {
            for (int j = i+1; j < n; j++) {
                if (i + j + 2 == n) continue;
                std::cout << i+1 << " " << j+1 << std::endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll m,l,r,t;
int main()
{
	int n,r;
	cin>>n>>r;
	if(n>=10)
	{
		cout<<r<<"\n";
	}
	else
	{
		cout<<r+(100*(10-n));
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int t; cin >> t;
	while(t--){
		int n, d; cin >> n >> d;
		int ans = 0;
		for(int i = 0; i < n - 1; i++){
			ans += 127;
			d ^= 127;
		}
		ans += d;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main(){
int i=0,j=0,k,flag=0;
char A[102],B[102];
cin>>A>>B;
i=strlen( A );
j=strlen( B );
if(i>j){
cout<<"GREATER"<<endl;
}else if(i<j){
cout<<"LESS"<<endl;
}else{
flag=1;
for(k=0;k<i;k++){
if(A[k]>B[k]){
cout<<"GREATER"<<endl;
flag=0;
break;
}else if(A[k]<B[k]){
cout<<"LESS"<<endl;
flag=0;
break;
}
}
if(flag==1)cout<<"EQUAL"<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
    int a, b, c ;
    cin >> a >> b >> c ;
    int count = 0 ;
    FOR(i,a,b+1){
        if(c%i==0){
            count++ ;
        }
    }
    
    cout << count <<endl ;
    

  return 0 ;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>

using namespace std;

double dp[3000][3000];
double A[3000];

int n;

double f(int i, int j) {
  if(i < 0) return j > n / 2;
  if(dp[i][j] != -1) return dp[i][j];
  return dp[i][j] = A[i] * f(i - 1, j + 1) + (1 - A[i]) * f(i - 1, j);
}

int main() {
  cin >> n;
  cout << fixed << setprecision(15);
  for(int i = 0; i < n; ++i)
    cin >> A[i];
  
  for(int i = 0; i < n; ++i)
    for(int j = 0; j <= n; ++j)
      dp[i][j] = -1;
  
  cout << f(n - 1, 0);
  
  return 0;
}

Measured memory_bytes: 70784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int x,a,b;
      cin >> x >> a >> b;
      if(abs(x-a)>abs(x-b)) cout << 'B' << endl;
      else cout << 'A' << endl;
      return 0;}


Measured memory_bytes: 256
import math
N,M = [int(i) for i in input().split(" ")]
S = 10**9+7
kn = math.factorial(N) % S
if N == M :
    print((kn*kn*2)%S)
elif N-M == 1 or M-N==1 :
    km = (math.factorial(M) % S)
    print((kn*km)%S)
else:
    print(0)


Measured memory_bytes: 4092
use std::io;

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

    //let n = s.trim().parse().unwrap();

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

    let xs: Vec<usize> = s.trim().split(' ').map(|x| x.parse().unwrap()).collect();

    let mut res = 0;
    for (i, &x) in xs.iter().enumerate() {
        if xs[x - 1] == i + 1 {
            res += 1;
        }
    }

    println!("{}", res / 2);
}


Measured memory_bytes: 2428
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
string s;

//inputします
void input() {
	cin >> s;
}

//ライブラリ置き場



//main
int main() {
    input();
	ff(i, 0, s.size()) {
		if (i % 2 == 0)cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    for(i=1;i<=9;i++){
        int temp = n/i;
        if(n%i==0 && temp<=9){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();

    Queue<Integer> queue = new PriorityQueue<>((i1, i2) -> -i1.compareTo(i2));

    for (int i = 0; i < n; i++) {
      queue.add(sc.nextInt());
    }

    for (int i = 0; i < m; i++) {
      int max = queue.remove();
      queue.add(max/2);
    }

    long res = 0;
    while(!queue.isEmpty()) {
      res += queue.remove();
    }

    os.println(res);
  }
}

Measured memory_bytes: 61944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env runghc
import Text.Printf
import Control.Applicative

sq x = x*x
main = map (read :: String -> Int) . words <$> getLine >>= \[a,b] ->
	if a/=0 then
		printf "%f\n" (minimum (map (\i ->
			abs $ (fromIntegral b)-(sqrt $ fromIntegral $ (sq i)+(sq (a-i)))
		) [0..(div a 2)]) :: Double)
		>> main
	else
		return ()

Measured memory_bytes: 4256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
string s;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	cin>>s;
	if(s=="ABC")cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }


int main()
{
	int n, temp;
	string s;

	cin >> s;
	n = s.size();
	vector<int> c(n, 0);
	temp = 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'R')
			temp++;
		else if (s[i - 1] == 'R')
		{
			c[i - 1] += temp / 2 + temp % 2;
			c[i] += temp / 2;
			temp = 0;
		}
	}
	// for (int i = 0; i < n; i++)
	// {
	// 	cout << c[i];
	// 	if (i != n - 1)
	// 		cout << " ";
	// 	else
	// 		cout << '\n';
	// }
	temp = 1;
	for (int i = n - 2; i >= 0; i--)
	{
		if (s[i] == 'L')
			temp++;
		else if (s[i + 1] == 'L')
		{
			c[i + 1] += temp / 2 + temp % 2;
			c[i] += temp / 2;
			temp = 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << c[i];
		if (i != n - 1)
			cout << " ";
		else
			cout << '\n';
	}
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
int32_t main() {
	int n, c, ans = 1; cin>>n>>c;
	vector<int> a(n, 0);
	for(int &x: a)
		cin>>x;
	int now = 0;
	for(int i = 0; i <n; i++){
		now = now + a[i];
		if(now <= c)
			ans++;
	}
			
	cout<<ans<<endl;
}


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

using namespace std;

int main(void)
{
	int a,b,ans;

	cin>>a>>b;

	if(a>b) ans=a+(a-1);
	else if(a==b) ans=a*2;
	else ans=b+(b-1);

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


Measured memory_bytes: 256
import math

a, b, C = map(int, input().split())

S = (a * b * math.sin(math.radians(C))) / 2
L = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
h = (2*S)/a

print(S)
print(L)
print(h)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	ll n,ans=0;
	cin>>n;
	for(ll i=1;i*i<n;i++){
		if(n%i==0){
			ll hoge=(n-i)/i;
			if(hoge!=i)ans+=hoge;
		}
	}
	cout<<ans<<endl;
}


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

using vi = std::vector<int>;
std::priority_queue<int, std::vector<int>, std::greater<int>> pq;

vi a;
std::vector<vi> edges;
std::vector<bool> used;

int dfs(int);
int64_t solve();

int main()
{
	int64_t ans{solve()};
	if (ans < 0) puts("Impossible");
	else printf("%lld\n", ans);

	return 0;
}

int64_t solve()
{
	int N, M;
	scanf("%d%d", &N, &M);
	a.resize(N);
	for (int i{}; i < N; i++)
		scanf("%d", &a[i]);
	edges.resize(N);
	for (int i{}; i < M; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		edges[x].push_back(y);
		edges[y].push_back(x);
	}
	if (M + N / 2 < N - 1) return -1;
	used.resize(N);
	int64_t sum{};
	for (int i{}; i < N; i++)
	{
		if (used[i]) continue;
		int min_i{dfs(i)};
		sum += a[min_i];
	}
	if (M == N - 1) sum = 0;
	for (int i{}; i < N - 1 - M - 1; i++)
	{
		sum += pq.top();
		pq.pop();
	}
	return sum;
}

int dfs(int index)
{
	used[index] = true;
	int min_i{index};
	for (auto& e: edges[index])
	{
		if (used[e]) continue;
		int tmp{dfs(e)};
		if (a[tmp] < a[min_i]) std::swap(tmp, min_i);
		pq.push(a[tmp]);
	}
	return min_i;
}

Measured memory_bytes: 6784
n = int(input())
ds = list(map(int, input().split()))

def initial():
    rain0 = 0
    for i in range(n):
        rain0 += ((-1)**i) * ds[i]
    return rain0

rain0 = initial()
rains = [rain0]

def solve():
    rain_i = rain0
    for i in range(n-1):
        if i != n-1:
            rain_i_ = 2 * ds[i] - rain_i
        else:
            rain_i_ = 2 * ds[i] - rain0
        
        rains.append(rain_i_)
        rain_i = rain_i_
        
solve()

for i in range(len(rains)):
    print(rains[i], end=" ")

Measured memory_bytes: 14616
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) a.begin(), a.end()
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}

int pow(int a, int b) {
  int res = 1;
  rep(i, b) res *= a;
  return res;
}
 
class Solver {
public:
  int N;
  string c[3];

  void solve() {
    rep(i, 3) cin >> c[i];
    rep(i, 3) cout << c[i][i];
    cout << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


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

int main(){
  string s,l,r;
  int q,f=0,c=0;
  cin>>s>>q;

  while(q--){
      int n;
      cin>>n;
      if(n==1){
          c++;
          //swap(l,r);
      }else{
          int a;
          char ch;
          cin>>a>>ch;
          if(c%2==0){
              if(a==1)l = ch+l;
              else r+=ch;
          }else{
              if(a==2)l = ch+l;
              else r +=ch;
          }
      }
  }
  if(c%2==0)
  cout<<l<<s<<r;
  else{
      reverse(l.begin(),l.end());
      reverse(r.begin(),r.end());
      reverse(s.begin(),s.end());
      cout<<r<<s<<l;
  }

}


Measured memory_bytes: 1104
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll n, p;
	string s;

	cin >> n;

	vector<tuple<string, ll, ll>> v;

	REP(i, n) {
		cin >> s >> p;
		v.push_back(make_tuple(s, -p, i + 1));
	}

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

	REP(i, n) {
		cout << get<2>(v[i]) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

template <class T>
T GCD(T a, T b) { return b == 0 ? a : GCD(b, a%b); }

int main()
{
  int N; cin >> N;
  vector<ll> T(N);
  for (int i = 0; i < N; ++i) cin >> T[i];

  ll ans=T[0];
  for (int i = 1; i < N; ++i) {
    ans = ans/GCD(ans, T[i])*T[i];
  }

  cout << ans << endl;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> prime(2000000, 1);
    prime[0] = 0;
    prime[1] = 0;
    for(int i = 2; i < 1500; i++){
        for(int j = (i << 1); j < 2000000; j+=i){
            prime[j] = 0;
        }
    }

    int N;
    while(true){
        cin >> N;
        if(N == 0) break;
        int l = N, r = N;
        while(prime[l] == 0) l--;
        while(prime[r] == 0) r++;
        cout << r-l << endl;
    }
    return 0;
}


Measured memory_bytes: 10536
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
class UnionFind {
public:
	vector<int>par, rank, node;//親、木の高さ、連結成分の大きさ
	//Constructer
	UnionFind(int n) :par(n), rank(n, 0),node(n,1) {
		for (int i = 0;i < n;i++)par[i] = i;
	}
	void init(int n) {
		for (int i = 0;i < n;i++) {
			par[i] = i;
			rank[i] = 0;
			node[i] = 1;
		}
	}

	int find(int x) {
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite_tree(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}
	int size(int x) {
		return node[find(x)];
	}

	void unite_node(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (size(x) < size(y))swap(x, y);
		node[x] += node[y];
		par[y] = par[x];
	}
};

ll ans[100010];

int main(void){
	int n, m;
	cin >> n >> m;
	UnionFind G(n + 1);
	vector<int>a(m), b(m);
	for (int i = 0;i < m;i++)cin >> a[i] >> b[i];
	ans[m - 1] = (ll)n * (n - 1) / 2;
	for (int i = m - 1;i >= 1;i--) {
		if (G.same(a[i], b[i])) {
			ans[i-1] = ans[i];
		}
		else {
			ans[i-1] = ans[i] - (ll)G.size(a[i])*G.size(b[i]);
			G.unite_node(a[i], b[i]);
		}
	}
	for (int i = 0;i < m;i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   int n,k;
   cin>>n>>k;
   cout<<n-k+1<<endl;
   return 0;
}

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

int main() {
  int N, M, X, Y, maxX, minY;
  cin >> N >> M >> X >> Y;
  maxX = X;
  minY = Y;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    maxX = max(maxX, x);
  }
  for (int i = 0; i < M; i++) {
    int y;
    cin >> y;
    minY = min(minY, y);
  }
  if (minY > maxX) cout << "No War" << endl;
  else cout << "War" << endl;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b; cin >> a >> b;

    cout << a - (a > b);
}


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

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr);
    int n;
    string s;
    string t;
    cin >> n >> s >> t;
    for (int i = n; i >= 0; --i) {
        if (s.substr(n - i) == t.substr(0, i)) {
            cout << 2 * n - i << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  double tillnw=0;
  int arr[200001];
  int n,k;
  cin>>n>>k;
  rep(i,n){
      cin>>arr[i];
        if(i>=k && arr[i]>arr[i-k]) cout<<"Yes\n";
        else if(i>=k) cout<<"No\n";
  }
  //cout<<d;
  return 0;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
double x,y,xx,yy,xxx,yyy,xxxx,yyyy;
int q;
int main(){
	cin>>q;
	while(q--){
		cin>>x>>y>>xx>>yy>>xxx>>yyy>>xxxx>>yyyy;
		int pd1=0,pd2=0,pd3=0,pd4=0,pd5=0;
		xx-=x,yy-=y,xxx-=x,yyy-=y,xxxx-=x,yyyy-=y;
		if((xx*yyy-xxx*yy)*(xx*yyyy-xxxx*yy)<=0) pd1=1;
		xx+=x,yy+=y,xxx+=x,yyy+=y,xxxx+=x,yyyy+=y;
		
		x-=xx,y-=yy,xxx-=xx,yyy-=yy,xxxx-=xx,yyyy-=yy;
		if((x*yyy-xxx*y)*(x*yyyy-xxxx*y)<=0) pd2=1;
		x+=xx,y+=yy,xxx+=xx,yyy+=yy,xxxx+=xx,yyyy+=yy;
		
		x-=xxx,y-=yyy,xx-=xxx,yy-=yyy,xxxx-=xxx,yyyy-=yyy;
		if((xxxx*y-x*yyyy)*(xxxx*yy-xx*yyyy)<=0) pd3=1;
		x+=xxx,y+=yyy,xx+=xxx,yy+=yyy,xxxx+=xxx,yyyy+=yyy;
		
		x-=xxxx,y-=yyyy,xx-=xxxx,yy-=yyyy,xxx-=xxxx,yyy-=yyyy;
		if((xxx*y-x*yyy)*(xxx*yy-xx*yyy)<=0) pd4=1;
		x+=xxxx,y+=yyyy,xx+=xxxx,yy+=yyyy,xxx+=xxxx,yyy+=yyyy;
		
		if(max(x,xx)>=min(xxx,xxxx)
		&& max(xxx,xxxx)>=min(x,xx)
		&& max(y,yy)>=min(yyy,yyyy)
		&& max(yyy,yyyy)>=min(y,yy)){
			pd5=1;
		}
//		cout<<pd1<<" "<<pd2<<" "<<pd3<<endl;
		if(pd1==0 || pd2==0 || pd3==0 || pd4==0 || pd5==0){
			cout<<"0"<<endl;
		}
		else cout<<"1"<<endl;
	}
	return 0;
}
/*
8
0 0 4 0 1 1 1 -1
0 0 4 0 2 1 3 -1
0 0 4 0 3 1 2 -1
0 0 4 0 4 3 2 -3
0 0 4 0 5 1 6 -1
0 0 4 0 5 0 7 0
0 0 4 0 1 2 4 1
0 0 4 0 1 -2 1 -4
*/


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int t[100005];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    t[a-1]++;
    t[b]--;
  }
  int ans=0;
  for(int i=1;i<=100000;i++){
    t[i]+=t[i-1];
    if(i<=t[i])ans=i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
using namespace std;
int main(){
while (1){
int a, b;
string op;
cin>>a>>op>>b;
if(op == "?") break;

int ans;
if(op == "+") ans = a + b;
if(op == "-") ans = a - b;
if(op == "*") ans = a * b;
if(op == "/") ans = a / b;

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


Measured memory_bytes: 3132