akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    int a, b;
};

template <class T>
void chmin(T &a, T b) {
    if (b < a) a = b;
}

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

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = { a, b };
    }

    vector<int> dp(h + 1, 1 << 30);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        int a = p[i].a;
        int b = p[i].b;
        for (int j = 0; j < h; j++) {
            chmin(dp[min(j + a, h)], dp[j] + b);
        }
    }

    cout << dp[h] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		char s[] = sc.next().toCharArray();
		int rgbsum[][] = new int[3][n+1];
		int is[] = new int[n];
		for(int i=0; i<n; i++) {
			int c = s[i];
			rgbsum[0][i+1] = rgbsum[0][i] + (c=='R' ? 1 : 0);
			rgbsum[1][i+1] = rgbsum[1][i] + (c=='G' ? 1 : 0);
			rgbsum[2][i+1] = rgbsum[2][i] + (c=='B' ? 1 : 0);
			if(c=='R') is[i]=0;
			if(c=='G') is[i]=1;
			if(c=='B') is[i]=2;
		}
		long ans = 0;
		for(int i=0; i<n-2; i++) {
			int c1 = is[i];
			for(int j=i+1; j<n-1; j++) {
				int c2 = is[j];
				if(c1 == c2) continue;
				int id = 3 - c1 - c2;
				int omit = j-i;
				if(j+1+omit>n) {
					ans += rgbsum[id][n]  - rgbsum[id][j+1];
				}else if(j+1+omit == n){
					ans += rgbsum[id][n-1] - rgbsum[id][j+1];
				}else {
					ans += rgbsum[id][n]  - rgbsum[id][j+1+omit] + rgbsum[id][j+1+omit-1] - rgbsum[id][j+1];
				}

			}
		}
		System.out.println(ans);
		sc.close();
	}




}


Measured memory_bytes: 36660
package main

import (
	"fmt"
	"os"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	inputs := scanNums(M)

	steps := make([]bool, N+1, N+1)

	for i := 0; i <= N; i++ {
		steps[i] = true
	}
	for _, v := range inputs {
		steps[v] = false
		if !steps[v-1] {
			fmt.Println(0)
			os.Exit(0)
		}
	}

	fib := make([]int, N+1, N+1)
	fib[0] = 1
	if steps[1] {
		fib[1] = 1
	} else {
		fib[1] = 0
	}
	for i := 2; i <= N; i++ {
		if steps[i] {
			fib[i] = fib[i-1] + fib[i-2]
		}
		fib[i] %= 1000000007
		// fmt.Println(i, fib[i])
	}

	res := fib[N]
	fmt.Println(res)

}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


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

public class Main {

    
    public void solve() throws IOException {
      int n = nextInt();
      int a[] = new int[n];
      for (int i = 0 ; i < n ; i++) {
        a[i] = nextInt()-1;
      }
      int res = 0;
      for (int i = 0 ; i < n ; i++) {
        if (a[a[i]] == i) {
          res ++;
        }
      }
      out.println(res/2);
    }

    

    
    
    BufferedReader bf;
    StringTokenizer st;
    PrintWriter out;
    
    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) 
            st = new StringTokenizer(bf.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public Main() throws IOException {
        bf = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));      
        solve();
        bf.close();
        out.close();
    }
    
    public static void main(String args[]) throws IOException {
        new Main();
    }
}

Measured memory_bytes: 21760
var S = parseInt(require('fs').readFileSync('/dev/stdin').toString());
var res = separate(S);
while (res.split(':').length < 3)
	res = '0:' + res;
console.log(res);

function separate(num) {
	if (num < 60) return String(num);
	return separate(Math.floor(num / 60)) + ":" + String(num % 60);
}

Measured memory_bytes: 15516
n = int(input())
a = list(map(int, input().split()))
i = 0
j = 0
c = 0
while 1:
    if j >= len(a):
        break
    if a[j] != i+1:
        j += 1
        c += 1
    else:
        j += 1
        i += 1
if len(a) == c:
    print(-1)
else:
    print(c)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrep1(i,n) for(ll i=n;i>=1;i--)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}

int main(){
	ll N,K; cin>>N>>K;
    vector<ll>V(N);
    ll ans=0;
    rep(i,N) cin>>V[i];

    rep1(i,min(K,N)){//i個回収 
        rep(l,i+1){//左からl個->右からi-l個
            priority_queue<ll,vector<ll>,greater<ll>> que; 
            rep(j,l) que.push(V[j]);
            FOR(j,N-i+l,N) que.push(V[j]);

            //K-i個まで捨てれる
            ll cnt=1;
            while(!que.empty() && cnt<=K-i && que.top()<0){
                que.pop();
                cnt++;
            } 
            ll tmp=0;
            while(!que.empty()){
                tmp+=que.top();
                que.pop();
            }
            chmax(ans,tmp);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
object Main {

  def calc(s: String, K: Int): String = {
    val chars = ('a' to 'z').mkString

    def next(str: String): String = {
      val ix = chars.indexOf(str.last)
      if (ix == 25) { // 末尾が'z'
        next(str.dropRight(1))
      } else {
        val c = chars(ix + 1)
        str.dropRight(1) + c
      }
    }

    def step(k: Int, building: String): String = k match {
      case 0 => building.dropRight(1) // 最後に'a'が足されている
      case _ =>
        s.indexOf(building) match {
          case -1 => step(k, next(building))
          case _ => step(k - 1, building + 'a')
        }
    }

    step(K, "a")
  }

  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val s = in.next()
    val K = in.next().toInt
    System.out.println(calc(s, K))
  }
}

Measured memory_bytes: 27068
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int w = scanner.nextInt();
        int[][] wav = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 2; j++){
                wav[i][j] = scanner.nextInt();
            }
        }
        System.out.println(new Main().f(wav, n, w));
    }

    public long f(int[][] wav, int n, int w) {
        long[] dp = new long[w+1];
        long ans = 0;
        for(int i = 0; i <= w; i++){
            if(i >= wav[0][0])
                dp[i] = wav[0][1];
            ans = Math.max(dp[i], ans);
        }
        for(int i = 1; i < n; i++){
            for(int j = w; j >= 0; j--){
                if(j >= wav[i][0]){
                    dp[j] = Math.max(wav[i][1] + dp[j-wav[i][0]], dp[j]);
                }
                ans = Math.max(dp[j], ans);
            }
        }
        return ans;
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> flag(n);
    for (int i = 0; i < h.size(); i++) {
        cin >> h[i];
    }
    int a, b;
    for (int j = 0; j < m; j++) {
        cin >> a >> b;
        if (h[a - 1] == h[b - 1]) flag[a - 1] = 1, flag[b - 1] = 1;
        else if (h[a - 1] > h[b - 1]) flag[b - 1] = 1;
        else if (h[a - 1] < h[b - 1]) flag[a - 1] = 1;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (flag[i] == 0) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3992
n = int(input())
r = sorted([list(map(int, input().split())) for i in range(n)])
b = sorted([list(map(int, input().split())) for i in range(n)])
ans = 0
for bx,by in b:
  now_ry = -1
  now_index = -1
  for key,(rx,ry) in enumerate(r):
    if bx > rx and by > ry and ry > now_ry:
      now_ry = ry
      now_index = key
  if now_ry >= 0:
    ans += 1
    r.pop(now_index)
print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC167B
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            string line;
            string[] sa;
            line = Console.ReadLine();
            sa = line.Split(' ');

            int a = int.Parse(sa[0]);
            int b = int.Parse(sa[1]);
            int c = int.Parse(sa[2]);
            int k = int.Parse(sa[3]);

            int na = Math.Min(a, k);
            k = Math.Max(k - na, 0);
            int nb = Math.Min(b, k);
            k = Math.Max(k - nb, 0);
            int nc = Math.Min(c, k);

            Console.WriteLine(na - nc);

#if DEBUG
            Console.WriteLine();
#endif
        }
    }
}


Measured memory_bytes: 27544
#input
def main():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))
    dp = [1] * N
    for _ in range(M):
        A, B = map(int, input().split())
        if H[A-1] > H[B-1]:
            dp[B-1] = 0
        elif H[A-1] < H[B-1]:
            dp[A-1] = 0
        elif H[A-1] == H[B-1]:
            dp[A-1] = 0
            dp[B-1] = 0

#output
    print(sum(dp))

if __name__ == "__main__":
    main()

Measured memory_bytes: 20116
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

int main(){
  int n;
  cin >> n;
  VI s = VI(n+1);
  REP(i, 1, n+1){
    cin >> s[i];
  }

  int ans = 0;
  for(int i = 1; i <= n+1; i++){
    if(s[i] == i){
      if(i != n+1 && s[i+1] == i+1){
        i++;
      }
      ans++;
    }
  }

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


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, m; cin >> n >> m;
  vll a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vll su(n+1);
  for(int i=0;i<n;++i) {
    su[i+1] = su[i] + a[i];
  }

  ll l = 1, r = 200001;
  
  while(r - l > 1) {
    ll mid = (l + r) / 2;

    ll cnt = 0;
    for(int i=0;i<n;++i) {
      auto it = upper_bound(a.begin(), a.end(), mid-a[i]);
      int pos = distance(a.begin(), it);
      cnt += n - pos;
    }
    if(cnt >= m) {
      l = mid;
    } else {
      r = mid;
    }
  }
  ll ans = 0;
  ll cnt = 0;
  ll ma = 0;
  for(int i=0;i<n;++i) {
    auto it = upper_bound(a.begin(), a.end(), l+1 - a[i]);
    int pos = distance(a.begin(), it);
    if(it != a.begin()) {
      it--;
      ma = max(ma, *it + a[i]);
    }
    ans += su[n] - su[pos] + a[i] * (n - pos);
    cnt += n - pos;
  }
  ans += ma * (m - cnt);

  cout << ans << endl;

}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	bool dp[x + 110] = {true};
	int s[6] = {100, 101, 102, 103, 104, 105};
	for (int ss : s) {
		rep (i, x) {
			if (dp[i]) dp[i + ss] = true;
		}
	}
	if (dp[x]) cout << 1 << endl;
	else cout << 0 << endl;	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 2019;

int main(){
    ll l, r;
    cin >> l >> r;
    r = min(l + 2019, r);
    ll ans = 2020;
    for(ll i = l; i < r; i++){
        for(ll j = i+1; j <= r; j++){
            ans = min(ans, i * j % mod);
        }
    }
    cout << ans << endl;
    return 0;
}

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

void solve(){
    ll n;
    cin >> n;
    Vl A(n);
    rep(i, 0, n) cin >> A[i];

    sort(ALL(A));
    ll a = 1, ans = 0;
    rep(i, 0, n-1){
        if(A[i] == A[i+1]){
            a++;
        }else{
            if(a%2 != 0) ans++;
            a = 1;
        }
        if(i == n-2){
            if(a%2 != 0) ans++;
        }
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 1024
def gcds(*numbers):
    from math import gcd
    from functools import reduce
    return reduce(gcd, numbers)

def resolve():
    K = int(input())
    ans = 0
    import itertools
    for i, j, k in itertools.combinations_with_replacement(range(1, K+1), 3):
        l = len(set([i, j, k]))
        mu = 1
        if l == 3:
            mu = 6
        elif l == 2:
            mu = 3
        ans += gcds(i, j, k) * mu
    print(ans)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 72356
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){

	cin >> n;
	for(int i =0;i<n;i++){
		cin >> x;
		v.push_back(x);
	}
	vi dp;
	dp.resize(n+5,1e9);
	int k = 2;
	dp[0]=0;
	for(int i =0;i<n;i++){
		if(dp[i]==1e9)continue;
		for(int j=1;i+j<n&&j<=k;j++){
			dp[i+j]=min(dp[i]+abs(v[i]-v[i+j]),dp[i+j]);
		}
	}
	cout << dp[n-1];

	
	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool flag=false;
  if(abs(a-c) <= d)
    flag=true;
  if(abs(a-b) <= d && abs(b-c) <= d)
    flag=true;
  cout << (flag?"Yes":"No") << endl;
}

int main(){
  solve();
  return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str s,t;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>s>>t;
    cout<<t<<s<<newl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int n,i;
	cin>>n>>i;
	cout<<n-i+1<<endl;
	return 0;
}


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


int main(void)
{
	long int n, x;
	long int i, j;
	long int min = 10000;
	long int sum = 0, count = 0;
	long int first = 0, last = 0;
	long int flg;
	long int l[100] = {0};
	
	scanf("%ld%ld", &n, &x);
	
	count++;
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &l[i]);
		sum += l[i];
		if(sum > x) {
			break;
		}
		count++;
	}
	
	printf("%ld\n", count);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define P pair<int,int>
#define ll long long
#define f first
#define s second
using namespace std;
int n,nn,nx,mx=-INF,mn=INF;
P a[200005];
ll ans;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    n=read();
    for(int i=1;i<=n;++i){
        a[i].f=read(),a[i].s=read();
        if(a[i].f>a[i].s) swap(a[i].f,a[i].s);
        mx=max(mx,a[i].s),mn=min(mn,a[i].s);
    }
    sort(a+1,a+n+1);
    ans=1ll*(mx-mn)*(a[n].f-a[1].f),nn=nx=a[1].s;
    for(int i=2;i<=n;++i){
        ans=min(ans,1ll*(mx-a[1].f)*(max(nx,a[n].f)-min(nn,a[i].f)));
        nn=min(nn,a[i].s),nx=max(nx,a[i].s);
    }
    printf("%lld",ans);
}

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

int main() {
  
  string a;
  cin >> a;
  
  if(a[0] == '9' || a[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int a, b;
    while(cin >> a >> b){
        if(a < b) cout << "a < b" << endl;
        else if(a > b) cout << "a > b" << endl;
        else cout << "a == b" << endl;
    }
}

Measured memory_bytes: 1152
//
//  main.cpp
//  TPC
//
//  Created by yuki on 2019/07/16.
//  Copyright © 2019 yuki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <algorithm>


using namespace std;

std::vector<int> range(int upper){
    std::vector<int> v(upper);
    std::iota (std::begin(v), std::end(v), 0);
    
    return v;
}

const unsigned char mostCommonChar(unsigned char a, unsigned char b, unsigned char c) {
    int _ac = 1;
    if (a == b) _ac += 1;
    if (a == c) _ac += 1;
    
    int _bc = 1;
    if (b == a) _bc += 1;
    if (b == c) _bc += 1;
    
    int _cc = 1;
    if (c == a) _cc += 1;
    if (c == b) _cc += 1;
    
    int m__max = std::max({_ac, _bc, _cc});
    
    if (m__max == _ac) {return a;}
    if (m__max == _bc) {return b;}
    if (m__max == _cc) {return c;}
    
    return -1;
}

const int difference(const std::string target, const std::string subject) {
    auto diffCounter = 0;
    for (const auto i: range(static_cast<int>(target.size()))) {
        if (target[i] != subject[i]) {
            diffCounter += 1;
        }
    }
    
    return diffCounter;
}

int main() {

    // ================================================ //
    int N;
    std::string A, B, C;
    
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;
    
    auto mostCommonList = std::string();
    
    for (const auto i: range(N)) {
        mostCommonList += mostCommonChar(A[i], B[i], C[i]);
        
    }
    
    auto diff = difference(mostCommonList, A) + difference(mostCommonList, B) + difference(mostCommonList, C);
    
    cout << diff << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a, b,c;
    
    cin >> a>>b;//>>c;
    
    if (a % 2 == 1 && b%2==1) cout << "Odd"<< endl;
    else cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

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

    if (b >= c) {
      System.out.println(b+c);
    }
    else {
      int sum = b*2;
      c = c-b;
      if (a>=c) {
        System.out.println(sum+c);
      }
      else {
        System.out.println(sum+a+1);
      }
    }


  }

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long l,r,ans=2018;
int main()
{
	cin>>l>>r;
	for(long long i=l;i<r;i++)
	{
		for(long long j=i+1;j<=r;j++)
		{
			ans=min(ans,i*j%2019);
			if(ans==0)
			{
				cout<<0;
				return 0;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
from itertools import product, accumulate

n, w = map(int, input().split())
w1, v1 = map(int, input().split())
packages = [[v1], [], [], []]
for _ in range(n - 1):
    wi, vi = map(int, input().split())
    packages[wi - w1].append(vi)
for ofs, lst in enumerate(packages):
    lst.sort(reverse=True)
    packages[ofs] = list(accumulate([0] + lst))

tmp_max = 0
for a, b, c, d in product(*(range(len(packages[ofs])) for ofs in range(4))):
    if w1 * (a + b + c + d) + b + 2 * c + 3 * d > w:
        continue
    tmp_max = max(tmp_max, sum(packages[ofs][m] for ofs, m in zip(range(4), (a, b, c, d))))
print(tmp_max)


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

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


Measured memory_bytes: 256
import math
import fractions

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

    # divisors.sort()
    return divisors

def bitlist(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

#a = list(map(int, input().split()))

n,a,b = list(map(int, input().split()))
es = [[] for i in range(n+1)]

for i in range(n-1):
    p,q = list(map(int, input().split()))
    es[p].append(q)
    es[q].append(p)

dista = [9999999 for i in range(n+1)]
distb = [9999999 for i in range(n+1)]



dista[a]=0
distb[b]=0

queue = [[a,0]]
snum = 0
while(True):
    if(snum==len(queue)):
        break
    nowel = queue[snum]
    nowv = nowel[0]
    #print(nowv)
    nowdist = nowel[1]
    #print(nowdist)
    elist = es[nowv]
    for j in range(len(elist)):
        if(dista[elist[j]]>9999990):
            queue.append([elist[j],nowdist+1])
            dista[elist[j]] = nowdist+1
    snum+=1
#print(dista)


queue = [[b,0]]
snum = 0
while(True):
    if(snum==len(queue)):
        break
    nowel = queue[snum]
    nowv = nowel[0]
    #print(nowv)
    nowdist = nowel[1]
    #print(nowdist)
    elist = es[nowv]
    for j in range(len(elist)):
        if(distb[elist[j]]>9999990):
            queue.append([elist[j],nowdist+1])
            distb[elist[j]] = nowdist+1
    snum+=1
#print(distb)

acan = [0 for i in range(n+1)]

for ii in range(n):
    i = ii+1
    if(dista[i] < distb[i]):
        acan[i]=1

maxb = 0
k = 0

for ii in range(n):
    i = ii+1
    if(maxb < distb[i] and acan[i]==1):
        maxb = distb[i]
        k = i

if(abs(dista[k] - distb[k])%2 == 0):
    print(maxb-1)
    #print("0:",k)
else:
    print(maxb-1)
    #print("1",k)








Measured memory_bytes: 112796
#!/usr/bin/env python3

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    s = read(str)
    t = read(str)

    min_mismatch = 10000
    for start in range(0, len(s) - len(t) + 1):
        mismatch = 0
        for i in range(start, start + len(t)):
            if s[i] != t[i - start]:
                mismatch += 1
        if mismatch < min_mismatch:
            min_mismatch = mismatch
    print(min_mismatch)


if __name__ == "__main__":
    main()


Measured memory_bytes: 73036
#include <stdio.h>
#include <math.h>
#define MAX 1000

int main(){
    int n;
    int i, j=0, sum;
    int score[MAX];
    double ave, tmp;
    double dev[MAX];

    while(1){
        scanf("%d", &n);
        if(n==0)break;
        sum=0;
        for(i=0;i<n;i++){
            scanf("%d", &score[i]);
            sum+=score[i];
        }
        ave=(double)sum/(double)n;
        tmp=0.0;
        for(i=0;i<n;i++){
            tmp+=pow(score[i]-ave, 2);
        }
        dev[j++]=sqrt(tmp/(double)n);
    }
    for(i=0;i<j;i++){
        printf("%f\n", dev[i]);
    }
    return 0;
}

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

int main()
{
    int a,b,c,x,count,i,j,s;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&x);
    count=0;
    for(i=0;i<=a;i++)
        for(j=0;j<=b;j++)
          for(s=0;s<=c;s++)
           {
              if(i*500+j*100+s*50==x)
                count++;
           }
           printf("%d\n",count);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    int a,b;
    cin >>a >> b;
    int ans=0;
    for(int i=a;i<=b;i++){
        if((i%10)==(i/10000)&&((i%100)/10)==((i/1000)%10))ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  vector<int> v;
  int n, k;
  cin>>n>>k;
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    v.push_back(x);
  }
  
  sort(v.begin(), v.end());
  
  int ago=0;
  for(int i=0; i<k; i++){
   
    ago = ago+v[i];
    
  }
  cout<<ago;
  return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_M = 100000;

int dp[5005][5005];




int main(int argc, char *args[]) {
	int N;
	int d[51];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	int sum = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			sum += d[i] * d[j];
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
pn = gets.chomp.split(' ').map(&:to_i)

sorted = pn.sort

count = N.times.inject(0) do |c, i|
  pn[i] == sorted[i] ? c : c + 1
end

puts count <= 2 ? 'YES' : 'NO'


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


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++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 iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll N,M;
vector<PLL> py(100010);
vector<ll> yd(100010);

vector<ll> P(100000,0);
vector<ll> Y(100000,0);
vector<ll> v[100001];

int main()
{
	FAST;
	cin >> N >> M;
	rep(i,M) {
		cin >> P[i] >> Y[i];
		v[P[i]].push_back(Y[i]);
	}

	rep(i,N) {
		sort(v[i+1].begin(), v[i+1].end());
	}

	rep(i,M) {
		cout << right << setfill('0') << setw(12) << P[i]*1000000 + lower_bound(v[P[i]].begin(), v[P[i]].end(), Y[i]) - v[P[i]].begin() + 1 << "\n";
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i=1; i <= n; i++)
        if ( to_string(i).size()%2 == 1 )
            sum++;
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
# vim: fileencoding=utf-8


def main():
    n, k = map(int, input().split())
    aList = list(map(int, input().split()))
    hyoukaList = []
    c = 1
    for i in range(n):
        if i < k:
            continue
        b = aList[i - k]
        a = aList[i]

        if b < a:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 94220
//g++  7.4.0

#include <bits/stdc++.h>

using namespace std ; 

int main()
{
     int n ; 
     cin >> n ; 
    
     int x = n / 1000 ;  
    
    if(n%1000 == 0){
         
         cout << "0" ; 
    }
    
    else{ 
         
        cout << 1000 - (n%1000) ; 
    }
}

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

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

    vector<int> e(n/2);
    vector<int> o(n/2);
    for (int i=0; i<n; ++i) {
        if (i % 2 == 0) o[i/2] = a[i];  // 奇数列odd a0, a2, a4, ...
        else e[i/2] = a[i];  // 偶数列even a1, a3, a5, ...
    }

    vector<int> es(100010, 0);
    vector<int> es_(100010, 0);
    vector<int> os(100010, 0);
    vector<int> os_(100010, 0);
    for (int i=0; i<n/2; ++i) {
        ++es[e[i]];  // a2kの個数
        ++es_[e[i]];
        ++os[o[i]];  // a2k+1の個数
        ++os_[o[i]];
    }

    sort(es.begin(), es.end());
    reverse(es.begin(), es.end());  // 降順
    sort(os.begin(), os.end());
    reverse(os.begin(), os.end());  // 降順

    int em = 0, em2 = 0;
    int om = 0, om2 = 0;
    for (int i=0; i<n/2; ++i) {
        if (es_[e[i]] == es[0]) em = e[i];
        if (os_[o[i]] == os[0]) om = o[i];
        if (es_[e[i]] == es[1]) em2 = e[i];
        if (os_[o[i]] == os[1]) om2 = o[i];
    }

    int res = 0;
    if (em == om) {
        if (es_[em] > os_[om]) {
            res += n/2 - es[0];
            res += n/2 - os[1];
        } else if (es_[em] < os_[om]) {
            res += n/2 - es[1];
            res += n/2 - os[0];
        } else{
            if (es_[em2] >= os_[om2]) {
                res += n/2 - es[1];
                res += n/2 - os[0];
            } else {
                res += n/2 - es[0];
                res += n/2 - os[1];
            }
        }
    } else {
        res += n/2 - es[0];
        res += n/2 - os[0];
    }

    cout << res << endl;

}

Measured memory_bytes: 2688
#include<stdio.h>

int field[3][1001][1001];
int main(){
  int n, m, k, i, j;
  scanf("%d%d%d", &n, &m, &k);
  for(i = 1;i <= n;i++){
    for(j = 1;j <= m;j++){
      char c;
      scanf(" %c", &c);
      int check[] = {0, 0, 0}, p;
      if(c == 'J')check[0]++;
      if(c == 'O')check[1]++;
      if(c == 'I')check[2]++;
      for(p = 0;p < 3;p++){
	field[p][i][j] = field[p][i - 1][j] + field[p][i][j - 1] - field[p][i - 1][j - 1] + check[p];
      }
    }
  }
  for(i = 0;i < k;i++){
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x1--;y1--;
    printf("%d %d %d\n", field[0][x2][y2] - field[0][x2][y1] - field[0][x1][y2] + field[0][x1][y1], 
			 field[1][x2][y2] - field[1][x2][y1] - field[1][x1][y2] + field[1][x1][y1], 
			 field[2][x2][y2] - field[2][x2][y1] - field[2][x1][y2] + field[2][x1][y1]);
  }  
  return 0;
							      
}

Measured memory_bytes: 12292
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, M, L;
    cin >> N >> M >> L;
    auto graph = make_vec_nd((ll)numeric_limits<int>::max(), N, N);
    rep(i,0,N) {
        graph[i][i] = 0;
    }
    rep(i,0,M) {
        ll A, B, C;
        cin >> A >> B >> C;
        A--;
        B--;
        graph[A][B] = C;
        graph[B][A] = C;
    }
    rep(i,0,N) {
        rep(s,0,N) {
            rep(t,0,N) {
                graph[s][t] = min(graph[s][t], graph[s][i] + graph[i][t]);
            }
        }
    }
    auto cost = make_vec_nd((ll)numeric_limits<int>::max(), N, N);
    rep(i,0,N) {
        cost[i][i] = 0;
    }
    rep(s,0,N) {
        rep(t,0,N) {
            if (graph[s][t] <= L) {
                cost[s][t] = 1;
            }
        }
    }
    rep(i,0,N) {
        rep(s,0,N) {
            rep(t,0,N) {
                cost[s][t] = min(cost[s][t], cost[s][i] + cost[i][t]);
            }
        }
    }
    ll Q;
    cin >> Q;
    rep(i,0,Q) {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;
        if (cost[s][t] >= numeric_limits<int>::max()) {
            cout << -1 << endl;
        } else {
            cout << cost[s][t] - 1 << endl;
        }
    }
}



Measured memory_bytes: 2048
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int n = int.Parse(ReadLine());
      List<string> s = new List<string>();
      
      for (int i=0;i<n;i++)
      {
        s.Add(ReadLine());
      }
      
      List<long> ans = new List<long>();
      
      for (int i=0;i<5;i++)
      {
        ans.Add(0);
      }
      
      for (int i=0;i<s.Count;i++)
      {
        if (s[i].Substring(0,1)=="M")
        {
          ans[0]+=1;
        }
        else if (s[i].Substring(0,1)=="A")
        {
          ans[1]+=1;
        }
        else if (s[i].Substring(0,1)=="R")
        {
          ans[2]+=1;
        }
        else if (s[i].Substring(0,1)=="C")
        {
          ans[3]+=1;
        }
        else if (s[i].Substring(0,1)=="H")
        {
          ans[4]+=1;
        }
      }
      long answ=0;
      for (int i=0;i<5;i++)
      {
        for (int j=0;j<5;j++)
        {
          for (int k=0;k<5;k++)
          {
            //Write(i);
            //Write(j);
            //WriteLine(k);
            if (i!=j && j!=k && i!=k)
            {
              answ+=(ans[i]*ans[j]*ans[k]);
            }
          }
        }
      }
      //WriteLine(string.Join("",ans));
      WriteLine(answ/6);
    }
}

Measured memory_bytes: 44688
#include<iostream>
 using namespace std ;
 int main(){
  int A,B,C,D;

  cin>>A>>B>>C>>D;
  if((A+B)>(C+D))
     cout<<"Left";
   else if((A+B)<(C+D))
     cout<<"Right";
	else
	cout<<"Balanced"<<endl ;  
  
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, X, M;
map<ll, ll> mp;
ll acc[100010];

signed main(){
    cin >> N >> X >> M;
    if(N <= M){
        ll ans = X;
        REP(i, N - 1){
            X = X * X % M;
            ans += X;
        }
        PRINT(ans);
        return 0;
    }
    mp[X] = 1; acc[1] = X;
    ll i = 2, j = 0;
    while(i <= N){
        X = X * X % M;
        acc[i] += acc[i - 1] + X;
        if(mp[X] == 0){
            mp[X] = i;
            i++;
        }else{
            j = mp[X];
            break;
        }
    }
    ll k = i - j;
    ll ans = acc[j - 1] + ((N - j + 1) / k) * (acc[i - 1] - acc[j - 1]);
    REP(l, (N - j + 1) % k){
        ans += X;
        X = X * X % M;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 7056
#include<iostream>
using namespace std;
int main() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (a <= b) {
			r = a;
			a = b;
			b = r;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b!=0){
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  ll A,B,K;
  cin >> A >> B >> K;
  FOR(i,0,K){
    if(i%2==0){
      A = A/2*2;
      B += A/2;
      A -= A/2;
    }
    else{
      B = B/2*2;
      A += B/2;
      B -= B/2;
    }
  }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

H,W = mint()
S = [input() for _ in range(H)]

def f(i,j):
    ans = False
    for x,y in [(i+1,j), (i-1,j), (i,j-1), (i,j+1)]:
        if 0<=x<H and 0<=y<W and S[x][y]=='#':
            ans = True
            break
    return ans

for i in range(H):
    for j in range(W):
        if S[i][j]=='#':
            if not f(i,j):
                print('No')
                exit()
print('Yes')

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

int H, W, K;
vector<string> C, T;

void input_init(void) {
	cin >> H >> W >> K;
	C.resize(H);
	for (int j = 0; j < H; ++j)
		cin >> C[j];
}

void paint(int y, int x) {
	T.clear();
	T.resize(H);
	for (int j = 0; j < H; ++j)
		T[j] = C[j];
	int col = 0;
	while (y > 0) {
		if ((y & 1) == 1) {
			T[col].clear();
			T[col] = string(W, '@');
		}
		y >>= 1;
		++col;
	}
	int row = 0;
	while (x > 0) {
		if ((x & 1) == 1) {
			for (int j = 0; j < H; ++j)
				T[j][row] = '@';
		}
		x >>= 1;
		++row;
	}
}

int cnt_check(void) {
	int k = 0;
	for (int j = 0; j < H; ++j) {
		for (int i = 0; i < W; ++i) {
			if (T[j][i] == '#')
				++k;
		}
	}
	return k;
}

int solve(void) {
	int cnt = 0;
	for (int j = 0; j < (1 << H) - 1; ++j) {
		for (int i = 0; i < (1 << W) - 1; ++i) {
			paint(j, i);
			if (cnt_check() == K)
				++cnt;
		}
	}
	return cnt;
}

int main(void) {
	input_init();
	int ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3576
def main():
    n = int(input())
    xs = [int(c) for c in input().split()]
    l = int(input())

    xs.append(10 ** 17)
    nexts = list(range(n))
    for fr in range(n):
        p, q = fr, n
        while q - p > 1:
            m = (p + q) // 2
            if xs[m] - xs[fr] <= l:
                p = m
            else:
                q = m
        nexts[fr] = p

    doubling = [nexts]
    for _ in range(20):
        base = doubling[-1]
        nexts = [base[base_next] for base_next in base]
        doubling.append(nexts)

    def query(fr, to):
        if fr >= to:
            return 0
        p, q = 0, 20
        while q - p > 1:
            m = (p + q) // 2
            if doubling[m][fr] >= to:
                q = m
            else:
                p = m
        return query(doubling[p][fr], to) + 2 ** p

    q_count = int(input())
    for _ in range(q_count):
        a, b = map(int, input().split())
        if a > b:
            a, b = b, a
        a -= 1
        b -= 1

        print(query(a, b))


if __name__ == '__main__':
    main()

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

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

    cout << S.at(0) << S.at(1) << S.at(2) << endl ;
}

Measured memory_bytes: 3632