akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<complex>

#define START 0
#define END 1
using namespace std;

typedef complex<double> point;

const double infty = 1e40;
const double eps = 1e-10;

bool eq(double a, double b){
  return abs(b-a) < eps;
}

struct anntena{
  point ul, rd;
  anntena(point a, point b):ul(a),rd(b){}
  bool isinside(const point &t){
    if( ul.real()<=t.real()&&t.real()<=rd.real()&&
	ul.imag()>=t.imag()&&t.imag()>=rd.imag())return true;
    return false;
  }
};

int main()
{
  int n;
  int tc=1;
  while(cin>>n && n>0){
    double res = 0;
    set<double> X;
    set<double> Y;
    vector<anntena> va;

    for(int i = 0; i < n; ++i){
      double x,y,r;
      scanf("%lf%lf%lf", &x, &y, &r);
      X.insert(x-r);
      X.insert(x+r);
      Y.insert(y-r);
      Y.insert(y+r);
      va.push_back( anntena(point(x-r,y+r), point(x+r,y-r) ) );
    }
    for(set<double>::iterator itx = X.begin(); itx != X.end(); ++itx){

      double x = *itx;
      ++itx;
      if(itx==X.end())break;
      double nx = *itx;
      --itx;
      double span_x = nx - x;
      for(set<double>::iterator ity = Y.begin(); ity != Y.end(); ++ity){
	double y = *ity;
	++ity;
	if(ity==Y.end())break;
	double ny = *ity;
	--ity;
	double span_y = ny - y;
	point cent = point((x+nx)/2,(y+ny)/2);
	bool cent_cont = false;
	for(int i = 0; i < (int)va.size(); ++i){
	  if( va[i].isinside( cent ) ) cent_cont = true;
	}
	if( cent_cont ){
	  res += span_x * span_y;
	}
      } 
    }
    printf("%d %.2lf\n", tc, res);
    ++tc;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;
 
int main() {
  #define int long long
  const int MAX_SIZE = 110;
  int h,w;
  cin >> h >> w;
  vstring s(h);
  rep(i,h){
    cin >> s[i];
  }
  vvint dp(MAX_SIZE,vint(MAX_SIZE,0));
  dp[0][0] = 0;
  rep1(i,w){
    if(s[0][i-1] != s[0][i]){
      dp[0][i] = dp[0][i-1] + 1;
    }
    else
      dp[0][i] = dp[0][i-1];
  }
  rep1(i,h){
    if(s[i-1][0] != s[i][0]){
      dp[i][0] = dp[i-1][0] + 1;
    }
    else
      dp[i][0] = dp[i-1][0];
  }
  for(int i = 1;i < h;i++){
    for(int j = 1;j < w;j++){
      int templeft = 0;
      int tempup = 0;
      if(s[i][j] != s[i-1][j])
        templeft = dp[i-1][j] + 1;
      else
        templeft = dp[i-1][j];
      if(s[i][j] != s[i][j-1])
        tempup = dp[i][j-1] + 1;
      else
        tempup = dp[i][j-1];
      dp[i][j] = min(templeft,tempup);
    }
  }
  /*rep(i,h){
    rep(j,w){
    	cout << dp[i][j] << " ";
    }
    cout << endl;
  }*/
  if(s[0][0] == '#')
  	cout << (dp[h-1][w-1])/2 + 1 << endl;
  else
    cout << (dp[h-1][w-1]+1)/2 << endl;
} 

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0]<<endl;
}

Measured memory_bytes: 768
import sys
input = lambda: sys.stdin.readline().rstrip()
n, t = map(int, input().split())
query = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    interval = query[i] - query[i - 1]
    ans += min(t, interval)

# 最後の一回分
ans += t
print(ans)


Measured memory_bytes: 30612
n,*a=`dd`.split.map &:to_i
f=->i{(1..n).map{|e|puts [i,e]*' '}}
p 2*n-1
x,y=a.minmax
if y.abs>x.abs
f[a.index(y)+1]
(1...n).each{|e|puts [e,e+1]*' '}
else
f[a.index(x)+1]
n.downto(2){|e|puts [e,e-1]*' '}
end

Measured memory_bytes: 4092
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    char a, b;
    cin >> a;
    b = a + 1;
    out(b);
}

Measured memory_bytes: 3528
program atcoder
    implicit none
    integer :: n,a,b,kaku,i,l
    character :: s*100009
    read*,n,a,b,s
    l = len(trim(s))
    kaku = a+b
    do i=1,l
        if(s(i:i)=='a' .and. kaku>0)then
            kaku = kaku - 1
            write(*,'(a)')"Yes"
        else if(s(i:i)=='b' .and. b>0 .and. kaku>0)then
            b = b - 1
            kaku = kaku - 1
            write(*,'(a)')"Yes"
        else
            write(*,'(a)')"No"
        endif
    enddo
    stop 
contains
end program atcoder


Measured memory_bytes: 932
n,k = map(int,input().split())
mod = 10**9 + 7

fact = [1]
finv = [1]
for i in range(1, 2*n):
    fact.append((fact[i-1] * i) % mod)
    finv.append(pow(fact[i], mod-2, mod))

if n-1 <= k:
    print((fact[2*n-1] * finv[n] * finv[n-1]) % mod)
    exit()

ans = 0
for i in range(k+1):
    ans += fact[n] * finv[n-i] * finv[i] * fact[n-1] * finv[n-1-i] * finv[i]
    ans %= mod

print(ans)

Measured memory_bytes: 134308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
    ll a, b, na;
    cin >> a >> b;
    ll ans, i = 1;
    while(true) {
        na = a*i;
        if (na % b == 0) {
            ans = na;
            break;
        }
        i++;
    }
    cout << ans << endl;
}


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

const long long MOD = 1e9 + 7;

int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> x(n), y(m);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    for (int j = 0; j < m; j++) {
        cin >> y[j];
    }

    long long ans = 0;
    long long x_sum = 0, y_sum = 0;
    for (int i = 0; i < n - 1; i++) {
        x_sum += (i + 1) * (n - i - 1) % MOD * ((x[i + 1] - x[i]) % MOD) % MOD;
        x_sum %= MOD;
    }

    for (int i = 0; i < m - 1; i++) {
        y_sum += (i + 1) * (m - i - 1) % MOD * ((y[i + 1] - y[i]) % MOD) % MOD;
        y_sum %= MOD;
    }

    cout << x_sum * y_sum % MOD << endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int N, K;
    cin >> N >> K;
    int h, ans = 0;
    for (int i=0; i<N; i++){
        cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
using System;

	class Program
	{
		public static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());
			int[] array= new int[n];
			for(int k=0;k<array.Length;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???

			for(int gap=2;(int)((Math.Pow(3,gap)-1)/2)<n;gap++)
			{			
				m++;
			}
			
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int j=0;j<G.Length;j++)
			{
				cnt+=sort( array, G[j]);//?????\?????????????????????
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		public static int sort(int [] A,int g)
		{
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0&&A[j]>v)
				{
					A[j+g]=A[j];
					j=j-g;
				count ++; //????????????????????§????????????????????§??????????????¢??????
				A[j+g]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 16620
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
//#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 501
#define EPS 0.01
struct data{
	string s;
	int val;
	int ind;
};
bool comp(struct data d1,struct data d2)
{
	if(d1.s != d2.s)
		return d1.s < d2.s;
	else
		return d1.val > d2.val;
}

int32_t main()
{
    IOS;

   	int n;
   	cin >> n;
   	vector<data>  v(n);
   	for(int i = 0;i < n;i++)
   	{
   		cin >> v[i].s >> v[i].val;
   		v[i].ind = i  + 1;
   	}
   	sort(v.begin(),v.end(),comp);
   	for(int i = 0;i < n;i++)
   		cout << v[i].ind << endl;

    return  0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(6//A//B)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

//メイン関数
int main(void){
  int H, W;

  while(1){
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0) break;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2120
n = int(input())
s = str(input())

#選んだリーダーよりも左 -> E, 右 -> W をとる
#数えるのはリーダーよりも左にいるWと右にいるE
E = []
W = []
e, w = 0, 0

for i in s:
    if i == 'E':
        e += 1
    elif i == 'W':
        w += 1
    E.append(e)
    W.append(w)

#k番目がリーダーとすると
ans = 10 ** 10
W.insert(0,0)

for k in range(n):
    can = W[k] + (E[-1]-E[k])
    if can <= ans:
        ans = can

print(ans)



Measured memory_bytes: 17640
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int X[100005];
int N;
int M;


int union_data[100005];

void union_init(int n){
  for(int i=0;i<n;i++){
    union_data[i] = i;
  }
}

int union_root(int x){
  int tmp = x;
  while(x!=union_data[x]){
    x = union_data[x];
  }
  while(tmp != union_data[tmp]){
    tmp = union_data[tmp];
    union_data[tmp] = x;
  }
  return x;
}

bool union_eq(int x,int y){
  return union_root(x) == union_root(y);
}

int union_join(int x, int y){
  if(union_eq(x,y)) return 0;
  union_data[union_root(y)] = union_root(x);
  return 0;
}




int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>X[i];
    X[i]--;
  }
  union_init(N);

  for(int i=0;i<M;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    union_join(x,y);
  }

  int ans = 0;
  for(int i=0;i<N;i++){
    if( union_eq(X[i],X[X[i]]) )ans++;
  }

  //for(int i=0;i<n;i++)cout<<t[i]<<" ";cout<<endl;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    // destination and length
    std::vector<std::vector<std::pair<int, int>>> edges(n);
    std::vector<int> colors(n, 0);

    for (int i = 0; i < n - 1; i++) {
        int u, v, w;
        std::cin >> u >> v >> w;
        u--;
        v--;

        edges[u].push_back(std::make_pair(v, w));
        edges[v].push_back(std::make_pair(u, w));
    }

    auto dfs = [&](auto f, int idx, int parent) -> void {
        for (auto edge : edges[idx]) {
            if (edge.first == parent) {
                continue;
            }
            if (edge.second % 2) {
                colors[edge.first] = (colors[idx] + 1) % 2;
            } else {
                colors[edge.first] = colors[idx];
            }
            f(f, edge.first, idx);
        }
    };

    dfs(dfs, 0, -1);

    for (auto c : colors) {
        std::cout << c << std::endl;
    }
}


Measured memory_bytes: 7680
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int> w(N + 1);
    for (size_t i = 1; i <= N; ++i) {
        cin >> w[i];
    }

    int minv = INF;
    for (size_t t = 1; t < N; ++t) {
        int s1 = 0, s2 = 0;
        for (size_t i = 1; i <= N; ++i) {
            if (i <= t) s1 += w[i];
            else s2 += w[i];
        }
        chmin(minv, abs(s1 - s2));
    }

    cout << minv << "\n";

    return 0;
}


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

static const int N = 100;

int main()
{
	int n, p[N + 1], m[N + 1][N + 1];

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i - 1] >> p[i];
	}

	for (int i = 1; i <= n; i++) m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j-1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;

	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include<set>
#include<tuple>
#define f first
#define sec second
#define t 3
using namespace std;
/*
12
13
*/

ll min(ll a, ll b)
{
    if(a<b)
    return a;
    return b;
}
ll max(ll a, ll b)
{
    if(a>b)
    return a;
    return b;
}

ll DP(ll n , ll arr[][t])
{
    ll dp[n][t];
    for(int i=0;i<t;i++)
    {
        dp[0][i]=arr[0][i];
    }

    for(int i=1;i<n;i++)
    {
           dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
           dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
           dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
       
    }

    ll ans=max(dp[n-1][1],max(dp[n-1][2],dp[n-1][0]));

    return ans;
   
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n=0;
    cin>>n;
    ll arr[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }

    cout<<DP(n,arr) ;


}

Measured memory_bytes: 4992
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  long long n, p;
  string s;
  cin >> n >> p >> s;

  long long res = 0;

  if (p == 2 || p == 5) {
    for (int i = n - 1; i >= 0; i--) {
      if ((s[i] - '0') % p == 0) {
        res += i + 1;
      }
    }
  } else {
    map<int, long long> mp;
    mp[0]++;
    long long cur = 0, b = 1;
    for (int i = n - 1; i >= 0; i--) {
      cur = (cur + (s[i] - '0') * b) % p;
      b = (b * 10) % p;
      res += mp[cur]++;
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 1028
N = int(input())
A = list(map(int, input().split()))
A.sort()
cumA = [0]
for i in range(N):
    cumA.append(cumA[-1] + A[i])
ans = 0
if A[0] * 2 >= A[1]:
    ans += 1
for i in range(N-1):
    if cumA[i+1] * 2 >= A[i+1]:
        ans += 1
    else:
        ans = 1
print(ans)


Measured memory_bytes: 14304
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=200+10,maxd=10000000+10;
int x[maxn],s[maxd],pri[maxd],r[maxn],a[maxn],b[maxn];
bool bz[maxd],dis[maxn][maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,num,sum,tmp,ans;
void prepare(){
    bz[1]=1;
    fo(i,2,maxd-10){
        if (!bz[i]) pri[++top]=i;
        fo(j,1,top){
            if ((ll)i*pri[j]>maxd-10) break;
            bz[i*pri[j]]=1;
            if (i%pri[j]==0) break;
        }
    }
}
bool dfs(int x){
    int i;
    fo(i,1,sum)
        if (dis[x][i]&&!pd[i]){
            pd[i]=1;
            if (!r[i]||dfs(r[i])){
                r[i]=x;
                return 1;
            }
        }
    return 0;
}
int main(){
    prepare();
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%d",&x[i]);
        s[x[i]]^=1;
    }
    fo(i,1,maxd-9){
        if (s[i]!=s[i-1]){
            if (i%2==1) a[++num]=i;
            else b[++sum]=i;
        }
    }
    fo(i,1,num)
        fo(j,1,sum)
            if (!bz[abs(a[i]-b[j])]) dis[i][j]=1;
    fo(i,1,num){
        fo(j,1,sum) pd[j]=0;
        if (dfs(i)) tmp++;
    }
    ans+=2*((num-tmp)/2);
    ans+=2*((sum-tmp)/2);
    ans+=tmp;
    if (num%2!=tmp%2) ans+=3;
    printf("%d\n",ans);
}


Measured memory_bytes: 53376
//abc127_a.cpp
//Thu Jun 27 22:27:46 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b;
	cin >> a >> b;

	if (a>=13){
		cout << b << endl;
	}else if (a>=6){
		cout << b/2 << endl;
	}else {
		cout << 0 << endl;
	}
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;

int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	//cout<<"snuke\n";
 	string s;
 	cin>>s;
 	sort(s.begin(),s.end());
 	if(s=="abc"){
 		cout<<"Yes\n";
 	}
 	else{
 		cout<<"No\n";
 	}

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll k,a,b;
    ll ans=1;
    cin >> k >> a >> b;
    if(b-a > 2){
        int kaisu = max((ll)0,(k-(a-1))/2);
        int tataku = k - kaisu*2;
        ans = kaisu*(b-a) + tataku + 1;
    }
    else{
        ans = k+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
d_list = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    d_list[a-1].append(b-1)
    d_list[b-1].append(a-1)

res = [-1]*n
res[0] = 0
q = []
q.append(0)
while len(q) > 0:
    current = q.pop(0)

    for nex in d_list[current]:
        if res[nex] == -1:

            res[nex] = current
            q.append(nex)
if -1 not in res:
    print('Yes')
    for ans in res[1:]:
        print(ans+1)
else:
    print("No")




Measured memory_bytes: 34528
//Product and GCD

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,p;cin>>n>>p;
    map<int,int>m{};
    int a = 2;
    while(p>=a*a){
        if(p%a==0){
            p/=a;
            m[a]++;
        }else{
            a++;
        }
    }
    m[p]++;
    int ans = 1;
    irep(i,m){
        if(i->second/n>0){
            rep(j,0,i->second/n)ans*=i->first;
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3624
# include <bits/stdc++.h>
using namespace std;
int main()
    {
        long long n;
        cin>>n;
        string s;
        //vector<string>vt;
        int AC = 0, TLE = 0, WA = 0, RE = 0;
        while(n--)
            {
                cin>>s;
                if(s == "AC")
                    AC++;
                else if(s == "TLE")
                    TLE++;
                else if(s== "WA")
                    WA++;
                else
                    RE++;
                //vt.push_back(s);
            }
        cout<<"AC x "<<AC<<"\n";
        cout<<"WA x "<<WA<<"\n";
        cout<<"TLE x "<<TLE<<"\n";
        cout<<"RE x "<<RE<<"\n";
        return 0;

    }

Measured memory_bytes: 3624
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, k = rli()
    k_max = (n-1)*(n-2)//2
    if k > k_max:
        print(-1)
        return
    edges = []
    edges_dist2 = []
    for i in range(n-1):
        edges.append((i+1, n))
        for j in range(i+1, n-1):
            edges_dist2.append((i+1, j+1))
    print(len(edges) + k_max-k)
    for v1, v2 in edges:
        print(v1, v2)
    for v1, v2 in edges_dist2[:k_max-k]:
        print(v1, v2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4000
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		Map<Long,Long> map = new TreeMap<>();
		for(int i = 0; i < n; i++) {
			long key = sc.nextLong();
			long value = sc.nextLong();
			if(map.containsKey(key)) {
				map.put(key, map.get(key)+value);
			} else {
				map.put(key, value);
			}
		}
		for(Long l : map.keySet()) {
			k -= map.get(l);
			if(k <= 0) {
				System.out.println(l);
				return;
			}
		}
	}
}

Measured memory_bytes: 96316
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    s = set()
    for _ in range(n):
        a = int(input())
        if a not in s:
            s.add(a)
        else:
            s.remove(a)
    print(len(s))

    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""


Measured memory_bytes: 17832
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    int m; scanf("%d", &m);
    while(m--){
        int ini, y, n; scanf("%d%d%d", &ini, &y, &n);

        int ans = 0;
        while(n--){
            int val = ini, type, due;
            double rate;
            scanf("%d%lf%d", &type, &rate, &due);
            if(type == 0){
                int interest = 0;
                for(int i=0;i<y;i++)interest += rate*val, val -= due;
                val += interest;
            }
            else{
                for(int i=0;i<y;i++) val*= 1 + rate, val -= due;
            }
            ans = max(ans, val);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 0
s = int(input())
t = 1
an = [s]
while t>0:
    if s%2 == 0:
        si = int(s/2)
    if s%2 == 1:
        si = 3*s+1
    for a in an:
        if si == a:
            print(len(an)+1)
            exit()
            t=0
    s = si
    an.append(si)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    double n,m,d;
    cin>>n>>m>>d;
    
    cout<<fixed<<setprecision(10);
    if(d==0) cout<<(m-1)/n<<endl;
    else cout<<2*(n-d)*(m-1)/(n*n)<<endl;
}


Measured memory_bytes: 256
using System;

namespace _0183
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (s == "0") break;
                string[] input = new string[] { s, Console.ReadLine(), Console.ReadLine() };
                char ret = '+';
                for (int i = 0; i < 3; i++)
                {
                    if (input[i][0] == input[i][1]
                        && input[i][1] == input[i][2])
                    {
                        if (input[i][0] != '+') ret = input[i][0];
                    }
                    if (input[0][i] == input[1][i]
                        && input[1][i] == input[2][i])
                    {
                        if (input[0][i] != '+') ret = input[0][i];
                    }
                }
                if (input[0][0] == input[1][1] && input[1][1] == input[2][2]) if (input[0][0] != '+') ret = input[0][0];
                if (input[0][2] == input[1][1] && input[1][1] == input[2][0]) if (input[0][2] != '+') ret = input[0][2];
                Console.WriteLine(ret == '+' ? "NA" : ret.ToString());
            }
        }
    }
}

Measured memory_bytes: 8716
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(n,a,b);
  Vi ANS(n);
  REP(i,n){
    if(b==1000000000) ANS[i] = 1;
    else ANS[i] = b+1;
  }
  REP(i,a){
    ANS[i] = b;
  }
  VOUT2(ANS)
}

Measured memory_bytes: 2176
#ABC141D
#heapq 効率的にリストの最小値を取り出す
def main():
    import sys, heapq as h
    N, M = map(int, sys.stdin.readline().split())
    A = list(map(lambda x:-int(x), sys.stdin.readline().split()))
    #print(A)
    h.heapify(A) #heap化
    #print(A)
    for m in range(M):
        a = h.heappop(A)
        #print(int(a/2))
        h.heappush(A, int(a/2))
        #print(A)
    print(-sum(A))

if __name__ =='__main__':
    main()


Measured memory_bytes: 14200
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  ll n, a, b; cin >> n >> a >> b;
  vector<ll> X(n), D;
  loop(i,0,n) cin >> X[i];
  loop(i,0,n-1) D.push_back(X[i+1]-X[i]);
  ll sum = 0;
  for (auto&&d: D) sum += min(d*a, b);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5044
na = 0
nb = 0
no = 0
nab = 0

while True:
    try:

        a,b = map(str,raw_input().split(","));

        if b == "A":
            na += 1
        elif b == "B":
            nb += 1
        elif b == "O":
            no += 1
        elif b == "AB":
            nab += 1

    except EOFError:
        break

print na
print nb
print nab
print no

Measured memory_bytes: 4224
#include <stdio.h>

int main(void)
{
  int a, b, x, i;

  scanf("%d%d",&a,&b);

  x=0;
  for(i=1;i<=2;i++) {
        if(a<=b) { x=x+b;
                  b=b-1; }
        else if(a>b) {  x=x+a;
                        a=a-1; }
        }
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint D; cin >> D;
  vi c(26); // contest 0-25
  for(lint i=0; i<26; i++) cin >> c[i];
  vvi s(D+1, vi(26)); // day 0-D
  for(lint d=1; d<=D; d++){
    for(lint j=0; j<26; j++){
      cin >> s[d][j];
    }
  }
  /*
  vi t(D+1); // day 0-D
  
  for(lint d=1; d<=D; d++){
    cin >> t[d];
    t[d]--;
  }
  */
  
  vi last(26,0);
  
  // lint ans = 0;
  
  for(lint d=1; d<=D; d++){
    vi diff(26);
    
    for(lint i=0; i<26; i++){ // if contest i (0-25)
      // ans += s[d][t[d]];
      lint plus = s[d][i];
    
      // last[t[d]] = d;
      lint oldlast = last[i];
      last[i] = d;
    
      lint minus = 0;
    
      for(lint j=0; j<26; j++){
        // ans -= c[j] * (d - last[j]);
        minus += c[j] * (d - last[j]);
      }
      
      last[i] = oldlast;
      diff[i] = plus - minus;
    }
    
    vi oldiff = diff;
    sort(ALL(diff));
    lint t = -1;
    for(lint j=0; j<26; j++){
      if(oldiff[j] = diff[25]) t = j;
    }
    cout << t+1 << endl;
    last[t] = d;
    
  }
  /*
  sort(ALL(c));
  lint tmp = 18; // delete suru kosuu
  for(lint j=0; j<tmp; j++) c.pop_back();
          
  for(lint d=1; d<=D; d++){
    cout << c[d%(26-tmp)] << endl;
  }
  */
}
      
      
    
  
  
  
  

Measured memory_bytes: 3716
n, m, c = map(int, input().split())
b = list(map(int, input(). split()))
cnt = 0

for i in range(n):
	a = list(map(int, input().split()))
	cal = c
	for x in range(m):
		cal += a[x] * b[x]
		if x == m - 1 and cal > 0:
			cnt += 1

print(cnt)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	@SuppressWarnings({ "unused", "unchecked" })
	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			int m = scanner.nextInt();
			int s = scanner.nextInt();
			int g1 = scanner.nextInt();
			int g2 = scanner.nextInt();
			if ((n | m | s | g1 | g2) == 0)
				break;
			s--;
			g1--;
			g2--;
			int[][] g = new int[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					g[i][j] = i == j ? 0 : INF;

			List<Pair>[] slist = new List[n];
			List<Pair>[] glist = new List[n];
			for (int i = 0; i < n; i++) {
				slist[i] = new ArrayList<Main.Pair>();
				glist[i] = new ArrayList<Main.Pair>();
			}

			while (m-- > 0) {
				int b1 = scanner.nextInt() - 1;
				int b2 = scanner.nextInt() - 1;
				int c = scanner.nextInt();
				slist[b1].add(new Pair(b2, c));
				glist[b2].add(new Pair(b1, c));
			}
			int[] acost = slove(s, slist);
			int[] bcost = slove(g1, glist);
			int[] ccost = slove(g2, glist);

			int ans = INF;
			for (int i = 0; i < n; i++)
				ans = Math.min(ans, acost[i] + bcost[i] + ccost[i]);
			System.out.println(ans);
		}
	}

	private int[] slove(int s, List<Pair>[] lists) {
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		pq.offer(new Pair(s, 0));
		int[] dp = new int[n];
		Arrays.fill(dp, INF);
		dp[s] = 0;
		while (!pq.isEmpty()) {
			Pair p = pq.poll();
			if (dp[p.d] < p.cost)
				continue;
			dp[p.d] = p.cost;
			for (Pair pair : lists[p.d]) {
				pq.offer(new Pair(pair.d, p.cost + pair.cost));
			}
		}
		return dp;
	}

	int INF = 1 << 29;
	int n;

	class Pair implements Comparable<Pair> {
		int d, cost;

		public Pair(int d, int cost) {
			super();
			this.d = d;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Pair [d=" + d + ", cost=" + cost + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return cost - o.cost;
		}

	}
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  int c = 0;
  for (char ss: s) {
    if (ss == 'a') {
      a++;
    } else if (ss == 'b') {
      b++;
    } else {
      c++;
    }
  }
  bool ok = true;
  if (s.size() <= 3) {
    if (a > 1 || b > 1 || c > 1) {
      ok = false;
    }
  } else {
    if (abs(a - b) > 1 || abs(b - c) > 1 || abs(c - a) > 1) {
      ok = false;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
s=int(input())
num=[s]
def f(n):
    if n%2==0:
        return(n//2)
    else:
        return(3*n+1)
a=0
while True:
    if f(num[a]) in num:
        print(a+2)
        break
    else:
         num.append(f(num[a]))
         a+=1

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>

#define FOR(i,a,b) for(int i = (a); i < (b); ++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 ALL(a) begin(a), end(a)

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

bool sdp[3001] = {0};
bool wdp[3001] = {0};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100;
	b *= 100;
	// water
	for(int i = 0; i * b <= f; ++i){
		for(int j = 0; j * a + i * b <= f; ++j){
			wdp[j * a + i * b] = true;
		}
	}
	//sugar
	for(int k = 0; k * d <= f; ++k){
		for(int l = 0; l * c + k * d <= f; ++l){
			sdp[l * c + k * d] = true;
		}
	}

	int mw = 0, ms = 0;

	// water
	for(int i = 1; i <= f; ++i){
		// sugar
		for(int j = 0; i + j <= f && i * e >= j * 100; ++j){
			if(!(wdp[i] && sdp[j])) continue;
			// 濃度比較
			if((ms + mw) * j >= ms * (i + j)){
				mw = i; 
				ms = j;
			}
		}
	}
	cout << ms + mw << " " << ms << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), putchar(), scanf()
#include <string.h>         // strlen()

int
main(int argc, char** argv)
{
	char a[101], b[101];
	int c[80];
	int n;
	int i, j;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%s", a);
		scanf("%s", b);
		int al = strlen(a);
		int bl = strlen(b);
		if (al > 80 || bl > 80)
		{
			printf("overflow\n");
			continue;
		}

		al--; bl--;
		int cl = 0;
		int cy = 0;
		while (al >= 0 || bl >= 0)
		{
			c[cl] = cy;
			if (al >= 0)
				c[cl] += a[al--] - '0';

			if (bl >= 0)
				c[cl] += b[bl--] - '0';

			cy = c[cl] / 10;
			c[cl++] %= 10;
		}

		if (cy != 0)
			c[cl++] = cy;

		if (cl > 80)
		{
			printf("overflow\n");
			continue;
		}

		for (j = cl - 1; j >= 0; --j)
			putchar(c[j] + '0');

		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
int k, t, x;
pair<int, pair<int, int> > a[128];
int main(void) {
  cin >> k >> t;
  for (int i = 0; i < t; i++) {
    cin >> x;
    a[i] = make_pair(x, make_pair(0, i));
  }
     
  int ans = 0, p = -1, y = 1;
  for (int i = 0; i < k; i++) {
    sort(a, a+t);
    for (int j = t-1; j >= 0; j--) {
      if (j == 0 && a[j].first == 0) {
        while (a[j].first == 0) j++;
        if (a[j].second.second == p) ans++;
        p = a[j].second.second; a[j].first--; a[j].second.first = -y++;
        //cout << p << endl;
        break;
      }
      
      if (a[j].first == 0) continue;
      if (a[j].second.second == p && j > 0) continue;
      
      if (a[j].second.second == p) ans++;
      p = a[j].second.second; a[j].first--; a[j].second.first = -y++;
      //cout << p << endl;
      break;
    }
  }
      
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    char str[105]={0};
    scanf("%s", str);

    long cnt0=0, cnt1=0;
    long i;
    for(i=0; i<strlen(str); i++) {
        if(str[i]=='R') cnt0++;
        else cnt1++;
    }

    if(cnt0>cnt1) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}


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

using namespace std;

typedef vector<char> vc;
typedef vector<vc> vvc;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<char, pii> mcpii;
typedef pair<pair<string, string>, int> ppssi;
typedef vector<ppssi> vppssi;

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second
#define read freopen("..\\in.txt", "r", stdin)
#define write freopen("..\\out.txt", "w", stdout)

const int dir_x[]{0, 0, -1, 1}, dir_y[]{-1, 1, 0, 0};

const int INF = 1e9 + 5;

ll bigPow(ll n, int k) {
    ll ans = 1L;
    for (int i = 1; i <= k; ++i) ans *= n;
    return ans;
}

int bigLog(ll n, int k) {
    double ass = log10(n) / log10(k);
    int lo = 0, hi = ass + 1;
    while (lo <= hi) {
        int mid = (lo + hi) / 2;
        ll x = bigPow(k, mid);
        if (x == n) return mid;
        if (x > n) {
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }
    return hi;
}

int main() {
    //read;
    int T = 1;
    //cin >> T;
    for (int tc = 1; tc <= T; ++tc) {
        int a, b, c;
        cin >> a >> b >> c;
        cout << c << " " << a << " " << b << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    vector<string> A(N),B(M);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<M;i++) cin>>B[i];
    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[i+k][j+l]!=B[k][l]) goto skip;
                }
            }
         	goto Yes;
          	skip:;
        }
    }
    cout<<"No"<<endl;
    return 0;
    Yes:cout<<"Yes"<<endl;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 51;

int n;
int A[MAXN], B[MAXN];

int val[MAXN];
char vis[MAXN];

char f[MAXN];

char check()
{
	FOR(i, 1, n) {
		memset(f, 0, sizeof f);
		f[A[i]] = true;
		DNF(j, 50, 0) FOR(k, 1, val[0]) {
			f[j % val[k]] |= f[j];
		}
		if (!f[B[i]]) return false;
	}
	return true;
}

int main()
{
	in(n);
	FOR(i, 1, n) in(A[i]);
	FOR(i, 1, n) in(B[i]);

	val[0] = 0;
	FOR(i, 1, 50) val[++val[0]] = i;

	if (!check()) puts("-1");
	else {
		FOR(i, 1, 50) vis[i] = true;
		DNF(i, 50, 1) {
			vis[i] = false;
			val[0] = 0; FOR(j, 1, 50) if (vis[j]) val[++val[0]] = j;
			if (!check()) vis[i] = true;
		}
		LL ans = 0;
		val[0] = 0; FOR(i, 1, 50) if (vis[i]) val[++val[0]] = i;
		assert(check());
		FOR(i, 1, 50) if (vis[i]) ans += (1ll << i);
		printf("%lld\n", ans);
	}
	
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  int answer = numeric_limits<int>::max() / 3;
  for (int y = -100; y <= 100; y++) {
    int sum = accumulate(
        ALL(a), 0, [y](int acc, int x) { return acc + (x - y) * (x - y); });
    answer = min(answer, sum);
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
s = int(input())
a = int(s/100)
b = s % 100

fa, fb = False, False
if a in range(1, 13):
    fa = True

if b in range(1, 13):
    fb = True

if fa and fb:
    print('AMBIGUOUS')
elif fa and not fb:
    print('MMYY')
elif not fa and fb:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 3060
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(M)]

result = []
stack = []

def path(start, visited):
    if len(visited) >= N:
        result.append(visited[:])
        exit
    stack.append(start)
    if len(stack) > 0:
        nextpoint = stack.pop()
        if nextpoint not in visited:
            visited.append(nextpoint)
            for i in range(M):
                if A[i][0] == start:
                    path(A[i][1], visited)
                if A[i][1] == start:
                    path(A[i][0], visited)
            visited.pop()

path(1, [])
result = list(map(list, set(map(tuple, result))))
print(len(result))


Measured memory_bytes: 9844
#include <iostream>
using namespace std;
int main(){
  int N;cin>>N;
  int sm = 0;
  int dai;
  for(int i = 1; N >= i; i++){
    sm+=i;
    if(sm > N){
      dai=i;break;
    }
  }
  for(int i = 1; dai >= i; i++){
    if(sm - N != i)cout << i << endl;
  }
}

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

#define max(a,b) \
  ({ __typeof__ (a) _a = (a); \
      __typeof__ (b) _b = (b); \
    _a > _b ? _a : _b; })

#define min(a,b) \
  ({ __typeof__ (a) _a = (a); \
      __typeof__ (b) _b = (b); \
    _a < _b ? _a : _b; })

int vacation(int *a, int K, int N) {
    int *r = calloc(N * 3, sizeof(int));
    int *rs = calloc(N * 3, sizeof(int));
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            if (i == 0) {
                rs[i * K + j] = a[i * K + j];
                r[i * K + j] = -1;
            } else {
                for (int h = 0; h < K; h++) {
                    if (h != j) {
                        int ca = rs[(i - 1) * K + h] + a[i * K + j];
                        if (rs[i * K + j] < ca) {
                            rs[i * K + j] = ca;
                            r[i * K + j] = h;
                        }
                    }
                }
            }
        }
    }

    int result = 0;
    for (int j = 0; j < K; j++) {
        result = max(result, rs[(N - 1) * K + j]);
    }

    free(rs);
    free(r);
    
    return result;
}

int main(int argc, const char * argv[]) {
    int N = 0;
    int K = 3;
    scanf("%i", &N);
    
    int *a = malloc(sizeof(int) * N * K);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < K; j++) {
            scanf("%i", &a[i * K + j]);
        }
    }
    
    printf("%i", vacation(a, K, N));
    
    free(a);
    return 0;
}


Measured memory_bytes: 2560