akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void)
{
    int row, col;
    int sum_row[100] = {};
    int sheet[100][100];
    
    cin >> row >> col;
    
    for(int i=0; i<row; i++){
        for(int j=0; j<col; j++){
            cin >> sheet[i][j];
            cout << sheet[i][j] << " ";
            sum_row[i] += sheet[i][j];
        }
        cout << sum_row[i] << endl;
    }

    int sum_of_sum = 0;
    for(int i=0; i<col; i++){
        int sum = 0;
        for(int j=0; j<row; j++){
            sum += sheet[j][i];
        }
        sum_of_sum += sum;
        cout << sum << " ";
    }
    cout << sum_of_sum << endl;
    
    return 0;
}



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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

const int N = 4444;

int f[N][N];

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  int max_p = (n + m - 1) / (k - 1);
  f[0][0] = 1;
  for (int i = 0; i < max_p; i++) {
    for (int j = 0; j <= n; j++) {
      for (int t = 0; j + t <= n && t < k; t++) {
        add(f[i + 1][j + t], f[i][j]);
      }
    }
  }
  int ans = 0;
  for (int cnt = 0; cnt < max_p; cnt++) {
    for (int j = 0; j <= n; j++) {
      int ways = f[cnt][j];
      int total = cnt * (k - 1);
      int t = total - j;
      if (j < n && t < m) {
        add(ans, ways);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 47488
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String tapOrder = sc.next();
        int len = tapOrder.length();
        boolean danceable = true;

        for(int i = 1; i <= len; i++) {
            char t = i % 2 == 0 ? 'R' : 'L';

            if(tapOrder.charAt(i-1) == t){
                danceable = false;
                break;
            }
        }

        System.out.println(danceable ? "Yes" : "No");

    }
}

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

int main() {
	int n;
	int sum=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
	if(sum%10!=0){cout<<sum<<endl;return 0;}
	sort(a,a+n);
	for(int i=0;i<n;i++){
	    sum-=a[i];
	    if(sum%10!=0){
	        cout<<sum<<endl;
	        return 0;
	    }
	    sum+=a[i];
	}
	cout<<"0"<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int k = s.nextInt(),x=s.nextInt();
        long total = 0;
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                long sum = i+j;
                if(x-sum<=k && x-sum>=0)total++;
            }
        }
        System.out.println(total);
    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25696
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i=0; i<n; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            int aa = a*a; int bb = b*b; int cc = c*c;
            if ( aa+bb == cc || aa+cc == bb || bb+cc == aa )
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13888
n=int(input())
L=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int, input().split())
    u-=1
    v-=1
    L[u].append([v,w])
    L[v].append([u,w])
ans=[-1]*n
ans[0]=0
que=[0]
import queue
que=queue.Queue()
que.put(0)
while not que.empty():
    v=que.get()
    for u, w in L[v]:
        if ans[u]!=-1:
            continue
        ans[u]=(ans[v]+w)%2
        que.put(u)
for a in ans:
    print(a)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

template<ll mod>
struct RollingHash{
  vector<ll> hash,p;
  ll base;
  RollingHash(string s, ll b){
    ll n = (ll)s.size();
    base = b;
    hash.assign(n+1,0);
    p.assign(n+1,1);
    for(ll i=0;i<n;i++){
      hash[i+1]=(hash[i]*base+s[i])%mod;
      p[i+1]=(p[i]*base)%mod;
    }
  }
  ll get(ll l, ll r){
    ll ret=hash[r+1]-(hash[l]*p[r-l+1])%mod;
    if(ret<0)ret+=mod;
    return ret;
  }
};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  //const ll tmp_mod=608396398;
  const ll tmp_mod=979418779;
  //const ll tmp_mod=775791517;
  using RH = RollingHash<tmp_mod>;
  ll base=0;while(base<100000)base=(rand()*rand()*998244353)%tmp_mod;
  ll n;cin>>n;
  string s;cin>>s;
  RH rh(s,base);
  /*auto v=vec(n,n,0LL);
  rep(i,0,n)rep(j,0,n){
    if(i+j<n)v[i][j]=rh.get(i,i+j);
  }*/
  rep(i,0,n-1)rep(j,i+1,n){
    if(s[i]!=s[j])continue;
    ll l=i,r=j;
    while(r-l>=2){
      ll mid=(l+r)/2;
      if(j+mid-i>=n||rh.get(i,mid)!=rh.get(j,j+mid-i)){
        r=mid;
      }
      else l=mid;
    }
    chmax(res,l-i+1);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
s_list = list(input())
str_list = ['A','C','G','T']
now_max = 0
for i,s in enumerate(s_list):
    if s in str_list:
        l = 1
        for next in s_list[i+1:]:
            if next in str_list:
                l += 1
            else:
                break
        now_max = max(l,now_max)
print(now_max)

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

int main() {
  int l;
  cin>>l;
  double side= ((double)l)/3.0;
  double next = ((double)l - side)/2;
  double third  = (double)l - side - next;
  printf("%f",side*next*third);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>

double power( double a, int n )
{
  double r;
  int abs_n;

  r = 1; abs_n = n < 0 ? -n : n;
  while ( abs_n > 0 ) {
    if ( abs_n % 2 == 1 ) { r *= a; }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1/r;
}

double nthroot( double a, int n )
{
  double x, y;

  if ( a <= 0 || n < 0 ) { return 0; }
  if ( n == 0 ) { return 1; }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do {
    x = y;
    y = ((n-1)*x + a/power(x, n-1)) / n;
  } while ( y < x );

  return y;
}

int is_power( int a )
{
  int i; 

  if ( a == 1 ) { return 1; }

  for ( i = 2; i <= floor(log2(a)); i++ ) {
    if ( power(floor(nthroot(a, i)), i) == a ) { 
      return 1;
    }
  }

  return 0;
}

int main()
{
  int K, i;
  std::cin >> K;

  for ( i = K; i >= 0; i-- ) {
    if ( is_power(i) ) {
      std::cout << i << std::endl;
      return 0;
    }
    else {
      continue;
    }
  }

  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair< int, int > Pi;
typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

const long long MOD = 1e9 + 7;
const long long INF = 5e18;
const int di[4] = { 1,0,-1,0 };
const int dj[4] = { 0,1,0,-1 };

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()

ll n,rui[1000010],mc[1000010],mm[1000010];
string s;
ll q,k;

void input(){
	cin>>n>>s>>q;
  for(int i=0;i<s.size();i++){
			if(s[i]=='C')rui[i+1]=rui[i]+1;
			else rui[i+1]=rui[i];
			if(s[i]=='M')mm[i+1]=mm[i]+1;
			else mm[i+1]=mm[i];
		}
		for(int i=0;i<s.size();i++){
			if(s[i]=='M')mc[i+1]=mc[i]+rui[i+1];
			else mc[i+1]=mc[i];
		}
	return;
}


void solve(){
	while(q--){
		cin>>k;
		ll ans=0;	
		for(ll i=0;i<s.size();i++){
			if(s[i]!='D')continue;
			int nex=min(n-1,i+k-1);
			ll t=(mm[nex+1]-mm[i+1])*rui[nex+1];
			t-=mc[nex+1]-mc[i+1];
			ans+=t;
		}
		cout<<ans<<endl;
	}
	return;
}

int main(){
	input();
	solve();
	return 0;
}


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

int main()
{
  int N;
  cin >> N;
  long long L[N+2];
  L[0] = 2LL;
  L[1] = 1LL;
  for(int i=2; i<=N; i++) L[i] = L[i-2] + L[i-1];

  cout << L[N] << endl;
}

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

#define EPS 1e-10

class point {
public:
	double x, y;
	point() {}
	point( double x_, double y_ ) : x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); }
	point operator +( point p ) { return point( x + p.x, y + p.y ); }
	point operator *( int a ) { return point( x * a, y * a ); }
};

class segment {
public:
	point p1, p2;
	segment() {}
};

double dot( point a, point b ) { return a.x * b.x + a.y * b.y; }
double cross( point a, point b ) { return a.x * b.y - a.y * b.x; }
double norm( point a ) { return a.x * a.x + a.y * a.y; }

double distance( segment s, point p )
{
	if( dot( s.p2 - s.p1, p - s.p1 ) < 0 ) return sqrt( norm( p - s.p1 ) );
	if( dot( s.p1 - s.p2, p - s.p2 ) < 0 ) return sqrt( norm( p - s.p2 ) );;
	return fabs( cross( s.p2 - s.p1, p - s.p1 ) / sqrt( norm( s.p2 - s.p1 ) ) );
}

int ccw( point p0, point p1, point p2 )
{
	point v1 = p1 - p0;
	point v2 = p2 - p1;
	if( cross( v1, v2 ) > EPS ) return 1;
	if( cross( v1, v2 ) < EPS ) return -1;
	if( dot( v1, v2 ) < -EPS ) return 2;
	if( norm( v1 ) < norm( v2 ) ) return -2;
	return 0;
}

bool intersect( segment s1, segment s2 )
{
	return ccw( s1.p1, s1.p2, s2.p1 ) * ccw( s1.p1, s1.p2, s2.p2 ) <= 0 &&
			ccw( s2.p1, s2.p2, s1.p1 ) * ccw( s2.p1, s2.p2, s1.p2 ) <= 0;
}

double distance( segment s1, segment s2 )
{
	if( intersect( s1, s2 ) ) return 0;
	return min( { distance( s1, s2.p1 ), distance( s1, s2.p2 ),
					distance( s2, s1.p1 ), distance( s2, s1.p2 ) } );
}

int main()
{
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		segment s1, s2;
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		cout << fixed << setprecision(10) << distance( s1, s2 ) << endl;
	}
}



Measured memory_bytes: 3292
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int price = stdIn.nextInt();
			if(price == 0)
			{
				break;
			}
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < 12; ++i)
			{
				int in = stdIn.nextInt();
				int out = stdIn.nextInt();
				list.add(in - out);
			}
			boolean endFlag = false;
			int sum = 0;
			for(int i = 0; i < 12; ++i)
			{
				sum += list.get(i);
				if(sum >= price)
				{
					System.out.println(i + 1);
					endFlag = true;
					break;
				}
			}
			if(!endFlag)
			{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 12000
s = gets.chomp

chars = s.chars

ans = 0
(0..("1" * (s.length - 1)).to_i(2)).each do |i|
  bit = i.to_s(2).rjust(s.length-1, "0").chars
  tmp = chars[0].dup

  chars.size.times.with_index(1) do |t, j|
    next if chars[j].nil?
    tmp << ((bit[j-1] == "1") ? "+" : "")
    tmp << chars[j]
  end
  ans += eval(tmp)
end

puts ans


Measured memory_bytes: 2044
N, K = map(int,input().split())
numbers = [list(map(int,input().split())) for _ in range(N)]
#print(numbers)
numbers.sort(key = lambda x:x[0])
#print(numbers)
cnt = 0
for idx,num in enumerate(numbers):
    cnt += num[1]
    if cnt >= K:
        print(numbers[idx][0])
        exit()



Measured memory_bytes: 29144
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int w=s.nextInt(),h=s.nextInt(),n=s.nextInt();
		int[] in = {0,w,0,h};
		for(int i=0;i<n;i++) {
			int x=s.nextInt(),y=s.nextInt(),a=s.nextInt();
			switch(a){
			case 1:
				in[0]=Math.max(in[0],x);
				break;
			case 2:
				in[1]=Math.min(in[1],x);
				break;
			case 3:
				in[2]=Math.max(in[2],y);
				break;
			case 4:
				in[3]=Math.min(in[3],y);
				break;
			}
		}
		System.out.println(Math.max(in[1]-in[0],0)*Math.max(in[3]-in[2],0));
	}
}

Measured memory_bytes: 23892
# 計数ソート
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_A
# 計算量 O(n+k)

import sys
input = sys.stdin.buffer.readline

n = int(input())
A = [int(i) for i in input().split()]
B = [None] * n
C = [0] * 10001

for a in A:
    C[a] += 1

for i in range(10001):
    C[i] = C[i - 1] + C[i]

for j in range(n)[::-1]:
    ptr = C[A[j]] - 1
    B[ptr] = A[j]
    C[A[j]] -= 1

print(" ".join([str(b) for b in B]))



Measured memory_bytes: 241184
#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> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N;
    cin >> N;
    vector<pair<int, int> >red, blue;
    rep(i, 0, N) {
        int a, b;
        cin >> a >> b;
        red.push_back(make_pair(b, a));
    }
    rep(i, 0, N) {
        int a, b;
        cin >> a >> b;
        blue.push_back(make_pair(a, b));
    }
    vsort(red);
    reverse(red.begin(), red.end());
    vsort(blue);
    //reverse(blue.begin(), blue.end());

    bool used_red[N];
    memset(used_red, false, sizeof(used_red));
    int cnt = 0;
    rep(i, 0, blue.size()) {
        bool haveChanged = false;
        rep(j, 0, red.size()) {
            if(not used_red[j]) {
                if(blue[i].second > red[j].first and blue[i].first > red[j].second) {
                    cnt++;
                    used_red[j] = true;
                    haveChanged = true;
                }
            }
            if(haveChanged) break;
        }
    }

    cout << cnt << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
int n,k;
vector<pair<long long,int> > v[100100];
vector<long long> x,y;
pair<long long,int> a[100100]; 
bool vis[100100];
int dh[100100];
long long res;
#define sqr(x) ((x)*(x))
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i].second>>a[i].first;
	}
	sort(a+1,a+n+1);
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(!vis[a[i].second]){
			vis[a[i].second]=true;
			dh[a[i].second]=cnt;
			cnt++;
		}
		v[dh[a[i].second]].push_back(make_pair(a[i].first,i));
	}
	long long num=0;
	long long sum=0;
	for(int i=0;i<cnt;i++){
		sort(v[i].begin(),v[i].end());
		for(int j=0;j<v[i].size();j++){
			int id=v[i][j].second;
			long long deli=v[i][j].first;
			if(id>n-k&&j!=v[i].size()-1)
				y.push_back(deli);
			if(id<=n-k&&j==v[i].size()-1)
				x.push_back(deli);
			if(id>n-k&&j==v[i].size()-1)
				num+=1LL;
			if(id>n-k)
				sum+=deli;
		}
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	res=sum+sqr(num);
	for(int i=x.size()-1,j=0;i>=0&&j<y.size();i--,j++){
		sum+=x[i]-y[j];
		num+=1LL;
		res=max(res,sum+sqr(num));
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 8444
// https://atcoder.jp/contests/agc047/tasks/agc047_a
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

// namespace mp = boost::multiprecision;
// using cpp_dec = mp::cpp_dec_float_50;
// using cpp_int = mp::cpp_int;
using namespace std;

#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define Aint(obj) (obj).begin(), (obj).end()
#define AintR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<pair<int, int>, int> cnt;
    REP(i, N) {
        // cpp_dec x;
        // cin >> x;
        // int t = static_cast<int>(x * 1e9);
        long double x;
        cin >> x;
        // 入力の小数部は9桁なので10^9倍し、丸め誤差を補正
        int t = llround(x * 1e9);
        // 2で割り切れる回数、5で割り切れる回数
        pair<int, int> p = {-9, -9};
        while (t % 2 == 0) {
            t /= 2;
            p.first++;
        }
        while (t % 5 == 0) {
            t /= 5;
            p.second++;
        }
        cnt[p]++;
    }
    // mapだと要素指定のアクセスができないのでvectorへ変換
    vector<pair<int, int>> ps;
    vector<int> cs;
    for (auto w : cnt) {
        ps.emplace_back(w.first);
        cs.emplace_back(w.second);
    }

    int ans = 0;
    REP(i, ps.size()) {
        pair<int, int> p = ps[i];
        // 2と5で共に9回以上割り切れるなら整数同士の組み合わせ: nC2
        if (p.first >= 0 && p.second >= 0) {
            ans += cs[i] * (cs[i] - 1) / 2;
        }
        REP(j, i) {
            // 積が2と5で共に9回以上割り切れる
            if (p.first + ps[j].first >= 0 && p.second + ps[j].second >= 0) {
                ans += cs[i] * cs[j];
            }
        }
    }

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


Measured memory_bytes: 3748
#include <stdio.h>
int main(void){
    long a,b,c,d;
    
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    
    if(b>0){
        if(a>0){
            if(d>0){
                printf("%ld",b*d);
            }
            else{
                printf("%ld",a*d);
            }
        }
        else{
            if(d>0){
                if(c>0){
                    printf("%ld",b*d);
                }
                else if(a*c<b*d){
                    printf("%ld",b*d);
                }
                else{
                    printf("%ld",a*c);
                }
            }
            else{
                printf("%ld",a*c);
            }
        }
    }
    else{
        if(c>0){
            printf("%ld",b*c);
        }
        else{
            printf("%ld",a*c);
        }
    }
    
        
    return 0;
}

Measured memory_bytes: 1720
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m =  sc.nextInt();

        List<Store> storeList = new ArrayList<>(n);
        for (int i = 0; i < n; i++){
            long price = sc.nextLong();
            long amount = sc.nextLong();
            Store store = new Store(price, amount);
            storeList.add(store);
        }

        storeList.sort(Comparator.comparingLong(a -> a.price));

        long money = 0L;
        int drinkAmount = 0;
        for (Store store : storeList){
            if (drinkAmount + store.amount >= m){
                money += store.price * (m - drinkAmount);
                break;
            }
            money += store.price * store.amount;
            drinkAmount += store.amount;
        }

        System.out.println(money);
    }

    static class Store{
        long price;
        long amount;
        public Store(long p, long a){
            price = p;
            amount = a;
        }
    }

}

Measured memory_bytes: 94612
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def f(n, a):
    ans = 0
    while n > 0:
        ans += n % a
        n //= a
    return ans


def main():
    N = int(readline())

    ans = INF
    for i in range(N + 1):
        ans = min(ans, f(i, 6) + f(N - i, 9))

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    string N;
    cin >> N;
    string ans = count(ALL(N),'7') > 0 ? "Yes" : "No";
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>

using namespace std;

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

	int a[3][3];
	bool arr[3][3]={false};

	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(a[i][j]==num)
					arr[i][j]=true;
			}
		}
	}
	if((arr[0][0] and arr[0][1] and arr[0][2]) or (arr[1][0] and arr[1][1] and arr[1][2]) or (arr[2][0] and arr[2][1] and arr[2][2])){
		cout << "Yes";
		return 0;
	}
	if((arr[0][0] and arr[1][0] and arr[2][0]) or (arr[0][1] and arr[1][1] and arr[2][1]) or (arr[0][2] and arr[1][2] and arr[2][2])){
		cout << "Yes";
		return 0;
	}
	if((arr[0][0] and arr[1][1] and arr[2][2]) or (arr[2][0] and arr[1][1] and arr[0][2])){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define zero_pad(num) setfill('0') << std::right << setw(num)
const int MOD=1e9+7;
const int INF=1e18;
const int N_MAX=1e5;
int N;
vector<int>Graph[N_MAX];
int oned[N_MAX],nd[N_MAX];

void odfs(int o,int k,int d){
    oned[k]=d;
    for(auto v:Graph[k]){
        if(v!=o)odfs(k,v,d+1);
    }
}
void ndfs(int o,int k,int d){
    nd[k]=d;
    for(auto v:Graph[k]){
        if(v!=o)ndfs(k,v,d+1);
    }
}

signed main(){
    cin>>N;
    REP(i,N-1){
        int a,b;cin>>a>>b;a--;b--;
        Graph[a].pb(b);
        Graph[b].pb(a);
    }
    odfs(-1,0,0);
    ndfs(-1,N-1,0);
    int ans=0;
    REP(i,N){
        if(oned[i]<=nd[i])ans++;
        else ans--;
    }
    cout<<(ans>0?"Fennec":"Snuke")<<endl;
}

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

int main(){
  int N, H, max_H;
  cin >> N;
  int ans=1;
  scanf("%d", &H);
  max_H = H;
  for(int i=0; i<N-1; i++){
    scanf("%d", &H);
    if(max_H <= H){
      ans++;
    }
    max_H = max(max_H, H);
  }
  cout << ans << endl;
}

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

int main()
{
	int n;
	int cnt = 0;
	int num;
	cin >> n ;
	int c2 = 0;
	for(int i = 0; i< n;i++)
	{
		cin >> num;
		if(num%4==0)cnt++;
		else if(num%2==0)c2++;
	}
	
	if(c2==0)
	{
		int t = n / 2;
		if(cnt>=t)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	else
	{
		int t;
		n = n -c2;
		if(n%2!=0)
		t = n/2+1;
		else
		t = n/2;
		if(cnt>=t)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    int m;

    cin>>n>>m;
    priority_queue<int> heap;
    ll ans=0;
    rep(i,0,n)
    {
        cin>>j;
        heap.push(j);
    }

    while(m--)
    {
        j=heap.top();
        j/=2;
        heap.pop();
        heap.push(j);
    }
    while(!heap.empty())
    {
        ans+=heap.top();
        heap.pop();
    }
    cout<<ans;


    return 0;
}



Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    a=abs(x-a);
    b=abs(x-b);
    if(a>b)
        printf("B");
    else
        printf("A");
}


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

const int MAXN = 1e5;

int N, M;
int P[MAXN + 10];

vector<int> G[MAXN + 10];

bool vis[MAXN + 10];
set<int> nodes, val;

void dfs(int u) {
   if(vis[u]) return;
   vis[u] = true;

   nodes.insert(u);
   val.insert(P[u]);
   
   for(int v : G[u]) dfs(v);
}

int main() {
   scanf("%d%d", &N, &M);
   for(int i = 1; i <= N; i++) {
      scanf("%d", &P[i]);
   }
   for(int i = 0; i < M; i++) {
      int u, v; scanf("%d%d", &u, &v);
      G[u].push_back(v);
      G[v].push_back(u);
   }
   int res = 0;
   for(int i = 1; i <= N; i++) {
      if(vis[i]) continue;
      nodes.clear(); val.clear();
      dfs(i);
      for(int u : nodes) {
         res += val.count(u);
      }
   }
   printf("%d\n", res);
}


Measured memory_bytes: 18560
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-C: Stable Sort

#include <cstring>
#include <algorithm>
#include <iostream>

struct Card {
  char suit;
  unsigned int rank;
  bool operator<(const Card& rhs) { return rank < rhs.rank; }
};

std::ostream& operator<<(std::ostream& os, const Card& card)
{
  return os << card.suit << card.rank;
}

std::istream& operator>>(std::istream& is, Card& card)
{
  return is >> card.suit >> card.rank;
}

static void print_cards(const Card cards[], const unsigned int n)
{
  const char* sep = "";
  for (unsigned int i = 0u; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void bubble_sort(Card cards[], const unsigned int n)
{
  for (unsigned int j = 0u; j < n-1; ++j) {
    for (unsigned int i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

static void selection_sort(Card cards[], const unsigned int n)
{
  for (unsigned int i = 0u; i < n-1; ++i) {
    unsigned int min_j = i;
    for (unsigned int j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  Card cards1[n], cards2[n];
  for (unsigned int i = 0u; i < n; ++i) {
    std::cin >> cards1[i];
  }
  std::memcpy(cards2, cards1, sizeof(cards1));

  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);
  if (std::memcmp(cards1, cards2, sizeof(cards1)) == 0) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }
}

// eof

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    long long int n, l = 0;
    cin >> n;
    vector<long long int> a(n);
    vector<int> num(200010, 0);

    long long int work;

    int count = 0, knock = 0;

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

        if(work == count + 1){
            count++;
        }else {
            knock++;
        }
    }

    if(count == 0){
        cout << -1;
    }else{
        cout << knock;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;

const int inf = 1000000009;

int dfs(vector<vector<int>> &graph, bitset<100> &used, int flow, int pos, int t) {
    if (pos == t) return flow;
    used[pos] = 1;
    for (int i=0; i<graph[pos].size(); i++) {
        if (used[i] == 0 && graph[pos][i] > 0) {
            int maxflow = dfs(graph, used, min(flow, graph[pos][i]), i, t);
            if (maxflow > 0) {
                graph[i][pos] = graph[i][pos] + maxflow;
                graph[pos][i] = graph[pos][i] - maxflow;
                return maxflow;
            }
        }
    }
    return 0;
}

int maxflow(vector<vector<int>> graph, int s, int t) {
    bool f = true;
    int sum = 0;
    while (f) {
        bitset<100> b(0); b[s] = 1;
        int current = dfs(graph, b, inf, s, t);
        sum += current;
        f &= current != 0;
    }
    return sum;
}

int main() {
    int v, e;
    cin >> v >> e;
    vector<vector<int>> graph(v);
    for(auto &l: graph) l.resize(v, 0);

    for(int i=0; i<e; i++) {
        int u, v, c; cin >> u >> v >> c;
        graph[u][v] = c;
    }
    
    cout << maxflow(graph, 0, v-1) << endl;
}


Measured memory_bytes: 3248
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
// #define INF 1LL<<60

const int INF = 1e9;

int main() {
    int H, W;
    cin >> H >> W;
    vector< vector<int> > c(10, vector<int>(10, INF));
    REP(i, 10) REP(j, 10) cin >> c[i][j];

    vector< vector<int> > A(H, vector<int>(W));
    REP(i, H) REP(j, W) cin >> A[i][j];

    REP(k, 10)
        REP(i, 10)
            REP(j, 10)
                if(c[i][j] > c[i][k] + c[k][j])
                    c[i][j] = c[i][k] + c[k][j];

    int ans = 0;
    REP(i, H)
        REP(j, W)
            if(A[i][j] == -1) {
                ans = ans;
            } else {
                ans += c[A[i][j]][1];
            }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			UniqueNumber un = new UniqueNumber(n);
			un.input(scan,n);
			un.point(n);
			un.output(n);
		}
	}
}

class UniqueNumber{
	int[][] myNumber;
	int[] myPoint;
	
	public UniqueNumber(int n){
		myNumber = new int[n][3];
		myPoint = new int[n];
		for(int i=0;i<n;i++){
			myPoint[i] = 0;
		}
	}
	
	public void input(Scanner scan,int n){
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				myNumber[i][j] = scan.nextInt();
			}
		}
	}
	
	public void output(int n){
		for(int i=0;i<n;i++){
			System.out.println(myPoint[i]);
		}
	}
	
	public void point(int n){
		boolean flag;
		for(int i=0;i<3;i++){
			for(int j=0;j<n;j++){
				flag = true;
				for(int k=0;k<n;k++){
					if(j!=k){
						if(myNumber[j][i]==myNumber[k][i]){
							flag = false;
							break;
						}
					}
				}
				if(flag){
					myPoint[j] += myNumber[j][i];
				}
			}
		}
	}
}

Measured memory_bytes: 20860
// 24/01/20 // 9:53 PM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(3e2) + 10;

int n;
double memo[MAXN][MAXN][2];

void solve(int x, int y, int z){
    for(int c=0; c<=n; c++)
        for(int b=0; b<=n; b++)
            for(int a=0; a<=n; a++){
                if(a+b+c>n || (a==0 && b==0 && c==0)) continue;

                double& estado = memo[a][b][c&1];
                double dn=n, da = a, db = b, dc = c;

                estado = dn;
                if(a>0) estado += da * memo[a-1][b][c&1];
                if(b>0) estado += db * memo[a+1][b-1][c&1];
                if(c>0) estado += dc * memo[a][b+1][~c&1];

                estado /= (da+db+dc);
            }
}

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

    cin >> n;

    int a=0, b=0, c=0;
    for(int i=0; i<n; i++){
        int temp;
        cin >> temp;

        a += (temp==1);
        b += (temp==2);
        c += (temp==3);
    }

    solve(a, b, c);

    cout.precision(10);
    cout.setf(ios::fixed);
    cout << memo[a][b][c&1] << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  vector<pair<int,int>> P(N);
  rep(i,N) P[i]=make_pair(B[i],A[i]);
  sort(all(P));
  ll now=0;
  rep(i,N){
    now+=P[i].second;
    if(now>P[i].first){
      cout<<"No"<<endl;
      break;
    }
    if(i==N-1) cout<<"Yes"<<endl;
  }
}

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

int main() {
  string str;
  cin >> str;
  for (int i = 0;i < 3;i++) {
    if (str.at(i) == '1') {
      str.at(i) = '9';
    }
    else {
      str.at(i) = '1';
    }
  }
  cout << str << endl;
}

Measured memory_bytes: 384
from collections import deque
import sys
input = sys.stdin.readline

def bfs():
    H, W = map(int, input().split())
    ls = deque([])
    D = [[0] * (W+2)]
    D += ([[0] + [float("inf")]*W + [0] for i in range(H)])
    D.append([0]*(W+2))
    G = [["#"]*(W+2)]
    for i in range(H):
        line = [i for i in input().strip()]
        for j in range(W):
            if line[j] == "#":
                ls.append([i+1, j+1, 0])
                D[i+1][j+1] = 0
        G.append(["#"]+line+["#"])
    G.append([["#"]*(W+2)])

    while len(ls) > 0:
        h, w, depth = ls.popleft()
        if depth + 1 < D[h+1][w] and G[h+1][w] != "#":
            ls.append([h+1, w, depth+1])
            D[h+1][w] = depth + 1
        if depth + 1 < D[h-1][w] and G[h-1][w] != "#":
            ls.append([h-1, w, depth+1])
            D[h-1][w] = depth + 1
        if depth + 1 < D[h][w+1] and G[h][w+1] != "#":
            ls.append([h, w+1, depth+1])
            D[h][w+1] = depth + 1
        if depth + 1 < D[h][w-1] and G[h][w-1] != "#":
            ls.append([h, w-1, depth+1])
            D[h][w-1] = depth + 1

    ans = 0
    for h in range(H+2):
        ans = max(ans, max(D[h]))
        
    return ans
    
print(bfs())

Measured memory_bytes: 220088
#include <stdio.h>
#include <string.h>
#define size 200000

int main(void)
{
	char S[size];	scanf("%s",S);
	int S_size = strlen(S);
	int ans = S_size,i;
	char castle[10];	sprintf(castle,"%c",S[0]);
	char kate[10];
	int flag = 0;
	for(i=1;i<S_size;i++){
		sprintf(kate,"%c",S[i]);
		if(strcmp(castle,kate)==0){
			ans--; i+=2;
			sprintf(castle,"%c",S[i]);
		}
		else if(strcmp(castle,kate)!=0){
			sprintf(castle,"%s",kate);
		}
		//printf("i = %d, flag = %d, ans = %d, kate = %s, castle = %s\n",i,flag,ans,kate,castle);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int a,b;
  char c[15],d[15],e[15];
  scanf("%s %s %d %d %s",&c,&d,&a,&b,&e);
  if((strcmp(c,e)==0)){
    printf("%d %d",a-1,b);
  }else{
    printf("%d %d",a,b-1);
  }
  return 0;
}

Measured memory_bytes: 1728
N=int(input())
A=[int(x) for x in input().split()]
B=[int(y) for y in input().split()]

ans=0
task=0
power=[]

for i in range(N):
  if A[i]< B[i]:
    ans+=1
    task+=(B[i]-A[i])
  else:
    power.append(A[i]-B[i])

power.sort(reverse=True)
for i in range(len(power)):
  if task<=0:
    break
  else:
    task-=power[i]
    ans+=1

if task>0:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 18356
#include<stdio.h>

int main(void){

    int a,b,c,d;

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

    if(a>c){
      d=c;
      c=a;
      a=d;
    }

    if(b>c){
      d=b;
      b=c;
      c=d;
    }

    if(a>b){
      d=a;
      a=b;
      b=d;
    }

    printf("%d %d %d\n",a,b,c);

    return 0;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

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; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int NX = 1e6, B = 55555;
int prime[NX];

vector<int> v;

void pre() {
    REP(i, 2, NX) prime[i] = 1;
    REP(i, 2, NX) {
        if(prime[i]) {
            string s = to_string(i);
            if(i%10 == 3 && i <= B) {
                v.pb(i);
            }
            if(sz(v) == 55) break;
            for(int j=2*i; j<NX; j+=i) {
                prime[j] = 0;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    int N;
    cin >> N;
    REP(i, 0, N) {
        cout << v[i] << " " ;
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 7600
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize
    };

    let mut res = 0;
    for a in 1..=n {
        let max_b = n / a;
        for b in 1..=max_b {
            if a * b >= n {
                break;
            }
            res += 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2272
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

vector<int> v[200010];
int dead[200010], sz[200010];

void dfs(int now, int rt) {
    sz[rt]++;
    dead[now] = 1;
    for (auto x: v[now]) if (!dead[x]) dfs(x, rt);
}

int main() {
    ios_base::sync_with_stdio(0);
    int n, m; cin >> n >> m;
    for (int i=0;i<m;i++) {
        int a, b; cin >> a >> b;
        v[a].pb(b); v[b].pb(a);
    }
    for (int i=1;i<=n;i++) if (!dead[i]) dfs(i, i);
    cout << *max_element(sz+1, sz+n+1) << endl;
}


Measured memory_bytes: 24660
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back

using namespace std;

int main(){
	lint n,a[SIZE],ans=1;
	bool tf=true;
	vector <int> s;
	cin>>n;
	if(n%2==0){
		rep(i,0,n){
			cin>>a[i];
			a[i]--;
			s.push_back(a[i]);
		}
	}
	else{
		rep(i,0,n){
			cin>>a[i];
			s.push_back(a[i]);
		}
	}
	sort(s.begin(),s.end());
	int i=0;
	while(i<n){
		if(n%2==0){
			if(s[i]!=i||s[i+1]!=i){
				tf=false;
				break;
			}
			i+=2;
		}
		else{
			if(i==0){
				if(s[i]!=i){
					tf=false;
					break;
				}
			}
			else
			if(s[i]!=i||s[i-1]!=i){
				tf=false;
				break;
			}
			i+=2;
		}
	}
	if(tf==true){
		if(n%2==1)n--;
		n/=2;
		rep(j,0,n){
			ans*=2;
			ans=ans%1000000007;
		}
	}
	else ans=0;

	cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>

using namespace std;

int main()
{
    char number;
    int sum;
    vector<char> arr;

    int i = 0;
    while(1) {
        number = cin.get();

        if (i==0 && number == '0') {
            break;
        }
        else if (number != '\n') {
            arr.push_back(number);
            i++;
        }else if (number == '\n') {
            int m = arr.size();
            sum = 0;

            for (int i = 0; i < m; i++) {
                char c = arr[i];
                int s = c - '0';
                sum = sum + s;
            }

            cout << sum << endl;
            arr.clear();
            i = 0;
        }
    }  
        
    
    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>

int main(void)
{
	int A, B, C, D;

	scanf("%d %d %d %d", &A, &B, &C, &D);

	if(A * B >= C * D)
		printf("%d", A * B);
	else
		printf("%d", C * D);

	return 0;
}

Measured memory_bytes: 128
//Name: Older Research Bldg. No.7
//Level: 1
//Category: シミュレーション,やるだけ
//Note:

/**
 * 入力がソートされているため、目的の年を超える入力が来た時点で、その直前の名称を出せばよい。
 * オーダーは O(N)。
 */
#include <iostream>
#include <string>

using namespace std;

bool solve() {
    int N, Q;
    if(!(cin >> N >> Q)) return false;

    string name = "kogakubu10gokan";
    for(int i = 0; i < N; ++i) {
        int y;
        string n;
        cin >> y >> n;
        if(y > Q) break;
        name = n;
    }
    cout << name << endl;
    return false;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int a,b;
    cin >> a >> b;
    if(b%a == 0){
        P(a+b);
    }else{
        P(b-a);
    }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()

pos = N
step = []
isGoal = 1
while pos > 0:
    for i in range(M, 0, -1):
        if pos - i <= 0:
            step.append(pos)
            pos = 0
        elif S[pos - i] == '0':
            step.append(i)
            pos -= i
        else:
            continue
        break
    else:
        isGoal = 0
        break

if isGoal:
    print(*[x for x in reversed(step)])
else:
    print(-1)


Measured memory_bytes: 50768
def print_atcg(data):
    if data == 'A':
        print('T')
    elif data == 'T':
        print('A')
    elif data == 'C':
        print('G')
    elif data == 'G':
        print('C')
    else:
        print('not found')


if __name__ == "__main__":
    data = input()
    print_atcg(data)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Read();
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		HashSet<int>[] friends = new HashSet<int>[n+1];
		for(int i=0;i<n+1;i++) friends[i] = new HashSet<int>();

		for(int j=0;j<m;j++)
		{
			input = Read();
			int a1 = int.Parse(input[0]);
			int a2 = int.Parse(input[1]);
			friends[a1].Add(a2);
			friends[a2].Add(a1);
		}

		int max = 0;
		HashSet<int> counted = new HashSet<int>();
		for(int i=1; i<=n; i++)
		{
			if(counted.Add(i))
			{
				HashSet<int> friendsCnt = new HashSet<int>();
				Search(i, friendsCnt, friends);
				max = max < friendsCnt.Count ? friendsCnt.Count : max;
				foreach(int f in friendsCnt) counted.Add(f);
			}
		}
		Write(max);
	}

	static void Search(int i, HashSet<int> friendsCnt, HashSet<int>[] friends)
	{
		if(friendsCnt.Add(i))
		{
			foreach(int f in friends[i])
			{
				Search(f, friendsCnt, friends);
			}
		}
	}

	static string[] Read()
	{
		return Console.ReadLine().Split(' ');
	}

	static void Write(object o)
	{
		Console.WriteLine(o.ToString());
	}
}



Measured memory_bytes: 106508