akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
using namespace std;

vector<int> G[100001];
int N;
int root;
int MAX_LOG_V = 17;
int POW[18];

int** parent;
int* depth;

void dfs(int node_id,int parent_id,int d){
	parent[0][node_id] = parent_id;
	depth[node_id] = d;
	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i] != parent_id)dfs(G[node_id][i],node_id,d+1);
	}
}

void init(){

	dfs(root,-1,0);

	for(int k = 0; k + 1 < MAX_LOG_V; k++){
		for(int node_id = 0; node_id < N; node_id++){
			if(parent[k][node_id] < 0)parent[k+1][node_id] = -1;
			else{
				parent[k+1][node_id] = parent[k][parent[k][node_id]];
			}
		}
	}
}


int lca(int left,int right){

	if(depth[left] > depth[right])swap(left,right);

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(depth[right]-depth[left] >= POW[k]){
			right = parent[k][right];
		}
	}

	if(left == right)return left;

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(parent[k][left] == parent[k][right]){
			//Do nothing
		}else{
			left = parent[k][left];
			right = parent[k][right];
		}
	}
	return parent[0][left];
}



int main(){

	for(int i = 0; i <= 17; i++)POW[i] = pow(2,i);

	scanf("%d",&N);

	int num,child;

	for(int i = 0; i < N; i++){
		scanf("%d",&num);
		for(int k = 0; k < num; k++){
			scanf("%d",&child);
			G[i].push_back(child);
		}
	}

	parent = new int*[MAX_LOG_V];
	for(int i = 0; i < MAX_LOG_V;i++)parent[i] = new int[N];
	depth = new int[N];
	root = 0;
	init();

	int Q;
	scanf("%d",&Q);

	int left,right;

	for(int i = 0; i < Q; i++){
		scanf("%d %d",&left,&right);
		printf("%d\n",lca(left,right));
	}

	return 0;
}

Measured memory_bytes: 19972
n, m = map(int, input().split())
a = [0 for i in range(m)]
b = [0 for i in range(m)]
c = []
for i in range(m):
    a[i], b[i] = map(int, input().split())
    c.append(list(map(int, input().split())))

dp = [10**6 for i in range(2**n)]
dp[0] = 0

string = [0 for i in range(n)]
for i in c[0]:
    string[i-1] = 1
string = ''.join(map(str, string))
num = int(string, 2)
dp[num] = a[0]

for i in range(1, m):
    string = [0 for i in range(n)]
    for j in c[i]:
        string[j-1] = 1
    string = ''.join(map(str, string))
    di = int(string, 2)
    for j in range(2**n):
        dp[j|di] = min(dp[j|di], dp[j]+a[i])

if dp[2**n-1] != 10**6:
    print(dp[2**n-1])
else:
    print(-1)

Measured memory_bytes: 46424
#include <iostream>
using namespace std;
 
int main(){
 
  int N;
  long long A, ans=1;
  
  cin >> N;
  
  for(int i=1; i<=N; i++){
  	cin >> A; 
    
    if(A==0){ ans=0;
             break;
    }
    
    if(A>1000000000000000000/ans)ans = -1;
    if(ans!=-1)ans*=A;
  
  }
  
  cout <<ans;
    
  return 0;
  
}

Measured memory_bytes: 3636
use proconio::input;

const N: usize = 10000001;

fn main() {
    input! {
        n: usize
    }
    let mut v = vec![0;N];
    for i in 1..=n {
        let mut j = i;
        while j <= n {
            v[j] += 1;
            j += i;
        }
    }
    let mut res = 0;
    for i in 1..=n {
        res += v[i] * i;
    }
    println!("{}", res);
}


Measured memory_bytes: 80136
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;


int main() {
 int n;
  string s;
  cin >> n >> s;
  int tmp,ans;
  ans=0;
  for(int i=1;i<n;i++){
    if(s.at(i)!='W'){
      ans++;
    }
  }
  tmp=ans;
  for(int i=1;i<n;i++){
    if(s.at(i-1)=='W'){
      tmp++;
    }
    if(s.at(i)=='E'){
      tmp--;
      if(tmp<ans){
        ans=tmp;
      }
    }
    
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 900
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int N;

    cin >> N;

    int A[N];

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

    double f;
    f = 0;
    for ( int i = 0; i < N; i ++ ) {
        f += ( 1.0 / (double)A[i] );
    }
    f = 1.0 / f;

    cout << std::setprecision(6) << f << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
t, a = gets.chomp.split.map(&:to_i)
ary = gets.chomp.split.map(&:to_i)
min = Float::INFINITY
min_index = n+1

ary.each_with_index do |item, index|
  tmp_temprature = (t-item*0.006-a).abs
  if tmp_temprature < min
    min_index = index
    min = tmp_temprature
  end
end
puts min_index+1


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string a, b, c;
  cin >> a >> b >> c;

  char t = 'A' - 'a';
  char A = a[0] + t, B = b[0] + t, C = c[0] + t;
  cout << A << B << C << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x-a) < abs(x-b)) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll H, W;

	cin >> H >> W;

	if (H == 1 || W == 1) cout << 1 << endl;
	else cout << (H * W + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>

constexpr long long MOD = 1000000007;

int main()
{
  std::string S;
  std::cin >> S;
  int n1 = (S[0] == '0' ? std::stoi(S.substr(1, 1)) : std::stoi(S.substr(0, 2)));
  int n2 = (S[2] == '0' ? std::stoi(S.substr(3, 1)) : std::stoi(S.substr(2, 2)));
  bool YYMM = false;
  if (0 < n2 && n2 < 13)
    YYMM = true;
  bool MMYY = false;
  if (0 < n1 && n1 < 13)
    MMYY = true;
  if (YYMM && MMYY)
    std::cout << "AMBIGUOUS" << std::endl;
  else if (YYMM && !MMYY)
    std::cout << "YYMM" << std::endl;
  else if (!YYMM && MMYY)
    std::cout << "MMYY" << std::endl;
  else
    std::cout << "NA" << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	
	int sum=a+b;
	if(sum%2){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	
	cout<<sum/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n, minj, cnt = 0;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    for (int i=0; i<n; i++){
        minj = i;
        for (int j=i; j<n; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        if (A[i] != A[minj]) cnt += 1;
        swap(A[i], A[minj]);
    }
    for (int i=0; i<n; i++){
        if (i == n-1){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3088
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	h := scanInts(n)

	sort.Ints(h)

	ans := 1 << 60
	for i := 0; i+k-1 < n; i++ {
		ans = min(ans, h[i+k-1]-h[i])
	}

	fmt.Fprintln(wr, ans)
}


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

using namespace std;

int main() {
  int D, G;
  int p[10];
  int c[10];
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for (int x = 0; x < (1 << D); x++) {
    int sum = 0;
    int num = 0;
    int rest_max = -1;  // 残りの配点のうち最も高いもの
    for (int i = 0; i < D; i++) {
      if ((x >> i) & 1) {
        sum += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (sum < G) {
      int v = 100 * (rest_max + 1);
      int howmany = (G - sum + v - 1) / v;
      if (howmany >= p[rest_max]) {
        continue;
      }
      num += howmany;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> maze(H+2, vector<int>(W+2,1));

  REP(h,H){
    REP(w,W){
      char tmp;
      cin >> tmp;
      if (tmp == '.')maze[h+1][w+1] = 0;
    }
  }


  int ans = 0;
  REP(h,H){
    REP(w,W){
      if (maze[h+1][w+1] == 0){
        vector<vector<int>> dist(H+2, vector<int>(W+2,10000000));

        deque<vector<int>> dq;
        vector<int> tmp(2);

        tmp[0] = h+1;
        tmp[1] = w+1;
        dq.push_back(tmp);
        dist[tmp[0]][tmp[1]] = 0;

        while(! dq.empty()){
          vector<int> next(2);
          vector<int> current(2);

          current = dq.front();
          dq.pop_front();
          ans = max({ans,dist[current[0]][current[1]]});

          //cout << current[0] << " " << current[1] << " " << dist[current[0]][current[1]] << endl;

          next[0] = current[0]-1;
          next[1] = current[1];
          if (maze[next[0]][next[1]] == 0){
            if (dist[next[0]][next[1]] > dist[current[0]][current[1]] + 1){
              dist[next[0]][next[1]] = dist[current[0]][current[1]] + 1;
              dq.push_back(next);
            }
          }

          next[0] = current[0]+1;
          next[1] = current[1];
          if (maze[next[0]][next[1]] == 0){
            if (dist[next[0]][next[1]] > dist[current[0]][current[1]] + 1){
              dist[next[0]][next[1]] = dist[current[0]][current[1]] + 1;
              dq.push_back(next);
            }
          }

          next[0] = current[0];
          next[1] = current[1]-1;
          if (maze[next[0]][next[1]] == 0){
            if (dist[next[0]][next[1]] > dist[current[0]][current[1]] + 1){
              dist[next[0]][next[1]] = dist[current[0]][current[1]] + 1;
              dq.push_back(next);
            }
          }

          next[0] = current[0];
          next[1] = current[1]+1;
          if (maze[next[0]][next[1]] == 0){
            if (dist[next[0]][next[1]] > dist[current[0]][current[1]] + 1){
              dist[next[0]][next[1]] = dist[current[0]][current[1]] + 1;
              dq.push_back(next);
            }
          }

        }

      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<string> s(n+1);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    s[n]="||";
    sort(s.begin(),s.end());
    int suc=1,tmp=0;
    string ans;
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1]){
            suc++;
        }
        else{
            if(suc>tmp){
                ans=s[i];
            }
            else if(suc==tmp){
                ans+='/'+s[i];
            }
            tmp=max(tmp,suc);
            suc=1;
        }
    }
    for(int i=0;i<ans.length();i++){
        if(ans[i]=='/'){
            cout<<endl;
        }
        else{
            cout<<ans[i];
        }
    }
    cout<<endl;
}

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

int main()
{
	double R;
	cin >> R;
	cout << setprecision(10) << 2 * R * M_PI << endl;
	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const double pi = acos(-1);

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  if (x <= a*a*b/2)
    cout << fixed << setprecision(8) << atan(a*b*b/(2*x)) * 180 / pi << endl;
  
  else
    cout << fixed << setprecision(8) << atan(2*(a*a*b-x)/(a*a*a)) * 180 / pi << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main(){
 string a,b;
 cin >> a >> b;
 string ans = "";
 if(a.length()<b.length())ans = "LESS";
 else if(a.length()>b.length())ans = "GREATER";
 else{
     if(a<b)ans="LESS";
     else if(a>b)ans="GREATER";
     else ans = "EQUAL";
 }
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
    fast();
    ll i,n;
    cin>>n;
    string s[n],temp;
    ll d[n],ans=0;
    bool flag=false;
    rep(i,n)
        cin>>s[i]>>d[i];
    cin>>temp;
    rep(i,n)
    {
        if(temp==s[i])
        {
            flag=true;
            continue;
        }
        if(flag)
        {
            ans+=d[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[1001],b[1001],cnt;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i],b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
		if(a[i]!=b[i])
			cnt++;
	if(cnt==0||cnt==2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define pp pair<int,int>
#define ff first
#define dd second
#define Q 100005
#define M 2005
#define N 200005

using namespace std; // zmienic na drzewo przedz

int n, k;

int mod = 1e9+7;

int tab[M];

map<int,int> ile;

int ans = 0;


main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> k;

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

    int kk = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) kk += (tab[i] > tab[j]);
    }

    ans = kk * k % mod;

    int ctr = 0;

    int w;
    if ((k & 1)) {
        w = k*((k-1)/2) % mod;
    } else {
        w = ((k/2)*(k-1)) % mod;
    }

 //   cout << w << endl;

    for (auto & i:ile) {
        ans += (((ctr * i.dd) % mod) * w) % mod;
        ctr += i.dd;
    }

    cout << (ans % mod) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout << a[0] + a[1] << endl;   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int N,K;
  std::cin >> N >> K;

  std::vector<int> a_arr(N);
  for(int i = 0; i < N; i++) std::cin >> a_arr[i];
  std::sort(a_arr.begin(), a_arr.end());

  long long ans=N, sum=0;
  for(int i = N-1; i >= 0; i--){
    if(sum+a_arr[i] < K) sum += a_arr[i];
    else ans = i;
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for _ in range(m):
  x=heapq.heappop(a)
  x=((x*(-1))//2)*(-1)
  heapq.heappush(a,x)










print(sum(a)*(-1))



Measured memory_bytes: 14180
N,M=map(int, input().split())
*H,=map(int, input().split())
G=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int, input().split())
    a,b=a-1,b-1
    G[a].append(b)
    G[b].append(a)
ans=0
for i in range(N):
    if G[i]:
        if H[i]>max(H[g] for g in G[i]): ans+=1
    else: ans+=1
print(ans)


Measured memory_bytes: 94864
K=int(input())
import sys

def gcd(a,b):
    if b!=0:
        return (gcd(b,a%b))
    else:
        return (a)

s=0
for i in range(1,K+1):
    for j in range(i,K+1):
        m=gcd(i,j)
        for k in range(j,K+1):
            if i==j and j==k:
                s=s+gcd(m,k)
            elif i==j and j!=k:
                s=s+gcd(m,k)*3
            elif i!=j and j==k:
                s=s+gcd(m,k)*3
            else:
                s=s+gcd(m,k)*6
print (s)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin>>n;
    string s,t;
    cin >>s >>t;
    vector<string> ans(2*n);
    rep(i,n){
        ans[2*i]=s[i];
        ans[2*i+1]=t[i];
    }
    rep(i,2*n) cout << ans[i];
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	for(int i=0;i<9;i++)
	    {
		String name=scan.next();
		int mor,aft;
		mor=scan.nextInt();
		aft=scan.nextInt();
		System.out.println(name+" "+(mor+aft)+" "+(200*mor+300*aft));
	    }
    }
}

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


int main(void) {
    int n, q, a, t, tmp1, tmp2;

    cin >> n >> q;
    fenwick_tree<long> tree(n);
    for (int i = 0; i < n; ++i) {
        cin >> a;
        tree.add(i, a);
    }

    for (int i = 0; i < q; ++i) {
        cin >> t >> tmp1 >> tmp2;
        switch (t) {
            case 0:
                tree.add(tmp1, tmp2);
                break;
            case 1:
                cout << tree.sum(tmp1, tmp2) << endl;
                break;
            default:
                ;
        }
    }

    return 0;
}


Measured memory_bytes: 8216
import sys
input = sys.stdin.readline
h,w,k = map(int,input().split())
s = 0
a = [[0]*(w+1)]
for i in range(h):
  ar = input().rstrip()
  for i in ar:
    if i == '#':
      s += 1
  a.append([0]+list(ar))
  
ans = 0
for i in range(2**(h+1)):
  for j in range(2**(w+1)):
    chk = s
    for num,ai in enumerate(a):
      if i>>num&1:
        for aa in ai:
          if aa == '#':
            chk -= 1
      else:
        for bb in range(w+1):
          if j>>bb&1 and ai[bb] == '#':
            chk -= 1
    if chk == k:
      ans += 1
print(ans//4)

Measured memory_bytes: 69120
#include <stdio.h>

int N;
int ans = 0;

void dfs(int limit,int num,int a,int b,int c){
  if(limit == 0) return;
  if(num <= N){
    if(a && b && c) ans++;
    dfs(limit-1,num*10+3,1,b,c);
    dfs(limit-1,num*10+5,a,1,c);
    dfs(limit-1,num*10+7,a,b,1);
  }
}

int main(void){
  scanf("%d",&N);
  int tmp = N;
  int cnt = 0;
  while(tmp > 0) tmp /= 10,cnt++;

  dfs(cnt+1,0,0,0,0);

  printf("%d\n",ans);

  return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  string s,t;cin>>s>>t;

  map<char, vector<int> > mp;
  for(int i=0;i<s.size();i++){
    mp[s[i]].push_back(i);
  }
  ll ans=0;
  int ptr=-1;
  for(int i=0;i<t.size();i++){
    char c = t[i];
    if(mp[c].size()==0){
      cout<<-1<<endl;
      return 0;
    }
    auto it = upper_bound(mp[c].begin(), mp[c].end(), ptr);
    if(it == mp[c].end()){
      ans+=s.size()-ptr+mp[c][0];
      ptr=mp[c][0];
    }else{
      ans+=*it-ptr;
      ptr=*it;
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4148
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
object Main extends App {
  val MOD = 1000000007

  val sc = new Scanner(System.in)

  val N = sc.nextInt
  val M = sc.nextInt

  val dp = Array.ofDim[Long](2, N + 1, N + 1)
  dp(0)(1)(1) = 1
  for(i <- 0 until M) {
    var from = i % 2
    var to = 1 - from

    dp(to) = Array.ofDim[Long](N + 1, N  + 1)

    for(j <- 1 to N) {
      for(k <- 1 to N) {
        val d = dp(from)(j)(k)
        if(d != 0) {
          if(N - j > 0) {
            dp(to)(j + 1)(k) += d * (N - j)
            dp(to)(j + 1)(k) %= MOD
          }
          if(j - k > 0) {
            dp(to)(j)(k) += d * (j - k)
            dp(to)(j)(k) %= MOD
          }
          dp(to)(j)(j) += d * k
          dp(to)(j)(j) %= MOD
        }
      }
    }
  }

  println(dp(M % 2)(N)(N))
}

Measured memory_bytes: 108692
use std::cell::Cell;
use std::io::BufRead;

const MOD: i64 = 1000000007;

#[derive(Debug)]
struct Graph {
    n: usize,
    es: Vec<Vec<usize>>,
    p2: Vec<i64>,
    total: Cell<i64>,
}

impl Graph {
    fn new(n: usize) -> Graph {
        let mut p2 = vec![];
        let mut x = 1;
        for _ in 0..n + 1 {
            p2.push(x);
            x = x * 2 % MOD;
        }
        Graph {
            n: n,
            es: vec![vec![]; n],
            p2: p2,
            total: Cell::new(0),
        }
    }

    fn dfs(&self, u: usize, p: usize) -> usize {
        let mut chd = vec![];
        let mut tsz = 1;
        for v in &self.es[u] {
            if *v == p { continue; }
            let sz = self.dfs(*v, u);
            chd.push(sz);
            tsz += sz;
        }

        if u != p {
            chd.push(self.n - tsz);
        }

        if chd.len() > 1 {
            let mut sum = 1i64;
            for sz in &chd {
                sum += self.p2[*sz] - 1;
            }
            self.total.set((self.total.get() + (self.p2[self.n - 1] - sum)) % MOD);
        }
        tsz
    }
}

fn read_line(mut buf: &mut String) -> &str {
    buf.clear();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right()
}

fn main() {
    let mut buf = String::new();
    let n: usize = read_line(&mut buf).parse::<usize>().unwrap();

    let mut g = Graph::new(n);
    for _ in 0..n - 1 {
        let mut it = read_line(&mut buf).split_whitespace().map(|x| x.parse::<usize>().unwrap() - 1);
        let a = it.next().unwrap();
        let b = it.next().unwrap();
        g.es[a].push(b);
        g.es[b].push(a);
    }
    g.dfs(0, 0);

    let mut ans = g.total.get();
    for _ in 0..n {
        ans = ans * ((MOD + 1) / 2) % MOD;
    }
    ans = (ans + MOD) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 31996
#include<stdio.h>
int main()
{
    int n,a[100],i,max=0,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
        if(max<a[i])
            max=a[i];
    }
    printf("%d\n",sum-(max/2));

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n,q;
    cin>>n>>q;
    dsu d(n);
    {
        int t,u,v;
        fr(_,q){
            cin>>t>>u>>v;
            if(t) cout<<d.same(u,v)<<'\n';
            else d.merge(u,v);
        }
    }
}

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


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n){
  if(n<2) return false;
  else if(n==2) return true;
  else if(n%2==0) return false;

  double sqrtN=sqrt(n);
  for(int i=3;i<=sqrtN;i+=2) if(n%i==0) return false;
  return true;
}

int main() {
  int x; cin>>x;
  while(1){
    if(isPrime(x)){
      cout<<x;
      return 0;
    }
    x++;
  }
}

Measured memory_bytes: 3664
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-29 12:50:48 +0900
# LastModified: 2020-06-29 13:21:56 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    which_ans = [0]*(n+1)
    penalty_cnt = [0]*(n+1)
    for _ in range(m):
        p, s = map(str, input().split())
        if which_ans[int(p)] == 0 and s == 'WA':
            penalty_cnt[int(p)] += 1
        elif which_ans[int(p)] == 0 and s == 'AC':
            which_ans[int(p)] = 1
    penalty_cnt = [0 if which_ans[i] == 0 else penalty_cnt[i] for i in range(1, n+1)]
    print(sum(which_ans), sum(penalty_cnt))

if __name__ == "__main__":
    main()


Measured memory_bytes: 11400
#include <iostream>

const int PRICE = 700;

int main()
{
  char s[4];
  int count = 0;

  std::cin >> s;

  if (s[0] == 'o') count++;
  if (s[1] == 'o') count++;
  if (s[2] == 'o') count++;

  std::cout << PRICE + (100 * count) << std::endl;

  return 0;
}

Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(a >0 && c > 0 ) {
        a -= d;
        c -= b;
    }

    if ( c <= 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    string s;
    cin >> s;
    int n=s.size();
    int r=0,b=0;
    rep(i,n){
        if(s[i]=='0'){
            r++;
        }else{
            b++;
        }
    }
    cout<<2*min(r,b)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	for (int i = 1; i <= n; i++) {
		int f;
		cin >> f;
		a[f]++;
	}
	sort(a.begin(), a.end());
	int cou = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] != 0)cou++;
	}
	if (k < cou) {
		for (int i = 1; i < n-k+1; i++) {
			ans += a[i];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str[];
		while(true){
			str=sc.nextLine().split(" ");
			if(str[0].equals("END") && str[1].equals("OF") && str[2].equals("INPUT")) break;
			for(int i=0;i<str.length;i++){
				System.out.print(str[i].length());
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

void q_sort(int x[], int start, int end);//x[start]から x[end]までの間を昇順にして、出力

int main(void)
{
	int N, K, h[100000], i, ans, a;
	scanf("%d%d", &N, &K);
	for (i = 0; i < N; i++)scanf("%d", &h[i]);
	q_sort(h, 0, N - 1);

	ans = h[K - 1] - h[0];
	for (i = 0; i <= N - K; i++) {
		a = h[i + K - 1] - h[i];
		if (a < ans)ans = a;
	}
	printf("%d", ans);
	return 0;
}

void q_sort(int x[], int start, int end)
{
	int i, k, pivot, temp;
	i = start;  
	k = end;    
	pivot = x[(i + k) / 2];
	while (1) {  
		while (x[i] < pivot)i++;
		while (pivot < x[k])k--;
		if (i >= k)break;
		temp = x[i];
		x[i] = x[k];
		x[k] = temp;//入れ替え
		i++;
		k--;
	}
	if (start < i - 1) q_sort(x, start, i - 1);
	if (k + 1 < end) q_sort(x, k + 1, end);
}

Measured memory_bytes: 512
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
n,k=mi()
a=li()
for i in range(k):
    tmp=[0]*n
    for j in range(n):
        x1=max(0,j-a[j])
        x2=min(n+1,j+a[j])
        tmp[x1]+=1
        if(x2<n-1):
            tmp[x2+1]-=1
       
    f=1
    a[0]=tmp[0]
    if(a[0]<n):
        f=0
    for j in range(1,n):
        tmp[j]+=tmp[j-1]
        a[j]=tmp[j]
        if(a[j]<n):
            f=0
    if(f):
        break
print(*a)

Measured memory_bytes: 151596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

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


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <iterator>
#include <set>
#include <utility>

namespace n91 {

void main_() {
  const auto n = scan<usize>();
  std::vector<usize> a;
  a.reserve(n + 1_z);
  a.emplace_back();
  std::copy_n(std::istream_iterator<usize>(std::cin), n, std::back_inserter(a));

  std::set<usize> b;
  for (const auto i : revrep(1_z, n + 1_z)) {
    bool f = a[i] == 1_z;
    for (usize j = i + i; j <= n; j += i) {
      if (b.find(j) != b.end()) {
        f = !f;
      }
    }
    if (f) {
      b.insert(i);
    }
  }

  std::cout << b.size() << std::endl;
  for (const auto e : b) {
    std::cout << e << " ";
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 9728
a = input().split()
for i in range(4):
    a[i] = int(a[i])
    
x = input().split()
for i in range(a[0]):
    x[i] = int(x[i])
    x.append(a[2])
    
y = input().split()
for i in range(a[1]):
    y[i] = int(y[i])
    y.append(a[3])
    
if max(x) < min(y):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
import functools
import sys


@functools.lru_cache(None)
def doit(n, k):
    if len(n) == 0 or k < 0:
        return k == 0
    d = int(n[0])
    return sum(doit(n[1:] if i == d else '9' * (len(n) - 1), k - 1 if i > 0 else k) for i in range(d + 1))


sys.setrecursionlimit(404)
print(doit(input(), int(input())))


Measured memory_bytes: 9632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASimpleCalulator solver = new ASimpleCalulator();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASimpleCalulator {
        public void solve(int testNumber, FastReader fs, PrintWriter pw) {
            long A = fs.nextLong(), B = fs.nextLong();
            long ans = (long) 1e15;
            if (A <= B) {
                ans = Math.min(ans, B - A);
            }
            A *= -1;
            if (A <= B) {
                ans = Math.min(ans, B - A + 1);
            }
            B *= -1;
            if (A <= B) {
                ans = Math.min(ans, B - A + 2);
            }
            A *= -1;
            if (A <= B) {
                ans = Math.min(ans, B - A + 1);
            }
            pw.println(ans);
        }

    }

    static class FastReader {
        BufferedReader bf;
        StringTokenizer st;

        public FastReader(InputStream is) {
            bf = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    String line = bf.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
            } catch (Exception e) {
            }

            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 8404
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

int n;
int a[N][3];
int mem[N][3];

class CVacation {
public:
    void init() {
        clr(mem, -1);
    }

    int solve(int i, int last) {
        if (i == n)
            return 0;
        if(last != -1 && mem[i][last] != -1)
            return mem[i][last];
        mem[i][last] = 0;
        for (int j = 0; j < 3; j++) {
            if (last != j)
                mem[i][last] = max(mem[i][last], solve(i + 1, j) + a[i][j]);
        }
        return mem[i][last];
    }

    void solve(istream &cin, ostream &cout) {
        init();
        cin >> n;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++)
                cin >> a[i][j];
        }
        cout << solve(0, -1);
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(void){
	int n,m;
	while(cin>>n>>m,n&&m){
		vector<int> taro,hanako;
		int sum1=0,sum2=0;
		for(int i=0,in;i<n;++i){
			cin>>in;
			sum1+=in;
			taro.push_back(in);
		}
		for(int i=0,in;i<m;++i){
			cin>>in;
			sum2+=in;
			hanako.push_back(in);
		}
		int d=sum1-sum2;
		vector<pair<int,int> > ans;
		for(int i=0;i<n;++i){
			for(int j=0;j<m;++j){
				if(d==2*(taro[i]-hanako[j])) ans.push_back(make_pair(taro[i],hanako[j]));
			}
		}
		if(ans.size()==0)cout<<"-1\n";
		else{
			int min=ans[0].first+ans[0].second,min_index=0;
			for(int i=1;i<ans.size();++i){
				int tmp=ans[i].first+ans[i].second;
				if(tmp<min){
					min=tmp;
					min_index=i;
				}
			}
			cout<<ans[min_index].first<<" "<<ans[min_index].second<<endl;
		}
	}
}

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var k = int.Parse(inputs[1]);

            var list = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();

            var dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.Abs(list[1] - list[0]);

            for (var i = 2; i < n; i++)
            {
                var d = int.MaxValue;
                for (var next = i - 1; next >= Math.Max(i - k, 0); next--)
                {
                    d = Math.Min(d, Math.Abs(list[i] - list[next]) + dp[next]);

                }
                dp[i] = d;
            }

            Console.WriteLine(dp[n - 1]);
        }
    }
}


Measured memory_bytes: 36512
main :: IO ()
main = do
  n <- readLn
  if n == 0
    then return ()
    else do
      ls <- getLine
      putStrLn $ solve ((map read . words) ls)
      main

solve :: [Int] -> String
solve ls
  | all (1 >= ) ls = "NA"
  | otherwise = show (1 + foldl (\acc x -> if x /= 0 then acc+1 else acc) 0 ls)

Measured memory_bytes: 9216
/*
 Author: Alokit Kumar
 */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int t,n,i,j,k,l;
   string s,s1;
   cin>>s;
   cin>>s1;
   l=0;
   for(i=0;i<s.size();i++)
   {
     if(s[i]!=s1[i]) l++;
   }
   cout<<l;
 }

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

class Node {
  public:
  int location;
  int p, l, r;
  Node() {}
};

class Point {
  public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y): id(id), x(x), y(y) {}
  bool operator < (const Point &p) const {
    return id < p.id;
  }
  void print() {
    printf("%d\n", id);
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

// compare関数
bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; };
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; };

// [l, r)
int makeKDTree(int l, int r, int depth) {
  if (!(l < r)) return NIL;
  int mid = (l + r) / 2;
  int t = np++;
  if (depth % 2 == 0) {
    sort(P + l, P + r, lessX);
  } else {
    sort(P + l, P + r, lessY);
  }
  T[t].location = mid;
  T[t].l = makeKDTree(l, mid, depth + 1);
  T[t].r = makeKDTree(mid+1, r, depth + 1);

  return t;
};

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if (sx <= x && x <= tx && sy <= y && y <= ty) {
    ans.pb(P[T[v].location]);
  }

  if (depth % 2 == 0) { // x軸
    if (T[v].l != NIL) {
      if (sx <= x) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T[v].r != NIL) {
      if (x <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
    }
  } else { // y軸
    if (T[v].l != NIL) {
      if (sy <= y) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
    }
    if (T[v].r != NIL) {
      if (y <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
    }
  }
};

int main() {
  int x, y;
  scanf("%d", &N);

  rep(i, 0, N) {
    scanf("%d %d", &x, &y);
    P[i] = Point(i, x, y);
    T[i].l = T[i].r = T[i].p = NIL; // 初期化
  }

  np = 0;

  int root = makeKDTree(0, N, 0);

  int q;
  scanf("%d", &q);
  int sx, tx, sy, ty;
  vector<Point> ans;
  rep(i, 0, q) {
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    ans.clear();
    find(root, sx, tx, sy, ty, 0, ans);
    sort(All(ans));
    rep(j, 0, ans.size()) {
      ans[j].print();
    }
    printf("\n");
  }

  return 0;
};



Measured memory_bytes: 16424
using System;

namespace abc152A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A == B)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long llong;

int main(int argc, const char * argv[]) {
    int X, Y, Z, K;
    
    cin >> X >> Y >> Z >> K;
    
    vector<llong> A(X);
    vector<llong> B(Y);
    vector<llong> C(Z);
    
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }
    
    vector<llong> AB;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            AB.push_back(A[i] + B[j]);
        }
    }
    sort(AB.begin(), AB.end(), greater<llong>());
    
    vector<llong> ABC;
    for (int i = 0; i < min(K, (int)AB.size()); i++) {
        for (int j = 0; j < Z; j++) {
            ABC.push_back(AB[i] + C[j]);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<llong>());
    
    for (int i = 0; i < K; i++) {
        cout << ABC[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 43240
#include<stdio.h>
#define N 36
struct Card{
  char suit;
  char value;
};
int main(){
  struct Card C1[N], C2[N],p;
  int n,i,j,mini,l=0;
  char ch;
  scanf("%d%c", &n, &ch);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
  }
  for(i=0;i<n;i++){
    C2[i] = C1[i];
  }
  for(i=0;i<n;i++){
      for(j=n-1;j>i;j--){
    if(C1[j].value < C1[j-1].value){
          p = C1[j];
          C1[j] = C1[j-1];
          C1[j-1] = p;
    }
      }
  }
  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if(C2[j].value < C2[mini].value)
	mini = j;
       }
    p = C2[i];
    C2[i] = C2[mini];
    C2[mini] = p;
  }
  for(i=0;i<n;i++){
    printf("%c%c",C1[i].suit,C1[i].value);
    if(i != n-1)
      printf(" ");
    if(i == n-1)
      printf("\n");
    }
  printf("Stable\n");
  
  for(i=0;i<n;i++){
    printf("%c%c",C2[i].suit,C2[i].value);
    if(i != n-1)
    printf(" ");
    if(i == n-1)
      printf("\n");
  }
  for(i=0;i<n;i++){
    if(C1[i].suit != C2[i].suit)
    l = 1;
  }
  if(l==1)
    printf("Not stable\n");
  else
    printf("Stable\n");
  return 0;
}

Measured memory_bytes: 612