akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n;
      cin >> n;
      bool flag=false;
      if((n/10)%111==0) flag=true;
      if((n%1000)%111==0) flag=true;
      if(flag) cout << "Yes" << endl;
      else cout << "No" << endl;
      return 0;}

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

int main() {
	double a, b, C, S, L, h;
	cin >> a >> b >> C;
	
	S = a*b*sin(M_PI*C/180)/2;
	L = sqrt(a*a+b*b-2*a*b*cos(M_PI*C/180)) + a + b;
	h = 2*S/a;
	
	printf("%f\n%f\n%f\n", S, L, h);
	
	return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    string S;
    cin >> S;
    if (S.compare("AAA") == 0 || S.compare("BBB") == 0)
    {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

bool judge[200000];
int d[200000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m;cin>>n>>m;

	for(int i=1; i<=n; i++){
		judge[i] =true;
	}

	int ans=0;
	int wa=0;
	for(int i=0; i<m; i++){
		int p; string s;cin>>p>>s;
		if(s!="AC" && judge[p]){
			d[p]++;
		}else {
			if(judge[p])ans++;
			judge[p] =false;
		}
	}
	for(int i=1; i<=n; i++){
		if(!judge[i]) wa+=d[i];
	}

	cout<<ans<<" "<<wa<<endl;


}




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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int len = 1e6+5;
ll a[len];

int main(){
    int k;
    scanf("%d", &k);
    for (int i = 1; i <= k; i++)
        scanf("%lld", &a[i]);

    ll l = 2, r = 2, fir, last;
    for (int i = k; i >= 1; i--){
        //printf("i = %d, l = %lld, r = %lld\n", i, l, r);
        if (a[i]*(r/a[i]) < l){
            printf("-1\n");
            return 0;
        }

        fir = (l/a[i]+(bool)(l%a[i]))*a[i];
        last = (r/a[i])*a[i];

        l = fir;
        r = last+a[i]-1;
    }

    printf("%lld %lld\n", l, r);
    return 0;
}


Measured memory_bytes: 1024
n = str(input())
if n[-1] == "0":
    print("pon")
elif n[-1] == "1":
    print("pon")
elif n[-1] == "2":
    print("hon")
elif n[-1] == "3":
    print("bon")
elif n[-1] == "4":
    print("hon")
elif n[-1] == "5":
    print("hon")
elif n[-1] == "6":
    print("pon")
elif n[-1] == "7":
    print("hon")
elif n[-1] == "8":
    print("pon")
elif n[-1] == "9":
    print("hon")    

Measured memory_bytes: 9104
package main

import "fmt"

func main(){
	var n int
	var l []int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++{
		var tmp int
		fmt.Scanf("%d", &tmp)
		l = append(l, tmp)
	}

	count := 0
	for len(l) > 0 {
		top := l[0]
		l = l[1:]
		tmp1 := l
		for len(tmp1) > 0 {
			val1 := tmp1[0]
			tmp1 = tmp1[1:]
			tmp2 := tmp1
			for len(tmp2) > 0 {
				val2 := tmp2[0]
				tmp2 = tmp2[1:]
				if top != val1 && top != val2 && val1 != val2 &&
					isTriangle(top, val1, val2) {
					count++
				}
			}
		}
	}
	fmt.Print(count)
}

func isTriangle(a int, b int, c int) bool {
	if a + b > c && a + c > b && b + c > a {
		return true
	}
	return false
}

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

int main(){

	int cnt, a, b, xl, xr, keta;
	string str, l1, l2, r;
  bool flg_zero;
  
  while(cin >> str){
  	cnt = 0;
  	l1 = "";
  	l2 = "";
  	r = "";
  	a = 0;
  	b = 0;
  	xl = 0;
  	xr = 0;
  	for(int i=0; i<str.length(); i++){
  		if(str[i] != '+' && str[i] != '='){
  			switch(cnt){
  				case 0: l1 += str[i]; break;
  				case 1: l2 += str[i]; break;
  				case 2: r += str[i]; break;
  			}
  		}
  		else cnt++;
  	}
  	
  	flg_zero = false;
  	if(l1.length() != 1 && l1[0] == 'X') flg_zero = true;
  	if(l2.length() != 1 && l2[0] == 'X') flg_zero = true;
  	if(r.length() != 1 && r[0] == 'X') flg_zero = true;
  	
  	keta = 1;
  	for(int i=l1.length() - 1; i>=0; i--){
  		if(l1[i] != 'X'){
  			a += (l1[i] - '0') * keta;
  		}
  		else xl += keta;
  		keta *= 10;
  	}

  	keta = 1;
  	for(int i=l2.length() - 1; i>=0; i--){
  		if(l2[i] != 'X'){
  			a += (l2[i] - '0') * keta;
  		}
  		else xl += keta;
  		keta *= 10;
  	}

  	keta = 1;
  	for(int i=r.length() - 1; i>=0; i--){
  		if(r[i] != 'X'){
  			b += (r[i] - '0') * keta;
  		}
  		else xr += keta;
  		keta *= 10;
  	}

  	int i;
  	if(flg_zero != true) i = 0;
  	else i = 1;
  	for(; i<10; i++){
  		if(a + xl * i == b + xr * i){
  			cout << i << endl;
  			break;
  		}
  		if(i == 9){
  			cout << "NA" << endl;
  		}
  	}
  	
  }

  return 0;

}

Measured memory_bytes: 1192
'''
標高がxメートルの地点での平均気温はT−x×0.006度です。
宮殿を建設する地点の候補はN個あり、地点iの標高はHiメートルです。
平均気温がA度に最も近い地点を選んで宮殿を建設。
宮殿を建設すべき地点の番号を出力してください。
'''

n=int(input())
t,a=map(int,input().split())
h=[t-int(i)*0.006 for i in input().split()]
ans=[-1,1000000000]#地点番号と標高のリスト（初期値）
for i in range(n):
    if abs(h[i]-a)<abs(ans[1]-a):#ans[1]は標高
        ans=[i,h[i]]#地点番号と標高を洗い替え
print(ans[0]+1)#地点番号を出力（1-indexのため、+1）

Measured memory_bytes: 3064
#include <stdio.h>

int main (void)
{
  unsigned int a, b, i;
  
  scanf("%d %d", &a, &b);
  
  for (i=0; i < 1250; i++) {
    if ((unsigned int)(i*0.08) == a && ((unsigned int)(i*0.1) == b)) {
      printf("%u", i);
      return 0;
    }
  }
  
  printf("%d", -1);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > pii;
typedef long long LL;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return ret;
}
void putint(LL v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
int n,M,fac[10005],ifac[10005];
int powM(int V,int T){
	int R=1;
	while(T){
		if(T&1) R=(LL)R*(LL)V%(LL)M;
		T>>=1;
		V=(LL)V*(LL)V%(LL)M;
	}
	return R;
}
int main(){
	int i,j,k;
	scanf("%d%d",&n,&M);
	fac[0]=1;
	for(i=1;i<=10000;++i){
		fac[i]=(LL)fac[i-1]*(LL)i%(LL)M;
	}
	ifac[10000]=powM(fac[10000],M-2);
	for(i=9999;i>=0;--i){
		ifac[i]=(LL)ifac[i+1]*(LL)(i+1)%(LL)M;
	}
	int res=0;
	for(i=0;i<=n;++i){// # of 3
		for(j=0;i+j<=n;++j){// # of 2
			int R=(LL)fac[n*3]*(LL)powM(ifac[2],j)%(LL)M*(LL)powM(ifac[3],i)%(LL)M;
			R=(LL)R*(LL)ifac[i]%(LL)M*(LL)ifac[j]%(LL)M*(LL)ifac[n*3-i*3-j*2]%(LL)M;
			R=(LL)R*(LL)powM(2,i)%(LL)M;
			res+=R;
			if(res>=M) res-=M;
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var ABCD = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B, C, D) = (ABCD[0], ABCD[1], ABCD[2], ABCD[3]);

        var state = new (int, int)[2] { (A, B), (C, D) };
        var i = 0;

        while(true)
        {
            var j = (i + 1) % 2;

            state[j].Item1 -= state[i].Item2;

            if (state[j].Item1 <= 0)
                break;

            i = j;
        }

        if (i == 0)
            WriteLine("Yes");
        else
            WriteLine("No");
    }
}


Measured memory_bytes: 27980
#include <bits/stdc++.h>
using namespace std;
int n, s;
bitset<4000021> f;
int main () {
	scanf("%d", &n);
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		f |= f << x;
		s += x;
	}
	for (int i = (s + 1) >> 1; i <= s; i++) {
		if (f[i]) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N; cin >> N;
  vector<int> data(N, 0);
  for(int i=0; i<N-1; i++){
    int A; cin >> A;
    data.at(A-1)++;
  }
  
  for(int i=0; i<N; i++){
    cout << data.at(i) << endl;
  }
  
}

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

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

using namespace std;

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

int main(){
    int n; cin >> n;
    unsigned long long vec[n];
    unsigned long long sum = 1;

    unsigned long long num = 1;
    rep(i, 18) num *= 10;


    unsigned long long minn = 1e9;
    rep(i, n) {
        cin >> vec[i];
        if(vec[i] == 0) {
            cout << 0;
            return 0;
        }
        minn = min(minn, vec[i]);
    }

    rep(i, n) {
        sum *= vec[i];
        if(sum > num || sum < minn) {
            cout << -1;
            return 0;
        }
    }

    cout << sum;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef pair<ull , ull> ulli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
typedef set <int> st;
typedef set <char> stc;
typedef vector<int>::iterator itr;

#define df first
#define ds second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<(b);i++)
#define f22(a,b) for(int j=(a);j<(b);j++)
#define sq(a) a*a
#define cu(a) (sq(a)*a)


const int hell = (int)1e9+7;
const int maxn = (int)2e5+5;
const int inf = 1e9+9;
const ll INF = 1e18;


int main() 
{ 
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    
    int n;
    char c;
    string s;
    
    cin >> n >> s;
    
    f0(s.length()){
    	
    	c = (((s[i]-'A'+n)%26)+'A');
    	cout << c;
	}
    
    
     
    return 0; 
    
}


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
ans = k
b = a[0] + (k-a[-1])
prev = a[0]
for i, v in enumerate(a):
    x = 0
    if i == 0:
        x = max(abs(a[i+1]-v), b)
    elif i == len(a)-1:
        x = max(b, abs(v-prev))
    else:
        x = max(abs(a[i+1]-v), abs(v-prev))
    ans = min(ans, k-x)
    prev = v
print(ans)

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

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

using namespace std;
using ll = long long;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c == 17)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ull x; cin >> x;
    ull k = 100;
    int c = 0;
    while (k < x)
    {
        k += (k / 100);
        c++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 3552
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left
from collections import deque


def solve():
  N = int(input())
  An = [int(input()) for _ in range(N)]
  if N==1:
    return 1
  else:
    ret = deque([An[0]])
    for a in An[1:]:
      idx = bisect_left(ret,a)
      if idx == 0:
        ret.appendleft(a)
      else:
        ret[idx-1] = a
    return len(ret)


print(solve())

Measured memory_bytes: 54360
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  
  int mx = 0;
  int d[3];
  vector< vector<int> > dp(n+1, vector<int>(3, 0));
  for(int i=1; i<=n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;

  return 0;
}



//EOF


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

int main(void){
  int n, m; cin >> n >> m;
  if(n % 2 == 1){
    for(int i = 0; i < n/2 + 1; i++){
      if(i == 0)
        cout << 0;
      else
        cout << " " << 0;
    }
    for(int i = 0; i < n/2; i++){
        cout << " " << m;
    }
    cout << endl;
  }else{
    for(int i = 0; i < n/2 + 1; i++){
      if(i == 0)
        cout << 0;
      else
        cout << " " << 0;
    }
    for(int i = 0; i < n/2 - 1; i++){
      cout << " " << m;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
bool f[1000006];
int x;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	
	f[1]=1;
  	for (int i=2; i<=1e6; i++)
  		if (!f[i]) 
  			for (int j=2*i; j<=1e6; j+=i)
  				f[j]=1;
  	
  	cin>>x;
  	
  	while (f[x]) {
  		x++;
  	}
  	
  	cout<<x<<endl;

	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;

    // 引数の受け取り
    //
    cin >> a >> b >> c;

    // 出力
    cout << ((b-a)==(c-b)?"YES":"NO") << endl;
    return 0;
}



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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 2e6;

// Template-Libs

// END

int A, B, C;

inline void input()
{
	A = read<int>(), B = read<int>(), C = read<int>();
}

inline void solve()
{
	printf("%lld\n", (LL) B + min(A + B + 1, C));
}

int main()
{
	input();
	solve();

	return 0;
}



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

struct Node {
    std::map<int, int> edge;
    long long k_distance{-1};
};

Node tree[100000];

void calc_distance(const int, const long long);

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        long long c;
        scanf("%d%d%lld", &a, &b, &c);
        a--; b--;
        tree[a].edge[b] = c;
        tree[b].edge[a] = c;
    }
    int q, k;
    scanf("%d%d", &q, &k);
    k--;

    calc_distance(k, 0);
    for (int i = 0; i < q; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        x--; y--;
        printf("%lld\n", tree[x].k_distance + tree[y].k_distance);
    }

    return 0;
}

void calc_distance(const int a, const long long distance)
{
    if (tree[a].k_distance != -1) return;

    tree[a].k_distance = distance;
    for (auto &e : tree[a].edge)
    {
        calc_distance(e.first, distance + e.second);
    }
    return;
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    ll ans=0;
    reps(i,1,N+1){
        if(i%3==0 or i%5==0) continue;
        ans+=i;
    }
    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio> 
#include <cstring>
#include <cmath>
#include <string>
using namespace std;
int a[105][105]={0};
int main()
{
	int ans=0;
	int w,h,n;
	cin>>w>>h>>n;
	while(n--)
	{
		int x,y,ar;
		cin>>x>>y>>ar;
		if(ar==1)
		{
			for(int i=1;i<=x;i++)
			{
				for(int j=1;j<=h;j++)
				{
					if(a[i][j]==0)
					{
					//	cout<<i<<" "<<j<<endl;
						a[i][j]=1;
						ans++;
					}
				}
			} 
			//cout<<ans<<endl;
		} 
		else if(ar==2)
		{
			for(int i=x+1;i<=w;i++)
			{
				for(int j=1;j<=h;j++)
				{
					if(a[i][j]==0)
					{
						a[i][j]=1;
					//	cout<<i<<" "<<j<<endl;
						ans++;
					}
				}
			} //cout<<ans<<endl;
		} 
		else if(ar==3)
		{
			for(int i=1;i<=y;i++)
			{
				for(int j=1;j<=w;j++)
				{
					if(a[j][i]==0)
					{
						a[j][i]=1;
						ans++;
					}
				}
			} //cout<<ans<<endl;
		} 
		else 
		{
			for(int i=y+1;i<=h;i++)
			{
				for(int j=1;j<=w;j++)
				{
					if(a[j][i]==0)
					{
					//	cout<<i<<" "<<j<<endl;
						a[j][i]=1;
						ans++;
					}
				}
			} //cout<<ans<<endl;
		} 
	}
	cout<<w*h-ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if (s == "Sunny"){
    cout << "Cloudy\n";
  }
  if (s == "Cloudy"){
    cout << "Rainy\n";
  }
  if (s == "Rainy"){
    cout << "Sunny\n";
  } 
  return 0; 
}

Measured memory_bytes: 256
local function pfact(x)
	local ret={}
	local c=0
	while(x%2==0)do c=c+1 x=x/2 end
	if(c~=0)then ret[2]=c end
	
	local i=3
	while(i*i<=x)do
		local c=0
		while(x%i==0)do c=c+1 x=x/i end
		if(c~=0)then ret[i]=c end
		i=i+2
	end
	ret[x]=(ret[x]or 0)+1
	return ret
end
N=io.read"*n"
P=io.read"*n"
r=1
for k,v in pairs(pfact(P))do
	r=r*k^math.floor(v/N)
end
print(r)

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

#define N 10

typedef long long ll;

ll getI () {
    ll x;
    scanf("%lld", &x);
    return x;
}

double getD () {
    double x;
    scanf("%lf", &x);
    return x;
}

char *getS (int size) {
    char *s = (char*)malloc(sizeof(char)*(size+1));
    scanf("%s", s);
    return s;
}

int main () {

    ll n = getI();
    double sum = 0;
    for (int i=0; i<n; i++) {
        double x = getD();
        char *u = getS(3);

        if (*u=='B') {
            sum += x * 380000.0;
        }else{
            sum += x;
        }

        free(u);
    }

    printf("%lf\n", sum);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long x;
    cin >> x;
    long long d = x / 500;
    x %= 500;
    long long e = x / 5;
    cout << d * 1000 + e * 5 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 100000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;

int main() {

	ll n;
	cin >> n;
	vector<ll> a(n);
	ll sum_all = 0;
	vector<ll> sum_comulative(n);
	rep(i, n) {
		cin >> a.at(i);
		sum_all += a.at(i);
		sum_comulative.at(i) = sum_all;
	}
	ll ans = mod;
	rep(i, n - 1) {
		ll x = sum_comulative.at(i);
		ll y = sum_all - x;
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
	return 0;
	
}



Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int D;
vector<LL> c(26);
vector<vector<LL>> s;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL solve(const vector<LL>& t) {
  LL ans = 0;
  vector<LL> last(26, 0);
  for (int d = 1; d <= D; ++d) {
    int i = d - 1;
    int j = t[i];
    last[j] = d;
    ans += s[i][j];
    for (int k = 0; k < 26; ++k) {
      ans -= c[k] * (d - last[k]);
    }
  }
  return ans;
}

int main() {
  cin >> D;
  cin >> c;
  s.resize(D, vector<LL>(26, 0));
  for (int i = 0; i < D; ++i) cin >> s[i];

  vector<LL> t(D);
  for (int d  =  0; d < D; ++d) t[d] = d % 26;

  LL prev = solve(t);
  int d = 0;
  for (int i = 0; i < 100000; ++i) {
    auto t_bk = t;
    t[d % D] = rand() % 26;

    LL score = solve(t);
    if (score > prev) {
      prev = score;
    } else {
      t = t_bk;
      ++d;
    }
  }

  for (int x : t) cout << x + 1 << endl;
}


Measured memory_bytes: 3728
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())

for l in range(len(N)):
    table = [0 for i in range(15)]
    cards = [int(i) for i in N[l].split(",")]
    for i in range(5):
        table[cards[i]] += 1

    two,three,four,ren = 0,0,0,0
    for i in range(15):
        if table[i] == 2:
            two += 1
        elif table[i] == 3:
            three += 1
        elif table[i] == 4:
            four += 1

    for i in range(14):
        if table[i] == 1 and table[i+1] == 1:
            ren += 1
    if table[10] == 1 and table[11] == 1 and table[12] == 1 and table[13] == 1 and table[1] == 1:
        ren = 4
    ans = "null"
    if four == 1:
        ans = "four card"
    elif two == 1 and three == 1:
        ans = "full house"
    elif ren == 4:
        ans = "straight"
    elif three == 1:
        ans = "three card"
    elif two == 2:
        ans = "two pair"
    elif two == 1:
        ans = "one pair"
    print(ans)


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

int distance(int m, int n){
	return abs(m-n);
}

bool can_make_triangle(int a, int b, int d){
	if(distance(a,b)<=d){
		return true;
	}else{
		return false;
	}
}

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

	//cout << a << " " << b << " " << c << " " << d << " "  << distance(a,b) << " " << distance(b,c) << " " << distance(c,a) << " " << endl;

	//直接
	if(can_make_triangle(a,c,d)){
		cout << "Yes" << endl;
		return 0;
	}else{
	if(can_make_triangle(a,b,d) && can_make_triangle(b,c,d)){ //間接
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}}
	return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;


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

  int n,m,c;cin>>n>>m>>c;
  vector<int> bs;
  for(int i=0;i<m;i++){
    int t;cin>>t;bs.push_back(t);
  }
  int res=0;
  for(int i=0;i<n;i++){
    int sum = 0;
    for(int j=0;j<m;j++){
      int t;cin>>t;
      sum += bs[j] * t;
    }
    if(sum + c > 0)res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
/*input
170
*/
/*
       _==/          i     i          \==_
     /XX/            |\___/|            \XX\
   /XXXX\            |XXXXX|            /XXXX\
  |XXXXXX\_         _XXXXXXX_         _/XXXXXX|
 XXXXXXXXXXXxxxxxxxXXXXXXXXXXXxxxxxxxXXXXXXXXXXX
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
 XXXXXX/^^^^"\XXXXXXXXXXXXXXXXXXXXX/^^^^^\XXXXXX
  |XXX|       \XXX/^^\XXXXX/^^\XXX/       |XXX|
    \XX\       \X/    \XXX/    \X/       /XX/
       "\       "      \X/      "      /"

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
//loops
#define f(i,s,n) for(ll i=(ll)s;i<(ll)n;i++)
#define rf(i,n,s) for(ll i=(ll)(n-1);i>=(ll)s;i--)
//reset
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
//IO
#define bio ios_base::sync_with_stdio;cin.tie(NULL)
//STL
#define pb push_back
#define pii pair<ll,ll>
#define vll vector<ll>
#define vpii vector<pii >
#define mll map<ll, ll>
#define mpii map<pii,ll> 
#define msll map<string, ll> 
#define sortv(v) sort(v.begin(),v.end())
#define F first
#define S second
//standard values
#define mod (ll)(1e9+7)
#define INF (ll)1e16
#define MAXN (ll)(1e5+5)
//comparator
bool cmp(pii a, pii b)
{
    return a.F < b.F;
}
ll exp(ll a,ll b){ll ans=1;while(b!=0){if(b%2==1)ans=ans*a;a=a*a;b/=2;}return ans;}
/********************************************************************************************************/
int main() 
{
  bio;
  int n;
  cin>>n;
  bool fg = false;
  while(n != 0 && !fg) {
    fg = (n%10) == 7;
    n/=10;
  }
  if (fg)
  {
    cout<<"Yes";
  }
  else {
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int INF = 1e9+7;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int w=0,r=0;
	for(int i=0;i<n;++i){
		if(s[i]=='W') ++w;
		else ++r;
	}
	int m=0;
	int rr=r;
	for(int i=0;i<n;++i){
		if(s[i]=='W' && rr>0){
			--rr;
			++m;
		}
		else if(s[i]=='R') --rr; 
	}
	cout<<min({w,r,m})<<'\n';
	return 0;
}

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

int main(){
  int n, k, d, a;
  cin >> n >> k;
  vector<int> sunuke(n);
  for(int i= 0; i < n; i++) sunuke[i] = 0;
  
  for(int i= 0; i < k; i++){
    cin >> d;
    for(int j= 0; j < d; j++){
      cin >> a;
      sunuke[a-1] = 1;
    }
  }
  
  int count = 0;
  
  for(int i= 0; i < n; i++){
    if(sunuke[i] == 0) count++;
  }
  
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int n,m;
int c[21];
int t[50001];
const int INF=1<<21;
void solve()
{	for(int i=1;i<=n;i++)
	t[i]=INF;
	t[0]=0;
	for(int i=1;i<=m;i++)
		for(int j=c[i];j<=n;j++)
		{
			t[j]=min(t[j-c[i]]+1,t[j]);
		}

}
int main()
{	cin>>n>>m;
for(int i=1;i<=m;i++)
	cin>>c[i];
solve();
cout<<t[n]<<endl;
	return 0;
}


Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
int n,ans,res;
struct edge {
    int v;
    int w;
    int id;
    edge() {}
    edge(int v, int w, int id) : v(v), w(w), id(id) {};
};

vector<ll> dijkstra(int n, vector<vector<edge> >& G, int s) {
    vector<ll> d(n, 1ll<<55); d[s] = 0;
    priority_queue<pair<ll, int> > que;
    que.push(make_pair(0ll, s));
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        int u = p.second;
        ll dist = -p.first;
        if (dist > d[u]) continue;
        for (edge e : G[u]) {
            if (d[e.v] > d[u]+e.w) {
                d[e.v] = d[u] + e.w;
                que.push(make_pair(-d[e.v], e.v));
            }
        }
    }
    return d;
}

const int MAXM = 1111;
int A[MAXM], B[MAXM], C[MAXM];

bool used[MAXM];

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<edge> > G(N);
	rep(i,0,M) {
		cin >> A[i] >> B[i] >> C[i];
		--A[i]; --B[i];
		G[A[i]].emplace_back(B[i], C[i], i);
		G[B[i]].emplace_back(A[i], C[i], i);
	}
	rep(i,0,N) {
		auto d = dijkstra(N, G, i);
    rep(j,0,M){
      if (d[A[j]] + C[j] == d[B[j]]){
        used[j] = true;
      }
    }
  }
  rep(i,0,M){
    if (used[i] == false)
    ans += 1;
  }
  std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
string S[2];
int pre;

int main() {
  cin >> N;
  cin >> S[0];
  cin >> S[1];

  ll ans = 1;
  for (int i = 0; i < N; ++i) {
    if (S[0][i] == S[1][i]) {
      if (pre == 0) {
        ans *= 3;
        ans %= MOD;
      } else if (pre == 1) {
        ans *= 2;
        ans %= MOD;
      } else {
        // none
      }

      pre = 1;
    } else {
      if (pre == 0) {
        ans *= 6;
        ans %= MOD;
      } else if (pre == 1) {
        ans *= 2;
        ans %= MOD;
      } else {
        ans *= 3;
        ans %= MOD;
      }

      pre = 2;
      ++i;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

int N;

int main()
{
    cin >> N;
    cout << ((N % 10 == 7 || N / 10 % 10 == 7 || N / 100 == 7) ? "Yes" : "No") << endl;
    // system("pause");
}

Measured memory_bytes: 3636
# abc103 D
n, m = gets.split.map(&:to_i)

ab = m.times.map {
  gets.split.map(&:to_i)
}.sort{|(xa,xb),(ya,yb)| xa == ya ? yb <=> xb : xa <=> ya }
# p ab
cnt = 0
loop do
  a, b = *ab.shift
  while ab.empty?.! && ab[0][0] < b
    si = ab.shift
    b = si[1] if si[1] < b
  end
  cnt += 1
  break if ab.empty?
end
p cnt




Measured memory_bytes: 13176
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    if(s<="2019/04/30") cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc109/tasks/abc109_c

import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextInt();
        ArrayList<Long> x = new ArrayList<>();
        ArrayList<Long> dif = new ArrayList<>();
        long gcd = 0;
        for (int i=0;i<N;i++){
            x.add(sc.nextLong());
        }
        x.add(X);
        sc.close();
        Collections.sort(x);
        for (int i=1;i<x.size();i++){
            dif.add(x.get(i)-x.get(i-1));
        }
        for (int i=0;i<dif.size();i++){
            gcd = GCD(gcd,dif.get(i));
        }
        System.out.println(gcd);
    }

    public static long GCD(long a,long b){
        if (a==0 || b==0){
            return Math.max(a,b);
        }
        if (a<b){
            long x = a;
            a = b;
            b = x;
        }
        if (a%b==b){
            return b;
        } else {
            return GCD(b,a%b);
        }
    }
}

Measured memory_bytes: 57184
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	ll h,w;
	cin >> h >> w;
	if(h==1 || w==1) cout << 1 << endl;
	else if(h*w%2==0) cout << h*w/2 << endl;
	else cout << (h*w+1)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
prefs = Array.new(n+1){Array.new()}
city = Struct.new("City", :num, :year, :pref, :id)
m.times do |i|
  pref_, year_ = gets.chomp.split(" ").map(&:to_i)
  prefs[pref_] << city.new(i, year_, pref_, nil)
end

ret = Array.new(n+1)
prefs.each do |pref|
  next if pref.empty?
  pref.sort!{|a, b| a[:year] <=> b[:year]}
  i = 1
  pref.each do |c|
    c[:id] = i
    ret[c[:num]] = c
    i += 1
  end
end

ret.each do |c|
  next if c.nil?
  puts sprintf("%06d", c[:pref]) + sprintf("%06d", c[:id])
end


Measured memory_bytes: 23696
def left(i):return  2 * i + 1
def right(i):return  2 * i + 2
def max_heapify(a, i):
    l = left(i)
    r = right(i)
    largest = l if  l < len(a) and a[l] > a[i] else i
    largest = r if  r < len(a) and a[r] > a[largest] else largest
    
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)
        
def build_max_heap(a):
    for i in range(len(a) // 2, -1, -1):
        max_heapify(a, i)
n = int(input())
heap = list(map(int, input().split()))
build_max_heap(heap)
print('', *heap)



Measured memory_bytes: 63700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] matrix = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                matrix[i][j] = sc.nextInt();
            }
        }
        int[][] d = warshallFloyd(matrix);
        long ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int a = sc.nextInt();
                if(a > -1) ans += d[a][1];
            }
        }

        System.out.println(ans);
        sc.close();
    }

    public static int[][] warshallFloyd(int[][] matrix){
        int[][] d = matrix.clone();
        int n = matrix.length;
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        return d;
    }

}


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

using namespace std;
const int MOD = 1000000007,MAX = 510000;
long int pow107 = (int)pow(10, 9) + 7,llimit = LONG_MAX,fac[MAX], finv[MAX], inv[MAX];
int ilimit = INT_MAX;

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long int COM(long int n,long int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2
//コンビネーションCOMinit(),COM(n,m)

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b)cout << c << endl;
    if(b == c)cout << a << endl;
    if(c == a)cout << b << endl;

}

Measured memory_bytes: 256
from sys import stdin
s = int(stdin.readline().rstrip())
numss = [s]
while True:
    if numss[-1] % 2 == 0:
        numss.append(int(numss[-1]/2))
    else:
        numss.append(int(3*numss[-1] + 1))
    
    if numss[-1] == 1:
        numss.extend([4,2,1])
        break
for i in range(len(numss)-1):
    if numss[i+1] in numss[:i+1]:
        print(i+2)
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int, int> > LR(N);
    for (auto & lr : LR) {
        cin >> lr.first >> lr.second;
    }
    sort(LR.begin(), LR.end());
    vector<int> MIN(N), MINR(N);
    MIN[0] = LR[0].second;
    MINR[N-1] = LR[N-1].second;
    for (int i = 1; i < N; ++i) {
        MIN[i] = min(MIN[i-1], LR[i].second);
        MINR[N-1-i] = min(MINR[N-i], LR[N-1-i].second);
    }
    int ans = 0;
    for (int i = 1; i < N; ++i) {
        ans = max(ans, max(0, MIN[i-1]-LR[i-1].first+1) + max(0, MINR[i]-LR[N-1].first+1));
    }
    for (int i = 1; i < N-1; ++i) {
        ans = max(ans, max(0, MIN[N-1]-LR[N-1].first+1) + max(0, LR[i].second-LR[i].first+1));
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

ll count_divisor(ll n) {
	ll mod = 1e9 + 7;
	ll res = 0;
	for(ll i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res = ((res % mod) + 1) % mod;
			if(i != n / i) res = (res % mod + 1) % mod;;
		}
	}
	return res;
}
vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

ll modkaijo(ll n) {
	ll mod = 1e9 + 7;
	ll res = 1;
	while(n > 1) {
		res = (res % mod) * (n % mod);
		n--;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	map<int, int> m;
	for(int i = N; i > 1; i--) {
		 map<int, int> tmp_m = prime_factor(i);
		 for(map<int, int>::iterator it = tmp_m.begin(); it != tmp_m.end(); it++) {
			 m[it->first] += tmp_m[it->first];
		 }
	}

	int rsl = 1;
	ll mod = 1e9 + 7;
	for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
		rsl = ((rsl % mod) * ((it->second + 1) % mod)) % mod;
	}
	cout << rsl << endl;


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// dijkstra O(ElogV)
// verify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A
template<typename T>
struct Dijkstra {
private:
    int V;
    struct edge { int to; T cost; };
    vector<vector<edge>> G;
public:
    const T inf = numeric_limits<T>::max();

    // s から i の最小コスト
    // 経路がない場合は inf
    vector<T> d;

    Dijkstra(int V) : V(V) {
        G.resize(V);
    }

    // 辺の追加
    // 有向の場合　directed = true
    void add_edge(int from, int to, T weight, bool directed = false) {
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }

    void build(int s) {
        d.assign(V, inf);
        typedef pair<T, int> P; //(cost,v)
        priority_queue<P, vector<P>, greater<P>> pq;
        d[s] = 0;
        pq.push(P(d[s], s));

        while (!pq.empty()) {
            P p = pq.top(); pq.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (const edge &e : G[v])
            {
                // 最小値が更新されるとき push
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    pq.push({d[e.to], e.to});
                }
            }
        }
    }
};

int main() {
    int n, m; cin >> n >> m;
    Dijkstra<ll> G(n);
    REP(i, m) {
        int a, b, c, d; scanf("%d%*c%d%*c%d%*c%d", &a, &b, &c, &d);
        G.add_edge(a - 1, b - 1, c, true);
        G.add_edge(b - 1, a - 1, d, true);
    }
    int s, g, V, P; scanf("%d%*c%d%*c%d%*c%d", &s, &g, &V, &P);
    s--; g--; V -= P;
    G.build(s);
    ll ans = V - G.d[g];
    G.build(g);
    ans -= G.d[s];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
vector<bool> isp;
int N;

void sieve() {
  isp[0] = false;
  isp[1] = false;
  for (int i=2; pow(i,2)<=N; i++) {
    if (isp[i]) for(int j=2; i*j<=N; j++) isp[i*j] = false;
  }
}

void solve(long long X){
   N = X;

  isp = vector<bool>(N+100, true);

  for (int i=0; i<100; i++) {
    sieve();
    if (isp[N]) {
      cout << N << endl;
      break;
    }
    N++;
  }
}

// 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)
int main(){
    long long X;
  scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s1, s2 = input(), input()

S1, S2 = s1[0], s2[0]

for s, _ in zip(s1, s2):
    if S1[-1] != s:
        S1 += s
        S2 += _

TATE, YOKO = 0, 1

if S1[0] == S2[0]:
    prev = TATE
    cum = 3
else:
    prev = YOKO
    cum = 6

for i in range(1, len(S1)):
    if S1[i] == S2[i]:
        now = TATE
    else:
        now = YOKO
    if now == TATE:
        if prev == YOKO:
            pass
        else:
            cum *= 2
        prev = TATE
    elif now == YOKO:
        if prev == YOKO:
            cum *= 3
        else:
            cum *= 2
        prev = YOKO

    cum %= (1000000007)
print(int(cum))


Measured memory_bytes: 38256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numD = sc.nextInt();
        int[] gates = new int[9];
        int[] jacky = new int[9];

        while (numD-- > 0) {
            int gatesWins = 0;
            int jackyWins = 0;
            int buttles = 0;
            for (int i = 0; i < 9; i++) {
                gates[i] = sc.nextInt();
            }
            for (int i = 0; i < 9; i++) {
                jacky[i] = sc.nextInt();
            }

            Permutation p = new Permutation(9);

            do {
                int gatesScore = 0;
                int jackyScore = 0;
                for (int i = 0; i < 9; i++) {
                    if (gates[i] > jacky[p.perm[i]]) gatesScore += gates[i]
                            + jacky[p.perm[i]];
                    else jackyScore += gates[i] + jacky[p.perm[i]];
                }
                // System.out.println("score:" + gatesScore + ", " + jackyScore);
                if (gatesScore > jackyScore) gatesWins++;
                else if (gatesScore < jackyScore) jackyWins++;
                buttles++;
            } while (p.nextPermutaion());
//            System.out.println("b" + buttles);
            System.out.println((double)Math.round((double) gatesWins / buttles * 100000) / 100000);
            System.out.println((double)Math.round((double) jackyWins / buttles * 100000) / 100000);


        }
    }

    static class Permutation {
        final int[] perm;
        final TreeSet<Integer> temp = new TreeSet<Integer>();

        public Permutation(int size) {
            perm = new int[size];
            for (int i = 0; i < size; i++) {
                perm[i] = i;
            }
        }
        
        boolean nextPermutaion() {
            int i = perm.length - 1;
            temp.clear();
            temp.add(perm[i--]);
            while (i >= 0) {
                Integer minGreater = temp.higher(perm[i]);
                if(minGreater == null) {
                    temp.add(perm[i--]);
                }
                else {
                    temp.add(perm[i]);
                    temp.remove(minGreater);
                    perm[i++] = minGreater;
                    for (; i < perm.length; i++) {
                        perm[i] = temp.pollFirst();
                    }
                    return true;
                }
            }
            return false;
        }
    }
}

Measured memory_bytes: 0