akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


main(){
  int k, n ;
  cin >> k >> n ;
  int a[n] ;
  int max_len = 0 ;
  cin >> a[0] ;
  for(int i=1;i<n;i++){
    cin >> a[i] ;
    if(max_len < a[i] - a[i-1]){
      max_len = a[i] - a[i-1] ;
    }
  }
  if(max_len < a[0] - a[n-1] + k){
    max_len = a[0] - a[n-1] + k ;
  }
  cout << k - max_len ;
  return 0 ;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

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

    int n;
    cin >> n;
    vector<int> A(n+1);
    vector<int> sub(n + 1);
    for(int i = 2; i <= n; i++){
        cin >> A[i];       
        sub[A[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << sub[i] << endl;
    }
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
vec G[200001],r(200001,0),r2(200001,0),r3(200001,0),A(200001);
ll a,z=0,k;
void dfs(int x){
    if(r[x]){
        a=x;
        return;
    }
    r[x]=1;
    z++;
    dfs(A[x]);
}
void dfs2(int x){
    if(x==a) return;
    z++;
    dfs2(A[x]);
}
void dfs3(int x){
    if(z==k){
        a=x;
        return;
    }
    z++;
    dfs3(A[x]);
}
int main(){
    ll n;
    cin>>n>>k;
    rep(i,n) cin>>A[i+1];
    dfs(1);
    ll b=z;
    if(k<z){
        z=0;
        dfs3(1);
        cout<<a;
        return 0;
    }
    z=0;
    dfs2(1);
    k-=z;
    k%=(b-z);
    z=0;
    dfs3(a);
    cout<<a;
}

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

int main()
{
	int N, K;
	int x;
  	int sum = 0;
  
	cin >> N >> K;

	for(int i=0;i<N;i++){
      cin >> x;
      if(2*x < K){
        sum += x*2;
      }else{
        sum += 2*(K - x);
      } 
	}
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s;
  cin >> s;
  
  int n = s.size();
  int i = 0;
  int j = 0;
  
  while(i < n-1){
    j = i+1;
    while(j < n){
      if(s.at(i) != s.at(j))
        j++;
      else
        break;
    }
    if(j == n)
      i++;
    else
      break;
  }
  
  if(i == n-1)
    cout << "yes" << endl;
  else
    cout << "no" << endl;
}

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

class Program
{
	static void Main(string[] args)
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());
		int[] dN = new int[N];

		for(int i=0; i<N; i++){
				int di = int.Parse(Console.ReadLine());
				dN[i] = di;
		}

		Array.Sort(dN);

		int counter = 0;

		for(int i=0; i<N-1; i++){
				if(dN[i] == dN[i+1]){
						counter ++;
				}
		}

		//出力
		Console.WriteLine(N - counter);
	}
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define pb push_back
#define pob pop.back()
#define forn  for(int i=0;i<n;i++)
int main()
{
   string s;
   cin>>s;
   int n=s.size();
   for(int i=0;i<n;i++)
   {
       if(s[i]==',') cout<<" ";
       else cout<<s[i];
   }

    return 0;
         
    
    
    
  
}

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

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double a,b,c,d;
    cin>>a>>b>>c>>d;

    if(ceil(a/d) == ceil(c/b)){
        cout<<"Yes";
    }else if(ceil(a/d) > ceil(c/b)){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&a!=c) cout << "Yes" << endl;
    else if(a==c&&a!=b) cout << "Yes" << endl;
    else if(b==c&&a!=b) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define rep(i,n,b) for(int i=0;i<n;i=i+b)
#define ld long double 
using namespace std;
int main()
{
   ll n;
   cin >> n;
   ll a[n];
   for(ll i=0;i<n;i++)
   {
    cin >> a[i];
   }
   ll max=LONG_LONG_MIN;
   ll sum=0;
   for(ll i=0;i<n;i++)
   {
    if(i==n-1)
    {
      break;
    }
    if(a[i]>max)
    {
      max=a[i];
    }
    if(max>a[i+1])
    { 
      sum=sum+(max-a[i+1]);
    }
   }
   cout << sum;
}

Measured memory_bytes: 5084
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	n, _ := strconv.Atoi(a + b)

	for i := 0; i < 320; i++ {
		if i*i == n {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

struct RollingHash {
    typedef long long ll;
    typedef pair<ll,ll> pll;

    ll base1, base2, mod1, mod2;
    vector<ll> hash1, hash2, pow1, pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }
    //[l, r)
    pll get(int l,int r) {
        ll t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

    RollingHash::pll concat(pll h1, pll h2, int h2_len) {
        return make_pair((h1.first*pow1[h2_len]+h2.first)%mod1, (h1.second*pow2[h2_len]+h2.second)%mod2);
    }

};

string s[310], t[310];
RollingHash rs[310], rt[310];
P rsh[310][310], rth[310][310];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, 0, n){
        cin >> s[i];
        rep(j, 0, n) t[j] += s[i][j];
    }
    rep(i, 0, n){
        s[i] += s[i];
        t[i] += t[i];
        rs[i].init(s[i]);
        rt[i].init(t[i]);
        rep(j, 0, n){
            rsh[i][j] = rs[i].get(j, j + n);
            rth[i][j] = rt[i].get(j, j + n);
        }
    }
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            bool f = true;
            rep(k, 0, n){
                if(rsh[(i + k) % n][j] != rth[(j + k) % n][i]) f = false;
            }
            if(f) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17152
#include<iostream>
#include<string>

using namespace std;

int main(){
	string word[100];
	string most, many;
	int cut[100] = {0}, num = 0, i = 0, j, k = 0, max = 0, max1 = 0;

	while(cin >> word[i]){
		bool flag = 0;

		cut[i] ++;
		if(i == 0) num = word[i].size();
		else{
			if(word[i].size() > num){
				num = word[i].size();
				most = word[i];
			}
		}
		i++;
	}

	for(i = 0; i < num; i ++){
		k = 0;
		for(j = 0; j < num; j ++){
			if(word[i] == word[j]) k ++;
		}
		if(k > max){
			max1 = i;
			max = k;
		}
	}

	cout << word[max1] << " " << most << endl;

	return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<ll> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

  unordered_map<char, long long> mp;
  rep(i, 0, n){
    mp[s[i]]++;
  }
  long long all = mp['R'] * mp['G'] * mp['B'];
  rep (i, 0, n){
    rep (j, i+1, n){
      if(s[i] == s[j]) continue;
      if(2 * j - i >= n) continue;
      if(s[i] == s[2 * j - i] || s[j] == s[2 * j - i]) continue;
      all--;
    }
  }
  cout << all << endl;
  return 0;
  }


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef vector<ll> vec;
typedef vector<vec> mat;
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}




int main(void){
	int n;
	string S;
	cin>>n>>S;
	string u="",t="";
	for(int i=0;i<2*n;i++){
		if(i<n)u.push_back(S[i]);
		else t.push_back(S[i]);
	}
	reverse(t.begin(),t.end());
	using R = pair<string,string>;
	map<R,ll>mp1,mp2;
	for(int i=0;i<(1<<n);i++){
		string x="",y="";
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				x.push_back(u[j]);
			}
			else y.push_back(u[j]);
		}
		reverse(y.begin(),y.end());
		mp1[R(x,y)]++;
	}
	for(int i=0;i<(1<<n);i++){
		string x="",y="";
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				x.push_back(t[j]);
			}
			else y.push_back(t[j]);
		}
		reverse(y.begin(),y.end());
		mp2[R(x,y)]++;
	}
	ll ans = 0;
	for(auto [x,y]:mp1){
		ans += mp2[x]*y;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 89688
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, x, l, sum = 0, ans = 1;

    cin >> n >> x;

    while (n--) {

        cin >> l;
        sum += l;

        if (sum <= x) ans++;
        else break;
    }

    cout << ans;

    return 0;
}


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

using namespace std;
typedef long long ll;
const int C=100001;

vector <vector <int> > gr(C);
int ij[C], a, b, n, m, ss[C], dp[C], mx;
int F[C], iF=0, jF;

int main(){
	int j, i;
	scanf ("%d %d", &n, &m);
	for (int z=0;z<m;z++)		scanf ("%d %d", &a, &b), gr[a].push_back(b), ij[a]++, ss[b]++;
	
	for (i=1;i<=n;i++)	if (ss[i]==0)	F[jF]=i, jF++;
	for (;iF<jF;iF++){
		a=F[iF];
		for (j=0;j<ij[a];j++){
			b=gr[a][j];
			dp[b]=max(dp[b], dp[a]+1);
			if (dp[b]>mx)	mx=dp[b];
			ss[b]--;
			if (ss[b]==0)	F[jF]=b, jF++;
		}
	}
	printf ("%d", mx);
	
return 0;}

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

int main(){
  int n,a,b,c;
  cin >> n;
  vector<vector<int>> arr(n);
  for(int i=0;i<n;i++){
      cin >> a >> b >> c;
      arr[i].push_back(a);arr[i].push_back(b);arr[i].push_back(c);
  }
  vector<int> temp = arr[0];
  
  for(int i=1;i<n;i++){
     arr[i][0] = arr[i][0] + max(temp[1],temp[2]);
     arr[i][1] = arr[i][1] + max(temp[2],temp[0]);
     arr[i][2] = arr[i][2] + max(temp[0],temp[1]);
     temp = arr[i];
  }
  int mm = INT_MIN;
  for(int i=0;i<temp.size();i++){
    mm = max(mm,temp[i]);
  }
  cout << mm << endl;
  return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

int main()
{
    int n; cin>>n;
    string s; cin>>s;
    
    int totalr = count(all(s),'R');
    
    int needr=0;
    for0(i,totalr) if(s[i]=='R') needr++;
    
    cout<<totalr - needr;
}


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

int main(){

  int n,m; cin >> n >> m;
    
  int cnt,i,a[101],b[101];
  
  for( i = 1; i <= m; i++ ) cin >> a[i] >> b[i];
    
  int bmax = -1;
  int flag = 0;

  for( i = 1; i <= m; i++ ){
    if( a[i] == 1 ){
      if( b[i] > bmax ){
	bmax = b[i];
	cnt = 0;
	flag = 1;
      }
    }
  }
  cnt++;
  int bmax2 = -1;
  if( flag == 1){
    while(1){
      if( bmax == n ) break;
      if( cnt > m ){
	flag = 0;
	break;
      }
      
      for( i = 1; i <= m; i++ ){
	if( a[i] <= bmax+1 && b[i] >= bmax+1 && bmax2 < b[i] ){
	  bmax2 = b[i];
	}
      }
      bmax = bmax2;
      cnt++;
    }
  }
  if( flag == 0 ) cout << "Impossible" << endl;
  else cout << cnt << endl;  
  
  return 0;
}
  

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int fluit_num;
  int kind_num;
  vector<int> prices;

  cin >> fluit_num >> kind_num;
  prices.resize(fluit_num);
  for(int i = 0; i < fluit_num; i++) {
    cin >> prices[i];
  }

  sort(prices.begin(), prices.end());

  int sum = 0;
  for(int i = 0; i < kind_num; i++) {
    sum += prices[i];
  }

  cout << sum << endl;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


signed main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int a = A * N;
	cout << MIN(a, B) << endl;
}











Measured memory_bytes: 256
import sys
from collections import deque

def doubly_lined_list():
	n = int(input())
	Q = deque()

	for i in range(n):
		line = sys.stdin.readline()
		command = line.split()[0]

		if command == 'insert':
			Q.appendleft(line.split()[1])
		elif command == 'delete':
			try:
				Q.remove(line.split()[1])
			except:
				pass
		elif command == 'deleteFirst':
			Q.popleft()
		elif command == 'deleteLast':
			Q.pop()

	print(' '.join(Q))

if __name__ == '__main__':
	doubly_lined_list()

Measured memory_bytes: 71900
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    vector<bool> rest(B,false);

    for (int i=1;i<200;i++) {
        rest[(A*i)%B] = true;
    }

    if (rest[C]){
        cout<<"YES"<<endl;
    }
    else {
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        string str; cin >> str;
        bool isA= 0, isB= 0;
        lp(i, 3) {
                if (str[i]== 'A')isA= 1;
                if (str[i]== 'B')isB= 1;
        }
        if (isA&& isB) cout <<"Yes\n";
        else cout << "No\n";
        return;
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long MOD = (long) 1e9 + 7;
        Map<Long, Long> map = primeFactorization(m);
        Combination combi = new Combination(n + 10000, MOD);
        long count = 1;
        for (long v : map.values()) {
            count = count * combi.nck(n + (int) v - 1, (int) v) % MOD;
        }

        System.out.println(count % MOD);

    }

    Map<Long, Long> primeFactorization(long n) {
        Map<Long, Long> map = new HashMap<>();
        for (long i = 2; i * i <= n; i++) {
            if (n % i != 0) continue;
            long count = 0;
            while (n % i == 0) {
                count++;
                n = n / i;
            }
            map.put(i, count);
        }
        if (n != 1) map.put(n, 1L);
        return map;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

    public class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            if (n < k) return 0;
            return facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }

}


Measured memory_bytes: 23892
n = int(input())

for i in range(1, n+1):
    x = i
    if x % 3 == 0:
        print(' ', i, sep='', end='')
        continue
    while x > 0 :
        if x % 10 == 3:
            print(' ', i, sep='', end ='')
            break
        x //= 10
print()


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  int r ;
  
  cin >> r ;
  
  cout << 2*3.1416*r ;
  
  return 0 ;
}


Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {

			int N = sc.nextInt();

			int check = 1;
			for (int i = 0; i < N; i++) {
				int next = sc.nextInt();
				if (next == check) {
					check++;
				}
			}

			if (check == 1) {
				System.out.println(-1);
			} else {
				System.out.println(N - check + 1);
			}

		}
	}

	static long lcm(long a, long b) {

		long gcd = gcd(a, b);
		return gcd * (a / gcd) * (b / gcd);
	}

	static long gcd(long a, long b) {

		long max = Math.max(a, b);
		long min = Math.min(a, b);

		if (max - min == 1) {
			return 1;
		}

		if (max % min == 0) {
			return min;
		} else {
			return gcd(min, max % min);
		}
	}

}


Measured memory_bytes: 64816
//    .------------------------------------------------------------.
//    |     ___   ___   _____     _     ___   ___    ___   ___     |
//    |    | _ \ | __| |_   _|   /_\   | _ \ |   \  | __| |   \    |
//    |    |   / | _|    | |    / _ \  |   / | |) | | _|  | |) |   |
//    |    |_|_\ |___|   |_|   /_/ \_\ |_|_\ |___/  |___| |___/    |
//    |                                                            |
//    |              ___    ___    ___    ___   ___                |
//    |             / __|  / _ \  |   \  | __| | _ \               |
//    |            | (__  | (_) | | |) | | _|  |   /               |
//    |             \___|  \___/  |___/  |___| |_|_\               |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2019-11-07 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>

#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("tune=native")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

template<class T>
using vec=vector<T>;
template<class T>
using v2d=vector<vector<T>>;
template<class T>
using prq=priority_queue<T>;
template<class T>
using rpq=priority_queue<T,vector<T>,greater<T>>;

const ll inf=1e18;

ll f(ll b,ll n)
{
    if(n<b)
        return n;
    return n%b+f(b,n/b);
}

int main()
{
    ll n,s;
    scanf("%lld%lld",&n,&s);
    if(s==n)
    {
        printf("%lld\n",n+1);
        return 0;
    }
    if(s>((n+1)>>1))
    {
        printf("-1\n");
        return 0;
    }
    for(ll i=2;i*i<=n;++i)
        if(f(i,n)==s)
        {
            printf("%lld\n",i);
            return 0;
        }
    for(ll i=sqrt(n);i>0;--i)
        if((n-s)%i==0)
        {
            ll b=(n-s)/i+1;
            if(f(b,n)==s)
            {
                printf("%lld\n",b);
                return 0;
            }
        }
    printf("-1\n");
}



Measured memory_bytes: 256
import sys
import numpy as np

if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    @cc.export('is_ok', '(i8[:],u8[:],u8,u8)')
    
    def is_ok(A, F, x, k):
        y = A - x // F
        tmp = y[y > 0].sum()
        return tmp <= k
      
    cc.compile()
    exit()
from my_module import is_ok

n, k = map(int, input().split())
A = np.array(input().split(), dtype="i8")
F = np.array(input().split(), dtype="u8")

A = np.sort(A)
F = np.sort(F)[::-1]

ok = 10 ** 12
ng = -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(A, F, mid, k):
        ok = mid
    else:
        ng = mid

print(ok)



Measured memory_bytes: 51740
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
using namespace std;
vector <ll> v;
int main()
{
    ///MUST READ THE POINTS BELOW BEFORE SUBMIT

    ll n, arr[105], i;
    cin >> n;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    v.pb(300);
    for(i = 0; i < n-1; i++)
        if(arr[i] != arr[i+1]) v.pb(arr[i]);
    v.pb(arr[n-1]), v.pb(0);
    ll ans = 1000, stock = 0;;
    for(i = 1; i < v.size()-1; i++){
        if(v[i-1] > v[i] and v[i] < v[i+1]){
            stock += ans/v[i];
            ans -= (ans/v[i])*v[i];
            //cout << "f: " << v[i] << endl;
        }
        if(v[i-1] < v[i] and v[i] > v[i+1]){
            ans += stock*v[i];
            stock = 0;
            //cout << "s: " << v[i] << endl;
        }
    }
    cout << ans << endl;


    ///MUST READ THE POINTS BELOW BEFORE SUBMIT
}
/**
    1. LOOK SPECIAL CASE N = 1.
    2. LOOK FOR OVERFLOW.
    3. LOOK FOR OUT OF BOUNDS.
**/


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String day = scanner.next();
        System.out.println(Days(day));
    }
public static int Days(String day){
        String[] days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        int counter = 0;
        boolean flag = false;
        for (String s : days) {
            if (day.equals(s)) {
                flag = true;
            }
            if (flag)
                counter++;
        }
        return counter;
    }
}

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

int n, m, a, b, c, _end;
int x[10][10];

int bfs(int p, int a) {
	int s[10], minx = 114514, sum;
	sum = 0;
	memset(s, 127, sizeof(s));
	s[a] = 0;
	for (int l = 0; l < p; l++) {
		for (int o = 0; o < p; o++) {
			if (s[o] < 114514) {
				for (int q = 0; q < p; q++) {
					if (x[o][q] < 114514) {
						s[q] = min(s[q], s[o] + x[o][q]);
					}
				}
			}
		}
	}
	for (int l = 0; l < p; l++) {
		sum += s[l];
	}
	minx = min(minx, sum);
	return minx;
}

int search(int p) {
	int t[10], maxn = 114514, maxid;
	for (int k = 0; k < p; k++) {
		t[k] = bfs(p, k);
	}
	for (int k = 0; k < p; k++) {
		if (maxn > t[k]) {
			maxn = t[k];
			maxid = k;
		}
	}
	return maxn * 100 + maxid;
}

void _cin() {
	memset(x, 51, sizeof(x));
	n = 0;
	_end = 0;
	cin >> m;
	if (m == 0) { _end = 1; return; }
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		n = max(n, max(a, b));
		x[a][b] = c;
		x[b][a] = c;
	}
	n += 1;
}

int main() {
	while (true) {
		_cin();
		if (_end == 1) { break; }
		cout << search(n) % 100 << ' ' << search(n) / 100 << endl;
	}
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int dig[110000] = {};

int main(){
    dig[0] = 1;
    for(int i = 1; i < 110000; i++){
        dig[i] = dig[i - 1] * 3 % MOD;
    }
    string S;
    cin >> S;
    int sz = S.size();
    long long int ans = 0;
    long long int P = 1;
    for(int i = 0; i < sz; i++){
        if(S[i] == '1'){
            ans += P * dig[sz - i - 1];
            ans %= MOD;
            P *= 2;
            P %= MOD;
        }
    }
    ans += P;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long K = GetLong();
		long S = GetLong();
		
		if(K == N)
		{
			WriteLine(string.Join(" ", Enumerable.Repeat(S, (int)N)));
			return;
		}

		long[] ans = new long[N];

		if(S == 1)
		{
			for(long i = 0; i < K; i++)
				ans[i] = 1;

			for(long i = K; i < N; i++)
				ans[i] = 2;
		}
		else
		{
			long even = S / 2;
			long odd = S - even;
			for(long i = 0; i < K + 1; i++)
				ans[i] = (i % 2 == 0) ? even : odd;

			long fill = (S < (long)1e9) ? S + 1 : (long)1e9 - 1;
			for(long i = K + 1; i < N; i++)
				ans[i] = fill;	
		}

		WriteLine(string.Join(" ", ans));
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

using namespace std;

int main()
{
     int K,R,inR;
     cin>>K>>R;
    if(K>=1&&K<=100&&R>=0&&R<=4111){
     if(K>=10){
        inR=R; 
     }
     else{
         inR=R+(100*(10-K));
     }
     cout<<inR;
    }
   return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int N;
    cin >> N;
    string s;
    cin >> s;
    int K = s.size();

    // dp[i][j] = キーをi回打って長さがjとなるような打ち方の数
    vvi dp(N + 1, vi(N + 1));
    dp[0][0] = 1;
    rep2(i, 1, N + 1) {
        rep(j, N + 1) {
            if (j == 0) {
                // 空文字の状態で'B'を押したとき
                (dp[i][j] += dp[i - 1][j]) %= mod;
            }
            if (j - 1 >= 0) {
                (dp[i][j] += 2 * dp[i - 1][j - 1]) %= mod;
            }
            if (j + 1 <= N) {
                (dp[i][j] += dp[i - 1][j + 1]) %= mod;
            }
        }
    }

    int ans = dp[N][K];
    // 2^K で割る
    rep(i, K) {
        // 2で割ることに対応
        (ans *= (mod + 1) / 2) %= mod;
    }
    cout << ans << endl;

}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            mp[i]++;
            n/=i;
            i--;
        }
    }
    if(n!=1) mp[n]++;
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        for(int i=1;itr->second>=i;i++){
            ans++;
            itr->second-=i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   /** #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif**/

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

      ll dp[n+1][n+1];
      for(int l=n-1;l>=0;l--)
      {
        for(int r=l;r<n;r++)
        {
          dp[l][r]= 1e18l+5;
          ll sum=0;
          for(int j=l;j<=r;j++)
            sum=sum+arr[j];

          if(l==r)
            dp[l][r]=0;
          else
          {
            for(int i=l;i<=r-1;i++)
            {
              dp[l][r]=min(dp[l][r], dp[l][i]+dp[i+1][r]+sum);
            }
          }



        }
      }
      cout<<dp[0][n-1];


  














return 0;
}

Measured memory_bytes: 1536
#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() {
  //string S;
  int X, Y, Z;
  cin >> X >> Y >> Z;
  
  /*if (S.substr(2,1) == S.substr(3,1) && S.substr(4,1) == S.substr(5,1)) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
  return 0;

/*answer
  bool ans = true;
  if (S[2] != S[3]) ans = false;
  if (S[4] != S[5]) ans = false;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
  */

 cout << Z << " " << X << " " << Y << endl; 


}

Measured memory_bytes: 256
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main() {
    int n, x;
    ll Q,H,S,D;
    cin>>Q>>H>>S>>D;
    ll N;cin>>N;
    if(N%2==0){
        N=N/2;
        cout<<min(Q*N*8,min(H*N*4,min(S*N*2,N*D)))<<endl;
    }else{
        ll ans=0;
        N=N/2;
        ans+=min(Q*N*8,min(H*N*4,min(S*N*2,N*D)));
        ans+=min(Q*4,min(H*2,S*1));
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import defaultdict
P = 7 ** 21 + 52
mod = 10 ** 9 + 7
N = int(input())
D = defaultdict(int)
C00 = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b == 0:
        C00 += 1
    elif a == 0:
        D[-1] += 1
    elif b == 0:
        D[-2] += 1
    else:
        x = a * pow(b, P - 2, P) % P
        D[x] += 1
ans = 1
for x in D:
    y = pow(-x, P - 2, P) if x > 0 else -3 - x
    if y in D and x > y: continue
    ans *= 1 + pow(2, D[x], mod) - 1 + pow(2, (D[y] if y in D else 0), mod) - 1
    ans %= mod
print((ans + C00 - 1) % mod)

Measured memory_bytes: 124660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3=x2+y1-y2,y3=y2+x2-x1;
    int x4=x1+y1-y2,y4=y1+x2-x1;
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[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 long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll A,B,X;
    cin >> A>>B>>X;
    if(X >= A && X <= A + B)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3564
n = int(input())
mx = int(10e6+1)
y=0
mn = int(10e13)
for v in range(1,mx):
    if v<=n and n%v==0:
        y=1
        left = n//v
        mn=min(v-1+left-1,mn)
    if v>n:
        break
if y:
    print(mn)
else:
    print(n-1)


Measured memory_bytes: 41680
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


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

string s;
cin >> s;
if(s=="SUN")fin(7);
if(s=="MON")fin(6);
if(s=="TUE")fin(5);
if(s=="WED")fin(4);
if(s=="THU")fin(3);
if(s=="FRI")fin(2);
if(s=="SAT")fin(1);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W, W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}
///////////////////////////End Sub//////////////////////////////////


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if(A + B == C + D) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b = readInts()
    if a <= 0 and 0 <= b:
        print("Zero")
        exit()
    if 1 <= a <= b:
        print("Positive")
    else:
        if (abs(b-a)+1)%2 == 0:
            print("Positive")
        else:
            print("Negative")

if __name__ == '__main__':
  main()


Measured memory_bytes: 5084
s = input()

a = int(s[0]+s[1])
b = int(s[2]+s[3])

if (a >= 1 and a <= 12):
   if (b >= 1 and b <= 12):
      print('AMBIGUOUS')
   else:
      print('MMYY')
else:
   if (b >= 1 and b <= 12):
      print('YYMM')
   else:
      print('NA')


Measured memory_bytes: 2940
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

typedef std::bitset<32> bitset;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  std::vector<bitset> a(n);
  for(int i=0;i<n;i++){
    uint32_t a_;
    cin>>a_;
    a[i]=bitset(a_);
  }

  int right=1;
  int32_t count[32]={};
  for(int i=0;i<32;i++){
    if(a[0][i]){
      count[i]=1;
    }
  }
  int64_t result=0;

  for(int left=0;left<n;left++){
    while(right<n){

      bool can_move_right=true;
      for(int i=0;i<32;i++){
        if(a[right][i]){
          if(count[i]+1>1){
            can_move_right=false;
            break;
          }
        }
      }

      if(can_move_right){
        for(int i=0;i<32;i++){
          if(a[right][i]){
            count[i]++;
          }
        }
        right++;
      }else{
        break;
      }

    }

    result+=right-left;

    if(right==left){
      right++;
    }else{
      for(int i=0;i<32;i++){
        if(a[left][i]){
          count[i]--;
        }
      }
    }


  }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

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

int main(void){
   string S;
   cin>>S;
   map<char,bool> judge;
   for(int i=0;i<S.size();i++){
      judge[S[i]]=true;
   }
   bool flag=true;
   if(judge['N']==true&&judge['S']==false){
      flag=false;
   }
   if(judge['S']==true&&judge['N']==false){
      flag=false;
   }
   if(judge['W']==true&&judge['E']==false){
      flag=false;
   }
   if(judge['E']==true&&judge['W']==false){
      flag=false;
   }
   if(flag) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  
  int a,b,x;
  
  cin >> a >> b >> x;
  
  if(a == 0 && b == 0){
    cout << 1 << endl;
    return 0;
  }
  
  if(a == 0){
    cout << b/x + 1 << endl;
    return 0;
  }

  else {
    cout << b/x - (a-1)/x << endl;
    return 0;
  }
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
char s[310][310], b[310][310];
bool check() {
	rep(i, n) {
		rep(j, n) {
			if (b[i][j] != b[j][i])return false;
		}
	}
	return true;
}
signed main() {
	cin >> n;
	rep(i, n) {
		rep(j, n)cin >> s[i][j];
	}
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			rep(k, n)b[j][k] = s[j][(k + i) % n];
		}
		if (check())ans++;
	}
	cout << ans * n << endl;
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) {
        cout << -1 << endl;
        exit(0);
    }
    int x = (n - 1) * (n - 2) / 2 - k;
    cout << (n - 1) + x << endl;
    for (int i = 2; i <= n; i++){
        cout << 1 << " " << i << endl;
    }
    if (x == 0) exit(0);
    bool flag = false;
    for (int i = 2; i <= n; i++){
        for (int j = i + 1; j <= n; j++){
            cout << i << " " << j << endl;
            x--;
            if (x == 0){
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
}

Measured memory_bytes: 256