akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

int main(){
	int H=get(),W=get(),h=get(),w=get();
	if (H%h==0&&W%w==0){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	int x=(H/h)*(W/w)+1,y=x*(h*w-1)+1;
	fo(i,1,H){
		fo(j,1,W)
		if (i%h==0&&j%w==0)printf("%d ",-y);else printf("%d ",x);
		putchar('\n');
		
	}
	return 0;
}

Measured memory_bytes: 2048
#define F first
#define S second
#define EPS 1E-10
using namespace std;
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#include <bits/stdc++.h>
#define int64 long long int
#define infl 0x3f3f3f3f3f3f3f3fll
#define uint64 unsigned long long int


int main ()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) puts ("Possible");
	else puts ("Impossible");
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> x(n);
    for (Int i = 0; i < n; i++) {
        cin >> x[i];
    }
    sort(all(x));
    Int mi = INF;
    for (Int i = 1; i <= 100; i++) {
        Int sum = 0;
        for (Int j = 0; j < n; j++) {
            sum += (x[j] - i) * (x[j] - i);
        }
        mi = min(mi, sum);
    }
    dump(mi);
    return 0;
}


Measured memory_bytes: 256
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, k, a[105];
bool dru[N];

int main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  for (int i = 0; i < a[1]; ++i)
    dru[i] = true;
  for (int i = a[1]; i <= k; ++i) {
    dru[i] = true;
    for (int j = 1; j <= n; ++j)
      if (a[j] <= i && dru[i-a[j]])
        dru[i] = false;
  }
  if (dru[k])
    cout<<"Second\n";
  else
    cout<<"First\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	vector<lint>a(3);
	rep(i,3)cin>>a.at(i);
	sort(all(a));
	cout<<(a.at(0)%2==0||a.at(1)%2==0||a.at(2)%2==0?0:a.at(0)*a.at(1))<<"\n";
}

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

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

import collections

c = collections.Counter(a)

combinations = [0] + [0] * n
for i in range(0, n+1):
    combinations[i] = (i * (i-1)) // 2
memo = [0] + [0] * n

for k in c:
    memo[k] = combinations[c[k]]

total = sum(memo)
for i in a:
    print(total - memo[i] + combinations[c[i] - 1])


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int W, H, dp[110][110][2][2];
const int MOD = 100000, dx[2] = {1,0}, dy[2] = {0,1};

void modAdd(int& a, int b) { a = (a + b) % MOD; }

void solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0][0][1] = dp[0][0][1][1] = 1;
	
	for_(y,0,H) for_(x,0,W) {
		for_(d,0,2) for_(f,0,2) {
			int nx = x + dx[d], ny = y + dy[d];
			
			modAdd(dp[ny][nx][d][0], dp[y][x][d][f]);
			
			if (f == 0) {
				int dd = (d + 1) % 2;
				nx = x + dx[dd];
				ny = y + dy[dd];
				
				modAdd(dp[ny][nx][dd][1], dp[y][x][d][f]);
			}
		}
	}
	
	int ans = 0;
	for_(d,0,2) for_(f,0,2) modAdd(ans, dp[H - 1][W - 1][d][f]);
	cout << ans << endl;
}

int main() {
	while (cin >> W >> H, W) solve();
}

Measured memory_bytes: 1356
while True:
    n = input()

    if n == 0:
        break

    s = raw_input().split()

    isLeftDown = True
    isRightDown = True
    isDown = True

    cnt = 0
    for i in range(n):
        if s[i] == "lu":
            isLeftDown = False
        elif s[i] == "ld":
            isLeftDown = True
        elif s[i] == "ru":
            isRightDown = False
        elif s[i] == "rd":
            isRightDown = True

        if isLeftDown == False and isRightDown == False and isDown == True:
            cnt += 1
            isDown = False
        if isLeftDown == True and isRightDown == True and isDown == False:
            cnt += 1
            isDown = True

    print cnt

Measured memory_bytes: 6396
#include<iostream>

using namespace std;

int BubbleSort(int ary[],int n){
    int count = 0;
    bool flag = true;
    while(flag){
        flag=false;
        for(int i=n-1;i>0;i--){
            if(ary[i] < ary[i-1]){
                int temp=ary[i-1];
                ary[i-1] = ary[i];
                ary[i] = temp;
                flag=true;
                count++;
            }
        }
    }
    return count;
}

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

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

    int count;
    count = BubbleSort(array,n);
    for(int i=0;i<n-1;i++){
        cout << array[i] << " ";
    }
    cout << array[n-1] << endl;
    cout << count << endl;
    return 0;
}


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

namespace AtCoder {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long cln(long D = -1) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return long.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			var Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		static string read() { return Console.ReadLine(); }
		#endregion

		static void Main(string[] args) {
			var I = cins();
			int A = I[0], B = I[1], C = I[2], D = I[3], E = I[4], F = I[5];
			var WaterCase = new bool[F / 100 + 1];
			for (int i = 0; i * B <= F / 100; i++) {
				WaterCase[i * B] = true;
				for (int j = 0; j * A + i * B <= F / 100; j++) {
					WaterCase[i * B + j * A] = true;
				}
			}
			int rest = 100 * A, ress = 0;
			for (int j = 1; j <= F / 100; j++) {
				if (!WaterCase[j]) continue;
				var sugarlim = Math.Min(F - 100 * j, E * j);
				var dtime = sugarlim / D;
				for (int m2 = 0; m2 <= dtime; m2++) {
					var M1 = (sugarlim - D * m2) / C;
					var nowsugar = C * M1 + D * m2;//[g]
					if (ress * (100 * j + nowsugar) < nowsugar * rest) {
						rest = 100 * j + nowsugar;
						ress = nowsugar;
					}
				}
			}
			print(rest+" "+ress);
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, X;
    vector<int> L;
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        int Li;
        cin >> Li;
        L.push_back(Li);
    }

    int sum = 0;
    int count = 1;
    for (auto Li : L) {
        sum += Li;
        if (sum > X) {
            break;
        }
        count++;
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
l = [1] * n
d = set()
d.add(1)

for i in range(m):
    x,y = map(int,input().split())
    l[x-1] -= 1
    l[y-1] += 1
    if(x in d):
        d.add(y)
        if(l[x-1] == 0):
            d.remove(x)

s = 0
for i in d:
    if(l[i-1] != 0):s += 1
print(s)


Measured memory_bytes: 12652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();

		if (N.charAt(1) == N.charAt(2) && (N.charAt(0) == N.charAt(1) || N.charAt(3) == N.charAt(1))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
while(true){
   var n=Arr.shift();
   if(n==0)break;
   var arr=[];
   for(var i=0;i<n;i++)arr.push(Arr.shift());
   arr.sort(function(a,b){return a-b;});
   arr.shift();
   arr.pop();
   var sum=arr.reduce(function(a,b){return a+b;});
   var ave=Math.floor(sum/arr.length);
   console.log(ave);
}

Measured memory_bytes: 8784
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    string s;
    cin >> s;
    rep(i,s.size()){
        if(s[i]!='h'){
            cout << "No"<<endl;
            return 0;
        }
        i++;
        if(s[i]!='i'){
            cout << "No"<<endl;
            return 0;
        } 
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <bitset>

int n,Li[1005],Mv[5005],Sum;
std::vector<int> g[1005];
std::bitset<5005> v;

int main()
{
    scanf("%d",&n);
    for(int i=2,u;i<=n;++i)scanf("%d",&u),g[u].push_back(i);
    for(int i=1;i<=n;++i)scanf("%d",&Li[i]);
    for(int i,x=n;x>=1;--x)
    {
        v=1,Sum=0;
        for(int y:g[x])v=(v<<Li[y])|(v<<Mv[y]),Sum+=Li[y]+Mv[y];
        for(i=Li[x];i>=0&&!v[i];--i);
        if(i==-1)return puts("IMPOSSIBLE"),0;
        Mv[x]=Sum-i;
    }
    return puts("POSSIBLE"),0;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[100005];

int main()
{
    scanf("%d %d", &n, &k);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans = 1000000000;
    for(int i = 1;i <= n-k+1;i++)
    {
        if(k == 1) ans = min(ans,abs(a[i]));
        else if((a[i] <= 0&&a[i+k-1] <= 0)||(a[i] >= 0&&a[i+k-1] >= 0))
        {
            ans = min(ans,max(abs(a[i]),abs(a[i+k-1])));
        }
        else ans = min(ans,abs(a[i])+abs(a[i+k-1])+min(abs(a[i]),abs(a[i+k-1])));
    }
    printf("%d",ans);
}

#endif // 1++


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

using namespace std;
pair<pair<string, int>, int> P[110];

int main() {
  int N, tmp;
  string S;

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S >> tmp;
    P[i] = make_pair(make_pair(S, -tmp), i);
  }
  sort(P, P + N);
  for (int i = 0; i < N; i++){
    printf("%d\n", P[i].second + 1);
  }
  return 0;
}

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

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int n;
bool U, D, L, R;
long long uU = -0x3f3f3f3f, uD = 0x3f3f3f3f;
long long dU = -0x3f3f3f3f, dD = 0x3f3f3f3f;
long long lR = -0x3f3f3f3f, lL = 0x3f3f3f3f;
long long rR = -0x3f3f3f3f, rL = 0x3f3f3f3f;
long long udL = 0x3f3f3f3f, udR = -0x3f3f3f3f;
long long lrU = -0x3f3f3f3f, lrD = 0x3f3f3f3f;
vector<double>tt;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		long long x, y;
		char opt;
		cin >> x >> y >> opt;
		if (opt == 'U')
		{
			U = 1;
			uU = max(uU, y);
			uD = min(uD, y);
			udL = min(udL, x);
			udR = max(udR, x);
		}
		else if (opt == 'D')
		{
			D = 1;
			dU = max(dU, y);
			dD = min(dD, y);
			udL = min(udL, x);
			udR = max(udR, x);
		}
		else if (opt == 'L')
		{
			L = 1;
			lrU = max(lrU, y);
			lrD = min(lrD, y);
			lL = min(lL, x);
			lR = max(lR, x);
		}
		else if (opt == 'R')
		{
			R = 1;
			lrU = max(lrU, y);
			lrD = min(lrD, y);
			rL = min(rL, x);
			rR = max(rR, x);
		}
	}
	tt.push_back(0);
	if (L&&R)
	{
		tt.push_back(0.5*(lR - rR));
		tt.push_back(0.5*(lL - rL));
	}
	if (U&&D)
	{
		tt.push_back(0.5*(dU - uU));
		tt.push_back(0.5*(dD - uD));
	}
	if (R && (U || D))
	{
		tt.push_back(udR - rR);
		tt.push_back(udL - rL);
	}
	if (L && (U || D))
	{
		tt.push_back(lR - udR);
		tt.push_back(lL - udL);
	}
	if (U && (L || R))
	{
		tt.push_back(lrU - uU);
		tt.push_back(lrD - uD);
	}
	if (D && (L || R))
	{
		tt.push_back(dU - lrU);
		tt.push_back(dD - lrD);
	}

	double ans = 1e20;
	for (double x : tt)
	{
		if (x >= 0)
		{
			double xmin = min({ lL - x, rL + x, (double)udL });
			double xmax = max({ lR - x,rR + x,(double)udR });
			double ymax = max({ uU + x,dU - x,(double)lrU });
			double ymin = min({ uD + x,dD - x,(double)lrD });
			ans = min(ans, (xmax - xmin)*(ymax - ymin));
		}
	}
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans[15],a;
char ch;
int main()
{
	while(cin>>ch&&ch!='\0')
	{
		if(ch=='0') ans[a++]=0;
		if(ch=='1') ans[a++]=1;
		if(ch=='B'&&a) a--;
	}
	if(a) for(int i=0;i<a;i++) printf("%d",ans[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
flag = True
if A[0] != 0:
    flag = False

ans = 0
cur = 1

nodes = [0] * (N + 1)
nodes[0] = 1
for i in range(1, N + 1):
    cur *= 2
    nodes[i] = cur
    cur -= A[i]
    if cur < 0:
        flag = False

L = 0
for i in range(N, -1, -1):
    L += A[i]
    L = min(L, nodes[i])
    ans += L

if N == 0:
    if A[0] == 1:
        print(1)
    else:
        print(-1)
elif flag:
    print(ans)
else:
    print(-1)

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

using namespace std;
using i64 = long long int;
using ui64 = unsigned long long int;

//////

int intax(int i,int p){
  return floor((double)i * (100+p) / 100);
}

int main(){
  int x,y,s;
  while(cin >> x >> y >> s,x&&y&&s){
    int res = -1;
    int mi,mj = 0;
    for(int i=1;i<s;i++){
      int xi = intax(i,x);
      if(xi>s)break;
      int j=1;while(intax(j,x)+xi<s)j++;
      while(true){
	int xj = intax(j,x);
	if(xi+xj>s)break;
	int yi = intax(i,y);
	int yj = intax(j,y);
	if(res < yi + yj){
	  mi = i,mj = j;
	}
	//cerr << i << " " << j << " " << yi + yj << endl;
	res = max(yi+yj,res);
	j++;
      }
    }
    //cerr << mi << " " << mj << endl;
    cout << res << endl;
  }
}



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

int main ()
{
  string s; cin >> s;
  int n = s.size();
  int c = 0, j = 0;

  for (int i =0; i < n; i++)
  {
    if ((i+1)%2 == 1 || i == 0)
    {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') c++;
    }
    else if ((i+1)%2 == 0 && i != 0)
    {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') j++;
    }
  }

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


Measured memory_bytes: 256
s = input()
n = len(s)

flg = True
for i in range(n-1):
    if s[i] == s[i+1]:
        flg = False
        print(i+1, i+2)
        break

if flg:
    for i in range(n-2):
        if s[i] == s[i+2]:
            flg = False
            print(i+1, i+3)
            break

if flg:
    print(-1, -1)

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
	int h,w,i,j;
	scanf("%d %d", &h, &w);
	char c;
	for(i=0; i<=h+1; i++)
	{
		for(j=0; j<=w+1; j++)
		{
			if(i==0 || i==h+1 || j==0 || j==w+1)
				printf("#");
			else
			{
				scanf(" %c", &c);
				printf("%c",c);
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

long long sub(long long H) {
    if (H == 1) {
        return 1;
    }
    long long res = floor(H/2);
    return 2 * sub(res) + 1;
}

int main() {
    long long H;
    cin >> H;
    cout << sub(H) << endl;
    return 0;
}

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

int decSort(const void* v1, const void* v2) {
    const long long int _v1 = *((const long long int*)v1);
    const long long int _v2 = *((const long long int*)v2);

    if ( _v1 > _v2 ) {
        return -1;
    } else if ( _v1 < _v2 ) {
        return 1;
    } else {
        return 0;
    }
}

int main() {
  long long int n,h,i,j;
  scanf("%lld %lld",&n,&h);
  long long int a[n];
  long long int b[n];
  for(i=0;i<n;i++) {
    scanf("%lld %lld",&a[i],&b[i]);
  }
  long long int amax = 0;
  for(i=0;i<n;i++) {
    if (amax < a[i]) {
      amax = a[i];
    }
  }
  qsort(b, n, sizeof(b[0]), decSort);
  //printf("%lld %lld\n",bid,maxt);
  long long int dam = h;
  long long int kaisu = 0;
  for(i=0;i<n;i++) {
    if (b[i] < amax) {
      goto LABEL2;
    }
    dam -= b[i];
    kaisu ++;
    if (dam < 1) {
      goto LABEL;
    }
  }
  //printf("%lld %lld %lld\n",dam,kaisu,amax);
  LABEL2:
  kaisu += (dam-1)/amax+1;
  LABEL:
  printf("%lld\n",kaisu);
  return 0;
}


Measured memory_bytes: 2556
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
if N >= 105 {
    for i in stride(from: 105, to: N+1, by: 2) {
        var cnt = 0
        for j in 3..<i {
            if i % j == 0 {
                cnt += 1
            }
        }
        if cnt == 6 {
            ans += 1
        }
    }
}
print(ans)


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

signed main(){
  int n,ans=0; cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3==0||i%5==0)
      continue;
    ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a <= 5)
        cout << 0;
    else if (a < 13)
        cout << b / 2;
    else
        cout << b;
}


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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}


struct Edge {int to, dist, cost;};
typedef vector< vector<Edge> > Graph;

int N;
void dijkstra(int start, Graph& graph) {
    priority_queue<pii, vector<pii>, greater<pii> > que;
    vi d(N, INF);
    d[start] = 0;
    que.push(mp(0, start));

    vi prev(N, -1);
    vi pc(N, -1);

    while(!que.empty()) {
        pii p = que.top(); que.pop();
        int v = p.second;
        if(d[v] > p.first) continue;
        tr(it, graph[v]) {
            if(
                (d[it->to] > d[v] + it->dist) ||
                (d[it->to] == d[v] + it->dist && pc[it->to] > it->cost)
                    )
            {
                d[it->to] = d[v] + it->dist;
                que.push(mp(d[it->to], it->to));
                prev[it->to] = v;
                pc[it->to] = it->cost;
            }
        }
    }

//    cerr << d << endl;
//    cerr << "prev: " << prev << endl;
//    cerr << "pc: " << pc << endl;

    cout << accumulate(pc.begin() + 1, pc.end(), 0) << endl;

}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    int M;
    while(cin >> N >> M, (N|M)) {
        Graph graph(N);

        rep(i, M) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u, --v;
            graph[u].push_back(Edge{v, d, c});
            graph[v].push_back(Edge{u, d, c});
        }

        dijkstra(0, graph);
    }




    return 0;
}

Measured memory_bytes: 2408
#include <stdio.h>
int main(void)
{
    char n[4];
    int i=0;
    scanf("%s", n);

    while(n[i]!='\0'){
        if(n[i]=='1') n[i]='9';
        else if(n[i]=='9') n[i]='1';
        i++;
    }

    printf("%s\n", n);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include<random>
using namespace std;
#define int long long
//#define double long double
//typedef unsigned long long ulong;
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 61ll)
#define mod 1000000007

int M, d[200200], c[200200];

signed main(){
    cin >> M;
    int sum = 0;
    int dsum = 0;
    for(int i = 0; i < M; i++){
        cin >> d[i] >> c[i];
        sum += d[i] * c[i];
        dsum += c[i];
    }
    dsum--;
    if(sum % 9 == 0)cout << (dsum * 9 + sum) / 9 - 1 << endl;
    else cout << (dsum * 9 + sum) / 9 << endl;

    

    return 0;
}

/*

*/

Measured memory_bytes: 3328
n, m = gets.chomp.split(" ").map(&:to_i)

cand = []
ship = Array.new(n+1, false)

m.times do 
  a, b = gets.chomp.split(" ").map(&:to_i)
  if b == n then
    cand << a
  elsif a == 1 then
    ship[b] = true
  end
end

cand.each do |i|
  if ship[i]
    puts "POSSIBLE"
    exit
  end
end
puts "IMPOSSIBLE"

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

int main(){
    string S;
    int a[26] = {};
    cin >> S;
    for (auto x : S) a[x-'a'] += 1;
    string judgment = "yes";
    for (auto i : a){
        if (i > 1){
            judgment = "no";
            break;
        }
    }
    cout << judgment << endl;
    return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%s" (fun s ->
    let n = String.length s in

    let rec loop i cur hist acc =
        if i = n then acc + hist + cur else
            let acc = loop (i + 1) (cur * 10 + int_of_char s.[i] - 48) hist acc in
            if cur = 0 then acc else loop i 0 (hist + cur) acc
    in
    loop 0 0 0 0 |> Printf.printf "%d\n"
)

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

int main(){
    int N, M;  cin >> N >> M;
    vector<vector<int>> tree(N);
    for(int i=0; i<M; i++){
        int u, v;  cin >> u >> v;
        u--;  v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    vector<int> path(N);
    for(int i=0; i<N; i++)
        path[i] = i;

    int ans = 0;
    do {
        for(int i=0; i<N-1; i++){
            int u = path[i];
            int v = path[i+1];
            bool ok = false;
            for(int r : tree[u]){
                if(r == v)
                    ok = true;
            }
            if(!ok)
                break;
            
            if(i == N-2){
                ans++;
            }
        }
    } while(next_permutation(path.begin() + 1, path.end()));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int fir = *max_element(all(a));
  int sec = 0;
  int dup = 0;
  for(d:a){
    if(d==fir) dup++;
    else if (sec < d) sec = d;
  }
  if(dup>1){
    rep(i,n) cout<<fir<<endl;
    return 0;
  }
  for(d:a){
    if(d == fir) cout<<sec<<endl;
    else cout<<fir<<endl;
  }
}



Measured memory_bytes: 2432
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	stack<int> S1;//如果是'\'则将其下标压如栈
	stack<pair<int, int> > S2;//first记录积水最左侧下标位置，second记录当前的面积
	char ch;
	int sum = 0;
	for (int i = 0; cin >> ch; i++)
	{
		if (ch == '\\') S1.push(i);//S1存下标
		else if (ch == '/' && S1.size() > 0)
		{
			int j = S1.top(); S1.pop();//取了S1的下标，再将其丢掉
			sum += i - j;//i是'/'的位置,j是'\'的位置，i-j为面积
			int a = i - j;
			while (S2.size() > 0 && S2.top().first > j)//此时算上面的面积,将上下两节面积加起来(越在左边的‘\’越靠前)
			{
				a += S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (S2.size() > 0) { ans.push_back(S2.top().second); S2.pop(); }
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (int i = 0; i < ans.size(); i++)
	{
		cout << " " << ans[i];
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A = N / 4 +1;
  bool decide = false;
  for(int i = 0; i < A; i++){
    for(int j = 0; j < A;j++){
      if(4*i+7*j == N){
        decide = true;
      }
    }
  }
  if(decide){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

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

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
    i64 from, to, cost;
    edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}
//

#pragma endregion

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

struct UnionFind
{
    vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y) return(false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if (data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }
};


int main() {
    // 1 => 1, 2 or 2, 1
    // 2 => 1, 1 or 2, 2
    i64 n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; ++i) {
        i64 x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        uf.unite(x, y);
    }
    i64 ans = 0;
    for (int i = 0; i < n; ++i) {
        if(uf.data[i] <= -1) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
    int A, B, C, D, E, k;
    cin >>	A >> B >> C >> D >> E >> k;
    if(E - A  > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)


int32_t main() {

	IOS;

	int h, w;
	pair<int, int> start, target;

	cin >> h >> w;
	cin >> start.first >> start.second >> target.first >> target.second;

	start.first--, start.second--, target.first--, target.second--;

	vector<vector<char>> v(h, vector<char>(w));
	vector<vector<int>> dis(h, vector<int>(w, inf));

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> v[i][j];

	dis[start.first][start.second] = 0;

	deque<pair<int, int>> qq;

	qq.push_front(start);
	pair<int, int> cur;

	vector<pair<int, int>> dir{{0, 1}, {0, -1}, {1, 0}, { -1, 0}};


	while (!qq.empty()) {
		auto [x, y] = qq.front();
		qq.pop_front();

		for (auto [dx, dy] : dir) {
			dx += x, dy += y;
			if (dx < 0 || dx == h || dy < 0 || dy == w || v[dx][dy] == '#')
				continue;

			if (dis[x][y] < dis[dx][dy]) {
				dis[dx][dy] = dis[x][y];
				qq.push_front({dx, dy});

				// if (make_pair(dx, dy) == target)
				// 	break;
			}
		}

		int left = max(0ll, y - 2);
		int right = min(w - 1, y + 2);
		int up = max(0ll, x - 2);
		int down = min(h - 1, x + 2);

		for (int i = up; i <= down; i++) {
			for (int j = left; j <= right; j++) {
				if (x == i && y == j || v[i][j] == '#')
					continue;

				if (dis[x][y] + 1 < dis[i][j]) {
					dis[i][j] = dis[x][y] + 1;
					qq.push_back({i, j});
				}
			}
		}
	}


	if (dis[target.first][target.second] == inf)
		cout << "-1";
	else
		cout << dis[target.first][target.second];

	return 0;
}

Measured memory_bytes: 12584
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    ll x,y;
    cin>>x>>y;
    ll ans=0;
    ll c=x;
    while(c<=y)
    {
        ans++;
        c*=2;
    }
    cout<<ans<<"\n";
  }  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    ll ans=0;
    rep(i,30){
        ll flag=0;
        vector<ll> c(N);
        rep(j,N) c[j]=b[j]%(1<<(i+1));
        sort(c.begin(),c.end());
        rep(j,N){
            ll d=a[j]%(1<<(i+1));
            flag+=lower_bound(c.begin(),c.end(),(1<<(i+1))-d)-lower_bound(c.begin(),c.end(),(1<<i)-d);
            flag+=lower_bound(c.begin(),c.end(),(1<<(i+2))-d)-lower_bound(c.begin(),c.end(),(1<<(i+1))+(1<<i)-d);            
        }
        if (flag%2==1) ans+=(1<<i);   
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
/*
Created on Thu Aug 27 21:32:39 2020

@author: roastedcoder

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
const int mod = 1e9+7;
const int INF = INT_MAX;
#define endl "\n"
#define append push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________



int main() {
	roastedcoder
	string n; cin>>n;
	int res = 0;
	for(int i = 0; i<n.length(); i++) {
		res += n[i]-'0';
	}
	res%9 == 0 ? cout<<"Yes" : cout<<"No";
}

//__________________________________________________________________
/*
Sample Input:
20 12 6

Sample Output:
12

*/

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define repUp(i, n) for(int i = 0; i <= n; i ++)
#define vpair(d)	vector<pair<d, d> >
#define pair(d)		pair<d,d >

using namespace std;

int main(){
	string s;
	cin >> s;
	long long k;
	cin >>k;
	int j;
	for(j = 0; j < k; j ++){
		if(s[j] != '1')
			break;
	}
	//cout << j << endl;
	if(j == k){
		cout << 1 << endl;
		return 0;
	}
	
 	int len = s.length();
	for(int i = 0; i < len; i ++){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << (x) << "\n"
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
vector<int>v1, v2;
int a[234567], ans;
signed main() {
	int n; cin >> n;
	for0(i, n)cin >> a[i];
	sort(a, a + n);
	int n1 = n - 2, n2 = n - 1; ans = a[n2];
	while (n1 > 1) { n1 -= 2; ans += a[--n2] * 2; }
	if (n1 == 1)ans += a[--n2]; puts(ans);
}

Measured memory_bytes: 5156
import sys
sys.setrecursionlimit(10**7)
mod = 10**9+7

n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)

lpow = [False] * (n+5)
lpow[0] = 1
def pow(n,p):
    if p<0:return 0
    if lpow[p]:
        return lpow[p]
    else:
        if p % 2 == 0:
            ret = (pow(n,p//2)**2) % mod
        else:
            ret = ((pow(n,p//2)**2)*n) % mod
        lpow[p] = ret
        return ret

res = 0
for i in range(n):
    res += (c[i]*pow(4,n-1)*(i+2))% mod
    res %= mod
print(res)

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> que;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    que.push(a);
  }
  while (M > 0) {
    int a = que.top();
    que.pop();
    a /= 2;
    que.push(a);
    M--;
  }
  long long int ans = 0;
  while (!que.empty()) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
import cmath
def f():
 global d
 p=[]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a,a+r,a+r+r*(1+3**.5*1j)/2,b-r]
 d=p+[d[-1]]
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


Measured memory_bytes: 5988
#include <iostream>
#include <map>

using namespace std;

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

  map<char, char> s2t;
  map<char, char> t2s;

  for (int i = 0; i < S.size(); i++) {

    if (s2t.count(S[i]) == 0) {
      // まだ存在しないのでset
      s2t[S[i]] = T[i];
    } else {
      if (s2t[S[i]] != T[i]) {
        cout << "No" << endl;
        return 0;
      }
      //cout << "sonzai suru:" << S[i] << " at " << s2t[S[i]] << endl;
    }
  }
  for (int i = 0; i < T.size(); i++) {

    if (t2s.count(T[i]) == 0) {
      // まだ存在しないのでset
      t2s[T[i]] = S[i];
    } else {
      if (t2s[T[i]] != S[i]) {
        cout << "No" << endl;
        return 0;
      }
      //cout << "sonzai suru:" << S[i] << " at " << s2t[S[i]] << endl;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
S=input()
T=input()
T_0_equal=[]
for i in range(len(S)):
  if(T[0]==S[i]):
    T_0_equal.append(i)
#print(T_0_equal)
for i in range(len(T_0_equal)):
  count=0
  for j in range(len(S)):
    if(T[j]!=S[(j+T_0_equal[i])%len(S)]):
      break
    else:
      count+=1
  if(count==len(S)):
  	print('Yes')
  	exit()
print('No')  

Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val x = LongArray(N) { 0L }
    val y = LongArray(N) { 0L }
    val h = LongArray(N) { 0L }

    for (i in 0 until N) {
        val (X, Y, H) = readLine()!!.split(" ").map { it.toLong() }
        x[i] = X
        y[i] = Y
        h[i] = H
    }

    fun check(cx: Long, cy: Long, H: Long): Boolean {
        if (h.max()!! > H) return false

        for (i in x.indices) {
            if (h[i] != Math.max(H - Math.abs(x[i] - cx) - Math.abs(y[i] - cy), 0L)) {
                return false
            }
        }

        return true
    }

    val mx = h.sorted().last()
    val idx = h.indexOf(mx)

    for (a in 0..100) {
        for (b in 0..100) {
            val dx = Math.abs(a - x[idx])
            val dy = Math.abs(b - y[idx])

            val ch = h[idx] + dx + dy

            if (check(a.toLong(), b.toLong(), ch)) {
                println("$a $b $ch")

                return
            }
        }
    }
}


Measured memory_bytes: 37916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a, b;
  cin >> a >> b;
  
  if (a.size() > b.size())
    cout << "GREATER";
  
  else if (a.size() < b.size())
    cout << "LESS";
  
  else {
    bool fin = false;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] > b[i]) {
        cout << "GREATER";
        fin = true;
        break;
      }
      else if (a[i] < b[i]) {
        cout << "LESS";
        fin = true;
        break;
      }
    }
    if (!fin)
      cout << "EQUAL";
  }
}

Measured memory_bytes: 3608
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	heap := NewHeap(func(a, b int) bool {
		return a > b
	})

	out := bufio.NewWriter(os.Stdout)
LOOP:
	for {
		sc.Scan()
		cmd := sc.Text()
		switch cmd {
		case "insert":
			v := scanInt(sc)
			heap.insert(v)
		case "extract":
			max := heap.extractMax()
			fmt.Fprintln(out, max)
		default:
			break LOOP
		}
	}
	out.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

type Heap struct {
	size   int
	heap   []int
	isHigh func(a, b int) bool
}

func NewHeap(isHigh func(a, b int) bool) Heap {
	heap := make([]int, 1) // 先頭は不使用
	return Heap{size: 0, heap: heap, isHigh: isHigh}
}

func (h *Heap) insert(v int) {
	h.size += 1
	if h.size > len(h.heap)-1 {
		h.heap = append(h.heap, v)
	} else {
		h.heap[h.size] = v
	}

	for i := h.size; i > 1; {
		parent := i / 2
		if h.isHigh(h.heap[parent], h.heap[i]) {
			break
		}
		h.heap[i], h.heap[parent] = h.heap[parent], h.heap[i]
		i = parent
	}
}

func (h *Heap) extractMax() int {
	if h.size <= 0 {
		panic("cannot extract from empty heap")
	}

	max := h.heap[1]
	h.heap[1] = h.heap[h.size]
	h.size -= 1
	h.maxHeapify(1)

	return max
}

func (h *Heap) maxHeapify(idx int) {
	left := idx * 2
	right := left + 1
	largest := idx

	if left <= h.size {
		if h.isHigh(h.heap[left], h.heap[idx]) {
			largest = left
		}
		if right <= h.size && h.isHigh(h.heap[right], h.heap[largest]) {
			largest = right
		}
	}

	if largest != idx {
		h.heap[idx], h.heap[largest] = h.heap[largest], h.heap[idx]
		h.maxHeapify(largest)
	}
}



Measured memory_bytes: 38848
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int ans = 0;

int main(){
  int x;
  cin >> x;
  cin >> n >> m;
  if(abs(x-n) < abs(x-m))print("A");
  else print("B");
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long a1,b1,t,a,b,c,d;
	scanf("%lld %lld",&a1,&b1);
	if(a1>b1)
	{
	    t=a1;
	    a1=b1;
	    b1=t;
	}
	a=a1;
	b=b1;
	d=a%b;
	a=b;
	b=d;
	while(d!=0)
	{
		d=a%b;
		a=b;
		b=d;
	} 
	printf("%lld\n",a1*b1/a);
    return 0;
}


Measured memory_bytes: 128
import collections
n=int(input())
A=list(map(int,input().split()))
a=collections.Counter(A)
key,value=zip(*a.most_common())
cnt=0
for i in range(len(key)):
  if key[i]>value[i]:
    cnt+=value[i]
  elif key[i]<value[i]:
    cnt+=value[i]-key[i]
print(cnt)
  

Measured memory_bytes: 27760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define REP(i,n)  for(int i=0;i<(n);i++)

int main(){
    int n,l;
    cin>>n >>l;
    VS s(n);
    for(int i=0;i<n;i++)cin>>s[i];
    sort(ALL(s));
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll n,d;
    cin >> n >> d;
    int cnt=0;
    rep(i,n) {
        ll x,y;
        cin >> x >> y;
        if (x*x+y*y<=d*d) ++cnt;
    }
    cout << cnt << endl;
     
    return 0;   
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
T largestrectangle(vector<T> &v){
  int n=v.size();
  T res=0;
  using P = pair<int, T>;
  stack<P> sp;
  sp.emplace(-1,T(-1));
  for(int i=0;i<n;i++){
    int j=i;
    while(sp.top().second>v[i]){
      j=sp.top().first;
      if(sp.top().second)
        res=max(res,(i-j+1)*(sp.top().second+1));
      sp.pop();
    }
    if(sp.top().second<v[i]) sp.emplace(j,v[i]);
  }
  while(!sp.empty()){
    if(sp.top().second)
      res=max(res,(n-sp.top().first+1)*(sp.top().second+1));
    sp.pop();
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  int ans=max(h,w);
  vector<int> vv(w-1,0);
  for(int i=0;i+1<h;i++){
    for(int j=0;j+1<w;j++){
      int cnt=0;
      for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
          cnt+=st[i+a][j+b]-'0';
      if(cnt&1) vv[j]=0;
      else vv[j]++;
    }
    chmax(ans,largestrectangle(vv));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    int mi = 0, mx = 0;
    rep(i, n){
        cin >> x[i];
        mi = min(mi, x[i]);
        mx = max(mx, x[i]);
    }
    int best = 1000000000;
    for (int i = mi; i <= mx; i++){
        int dist = 0;
        rep(j, n){
            dist += pow(i - x[j], 2);
        }
        if (dist < best) best = dist;
    }
    cout << best << endl;
    return 0;
}

Measured memory_bytes: 384