akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int D, T, S;
    cin >> D >> T >> S;
    ATYN(S*T >= D)

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 20000,MaxS = 30000;
typedef long long LL;
int n;
vector<int> s;
LL sum;

int main() {
    scanf("%d",&n);
    if (n==3) return printf("%d %d %d\n",2,5,63),0;
    s.push_back(2);s.push_back(3);sum=5;n-=2;
    for (int i=4;i<=MaxS;++i)
        if (i%2==0 || i%3==0) {
            s.push_back(i);
            n--;
            sum+=i;
            if (n==0) break;
        }
    if (sum%6) {
        int it=s.back();
        for (int i=MaxS;i>it;--i) if (i%2==0 || i%3==0) {
            for (int j=(int)s.size()-1;j>=2;--j) if ((sum-s[j]+i)%6==0) {
                sum=sum-s[j]+i;
                s[j]=i;
                break;
            }
            if (sum%6==0) break;
        }
    }
    for (int i=0;i<(int)s.size();++i) printf("%d ",s[i]);
    return 0;
}

Measured memory_bytes: 512
n = int(input())
h = [int(i) for i in input().split()]
ans = 0
while sum(h) > 0:
    L = 0
    if 0 not in h:
        ans += 1
        for i in range(n):
            h[i] -= 1
    else:
        for i in range(n):
            if h[i] == 0 and L != i:
                for j in range(L,i):
                    h[j] -= 1
                ans += 1
                L = i + 1
            elif h[L] == 0:
                L += 1
            if i == n-1 and h[i] != 0:
                for j in range(L,n):
                    h[j] -= 1
                ans += 1
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
 
priority_queue<pair<int,int> >pq;
 
int n;
int a[maxn],b[maxn];
ll ans=0;
 
inline int getpos(const int &x){if(x==n+1)return 1;if(x==0)return n;return x;}
void No(){cout<<"-1\n";exit(0);}
 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
//	freopen("data.in","r",stdin);
	
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++)
	{
		pq.push(make_pair(b[i],i));
	}
	
	while(!pq.empty())
	{
		int p=pq.top().second;pq.pop();
		int minu=b[getpos(p-1)]+b[getpos(p+1)];
		int k=(b[p]-a[p])/minu;
		if((b[p]-a[p])%minu==0)
		{
			ans+=k;
			b[p]=a[p];
			continue;
		}
		if(minu>=b[p])No();
		if(k==0)k++;
		ans+=k;
		b[p]%=minu;pq.push(make_pair(b[p],p));
		if(b[p]<a[p])No();
	}
	cout<<ans<<'\n';
//	cerr<<"loopcount:"<<lc<<'\n';
	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int l[203],n,ans;
int main(){
  cin>>n;
  for(int i=0;i<n*2;i++)cin>>l[i];
  sort(l,l+(n*2));
  for(int i=(n*2)-2;i>=0;i-=2)ans+=l[i];
  cout<<ans<<endl;
}


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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

vector<ll> divisors(ll n) {
    vector<ll> v;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            v.push_back(i);
            if (i * i != n) {
                v.push_back(n / i);
            }
        }
    }
    return v;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> d = divisors(n);
    ll ans = (ll)INF * INF;
    REP(i, sz(d)) {
        ll x = n / d[i];
        chmin(ans, x - 1 + d[i] - 1);
    }
    cout << ans << EOL;
}


Measured memory_bytes: 384
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int a[maxn],sum,ans,n,k,b[maxn];

inline bool jud(int x)
{
	for(int i=1;i<=n;i++) b[i]=a[i]%x;
	sort(b+1,b+n+1);
	int l=1,r=n,nl=0,nr=0;
	while(nl<=k) {nl+=b[l]; l++;} l--;
	while(nr<=k) {nr+=(x-b[r]); r--;} r++;
	if(l-1>=r) return true; return false;
}

int main()
{
	n=5; k=2;
	n=read(); k=read(); ans=1;
	for(int i=1;i<=n;i++) a[i]=read(),sum+=a[i];
	for(int i=2;i*i<=sum;i++)
	{
		if(sum%i==0)
		{
			if(jud(i)) ans=max(ans,i);
			if(jud(sum/i)) ans=max(ans,sum/i);
		}
	}
	if(jud(sum)) ans=max(ans,sum);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define MAX 100005
#define read (freopen("input.txt", "r", stdin));
#define write (freopen("output.txt", "w", stdout));

using namespace std;

int main()
{
    //read; write;
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, l, r, m;

    cin>>n>>m;

    int Min = 1e9, Max = 0;
    for(int i = 0; i < m; i++){
        cin>>l>>r;
        Max = max(Max, l);
        Min = min(Min, r);
    }

    if(Max > Min){
        cout<<0<<endl;
    }
    else{
        cout<<Min - Max + 1<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
 
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])

dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))    

Measured memory_bytes: 285892
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
using namespace std;

int main(){
	ll n, k; cin >> n >> k;
	string s; cin >> s;
	s[k - 1] += 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
using namespace std;
long long mem[50] = {0};
long long fib(int n){
	if (mem[n] != 0) return mem[n];
	if (n == 0 || n == 1){
		mem[n] = 1;
		return 1;
	}
	else{
		mem[n] = fib(n - 1) + fib(n - 2);
		return fib(n - 1) + fib(n - 2);
	}
}
int main(){
	int n;
	cin >> n;
	cout << fib(n) << "\n";
	return 0;
}


Measured memory_bytes: 3088
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

tree = []
root_index = []
depths = []


def main():
    n = int(input())

    # 初期化
    for i in range(n):
        tree.append(Node(i, None, None))
        root_index.append(i)
        depths.append(0)

    for i in range(n):
        node_number, _, *c_list = list(map(int, input().split()))
        tree[node_number].child = c_list

        for c in c_list:
            tree[c].parent = tree[node_number]
            root_index.remove(c)

    root = tree[root_index[0]]
    root.parent = Node(-1, None, None)

    setDepth(root, 0)
    showTree(root)


def setDepth(node, d):
    depths[node.number] = d
    for c in node.child:
        setDepth(tree[c], d + 1)


def getDepth(node_number):
    return depths[node_number]


def showTree(root):
    for node in tree:
        type = ""
        if node.parent.number == -1:
            type = "root"
        elif len(node.child) == 0:
            type = "leaf"
        else:
            type = "internal node"

        print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(str(node.number), str(node.parent.number), str(depths[node.number]), type, node.child))


class Node():
    def __init__(self, number, parent, child):
        self.number = number
        self.parent = parent
        self.child = child


if __name__ == '__main__':
    main()



Measured memory_bytes: 39036
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	char a, b;
	scanf("%c %c", &a, &b);
	//cin >> a >> b;
	//cout << r << endl;
	printf((a==b) ? "H\n" : "D\n");
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, m;
int ans[101010];
vector<int> v[101010];
void solve(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a,b;
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int p = q.front(); q.pop();
		for(int i = 0; i < v[p].size(); i++){
			int j = v[p][i];
			if(ans[j]) continue;
			ans[j] = p+1;
			q.push(j);
		}
	}
	for(int i = 1; i < n; i++){
		if(ans[i] == 0){
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
	for(int i = 1; i < n; i++){
		cout << ans[i] << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 10588
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int N;
// string S[100000];
int AC;
int WA;
int TLE;
int RE;
string tmp;
int main(){
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        /* code */
        cin >> tmp;
        if(tmp == "AC"){
            AC++;
        }
        else if(tmp == "WA"){
            WA++;
        }
        else if(tmp == "TLE"){
            TLE++;
        }
        else if(tmp == "RE"){
            RE++;
        }
    }

    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;
P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1)%LEN;
}
P dequeue(){
	P x = Q[head];
	head = (head + 1)%LEN;
	return x;
}

int min(int a,int b){return a<b ? a:b;}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for(i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n+1;
	
	while(head != tail){
		u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else{
			printf("%s %d\n",u.name, elaps);
		}
	}
	return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

bool check(int a){
    if(a >= 1 && a <= 12){
        return true;
    }else{
        return false;
    }
}
int main(){
    int s;
    cin >> s;
    int a = s / 100;
    int b = s % 100;
    bool f = check(a);
    bool d = check(b);
    if(f && d){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }else if(f && !d){
        cout << "MMYY" << endl;
        return 0;
    }else if(!f && d){
        cout << "YYMM" << endl;
        return 0;
    }else if(!f && !d){
        cout << "NA" << endl;
        return 0;
    }
    return 0;
}

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

using namespace std;

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

  int N;
  cin >> N;

  int x, y;
  long long a, b;
  cin >> a >> b;
  for (int i = 1; i < N; ++i) {
    cin >> x >> y;
    long long n = max((a - 1) / x + 1, (b - 1) / y + 1);
    a = n * x;
    b = n * y;
  }

  cout << a + b << endl;

  return 0;
}


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

int main ()
{
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
	
//	freopen ("//specify file name","r",stdin);
//	freopen ("output.txt","w",stdout);
	
	int n,k;
	cin>>n>>k;
	
	long long array[n];
	
	for (int i=0;i<n;i++) cin>>array[i];
	
	long long dp[n];
	
	dp[0]=0;
	
	for (int i=1;i<n;i++)
	{
		dp[i] = dp[i-1]+abs(array[i-1]-array[i]);
		
		for (int j=2;j<=k;j++)
		{
			if (i>=j)
			dp[i] = min (abs(array[i-j]- array[i]) + dp[i-j] , dp[i]);
			
		}
	
		
	  // dp[i]= min ( (abs(array[i-2]-array[i]) + dp [i-2]), abs (array[i-1] - array[i])+ dp[i-1]  );
		
	}
	cout<<dp[n-1];
	
	return 0;
	
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class abc154_c
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int N = readint();
            int[]A = ReadIntArray();

            HashSet<int> s = new HashSet<int>();
            int ngCount = 0;
            foreach(int i in A)
            {
                if (s.Contains(i))
                {
                    ngCount = 1;
                    break;
                }
                s.Add(i);
            }
            if (ngCount > 0)
            {
                println("NO");
            }
            else
            {
                println("YES");
            }
        }

        private static void println(string s)
        {
            Console.WriteLine(s);
        }

        private static int readint()
        {
            String s = Console.ReadLine();
            return int.Parse(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }

#if TEST
#else
    }
}
#endif


Measured memory_bytes: 35408
using System;
using System.Collections.Generic;

namespace MyProgram{
    class AtCoder{
        static void Main(){
            long[] input0 = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
            long N = input0[0];
            long K = input0[1];
            long[] a = new long[N];
            long[] b = new long[N];
            for(var i=0;i<N;i++){
                long[] input = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
                a[i] = input[0];
                b[i] = input[1];
            }
            var dict = new Dictionary<long,long>();
            for(var i=0;i<N;i++){
                if(!dict.ContainsKey(a[i]))dict[a[i]] = b[i];
                else dict[a[i]]+=b[i];
            }
            Array.Sort(a);
            long temp = -1;
            long count=0;
            for(var i=0;i<N;i++){
                if(temp != a[i])count+=dict[a[i]];
                temp = a[i];
                if(count >=K){
                    Console.WriteLine(a[i]);
                    break;
                }
            }
        }  
    } 
}

Measured memory_bytes: 20676
#include <stdio.h>

int main(void) {
	double tmp;
	double bottom = 10000000000;
	double top = 0;
	
	while(scanf("%lf", &tmp)==1) {
		if(bottom > tmp) {
			bottom = tmp;
		}
		if(top < tmp) {
			top = tmp;
		}
	}
	
	printf("%.1lf", top-bottom);
	
	return 0;
}

Measured memory_bytes: 652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  reverse(all(a));
  ll ans=0;
  vector<ll> v(0);
  rep(i,n-1){
    if(a[i]==a[i+1]){
      v.push_back(a[i]);
      i++;
    }
    if(v.size()==2){
      break;
    }
  }
  if(v.size()==2) cout << v[0]*v[1] << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int count=0;
    string a,b;
    cin>>a;
    cin>>b;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
        {
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3864
def main():
  n=int(input())
  ans=[]
  if n==0:
    print(0)
  while n!=0:
    s=n%2
    ans.append(s)
    if s==0:
      n//=(-2)
    else:
      n=(n-1)//(-2)
  ans=ans[::-1]
  print(''.join([str(bit) for bit in ans]))
if __name__=='__main__':
  main()

Measured memory_bytes: 3060
x, k, d = map(int, input().split())
n1 = abs(x) - d * k
if n1 >= 0:
  print(n1)
else:
  m = abs(x) // d
  if (m - k) % 2 == 0:
    print(abs(x) - m * d)
  else:
    print(abs((abs(x) - (m + 1) * d)))

Measured memory_bytes: 9180
(* O(n) *)
let solve n k =
  let rec find acc i =
    if i + k - 1 > n then
      acc
    else
      find (acc + 1) (i + 1)
  in
    find 0 1

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [n; k] -> solve n k |> string_of_int |> print_endline
  | _ -> ()

Measured memory_bytes: 384
#include<stdio.h>

#include<math.h>

#define MAX 300000



int main(){

	int i,j;

	int n;

	int board[MAX + 1];



	for(i = 0;i < MAX;i++){

		board[i] = (i % 7 == 1 || i % 7 == 6);

	}

	board[1] = 0;



	j = 6;

	while(j < MAX){

		for(i = 2 * j;i < MAX;i += j)board[i] = 0;

		j++;

		while(!board[j]){

			if(j == MAX - 1)break;

			j++;

		}

		if(j == MAX - 1)j++;

	}

	

	while(scanf("%d",&n),n != 1){

		printf("%d:",n);

		for(i = 0;i <= n;i++){

			if(board[i]){

				if(n % i == 0)printf(" %d",i);

			}

		}

		puts("");

	}

	return 0;

}

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

int cmp(const void *a, const void *b) {
  return ((long*)a)[1]  - ((long*)b)[1];
}

int main() {
  int n, i;

  int time = 0;

  long a[200000][2];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%ld", &(a[i][0]));
    scanf("%ld", &(a[i][1]));
  }

  qsort(a, n, 2 * sizeof(long), cmp);

  for (i = 0; i < n; i++) {
    time += a[i][0];
    if (time > a[i][1]) {
      printf("No\n");
      exit(0);
    }
  }
  printf("Yes\n");
}


Measured memory_bytes: 6396
use std::collections::HashMap;

fn main() {
    let n = read();

    let mut map: HashMap<i64, i64> = HashMap::new();
    for i in 1..n + 1 {
        trial_division_sqrt(i, &mut map);
    }

    // for (k, v) in &map {
    //     println!("{}, {}", k, v);
    // }
    let mut ans: i64 = 1;
    for v in map.values() {
        // println!("{}", *v);
        ans *= *v + 1;
        ans %= 1000000007;
    }

    println!("{}", ans);
}

fn trial_division_sqrt(n: i64, map: &mut HashMap<i64, i64>) {
    let mut n = n;
    let limit = ((n as f64).sqrt() + 2.0) as i64;

    for i in 2..limit {
        while n % i == 0 {
            n /= i;
            if map.contains_key(&i) {
                *map.get_mut(&i).unwrap() += 1;
            } else {
                map.insert(i, 1);
            }
        }
    }
    if n > 1 {
        if map.contains_key(&n) {
            *map.get_mut(&n).unwrap() += 1;
        } else {
            map.insert(n, 1);
        }
    }
}

fn read() -> i64 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
def gcd( x, y )
	if 0 == y
		return x
	else
		return gcd( y, x%y )
	end	
end

a, b = gets.split( " " ).map { |val| val.to_i }
if a < b
	a, b = b, a
end
puts( gcd( a, b ) )

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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

void solve(long long N, std::vector<long long> B) {
    vl A(N, MAX);
    rep(i, N - 1) {
        A[i] = min(A[i], B[i]);
        A[i + 1] = min(A[i + 1], B[i]);
    }
    for (auto&& i : A) {
        ans += i;
    }
    print(ans);
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> B(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &B[i]);
    }
    solve(N, std::move(B));

    return 0;
}


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

using namespace std;


int main(void){

  int A;
  int n,m;
  int count[101];

  while(1){

    cin >> n >> m ;

    
  if( n == 0 && m == 0 ) break;

  for(int i = 0; i < m ; i++ ) count[i] = m - i;

  for( int i = 0 ; i < n ; i++ ){

    for( int j = 0 ; j < m ; j++ ){

      cin >> A;
      
      if( A == 1 ) count[j] += 1000; 
      
    }
  }

  sort( count , count + m );
  
  cout << 1 + m - ( count[ m - 1 ] % 1000);
  
  for( int i = m - 2 ; i >= 0 ; i-- ){

    cout << " " << 1 + m - ( count[ i ] % 1000);

  }

  cout << endl;

  }

    return 0;
}
  

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;++i)cin>>v[i];
    sort(v.begin(),v.end(),greater<int>());
    int sum=0;
    for(int i=0;i<k;++i)sum+=v[i];
    cout<<sum<<"\n";
    return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


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

    if (s.size() % 2 != 0) {
        cout << "No" << endl;
        ret();
    }

    rep(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] == 'h') continue;
            else {
                cout << "No" << endl;
                ret();
            }
        } else {
            if (s[i] == 'i') continue;
            else {
                cout << "No" << endl;
                ret();
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
const int HW_MAX = 200;
const int C_NUM = 10;
int main (void) {
    int H;
    int W;
    int c[C_NUM][C_NUM];
    int A[HW_MAX][HW_MAX];

    cin >> H >> W;
    for (int i = 0; i < C_NUM; i++) {
        for (int j = 0; j < C_NUM; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    for (int k = 0; k < C_NUM; k++) {
        for (int i = 0; i < C_NUM; i++) {
            for (int j = 0; j < C_NUM; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] != -1) ans += c[A[i][j]][1];
        }
    }

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

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

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

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) {
      break;
    }
    vector<int> a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int su = 0;
    for(int i=1;i<n-1;++i) {
      su += a[i];
    }
    cout << su / (n - 2) << endl;
  }

}



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

int n;
double a[55];

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    for (int i = 1; i < n; ++i)
        a[i] = (a[i] + a[i-1])/2;
    printf("%.9lf\n", a[n-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n;cin>>n;
  ll L[100];L[0]=2;L[1]=1;
  rep(i,89) L[i+2] = L[i+1] + L[i];
  cout << L[n] << endl;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int c = 0;
  int d = 1;
  while(c < n) {
    if (d * 2 < d + k) {
      d *= 2;
    } else {
      d += k;
    }
    c++;
  }
  cout << d << endl;
}


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

int main()
{
int a,b,c,x;
cin>>a>>b>>c>>x;
long int sum=0;
for(int i=0;i<=a;i++){
  for(int j=0;j<=b;j++){
    int t=x-500*i-100*j;
    t/=50;
    if(t>=0 && t<=c)
      sum++;
  }
}
cout<<sum;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];

  ll leftLength, rightLength = 0;
  int leftIdx = 0;
  int rightIdx = n-1;
  
  while (true) {
    if (leftLength<rightLength) {
      leftLength += a[leftIdx];
      if (leftIdx == rightIdx)
      break;
      leftIdx++;
    } else {
      rightLength += a[rightIdx];
      if (leftIdx == rightIdx)
      break;
      rightIdx--;
    }
    
  }
  std::cout << abs(leftLength - rightLength) << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

const int long long st = 1000000007;

int main(){
    int n; cin >> n;
    long long ans = 1;
    for(int i = 1; i<=n; ++i){
        ans = ans*i%st;
    }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a>b){
swap(a,b);
}if(b>c){
swap(b,c);
}if(a>b){
swap(a,b);
}
cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 3088
using System;

class ABC_166_D
{
    static void Main(string[] args)
    {
        int X = int.Parse(Console.ReadLine());

        long[] table = new long[241];
        for(int i=0; i<241; i++)
        {
            long n = i - 120;
            table[i] = n*n*n*n*n;
        }

        int A = 0;
        int B = 0;

        for (int i = 0; i < table.Length; i++)
        {
            A = i - 120;
            for (int j = 0; j < table.Length; j++)
            {
                B = j - 120;
                if(table[i]-table[j]==X)
                {
                    Console.WriteLine(string.Format("{0} {1}", A, B));
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 27444
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define eps 1e-3
#define debug(a) cout << #a": " << a << endl;
inline int lowbit(int x){ return x & -x; }
const int N = 3e5 + 10;
const int mod = (int) 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
using namespace std;

//char buf[100000],*p1=buf,*p2=buf;
//inline char nc(){
//  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline bool read(int & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//inline bool readL(LL & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//LL q_pow(LL base, LL b){LL res=1;for(base%=mod;b;b>>=1,base=base*base%mod)if(b&1){res=res*base%mod;}return res;}

struct node {
  int X, Y, H;
  bool operator < (const node &t) const {
    return H > t.H;
  }
}point[105];

int main(){
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    scanf("%d%d%d", &point[i].X, &point[i].Y, &point[i].H);
  }
  sort(point + 1, point + 1 + n);
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <= 100; j++) {
      int hight = 0;
      bool flag = true, extraFlag = false;
      for(int k = 1; k <= n; k++) {
        if(k == 1) {
          if(point[k].H == 0) extraFlag = true;
          hight = point[k].H + abs(point[k].X - i) + abs(point[k].Y - j);
        }
        else {
          if(point[k].H == 0) {
            if(extraFlag) hight = min(hight, abs(point[k].X - i) + abs(point[k].Y - j));
            else if(abs(point[k].X - i) + abs(point[k].Y - j) < hight) {
                flag = false;
                break;
              }
          } else if(hight != point[k].H + abs(point[k].X - i) + abs(point[k].Y - j)) {
            flag = false;
            break;
          }
        }
      }
      if(flag) {
        printf("%d %d %d", i, j, hight);
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
nmc_data = input()
b_data = input()
nmc = nmc_data.split(" ")
b = b_data.split(" ")

nmc_int = []
for i in range(3):
    nmc_int.append(int(nmc[i]))
b_int = []
for i in range(int(nmc[1])):
    b_int.append(int(b[i]))

answer = 0
for j in range(int(nmc[0])):
    a_data = input()
    a = a_data.split()
    a_int = []
    for k in range(len(a)):
        a_int.append(int(a[k]))
    getsum = nmc_int[2]
    for i in range(nmc_int[1]):
        getsum = getsum + a_int[i] * b_int[i]
    if getsum > 0:
      answer += 1
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
inline void chmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, T b) { a = max(a, b); }
template <class T>
inline bool kbit(T &x, int k) { return ((x >> k) & 1LL); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin >> x;
    for (ll b = -200; b <= 200; b++) {
        for (ll a = -200; a <= 200; a++) {
            if (a * a * a * a * a - b * b * b * b * b == x) {
                cout << a << " " << b << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int>p(n);
  vector<int>q(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> q.at(i);
  }
  vector<int>a(n);
  for(int i=0;i<n;i++){
    a.at(i)=i+1;
  }
  map<vector<int>,int>mp;
  do{
    mp[a]=mp.size();
  }while(next_permutation(a.begin(),a.end()));
  int ans=fabs(mp[p]-mp[q]);
  cout << ans << endl;
}
         
  

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

int main( ) {
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool isPostalCode = true;
  if ( s.size() != (a + b + 1) ) isPostalCode = false;

  if ( s[a] != '-' ) isPostalCode = false;

  for( int i = 0; i < s.size(); i++ ) {
    if ( i == a ) continue; 
    bool isNum = false;
    for (int j = 0; j < 10; j++ ) {
      char x = '0' + j;  
      if ( x == s[i] ) isNum = true;
    }
    if( !isNum ) isPostalCode =false;
  }
  if( isPostalCode ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 888
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left, insort
from itertools import accumulate
def inpl(): return tuple(map(int, input().split()))

K = int(input())
A = inpl()
if A[-1] != 2:
    print(-1)
    exit()

l, r = 2, 3
for a in A[:-1][::-1]:
    l = (l//a)*a + int(l%a!=0)*a
    r = (r//a)*a + (a-1)
    if r < l:
        print(-1)
        break
else:
    print(l, r)


Measured memory_bytes: 14656
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=10;
using namespace std;
int main(){
	int i,j;
	char a[N],b[N];
		cin>>a;
		getchar();
			cin>>b;
		if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
			cout<<"YES"<<endl;
			}
			else
				cout<<"NO"<<endl;
	
	return 0;
	}

Measured memory_bytes: 256
# 初期入力
K,N = (int(x) for x in input().split(" "))
A = list(map(int, input().split()))
A.append(0) # 基準地点を最後に追加、スタートが０でもうまくいく

# 1件となりまでの距離
kyori = [ A[i+1] -A[i] for i,v in enumerate(A[:-1]) ]
kyori[-1] = kyori[-1] + K # n番目から基準までは全体から「引く」
kyori.append(A[0] -A[-1] ) # 基準から1番目までの距離
x_saisyo_saigo = kyori[-2] +kyori[-1]
kyori.append(x_saisyo_saigo) # n番目から1番目の距離

# 最短距離は、全体からmax(隣の家との距離)を引く
kyori_min = K - max(kyori)
print(kyori_min)

Measured memory_bytes: 26444
#include<stdio.h>
int n,q,k;
int A[20];

int solve(int i,int sum ){
    if(i==n) return sum==k;

    if( solve(i+1,sum) ) return 1;
    if( solve(i+1,sum+A[i]) ) return 1;

    return 0;
}

int main(void){
    int i;

    scanf("%d",&n);
    for(i=0;i<n;i++){
	scanf("%d",&A[i]);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
	scanf("%d",&k);
	if( solve(0,0) ) printf("yes\n");
	else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	puts(C>=A&&B>=C?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
require 'set'
class Dice
  attr_accessor :faces

  # |T F L|
  # |B U R|
  def initialize(faces)
    top, front, right, left, back, bottom = faces
    @faces = [[top, bottom], [front, back], [left, right]]
  end

  def move(commands)
    commands.split('').each do |com|
      case com.upcase.to_sym
      when :E
        faces[0], faces[2] = faces[2], faces[0].reverse
      when :W
        faces[0], faces[2] = faces[2].reverse, faces[0]
      when :N
        faces[0], faces[1] = faces[1], faces[0].reverse
      when :S
        faces[0], faces[1] = faces[1].reverse, faces[0]
      end
    end
  end

  def ==(other)
    me = faces
    he = other.faces
    me_face_set = me.map{|f| Set[*f]}
    he_face_set = he.map{|f| Set[*f]}
    if Set[*me_face_set] != Set[*he_face_set]
      return false
    end
    commands = (["N"]*3 + ["E"]*3)
    commands.permutation(commands.size).to_a.uniq.each do |com|
      com.each do |c|
        move(c)
        return true if faces == other.faces
      end
    end
    false
  end

end

$stdin = DATA if $<.eof?

gets

dices = ARGF.each.map do |line|
  Dice.new(line.split.map(&:to_i))
end

match = dices.combination(2).any? do |da, db|
  da == db
end

puts(match ? "No" : "Yes")

Measured memory_bytes: 10308
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll K; cin >> K;
    ll L = (K % 7 == 0) ? K / 7 * 9 : 9 * K;
    ll cnt = 1;
    ll M = 10 % L;
    while (cnt < L) {
        if (M == 1) {
            cout << cnt << endl;
            return 0;
        }
        M = (M * 10) % L;
        cnt++;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
using namespace std;
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int inf = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 1500;
const ll mod = 1e9 + 7;
int dir[4][2] = { { 1,0 },{ 0,1 } ,{ 0,-1 },{ -1,0 } };
bool vis[maxn][maxn];
queue<pair<int,int>> q;
int cnt[maxn][maxn];
int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> g(n);
    for (int i = 0; i < n; i++)
        cin >> g[i];
    q.push({ 0,0 });
    vis[0][0] = 1;
    cnt[0][0] = 1;
    while (!q.empty())
    {
        pair<int,int> f = q.front();
        q.pop();
        for (int i = 0; i < 2; i++)
        {
            int x = f.first + dir[i][0], y = f.second + dir[i][1];
            if (x >= 0 && x < n && y >= 0 && y < m && g[x][y] == '.')
            {
                cnt[x][y] = (cnt[f.first][f.second] + cnt[x][y]) % mod;
                if (!vis[x][y])
                {
                    vis[x][y] = 1;
                    q.push({ x,y });
                }
            }
        }
    }
    cout << cnt[n - 1][m - 1] << endl;
    return 0;
}

Measured memory_bytes: 12724
fun main (args: Array<String>) {
    val userInput : String = readLine()!!
    val sameArray = arrayListOf(2,4)
    var isSameFlag:Boolean = true
    for (i:Int in sameArray) {
       if(!(userInput[i] == userInput[i+1])) {
           isSameFlag = false
       }
    }
    if (isSameFlag) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 31796
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	string s; cin >> s;
    
    sort(s.begin() , s.end());
    
    int counter = 0;
    char c = s[0];
    
    if(s.size() == 1)
    {
        cout << "No";
        return 0;


    }
    
    REP(i,s.size()){
        if(s[i] == c)
        {
            counter++;
        }
        else if(counter % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
        else{
            c = s[i];
            counter = 1;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] A=new int[101];
int a=0;
while(true){
String x=scan.next();
String y=scan.next();
int n=Integer.parseInt(x);
int m=Integer.parseInt(y);
if(n==0&&m==0)
break;
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
for(int k=j+1;k<=n;k++){
if(i+j+k==m)
sum++;
}
}
}
A[a]=sum;
a++;
}
for(int z=0;z<a;z++)
System.out.println(A[z]);
}
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  vll x(200100);
  irep(i,1,n){
    ll v=i-a[i];
    if(v>0 && v<=200000) x[v]++;
  }
  
  ll ans=0;
  rep(i,n){
    ll v=a[i]+i;
    if(v>200000) continue;
    ans+=x[v];
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 6368
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


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

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        String[] SX = new String[q];
        String[] SY = new String[q];
        for(int i = 0; i < q; i++) {
            SX[i] = sc.next();
            SY[i] = sc.next();
        }
        for(int i = 0; i < q; i++) {
            System.out.println(solve(SX[i], SY[i]));
        }
    }

    public static int solve(String X, String Y) {
        int m = X.length();
        int n = Y.length();
        int[][] dp = new int[m + 1][n + 1];
        for(int i = 0; i < m + 1; i++) dp[i][0] = 0;
        for(int j = 0; j < n + 1; j++) dp[0][j] = 0;
        for(int i = 1; i < m + 1; i++) {
            for(int j = 1; j < n + 1; j++) {
                if(X.charAt(i - 1) == Y.charAt(j - 1)) dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        return dp[m][n];
    }
}

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

bool A(string s){
    string t=s;
    reverse(t.begin(), t.end());
    return t==s;
}

int main() {
    string S;
    cin >> S;
    bool ans=true;
    if (!A(S)) ans=false;
    if (!A(S.substr(0,S.size()/2))) ans=false;
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

    int n = 0;
    int k = 0;
    int c = 0;
    int a[100];
    int out = 0;
    cin >> n >> k >> c;
    for (int l = 0; l < k; ++l) {
        cin >> a[l];
    }
    for (int i = 0; i < n; ++i) {
        int ans = 0;
        for (int j = 0; j < k; ++j) {
            int v = 0;
            cin >> v;
            ans += v*a[j];
        }
        ans += c;
        if(ans > 0){
            out++;
        }
    }
    cout<< out << endl;
    return 0;
}


Measured memory_bytes: 256