akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int ans[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind UF(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        UF.merge(a, b);
        ans[a]--;
        ans[b]--;
    }
    rep(i, N) {
        ans[i] += UF.size(i) - 1;
    }
    rep(i, K) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(UF.issame(a, b)) {
            ans[a]--;
            ans[b]--;
        }
    }
    rep(i, N) {
        if(i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4008
#include<stdio.h>
#define M 1000000007 

long long int power(long long int x,  long long int n) {
	 long long int tmp;

	 if (n == 0)return 1;

	 tmp = power((x*x) % M, n / 2);
	 if (n % 2) {
		 tmp = (tmp * x) % M;
	 }
	return tmp;
}

int main(void)
{
	long long int m, n;
	scanf("%lld %lld", &m, &n);
	printf("%lld\n",power(m,n));
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
pair<int,int> a[2222];
int n;
vector<int> v[2222],v2[2222];
priority_queue<int> pq;
bool use[2222];
inline void dfs(int x){
	use[x]=1;
	for(int i=0;i<v[x].size();++i){
		if(use[v[x][i]]) continue;
		v2[x].push_back(v[x][i]);
		dfs(v[x][i]);
	}
} 
int main(){
	int i,j;
	cin>>n;
	for(i=1;i<=n;++i){
		cin>>a[i].first;
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n;++i) for(j=1;j<=n;++j) if(__gcd(a[i].first,a[j].first)!=1) v[i].push_back(j);
	for(i=1;i<=n;++i) if(!use[i]) pq.push(i),dfs(i);
	memset(use,0,sizeof(use));
	while(!pq.empty()){
		int t(pq.top());
		pq.pop();
		use[t]=0;
		for(i=0;i<v2[t].size();++i) pq.push(v2[t][i]);
		cout<<a[t].first<<' ';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 15872
gets

total=[]

while line = gets
  arr = line.chomp.split(/\s+/).map(&:to_i)
  puts "#{arr.join(" ")} #{arr.sum}"
  arr.each_with_index {|v,i| total[i] ||=0; total[i] += v}
end
puts "#{total.join(" ")} #{total.sum}"


Measured memory_bytes: 6992
#include<stdio.h>
#include<math.h>

int main(){
  int i,j=0,l;
  int x;
  int count=0;
  int n[10000];
  
  scanf("%d",&i);
  
  while(1){
    scanf("%d",&n[j]);
    if(i == j+1)break;
    else j++;
  }
  
  for(j=0 ; j<i ; j++){
    for(x=2 ; x <= sqrt(n[j]) ; x++){
      if(n[j] % x ==0) break;
    }
      if(n[j] % x!=0 || n[j]==2 || n[j]==3) count++;
    }
  printf("%d\n",count);
}



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

import sys
import numpy as np
from itertools import groupby
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = list(readline().decode().rstrip())
K = int(readline())

g = [len(list(g)) for _, g in groupby(S)]

if len(g) == 1:
    print(len(S) * K // 2)
else:
    acc = sum(l // 2 for l in g) * K
    if S[0] == S[-1] and g[0] % 2 == 1 and g[-1] % 2 == 1:
        acc += K - 1
    print(acc)


Measured memory_bytes: 12412
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll count = 0;
  for(ll i=1;i<=n;i++){
    if(i%3==0||i%5==0){
      
    }else{
      count = count + i;
    }
  }
  cout<<count<<endl;
}

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

int main(){
    int N;
    cin >> N;
    int total = 0;
    for(int i = 0; i < N; i++){
        int start,end;
        cin >> start >> end;
        total += end - start + 1;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	long int L, R, i, j, min_temp ;
	int min= 2019;
 
	scanf("%ld", &L);
	scanf("%ld", &R);
 
	if(R-L >= 2019-1){
		min = 0;
		printf("%d", min);
		return 0;
	}
 
	for(i=L; i<=R; i++){
		for(j=i+1; j<=R; j++){
			if((i*j)%2019 < min){
				min = (i*j)%2019;
			}
		}
	}
	
	printf("%d", min);		
 
	return 0;
}

Measured memory_bytes: 128
while True:
    n, x = map(int, input().split())
    if n == 0:
        break
    cnt = 0
    for i in range(1, min(n - 1, x // 3)):
        for j in range(i + 1, n):
            if j < x - i - j <= n:
                cnt += 1


    print(cnt)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;cin >> A >> B;
  int count = 0;
  repp(i,A,B+1){
    string s = to_string(i);
    int N = s.length();
    bool isPN = true;
    rep(j,N/2){
      if(s[j] != s[N-1-j])isPN=false;
    }
    if(isPN)++count;
  }
  cout << count << endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int sum[n]={};
  int a[n][3],b[n][100]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin >> a[i][j];
      b[j][a[i][j]-1]+=1;
    }
  }
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      if(b[j][a[i][j]-1]==1)
        sum[i]+=a[i][j];
  for(int i=0;i<n;i++)
    cout << sum[i] << endl;
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	char a, b;
	cin >> a >> b;
	if (a==b) {
		cout << 'H' << endl;
	}
	else {
		cout << 'D' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n,m;
  cin >> n >> m;
  int sum = 0;
  REP(i,m){
    int a;
    cin >> a;
    sum += a;
  }
  cout << (n>=sum ? n-sum : -1) << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int mx = 0;
  int mx2 = 0;
  rep(i, N)
  {
    if (mx < A[i])
    {
      mx2 = mx;
      mx = A[i];
    }
    else if (mx2 < A[i])
    {
      mx2 = A[i];
    }
  }

  rep(i, N)
  {
    if (A[i] == mx)
      cout << mx2 << endl;
    else
      cout << mx << endl;
  }

  return 0;
}


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

int main(){
    int S;
    cin >> S;
    
    int h, m, s;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll dp[55][55][2505];

int main() {
  ll n, k;
  cin >> n >> k;

  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  FOR(i, 1, n + 1) {
    rep(j, i + 1) {
      FOR(k, 2 * j, n * n + 1) {
        if (j < i) dp[i][j][k] = (j + 1) * (j + 1) * dp[i - 1][j + 1][k - 2 * j];
        dp[i][j][k] += (2 * j + 1) * dp[i - 1][j][k - 2 * j];
        if (j != 0) dp[i][j][k] += dp[i - 1][j - 1][k - 2 * j];
        dp[i][j][k] %= mod;
      }
    }
  }
  cout << dp[n][0][k] << endl;


  
  return 0;
}

Measured memory_bytes: 59520
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let s: String = read();
    let ch: Vec<char> = s.chars().collect();
    let mut count:i64 = 0;
    for i in 0..3{
	if ch[i]=='o' {
	    count+=1;
	}
    }
    println!("{}",700+count*100);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <istream>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <map>


using namespace std;


int mod(int a, int b) {
    int r = a % b;
    return r < 0 ? r + b : r;
}


int main() {
    long long l, r; cin >> l >> r;
    long long cnd, cur_cnds_size;
    bool is_terminate = false;

    int cnt = 0;
    set<int> candidate_set;
    for (int i=l; i<r; i++) {
        for (int j=i+1; j<=r; j++) {
            cnd = ((i%2019)*(j%2019)%2019);
            candidate_set.insert(cnd);
            cnt++;

            if (cnt >= 100000) {
                is_terminate = true;
                break;
            }
        }

        if (is_terminate) break;
    }
    cout << *candidate_set.begin() << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int number[4];

int usednum[4];
int num[4];
int ope[3];

int solve(int c, int o);
int check();
void makeEx(int type);
int culc(int a, int c, int b);

int main() {
	int i, count = 0;

	while (1) {
		memset(usednum, 0, sizeof(usednum));
		for (i = 0; i < 4; i++) {
			cin >> number[i];
			if (number[i] == 0)
				count++;
		}
		if (count == 4)
			break;
		if (solve(0, 0) == 0)
			cout << "0" << endl;
	}
	return 0;
}

int solve(int c, int o) {
	int i;

	if (c == 4 && o == 3) {
		if (check()) {
			return 1;
		}
	} else {
		if (c - o == 1) {
			for (i = 0; i < 3; i++) {
				ope[o] = i;
				if (solve(c, o + 1))
					return 1;
			}
		} else {
			for (i = 0; i < 4; i++) {
				if (!usednum[i]) {
					num[c] = number[i];
					usednum[i] = 1;
					if (solve(c + 1, o))
						return 1;
					usednum[i] = 0;
				}
			}
		}
	}
	return 0;
}

int check() {
	if (culc( culc( culc( num[0], ope[0], num[1]), ope[1], num[2]), ope[2], num[3]) == 10) {
		makeEx(1);
		return 1;
	}
	if (culc( culc(num[0], ope[0], num[1]), ope[1], culc(num[2], ope[2], num[3])) == 10) {
		makeEx(2);
		return 1;
	}
	return 0;
}

int culc(int a, int c, int b) {
	int ans = a;
	switch (c) {
	case 0:
		ans += b;
		break;
	case 1:
		ans -= b;
		break;
	case 2:
		ans *= b;
		break;
	}
	return ans;
}

void makeEx(int type) {
	char c[3];
	int i;
	for (i = 0; i < 3; i++) {
		switch (ope[i]) {
		case 0:
			c[i] = '+';
			break;
		case 1:
			c[i] = '-';
			break;
		case 2:
			c[i] = '*';
			break;
		}
	}
	if (type == 1)
		printf("(((%d %c %d) %c %d) %c %d)", num[0], c[0], num[1], c[1], num[2], c[2], num[3]);
	else
		printf("((%d %c %d) %c (%d %c %d))", num[0], c[0], num[1], c[1], num[2], c[2], num[3]);
	putchar('\n');
}

Measured memory_bytes: 1184
import Data.List
main=do
 getLine
 a<-sort.map read.words<$>getLine
 let x=reverse$sort$f a
 print$if length x>=2 then(product$take 2 x)else 0
f(a:b:s)
 |a==b=a:f s
 |otherwise=f$b:s
f _=[]

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

using static Input;
//using static Util;
class Program
{
    static string S;
    static void INPUT()
    {
        S = NextString();
    }
    static void OUT()
    {
        var b = false;
        foreach (var c in S)
        {
            b |= c == '7';
        }

        Console.WriteLine(b ? "Yes" : "No");
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}




Measured memory_bytes: 17612
def boundary_find(array, limit):
    ceil = len(array) - 1 
    floor = 0
    while 1:
        center = (ceil + floor) // 2
        if array[center] <= limit:
            floor = center
        else:
            ceil = center
        if ceil - floor == 1:
            break
    return ceil

n, c, k = map(int, input().split())
tList = [int(input()) for _ in range(n)]
tList.sort()
count = 0
first = 0
while 1:
    limit = tList[first] + k
    last = min(first + c, n)
    if tList[last - 1] <= limit:
        mark = last
    else:
        mark = boundary_find(tList, limit)
    count += 1
    first = mark
    if first == n:
        break
print(count)

Measured memory_bytes: 7508
#include <stdio.h>
int main(){
int ma[10];
int f,s,t,i;
for(i=0;i<10;i++){
scanf("%d",&ma[i]);
}
f=0;
s=0;
t=0;
for(i=0;i<10;i++){
if(ma[i]>t){
t=ma[i];
}
if(ma[i]>s){
t=s;
s=ma[i];
}
if(ma[i]>f){
s=f;
f=ma[i];
}
}
printf("%d\n%d\n%d\n",f,s,t);
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void) {
  int i, j, k, a[100], n, l, minj, temp, count = 0;
  char buf[2];
  scanf("%d", &l);
  for (n = 0; n < l && (j = scanf("%d%1[\n]", a+n, buf)) == 1; n++) ;
  if (j == 2)
  n++;

  for (i = 0; i < l; i++) {
    minj = i;
    for (j = i; j < l; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    if (a[i] != a[minj]) {
      count++;
    }
    temp = a[i];
    a[i] = a[minj];
    a[minj] = temp;
  }

    for (k = 0; k < l; k++) {
      printf("%d", a[k]);
      if (k < n - 1) {
        printf(" ");
      }
    }
    printf("\n");
    printf("%d\n", count);
    return 0;
  }



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

void constructXOR(int A[], int n) 
{ 
	int XOR = 0; 
	for (int i = 0; i < n; i++) 
		XOR ^= A[i]; 
	for (int i = 0; i < n; i++) 
		A[i] = XOR ^ A[i]; 
} 

int main() 
{ 
    long int n;
    cin>>n;
	int A[n]; 
    for(int i=0;i<n;i++)
      cin>>A[i];
	constructXOR(A, n); 
	for (int i = 0; i < n; i++) 
		cout << A[i] << " "; 
	return 0; 
} 


Measured memory_bytes: 4368
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

int main(){
  double v, y, t;
  while(cin >> v){
    for(int i = 1;; i++){
      y = 5 * i - 5;
      // y = 4.9 * t * t;
      t =  sqrt(y / 4.9);
      if(9.8 * t >= v){
        cout << i << endl;
        break;
      }
    }
  }
}

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

int q;
string X, Y;


int main(void) {
  cin >> q;
  for (int i = 0; i < q; i++) {
    int dp[1000][1000];
    cin >> X >> Y;
    memset(dp, 0, sizeof(dp));

    dp[0][0] = X[0] == Y[0];
    for (int j = 1; j < Y.size(); j++) dp[0][j] = dp[0][j-1] || X[0] == Y[j];
    for (int j = 1; j < X.size(); j++) dp[j][0] = dp[j-1][0] || X[j] == Y[0];

    for (int j = 1; j < X.size(); j++) {
      for (int k = 1; k < Y.size(); k++) {
        if (X[j] == Y[k]) {
          dp[j][k] = dp[j-1][k-1] + 1;
        } else {
          dp[j][k] = max(dp[j-1][k], dp[j][k-1]);
        }
      }
    }

    cout << dp[X.size()-1][Y.size()-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 7072
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    V = string_to_int(inputs[0])
    N = len(V)
    N_HALF = N // 2
    counts = {
        0: {},
        1: {}
    }
    for i, v in enumerate(V):
        key = i % 2
        if v in counts[key]:
            counts[key][v] += 1
        else:
            counts[key][v] = 1

    counts_sorted = []
    for i in range(2):
        counts_sorted.append(
            sorted(list(counts[i].items()), key=lambda x: x[1], reverse=True)
        )

    def count_replace(first, first_i, second, second_i):
        replace_count = N_HALF - counts_sorted[first][first_i][1]
        replace_count += N_HALF - counts_sorted[second][second_i][1]
        return replace_count

    if counts_sorted[0][0] == counts_sorted[1][0]:
        len_0 = len(counts_sorted[0])
        len_1 = len(counts_sorted[1])
        if len_0 == 1 and len_1 == 1:
            return N_HALF
        elif len_0 == 1:
            return N_HALF - counts_sorted[1][1][1]
        elif len_1 == 1:
            return N_HALF - counts_sorted[0][1][1]
        else:
            cs = []
            cs.append(count_replace(0, 0, 1, 1))
            cs.append(count_replace(0, 1, 1, 0))
            return min(cs)

    else:
        return count_replace(0, 0, 1, 0)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 63980
N=int(input())
List = [[] for i in range(N+1)]
for i in range(N):
    l=list(map(int,input().split()))
    List[l[0]]=l[2:]
#print(List)
D=[10**9 for i in range(N+1)]

Q=[[0,1]]
for i in range(10**9):
    if len(Q)==i:
        break
    if D[Q[i][1]]==10**9:
        D[Q[i][1]]=Q[i][0]
        for j in List[Q[i][1]]:
            if D[j]==10**9:
                Q.append([Q[i][0]+1,j])
for i in range(1,N+1):
    if D[i]==10**9:
        print(i,-1)
    else:
        print(i,D[i])


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

int N;
vector<int> a = { 11 };

bool isPrime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> N;
	for (int i = 12; i < 55555; i++) {
		if (isPrime(i) && i % 5 == 1) {
			a.push_back(i);
			if (a.size() == N) break;
		}
	}

	string ans = to_string(a[0]);
	for (int i = 1; i < N; i++) {
		ans += " " + to_string(a[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    cout << abs(a[n-1]-a[0]) << endl;
    return 0;
}

Measured memory_bytes: 256
N,K,Q=map(int,input().split())
A=list(map(int,input().split()))
a=list(set(A))
a.sort()
ans=float("inf")
def condition(i,num):
    if i>a[num]:
        return False
    X=a[num]
    Y=A[i]
    check=0
    stack=0
    count=0
    for k in range(0,N):
        if A[k]>X:
            stack+=1
        elif A[k]>=Y:
            stack+=1
            count+=1
        else:
            t=stack+1-K
            check+=max(min(t,count),0)
            stack=0
            count=0
    t=stack+1-K
    check+=max(min(t,count),0)
    return check>=Q

for i in range(0,N):
    start=0
    end=len(a)-1
    while end-start>1:
        test=(end+start)//2
        if condition(i,test):
            end=test
        else:
            start=test
    if condition(i,start):
        ans=min(ans,a[start]-A[i])
    elif condition(i,end):
        ans=min(ans,a[end]-A[i])
print(ans)


Measured memory_bytes: 54748
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;
const int MAX = 310;

ll dp[MAX][MAX][MAX];

int main(){
	int N, M; cin >> N >> M;
	ll sum = 1;
	rep(j, MAX) dp[1][j][0] = 1;
	for(int sv=2; sv<MAX; sv++){
		for(int se=1; se<MAX; se++){
			for(int bv=0; bv<=sv-1; bv++){
				if(bv==0){
					if(se<sv) sum = 0;
					dp[sv][se][bv] = sum;
					sum = dp[sv][se][bv]*sv%mod;
				}else{
					dp[sv][se][bv] = (bv*dp[sv][se-1][bv] + (sv-1)*dp[sv-1][se-1][bv-1])%mod;
					sum = (sum + dp[sv][se][bv]*(sv-bv))%mod;
				}
			}
		}
	}
	cout << dp[N][M][0] << endl;
	return 0;
}


Measured memory_bytes: 232192
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    int n,c,k,t,tlim,jokyaku,ans=0;cin>>n>>c>>k;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>t;vec[i]=t;
    }
    sort(all(vec));
    for(int i=0;i<n;i++){
        t=vec[i];
        if(i==0){
            tlim=t+k;
            jokyaku=1;
        }
        else{
            if(tlim<t){
                ans++;
                tlim=t+k;
                jokyaku=1;
            }
            else{
                if(jokyaku+1>c){
                    ans++;
                    tlim=t+k;
                    jokyaku=1;
                }
                else jokyaku++;
            }
        }
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    lli sum = 0;

    rep(i, n+1) if(i%3 != 0 && i%5 != 0) sum += i;
    cout << sum << endl;
}

Measured memory_bytes: 3596
import itertools
N = int(input())
lis_hl = list(itertools.product('01',repeat = N))
#1正直者 　0不親切
A = []
X = []
for i in range(N):
    A.append(int(input()))
    Y =[]
    for j in range(A[-1]):
        Y.append(list(map(int,input().split())))
    X.append(Y)
honesty = 0
for hl in lis_hl:#honesty laier list
    flag = 0
    for i in range(N):#人について探査
        if flag == 0:
            is_hl = hl[i]# これから証言するひとは正直者か
            if is_hl == '1':
                
                for xi in X[i]:#証言を全探索
                    if xi[1] != int(hl[xi[0]-1]):
                        flag = 1
                        break
    if flag == 0:
        honesty = max(honesty,hl.count('1'))
print(honesty)


Measured memory_bytes: 14508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S;
    cin >> S;
    char last = ' ';
    rep(i,4){
        if(last == S[i]){
            cout << "Bad" << endl;
            return 0;
        }
        last = S[i];
    }
    cout << "Good" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int n,m,z;
ll ans;
ll x[100001],y[100001];

int main(){

  cin>>n>>m;
  z = (n-1)*(m-1);
  for(int i=0;i<n;i++)
    cin>>x[i];
  for(int i=0;i<m;i++)
    cin>>y[i];

  ll sumx=0,sumy=0;
  for(int i=1;i<=n;i++){
    sumx+= (2*i-n-1)*x[i-1];
    sumx %=mod;
}
  for(int i=1;i<=m;i++){
    sumy+=(2*i-m-1)*y[i-1];
    sumy %=mod;
  }
  ans = (sumx*sumy)%mod;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
import math
Q = int(raw_input())
L, R = [], []
for i in range(Q):
	l_r = [int(num) for num in raw_input().split()]
	L.append(l_r[0])
	R.append(l_r[1])

max_num = max(R)
def calc_sosus(max_num):
	IsPrimes = [True] * (max_num + 1)
	IsPrimes[0] = False
	IsPrimes[1] = False
	for min_i in range(2, int(math.sqrt(max_num)) + 1):
		if IsPrimes[min_i]:
			for num in range(min_i*min_i, max_num+1, min_i):
				IsPrimes[num] = False
	return IsPrimes

IsPrimes = calc_sosus(max_num)

c_s = [0] * (max_num + 1)
for i in range(2, max_num + 1):
	if (IsPrimes[i]) & (((i+1) % 2)==0) & (IsPrimes[(i+1)/2]): 
		c_s[i] = c_s[i-1] + 1
	else:
		c_s[i] = c_s[i-1]

for i in range(Q):
	print c_s[R[i]] - c_s[L[i]-1]

Measured memory_bytes: 15004
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ll z=n%10;
    if (z==2||z==4||z==5||z==7||z==9)
    {
        cout<<"hon\n";
    }
    else if (z==3)
    {
        cout<<"bon\n";
    }
    else
    {
        cout<<"pon\n";
    }
    
    
}


Measured memory_bytes: 3652
IDENTIFICATION DIVISION.
PROGRAM-ID. 167B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(144).
01 A          PIC 9(10).
01 B          PIC 9(10).
01 C          PIC 9(10).
01 K          PIC 9(10).
01 CNT        PIC S9(10).
01 OUT        PIC -(10)9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO A B C K.
*>
  IF (A >= K)
    MOVE K TO A
    MOVE 0 TO C
  ELSE
    IF (A + B >= K)
      MOVE 0 TO C
    ELSE
      COMPUTE C = K - A - B
    END-IF
  END-IF.
*>
  COMPUTE CNT = A - C.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


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

int main() {
  int N;
  cin >> N;
  int m = 1;
  int x = N;
  int y;
  
	while (x >= 1) {
      y += x % 10;
      m *= 10;
      x = N / m; 
    }
  
  if (N % y == 0)
	  cout << "Yes" << endl;
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
//package maximumcup2018;
import java.util.*;

public class Main {

    static public int n;
    static int[] A = new int[50];
    static int[] B = new int[50];

    public Boolean fun(Long bit){
        boolean[][] arr = new boolean[51][51];
        for(int i = 0; i <= 50; i++) {
                arr[i][i] = true;
        }
        for(int i = 1;i <= 50; i++){
            if((bit & (1L<<i)) != 0){
                for(int j = 0;j <= 50;j++){
                    arr[j][j%i] = true;
                }
            }
        }

        for(int k = 0;k <= 50;k++){
            for(int i = 0;i <= 50;i++){
                for(int j = 0;j <= 50;j++){
                    arr[i][j] |= arr[i][k] & arr[k][j];
                }
            }
        }

        Boolean flag = true;

        for(int i = 0;i < n;i++){
            if(!arr[A[i]][B[i]])flag = false;
        }

        return flag;

    }

    public void solve(){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        for(int i = 0;i < n;i++) {
            A[i] = sc.nextInt();
        }
        for(int i = 0;i < n;i++) {
            B[i] = sc.nextInt();
        }

        Long ans = (1L << 50) - 1;

        if(!fun(ans)) {
            System.out.println(-1);
            return;
        }

        for(int i = 50;i >= 0;i--){
            Long tmp = ans & ~(1L << i);
            if(fun(tmp))ans = tmp;
        }

        System.out.println(ans);

    }

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

Measured memory_bytes: 24792
#include<stdio.h>
#include<stdlib.h>
int *marge(int[], int, int);
int cnt;
int main(){
  int n, i;
  scanf("%d", &n);
  int *A;
  A = (int *)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++)
    scanf("%d", &A[i]);
  cnt = 0;
  A = marge(A, 0, n);
  for(i = 0; i < n - 1; i++)
    printf("%d ", A[i]);
  printf("%d\n%d\n", A[i], cnt);
  free(A);
  return 0;
}

int *marge(int A[], int l, int r){
  if(l == r - 1){
    int *tmp;
    tmp = (int *)malloc(sizeof(int));
    tmp[0] = A[l];
    return tmp;
  }
  int *L, *R;
  L = (int *)malloc(sizeof(int) * ((r - l) / 2));
  R = (int *)malloc(sizeof(int) * ((r - l + 1) / 2));
  L = marge(A, l, (l + r) / 2);
  R = marge(A, (l + r) / 2, r);
  int *B;
  int i, j, k;
  i = j = k = 0;
  B = (int *)malloc(sizeof(int) * (r - l));
  while(1){
    if(i < (r - l) / 2 & j < (r - l + 1) / 2){
      if(L[i] < R[j]){
	B[k] = L[i];
	i++;
	k++;
      }
      else{
	B[k] = R[j];
	j++;
	k++;
      }
      cnt++;
    }
    else{
      if(i < (r - l) / 2 | j < (r - l + 1) / 2){
	if(i < (r - l) / 2){
	  B[k] = L[i];
	  i++;
	  k++;
	}
	else{
	  B[k] = R[j];
	  j++;
	  k++;
	}
	cnt++;
      }
      else
	break;
    }
  }
  free(L);
  free(R);
  return B;
}

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

int main(){
  string s;
  cin >> s;
  
  bool easy_dance = true;
  
  for( int  i = 0; i < s.size(); i++ ){
    if( ( i % 2 == 0 && s.at(i) == 'L' ) || ( i % 2 == 1 && s.at(i) == 'R' ) ){
      easy_dance = false;
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
  
      


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int maxn = 107;
int a[maxn*maxn];
int d[maxn][maxn];
int n,m,c;
int main()
{
    cin>>n>>m>>c;
    for(int i=1;i<=c;i++)cin>>a[i];
    int k = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i&1)
            {
                if(a[k]>0)
                {
                    d[i][j]=k;
                    a[k]--;
                    if(a[k]==0)k++;
                }
            }
            else
            {
                if(a[k]>0)
                {
                    d[i][m-j+1]=k;
                    a[k]--;
                    if(a[k]==0)k++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }
}


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

#ifdef _DEBUG
#define ASSERT(x) assert(x)
#define DLOG(x) cout << #x " " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif

using namespace std;

struct Node {
  int parent{-1};
  int depth{-1};
  vector<int> children;
};

int calcDepth(map<int, Node>& nodes, int id) {
  auto& n = nodes[id];
  auto d = n.depth;
  if (d != -1) {
    return d;
  } else if (n.parent == -1) {
    return 0;
  }
  int d0 = calcDepth(nodes, n.parent);
  return n.depth = d0 + 1;
}

int main() {
  int n;
  cin >> n;
  map<int, Node> nodes;
  for (int i = 0; i < n; ++i) {
    int id;
    int numChild;
    cin >> id >> numChild;
    auto& children = nodes[id].children;
    for (int j = 0; j < numChild; ++j) {
      int childId;
      cin >> childId;
      children.push_back(childId);
      ASSERT(nodes[childId].parent == -1);
      nodes[childId].parent = id;
    }
  }

  for (auto&& pair : nodes) {
    auto id = pair.first;
    auto& n = pair.second;
    if (n.depth == -1) {
      n.depth = calcDepth(nodes, id);
    }
    cout << "node " << id << ": parent = " << n.parent << ", depth = " << n.depth
         << ", ";

    if (n.parent == -1) {
      cout << "root";
    } else if (n.children.empty()) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }

    cout << ", [";
    bool first{true};
    for (auto&& c : n.children) {
      if (first)
        first = false;
      else
        cout << ", ";
      cout << c;
    }
    cout << "]" << endl;
  }
}



Measured memory_bytes: 11640
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
int K ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  cin >> N >> K ;
  ll a  = 0 ;
  ll b  = 0 ;
  for (int x = 1 ; x <= N ;  x++){
  if( x%K == 0 )
    a++;
  if( x%K ==K/2 )
    b++;
  }
  ll ans = 0 ;
  ans += a*a*a;
  if(K %2 == 0 ){
  ans += b*b*b ;
  }
  cout << ans << endl ;



  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
    int R;
    double c;
    cin>>R;
    c=2*3.14159265358979323846*R;
    cout<<fixed<<setprecision(20)<<c<<endl;
    return 0;
}


Measured memory_bytes: 3760
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}


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

int main()
{
    int n,a,b,c,d;
    char s[200000];
    int result = 1;

    if(scanf("%d %d %d %d %d", &n, &a, &b, &c, &d) < 5){
        exit(1);
    }
    if(scanf("%s", s) <1){
        exit(1);
    }
    
    while(c != a || d !=b){
 //       printf("%d, %d\n",a,b);
        
        if(c > d && a < b){
            if(s[a+1] == '.' && (a+2) != b && (a+2) <= c){
                a = a + 2;
            }else if(s[a] == '.' && (a+1) != b && (a+1) <= c){
                a++;
            }else if((a+2) == b || (a+1) == b){
                if(s[b] == '.' && (b+1) <= d){
                    b++;
                }else if(s[b+1] == '.' && (b+2) <= d){
                    b = b + 2;
                }
                else{
                    result = 0;
                    break;
                }
            }else{
                result = 0;
                break;
            }
        }else if(c > d && c != a){
            if(s[a+1] == '.' && (a+2) <= c){
                a = a + 2;
            }else if(s[a] == '.' && (a+1) <= c){
                a++;
            }else{
                result = 0;
                break;
            }
        }else if(c > d && d != b){
            if(s[b+1] == '.' && (b+2) <= d){
                b = b + 2;
            }else if(s[b] == '.' && (b+1) <= d){
                b++;
            }else{
                result = 0;
                break;
            }
        }else if(d != b){
            if(s[b+1] == '.' && (b+2) <= d){
                b = b + 2;
            }else if(s[b] == '.' && (b+1) <= d){
                b++;
            }else{
                result = 0;
                break;
            }
        }else if(c != a){
            if(s[a+1] == '.' && (a+2) <= c){
                a = a + 2;
            }else if(s[a] == '.' && (a+1) <= c){
                a++;
            }else{
                result = 0;
                break;
            }
        }
    }
//    printf("%d, %d\n",a,b);
    
    if(result == 0){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long  W,H,x,y;
  double ans;
  int ans2;
  cin >> W >> H >> x >> y;
  if(W/2==x && H/2 == y && W%2==0 && H%2==0)
    ans2=1;
  else
    ans2=0;

  printf("%lf %d\n",(double)(W*H)/2.0,ans2);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define MAX(a, b)((a) < (b) ? (b) : (a))

using namespace std;

int pow32(int base, int exp)
{
    int ret = 1;
    
    while (exp) {
        if ((exp & 1) == 1) ret *= base;
        
        exp >>= 1;
        base *= base;
    }
    
    return ret;
}

void YES()
{
    printf("YES\n");
}

void NO()
{
    printf("NO\n");
}
 
int main() {
	int N;
	int a, b, c;
	int longest;

	scanf("%d", &N);
	
	while (N--) {
	    scanf("%d %d %d", &a, &b, &c);
	    
	    longest = MAX(a, MAX(b, c));
	    
	    if (longest == a) {
	        if (pow32(a, 2) == (pow32(b, 2) + pow32(c, 2))) YES();
	        else NO();
	    } else if (longest == b) {
	        if (pow32(b, 2) == (pow32(a, 2) + pow32(c, 2))) YES();
	        else NO();
	    } else if (longest == c) {
	        if (pow32(c, 2) == (pow32(a, 2) + pow32(b, 2))) YES();
	        else NO();
	    }
	}
	
	return 0;
}

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

int main() {

  string s;
  cin >> s;

  int K;
  cin >> K;

  set<string> st;

  for (int i = 0; i < s.size(); i++) {
    string s_ = "";
    for (int j = i; j < s.size(); j++) {
      s_ += s[j];
      st.insert(s_);
      if (K < s_.size()) {
        break;
      }
    }
  }

  int count = 1;
  for (auto item:st) {
    if (count == K) {
      cout << item << endl;
      break;
    }
    count++;
  }

  return 0;

}


Measured memory_bytes: 2176
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

func main() {
	sc.Split(bufio.ScanWords)

	for i := 0; i < 5; i++ {
		tmp := nextInt()
		if tmp == 0 {
			fmt.Println(i + 1)
		}
	}

}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;

#ifdef LOCAL
  #define debug_echo(e) cin << "L" << __LINE__ << ": " << e
  #define debug_repr(e) cin << "L" << __LINE__ << ": " << #e << " = " << e
#else
  #define debug_echo(e)
  #define debug_repr(e)
#endif

int main() {
  ll N; cin >> N;
  ll ans = 0;
  rep (i, N+1) {
    if (i*i <= N) {
      ans = i*i;
    } else {
      break;
    }
  }
  cout << ans << endl;
}


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

int main() {
    string abcd; cin >> abcd;
    int ABCD=0; 
    int cnt=0;
    ABCD = stoi(abcd);
    cnt=4;

    for(int i=0; i<(1<<cnt); i++){
        int ans = 0;
        int tmp = ABCD;
        string s;
        for(int j=cnt-1; j>=0; j--){
            if(1<<j & i){
                ans -= tmp/(int)pow(10, j);
                if(j!=cnt-1) s += '-';
                s += to_string(tmp/(int)pow(10, j));
                tmp = tmp % (int)pow(10,j);
            }
            else{
                ans += tmp/(int)pow(10, j);
                if(j!=cnt-1) s += '+';
                s += to_string(tmp/(int)pow(10, j));
                tmp = tmp % (int)pow(10,j);
            }
        }


        if(ans==7){
            cout << s << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<u32>();

    let mut sum = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            sum += v[i] * v[j];
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    long long n;
    long long daisum;
    cin >> n;

    long long ai;
    long long aim;
    daisum = 0;
    for (int i=0; i<n; i++) {
        if (i==0) {
            // 2
            cin >> aim;
        } else {
            // 1
            cin >> ai;
            if (aim > ai) {
                daisum += (aim-ai);
            } else {
                aim = ai;
            }
        }
    }
    
    cout << daisum;
}


Measured memory_bytes: 3592