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

int main(){
  long long N, W;
  cin >> N >> W;
  vector<long long> w0, w1, w2, w3;
  long long w; cin >> w;
  long long v; cin >> v; w0.push_back(v);
  for (int i=1; i<N; i++){
    long long wgt, val;
    cin >> wgt >> val;
    if (wgt-w==0) w0.push_back(val);
    else if (wgt-w==1) w1.push_back(val);
    else if (wgt-w==2) w2.push_back(val);
    else w3.push_back(val);
  }
  sort(w0.begin(), w0.end(), greater<long long>());
  sort(w1.begin(), w1.end(), greater<long long>());
  sort(w2.begin(), w2.end(), greater<long long>());
  sort(w3.begin(), w3.end(), greater<long long>());
  for (int i=1; i<N; i++){
    if (i<w0.size()) w0[i] += w0[i-1];
    if (i<w1.size()) w1[i] += w1[i-1];
    if (i<w2.size()) w2[i] += w2[i-1];
    if (i<w3.size()) w3[i] += w3[i-1];
  }
  long long ans = 0;
  for (int i=0; i<=w0.size(); i++){
    for (int j=0; j<=w1.size(); j++){
      for (int k=0; k<=w2.size(); k++){
        for (int l=0; l<=w3.size(); l++){
          if (i*w+j*(w+1)+k*(w+2)+l*(w+3)<=W){
            long long tmpans = 0;
            if (i>0) tmpans += w0[i-1];
            if (j>0) tmpans += w1[j-1];
            if (k>0) tmpans += w2[k-1];
            if (l>0) tmpans += w3[l-1];
            ans = max(ans, tmpans);
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! { s: chars }
    let mut ans = 0;
    let n = s.len();

    'outer: for i in 1..n {
        let mut x  = true;
        if (n-i) % 2 == 0{
            for j in 0..(n-i)/2 {
                if s[j] != s[j+(n-i)/2] {
                    x = false;
                }
            }
            if x {
                ans = n - i;
                break 'outer;
            }
        }
    }

    puts!("{}\n",ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2196
al = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
N = int(input())
M = N
v = 1
while True:
    if(M<=26**v):
        break
    M -= 26**v
    v += 1
if(N<=26):
    anss = al[N%26-1]
else:
  for i in range(v):
      N -= 26**i  
  ans = []
  for i in range(v):
      ans.append("a")
  for i in range(v):
      ans[-i-1]=al[N%26]
      N = N//26
  ans.reverse()
  anss = ""
  for i in range(len(ans)):
      anss += ans[-i-1]
print(anss)
    


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    LL x,a,b;
    cin >> x >> a >> b;
    if (b-a <= 0) {
        cout << "delicious" << endl;
    }else if (b-a <= x){
        cout << "safe" << endl;
    }else{
        cout << "dangerous" << endl;
    }

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;

	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a.at(i);

	sort(a.begin(), a.end());
	for(int i=1;i<n;i++){
		if(a.at(i-1)==a.at(i)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
module StringSet = Set.Make (String)

let () =
  let n = int_of_string @@ read_line () in
  let ws = Array.init n @@ fun _ -> read_line () in
  let wss = Array.make (n + 1) StringSet.empty in
  for i = 0 to n - 1 do
    wss.(i + 1) <- StringSet.add ws.(i) wss.(i)
  done;
  print_endline @@
  if
    Array.fold_left ( && ) true @@
    Array.init (n - 1) @@ fun i ->
      not (StringSet.mem ws.(i + 1) wss.(i + 1)) && ws.(i).[String.length ws.(i) - 1] = ws.(i + 1).[0]
  then "Yes"
  else "No"


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define  MOD 1000000007

using namespace std;
typedef long long ll;

int n,arr[105],k;
ll dp[105][100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    for(int i=0;i<=n;i++)dp[i][0]=1;
    for(int i=0;i<=k;i++)dp[0][i]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            ll sum=dp[i-1][j];
            if(j-arr[i]-1>=0)sum-=dp[i-1][j-arr[i]-1];
            while(sum<0)sum+=MOD;
            dp[i][j]=(dp[i][j-1]+sum)%MOD;
        }
    }
    /*for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }*/
    /*if(k==0)cout<<1;
    else*/
    ll res=dp[n][k]-dp[n][k-1];
    while(res<0)res+=MOD;
    cout<<res;
}

Measured memory_bytes: 80128
H, W = list(map(int, input().split()))
DP = [[0] * W] * H
for i, c in enumerate(input()):
    if i == 0:
        DP[0][0] = 1
    elif c == '.':
        DP[0][i] = DP[0][i-1]
    else:
        DP[0][i] = 0

for h in range(1, H):
    for i, c in enumerate(input()):
        if i == 0:
            if c == '.':
                DP[h][0] = DP[h-1][0]
            else:
                DP[h][0] = 0
        else:
            if c == '.':
                DP[h][i] = DP[h-1][i] + DP[h][i-1]
            else:
                DP[h][i] = 0

print(DP[-1][-1] % 1000000007)

Measured memory_bytes: 50524
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int N,M;
int done[50];
vector< vector<int> > path;

void dfs( int a, int b, int c ) {
    
    done[c] = 1;
    
    for ( int i = 0; i < path[c].size(); i++ ) {
        int n = path[c][i];
        if ( a == c && b == n ) { continue; }
        if ( b == c && a == n ) { continue; }
        if ( !done[n] ) { dfs( a, b, n ); }
    }
    
}


void bfs( int a, int b ) {
    
    fill( done, done+50, 0 );
    
    queue<int> Q;
    for ( int i = 0; i < path[0].size(); i++ ) {
        if ( ( a == 0 && b == path[0][i] ) || ( a == path[0][i] && b == 0 ) ) { continue; }
        Q.push(path[0][i]);
        done[path[0][i]] = 1;        
    }
    
    while ( !Q.empty() ) {
        int c = Q.front();
        Q.pop();
        
        for ( int i = 0; i < path[c].size(); i++ ) {
            int n = path[c][i];
            if ( ( a == c && b == n ) || ( a == n && b == c ) ) { continue; }
            if ( !done[n] ) {
                Q.push(n);
                done[n] = 1;
            }
        }
    }
    
}

bool is_all() {
    for ( int i = 0; i < N; i++ ) {
        if ( !done[i] ) { return false; }
    }
    return true;
}

int main() {
    
    cin >> N >> M;
    path.resize(N);
    vector< pair<int, int> > P;
    for ( int i = 0; i < M; i++ ) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
        P.push_back( make_pair(a,b) );
    }
    
    int ans = 0;
    for ( int i = 0; i < M; i++ ) {                
        fill( done, done+50, 0 );
        // bfs( P[i].first, P[i].second );
        dfs( P[i].first, P[i].second, 0 );
        if ( !is_all() ) { ans++; }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  ll h,w;
  cin>>h>>w;
  ll ans=h*w;
  //cut hor.
  ans=((h+2)/3-h/3)*w;
  //cut vertically
  ans=min(ans,((w+2)/3-w/3)*h);
  //1,2
  rep(i,1,h)
    {
      vector<ll> tmp;
      tmp.pb(w*i);
      tmp.pb((h-i)*((w+1)/2));
      tmp.pb((h-i)*(w/2));
      sort(all(tmp));
      ans=min(ans,tmp[2]-tmp[0]);
    }
  //2,1
  swap(h,w);
  rep(i,1,h)
    {
      vector<ll> tmp;
      tmp.pb(w*i);
      tmp.pb((h-i)*((w+1)/2));
      tmp.pb((h-i)*(w/2));
      sort(all(tmp));
      ans=min(ans,tmp[2]-tmp[0]);
    }
  cout<<ans<<endl;
  return 0 ;
}


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

int main() {
	
	int n,m;
	cin >> n >> m;
	string t;
	for(int i=0; i<n; i++) t+='0';
	map<int,int> a;
	for(int i=1; i<=3; i++) a[i]=-1;
	
	bool flg=1;
	for(int i=0; i<m; i++){
		int s,c;
		cin >> s >> c;
		if(n!=1 && s==1 && c==0) flg=0;
		if(a.at(s)!=-1 && a.at(s)!=c) flg=0;
		a.at(s)=c;
		t.at(s-1)=(char) (c+'0');
	}
	if(n==3 && a.at(1)==-1) t.at(0)='1';
	if(n==2 && a.at(1)==-1) t.at(0)='1';
	if(!flg) cout << "-1" << endl;
	else cout << stoi(t) << endl;
	
}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[3][110];
int idx[3];

int main(void) {
  REP(i, 3)
    scanf("%s", buf[i]);
  int turn = 0;
  for(;;) {
    char ch = buf[turn][idx[turn]++];
    if(ch == 0) {
      printf("%c\n", 'A'+turn);
      break;
    }
    turn = ch - 'a';
  }
  return 0;
}



Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var a = input[0];
			var b = input[1];

			System.Console.WriteLine(a * b + " " + (a * 2 + b * 2));

		}
	}
}




Measured memory_bytes: 18464
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void ABC147C();

int main()
{
	ABC147C();
	fflush(stdout);
	return 0;
}

static void ABC147C()
{
	int N;
	getint(N);

	std::vector<std::vector<std::pair<int, int>>> evid(N);
	for (int i = 0; i < N; i++) {
		int ai;
		getint(ai);
		evid[i].resize(ai);
		for (int j = 0; j < ai; j++) {
			getint(evid[i][j].first, evid[i][j].second);
		}
	}

	int maxHonest = 0;
	for (int i = 0; i < (1 << N); i++) {

		bool allOk = true;
		for (int p = 0; p < N; p++) {
			if (!((i >> p) & 0x1)) {
				continue;
			}
			int evdCount = evid[p].size();
			for (int e = 0; e < evdCount; e++) {
				int honest = evid[p][e].second;
				int number = evid[p][e].first - 1;

				int bit = (i >> number) & 0x1;
				if (honest != bit) {
					allOk = false;
					break;
				}
			}
			if (!allOk) break;
		}
		if (allOk) {
			int honestCount = 0;
			int bits = i;
			while (bits) {
				if (bits & 0x1) honestCount++;
				bits >>= 1;
			}
			maxHonest = std::max(honestCount, maxHonest);
		}
	}
	printf("%d\n", maxHonest);
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
long long N,K,cnt=0LL,m;
int main(){
   cin>>N>>K;
   long long A[N],visited[N];
   memset(visited,-1,sizeof visited);
   for(int i=0;i<N;i++){cin>>A[i];A[i]-=1;}
   vector<long long>r={0};
   visited[0]=K;
   while(K!=0LL){
      long long n=A[r.back()];
      //cout<<"K:"<<K-1<<endl;
      //cout<<n+1<<endl;
      if(visited[n]!=-1){
         K--;
         m=visited[n]-K;
         //cout<<"m"<<m<<endl;
         //cout<<"cnt"<<cnt<<endl;
         K%=m;
         if(K==0){cout<<n+1<<endl;return 0;}
         //cout<<"K"<<K<<endl;
         K++;
         memset(visited,-1,sizeof visited);
      }
      visited[n]=--K;
      r.push_back(n);
   }
   //for(auto x:r)cout<<x<<endl;
   cout<<r.back()+1<<endl;
   return 0;
}

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

int main(){
        int n,i;
        long long tmp,ans=1,flg=0;
        cin >> n;
        for(i=0;i<n;++i){
                cin >> tmp;
                if(tmp==0){
                        ans = 0;
                        break;
                }
                if((long long)1000000000000000000/ans<(long long)tmp) flg = 1;
                if(flg==1) continue;
                ans *= tmp;
        }
        if(flg==1 && ans!=0) cout << -1 << endl;
        else cout << ans << endl;
        return 0;
}

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

using namespace std;

int main() {
  string s; cin >> s;
  bool ok = true;
  for(int i = 0 ; i < (int)s.size() ; ++i) {
    if(i % 2 == 0) {
      if(s[i] == 'L') { ok = false; break; }
    }
    else {
      if(s[i] == 'R') { ok = false; break; }
    }
  }
  if(ok) cout << "Yes\n";
  else cout << "No\n";
}


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

using namespace std;

int main(){
    set<int> hoge;
    
    for(int i=0;i<3;i++){
        int a;
        cin>>a;
        hoge.insert(a);
    }
    
    cout<<hoge.size()<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	int d = max(a, max(b, c));
	int s = a + b + c;
	s = s - d;
	cout <<  s + d*pow(2 ,k);
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


signed main(){

	lli n;
	string s;
	cin>>n>>s;

	lli cnt=0;

	REP(i,0,n-2){
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt++;
	}
	cout<<cnt<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n, a[100];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i = n - 1; i >= 0; i--)
    {

        if (i != 0)
        {

            printf("%d ", a[i]);
        }else
        {
            printf("%d", a[i]);
        }
        
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=10005;
const int NN=2005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    str s;
    int k;
    cin >> k >> s;
    if (s.size()<=k){
        cout << s << E;
    }else {
        str ans="";
        for (int i=0;i<k;i++){
            ans+=s[i];
        }
        ans+="...";
        cout << ans << E;
    }


    r0;
}
/*








*/


Measured memory_bytes: 3652
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    hp=[]
    for _ in range(n):
        a,b=MI()
        heappush(hp,[a,b])
    s=0
    while 1:
        a,b=heappop(hp)
        s+=b
        if s>=k:
            print(a)
            break
main()

Measured memory_bytes: 19700
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}

int gcd(int w,int m){
  while(1){
    if (w %  m==0)return m;
    int temp;
    temp = w%m;
    w = m;
    m = temp;
  }
}

long long lcm(long long w,long long m){
  return (w*m)/gcd(w,m) ;//w > m
}

int main(){
  long long n,m;
  string s, t;
  cin >> n >> m;
  cin >> s >> t;
  long long l = lcm(max(n,m), min(n, m));
  map<long long, char> M;
  for(long long i = 0;i < n;i++){
    M[i * l/n] = s[i];
  }

  bool fg = true;
  for(int i = 0 ;i < m;i++){
    if (M.count(i * l/m) != 0 && M[i*l/m] != t[i]){
      fg = false;
    }
  }
  if (fg)cout << l << endl;
  else cout << -1 << endl;
  return 0;
}
 
 


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

using ll = long long;
int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<int> xary, yary;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    sort(begin(xary), end(xary));
    sort(begin(yary), end(yary));
    ll ans = 1LL * (xary[n - 1] - xary[0]) * (yary[n - 1] - yary[0]);
    for (int xi = 0; xi < n; ++xi) {
        for (int xj = xi + 1; xj < n; ++xj) {
            for (int yi = 0; yi < n; ++yi) {
                for (int yj = yi + 1; yj < n; ++yj) {
                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];
                    for (int i = 0; i < n; ++i) {
                        if (lx <= x[i] and x[i] <= rx and by <= y[i] and
                            y[i] <= uy) {
                            num++;
                        }
                    }
                    if (num >= k) ans = min(ans, 1LL * (rx - lx) * (uy - by));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    bool can=false;
    int pos;
    for(int i=1;i*i/2<N;i++){
        if(i*(i+1)/2==N){
            can=true;
            pos=i+1;
            break;
        }
    }
    if(can) cout << "Yes" << endl;
    else {
        cout << "No" << endl;
        return 0;
    }

    vc<pi> edge;
    rep(i,pos){
        rng(j,i+1,pos){
            edge.eb(i,j);
        }
    }

    vi ans[pos];
    rep(i,SZ(edge)){
        ans[edge[i].fi].eb(i+1);
        ans[edge[i].se].eb(i+1);
    }

    cout << pos << endl;
    rep(i,pos){
        cout << SZ(ans[i]) <<" ";
        rep(j,SZ(ans[i])){
            cout << ans[i][j];
            if(j==SZ(ans[i])-1){
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}


signed main() {
    string s; cin>>s;
    int cnt = 0;

    for(int i=0; i<(s.length());i++){
        int si = s[i]-'0';
        cnt = (cnt+si) % 9;
    }

    if(cnt==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

import sys

if __name__ == '__main__':
    N = int(raw_input())
    l = map(int, raw_input().split())
    cnt = 0
    for i in range(0, N):
        for j in range(N - 1, i, -1):
            if l[j] < l[j - 1]:
                l[j], l[j - 1] = l[j - 1], l[j]
                cnt += 1
    print ' '.join(map(str, l))
    print cnt


Measured memory_bytes: 4664
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	long a;
	while(scan.hasNext())
	    {
		long x1=0;
	a=scan.nextInt();
	
	for(long i=600;i>0;i-=a)
	    {
		
		x1+=a*((int)Math.pow(i-a,2));
		
	    }
	
	System.out.println(x1);
	
	    }
    }
}

Measured memory_bytes: 17200
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXM = 64;
vector<int> G[MAXM];
const int LIMIT = 500;
int dp[64][64][LIMIT];

int dfs(int a, int b, int t) {
    if (a == b) return t;
    if (t >= LIMIT) return LIMIT;
    if (dp[a][b][t] >= 0) return dp[a][b][t];
    if ((t & 1) == 0) {
        int ret = dfs(a, b, t+1);
        for (int i = 0; i < (int)G[a].size(); i++) {
            ret = max(ret, dfs(G[a][i], b, t+1));
        }
        return dp[a][b][t] = ret;
    } else {
        int ret = LIMIT;
        for (int i = 0; i < (int)G[b].size(); i++) {
            ret = min(ret, dfs(a, G[b][i], t+1));
        }
        return dp[a][b][t] = ret;
    }
}

int main(void) {
    int T;
    cin >> T;
    while (T--) {
        for (int i = 0; i < MAXM; i++) G[i].clear();
        for (int i = 0; i < 64; i++) for (int j = 0; j < 64; j++) {
            for (int k = 0; k < LIMIT; k++) {
                dp[i][j][k] = -1;
            }
        }
        int a, b;
        int M;
        cin >> M;
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < M; j++) {
                int tmp;
                scanf("%d", &tmp);
                if (tmp == 1) G[i].push_back(j);
            }
        }
        scanf("%d %d", &a, &b);
        int ans = dfs(a, b, 0);
        if (ans >= LIMIT) cout << "infinity" << endl;
        else cout << ans/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 9320
while True:
    (H, W) = [int(x) for x in input().split()]
    if H == W == 0:
        break
 
    for hc in range(H):
        if hc == 0 or hc == H -1:
            print('#' * W)
        else:
            print('#' + '.' * (W -2) + '#')
    print()

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

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

    if(a > 0)  {
        cout << "Positive" << endl;
    }else if (a <= 0 && b >= 0){
        cout << "Zero" << endl;
    }else if(b < 0){
        if((abs(a)-abs(b) + 1) % 2 == 0){
            cout << "Positive" << endl;
        }else{
            cout << "Negative" << endl;
        }
    }
}

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

t=[]

line=(input().split())

for i in range(n):
    t.append(int(line[i]))

m=int(input())
sumt=[]

for i in range(m):
    time=0
    p,x=map(int,input().split())
    for j in range(n):
        if j==(p-1):
            time=time+x
        else:
            time=time+t[j]
    sumt.append(time)

for i in range(m):
    print(sumt[i])

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k,s=MI()
    ans=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            if 0<=z<=k:
                ans+=1
    print(ans)

main()

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

namespace Atcoder1
{
    class Program
    {
        static void Main(string[] args)
        {
            float num1 = float.Parse(Console.ReadLine());
            float length = num1 / 3;
            float result = length * length * length;
            Console.WriteLine("{0:f12}",result);

        }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;
typedef pair<lld,lld> node;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	vector<node> p(n);

	for(int i = 0; i < n; i++)
	{
		cin >> p[i].first >> p[i].second;
	}

	vector<lld> x,y;
	for(int i = 0; i < n; i++)
	{
		x.push_back(p[i].first);
		y.push_back(p[i].second);
	}

	unsigned long long  sol = 4*1e18;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			for(int k = 0; k < n; k++)
			{
				for(int l = 0; l < n; l++)
				{
					lld x_min = min(min(p[i].first,p[j].first),min(p[k].first,p[l].first));
					lld x_max = max(max(p[i].first,p[j].first),max(p[k].first,p[l].first));
					lld y_min = min(min(p[i].second,p[j].second),min(p[k].second,p[l].second));
					lld y_max = max(max(p[i].second,p[j].second),max(p[k].second,p[l].second));

					lld cnt = 0;

					for(int q = 0; q < n; q++)
					{
						if (x_min <= p[q].first && p[q].first <= x_max && y_min <= p[q].second && p[q].second <= y_max )
						{
							cnt++;
						}
					}

					if (cnt >= K && x_max != x_min && y_max != y_min)
					{
						//cout << cnt << endl;
						unsigned long long s = abs(x_max-x_min) * abs(y_max-y_min);
						if (s < sol)
						{
							sol = s;
						}
					}
				}
			}
		}
	}

	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define for(i, N)  for(int i = 0; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Q, sum = 0;cin >> N;
map<ll, ll> P;
vector<ll> A(N);

for(i, N)
{cin >> A[i];P[A[i]]++;sum += A[i];}

cin >> Q;
vector<ll> B(Q);
vector<ll> C(Q);

for(i, Q)
{cin >> B[i] >> C[i];}

for(i, Q){
P[C[i]] += P[B[i]];
sum += P[B[i]]*(C[i] - B[i]);
P[B[i]] = 0;
cout << sum << endl;
}
}

Measured memory_bytes: 11412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int a, b, c;
set<int> si;

int main() {
	cin >> a >> b >> c;
	for (int i = 1; si.find(a*i%b) == si.end(); i++) {
		si.insert(a*i%b);
	}
	if (si.find(c) != si.end())cout << "YES" << endl;
	else cout << "NO" << endl;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

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



// Main Code
int arr[20];
int p[20];
int main()
{
	int n, m;
	cin>>n>>m;
	rep(i, 0, m)
	{
		int k;
		cin>>k;
		while(k--)
		{
			int u;
			cin>>u;
			u--;
			arr[u] |= (1 << i);
		}
	}
	int init = 0;
	rep(i, 0, m)
	{
		int x;
		cin>>x;
		x = !x;
		init |= (x << i);
	}
	
	ll ans = 0;
	rep(i, 0, (1 << n))
	{
		ll curr = init;
		rep(j, 0, 11)
		{
			if(((1 << j)&i) != 0)
			{
				curr = curr ^ arr[j];
			}
		}
		//cout<<curr<<endl;
		if(curr == ((1 << m) - 1)) ans++;
	}
	cout<<ans<<endl;
}


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

int main(){
  int n;
  vector<int> result;

  while(cin>>n,n!=0){
    int count=0;
    int i=n+1;
    if(n!=1){
      if(i%2==0) i++;
      while(i<=2*n){
	int k=0;
	for(int j=3;j<=sqrt(i);j+=2){
	  if(i%j==0){
	    k=1;
	    break;
	  }
	}
	if(k==0) count++;
	i+=2;
      }
    }
    else count++;
    
    result.push_back(count);
  }
  
  for(auto i:result){
    cout<<i<<endl;
  }
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#pragma GCC optmize("03")
#define boost ios::sync_with_stdio(); cin.tie(); cout.tie();
using namespace std;
#define st first
#define nd second
typedef long long ll;
typedef pair <int, int> pii;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;
void solve()
{
    ll n,d;
    cin >> n >>d;
    ll a,b;
    ll ans =0;
    for(ll i =0; i < n;i++){
        cin >> a >> b;
        ll skrrt = ll(a*a) + ll(b*b);
        ll skrrt2 = ll(d*d);
        if(skrrt <= skrrt2){
            ans++;
        }
    }
    cout << ans;
}
int main()
{
    boost
    //int t; cin >> t; while(t--)
    solve();
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    s[5]=' ';
    s[13]=' ';

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
int main(){
  ll l,r;
  cin >> l >> r;
  
  ll width = r - l;
  ll s = l;
  l %= 2019;
  
  if(2019 <= l + width || l == 0){
    cout << 0 << endl;
  }else{
    vector<ll> a(width+1);
   for(ll i = 0; i < width + 1 ; i++){
      a[i] = i + l;
    }
    
    ll tmp;
    ll min = 1e9;
   for(int i = 0;i < width + 1;i++){
     for(int j = 0;j < width + 1 && j < i;j++){
       tmp = a[i] * a[j];
       tmp %= 2019;
       if(tmp < min) min = tmp;
     }
   }
    
    cout << min << endl;
  }
  
  
}
  

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

using static Input;
using static Util;
class Program
{
    static long N;
    static void INPUT()
    {
        N = NextLong();
    }

    static void OUT()
    {
        var count = 0;
        foreach (var p in PrimeFactor(N).GroupBy(__ => __))
        {
            var c = p.Count();
            for (int i = 1; i <= c; i++)
            {
                count++;
                c -= i;
            }
        }
        Console.WriteLine(count);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
    /// <summary>
    /// 素因数分解
    /// </summary>
    /// <param name="n"></param>
    /// <returns></returns>
    public static IEnumerable<long> PrimeFactor(long n)
    {
        long i = 2;
        long tmp = n;

        while (i * i <= n)
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;
    }
}

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

using namespace std;
using ll = long long;


int main()
{
    int n, q; cin >> n >> q;
    vector<tuple<ll,ll,ll>> e;

    for(int i = 0; i < n; i++) {
        int s, t, x; cin >> s >> t >> x; 
        s -= x, t -= x;
        e.emplace_back(s, -1, x);
        e.emplace_back(t, 0, x);
    }

    for(int i = 0; i < q; i++) {
        int d; cin >> d;
        e.emplace_back(d, 1, i);
    }
    sort(e.begin(), e.end());

    //イベントソート(時系列順に見ていっていろいろする?)
    vector<ll> res(q);
    multiset<ll> se; //座標が入ってる
    for(auto p : e) {
        ll a, type, c; tie(a, type, c) = p;
        //工事が始まった
        if(type == -1) {
            se.insert(c);
        }
        //工事が終わった
        if(type == 0) {
            se.erase(se.lower_bound(c));
        }

        //
        if(type == 1) {
            res[c] = (se.size() ? *se.begin() : -1);
        }
    }
    for(auto i : res)cout << i << endl;

}

Measured memory_bytes: 26724
#include <cstdio>
#include <cmath>

#include <algorithm>
#include <utility>
#include <vector>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int N = 200000;
int n, q;
LL a[N], b[N], c[N];
LL ec[N];
const LL INF = 2000000000LL;
std::pair< LL, std::pair<int, int> > p[N * 2];

int id[N];
std::vector<int> vec[N];

void uf_init() {
	inc(i, n) {
		id[i] = i;
		vec[i].push_back(i);
	}
}

bool unite(int x, int y) {
	int vx = id[x], vy = id[y];
	if(vx == vy) { return false; }
	
	if(vec[vx].size() < vec[vy].size()) { swap(vx, vy); }
	for(auto && e : vec[vy]) {
		id[e] = vx;
		vec[vx].push_back(e);
	}
	vec[vy].clear();
	
	return true;
}

int main() {
	scanf("%d%d", &n, &q);
	inc(i, q) { scanf("%lld%lld%lld", &a[i], &b[i], &c[i]); }
	
	inc(i, n) { ec[i] = INF; }
	
	inc(i, q) {
		setmin(ec[ a[i] ], c[i] + 1);
		setmin(ec[ b[i] ], c[i] + 2);
	}
	
	LL pre = INF;
	inc(i, n * 2) {
		setmin(ec[i % n], pre + 2);
		pre = ec[i % n];
	}
	
	inc(i, n) {
		p[i] = std::make_pair(ec[i], std::make_pair(i, (i + 1) % n));
	}
	inc(i, q) {
		p[n + i] = std::make_pair(c[i], std::make_pair(a[i], b[i]));
	}
	
	std::sort(p, p + n + q);
	
	uf_init();
	LL ans = 0;
	inc(i, n + q) {
		if(unite(p[i].second.first, p[i].second.second)) { ans += p[i].first; }
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 26360
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x=0,ans=0;
  scanf("%d",&x);
  char s[x];
  scanf("%s",s);
  for (int i = 0; i < x-2; i++) {
    if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=1e5+5;
int n,id[N],fa[N],siz[N]; ll a[N]; map<ll,int> mp;
bool cmp(int x,int y){ return a[x]>a[y]; }
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%lld",&a[i]);
		mp[a[i]]=i; id[i]=i; siz[i]=1;
	}
	sort(id+1,id+1+n,cmp);
	rep (i,1,n-1){
		int x=id[i];
		fa[x]=mp[a[x]-n+2*siz[x]];
		if (!fa[x]) return puts("-1"),0;
		siz[fa[x]]+=siz[x];
	}
	rep (i,1,n-1) a[id[n]]-=siz[id[i]];
	if (a[id[n]]) return puts("-1"),0;
	rep (i,1,n-1) printf("%d %d\n",id[i],fa[id[i]]);
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

const int MAX = 300000;
map<P,int> mp;
int par[2][MAX], size[2][MAX], sum[2][MAX];

void init(){
	rep(i,MAX)rep(j,2)par[j][i] = i;
	rep(i,MAX)rep(j,2)sum[j][i] = 1;
}

int find(int t, int x){
	if(par[t][x] == x)return x;
	return par[t][x] = find(t, par[t][x]);
}

void unite(int t, int x, int y){
	x = find(t, x);
	y = find(t, y);
	if(size[t][x] < size[t][y]){
		par[t][x] = y;
		sum[t][y]++;
	}else{
		par[t][y] = x;
		if(size[t][x] == size[t][y])size[t][y]++;
		sum[t][x]++;
	}
}

bool same(int t, int x, int y){
	return find(t, x) == find(t, y);
}

vector<int> ans;
signed main(){
	init();
	int n, m1, m2;
	scanf("%lld%lld%lld", &n, &m1, &m2);
	
	rep(i,m1){
		int x, y;
		scanf("%lld%lld",&x, &y);
		unite(0, x-1, y-1);
	}
	rep(i,m2){
		int x, y;
		scanf("%lld%lld", &x, &y);
		unite(1, x-1, y-1);
	}
	
	rep(i,n){
		int x = find(0, i), y = find(1, i);
		mp[P(x, y)]++;
	}
	rep(i,n){
		int x = find(0, i), y = find(1, i);
		ans.push_back(mp[P(x, y)]);
	}
	
	rep(i,ans.size())printf("%lld%c", ans[i], i == ans.size()-1 ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 27892
#include <stdio.h>

int main(void)
{
    int a, b;

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

    if(1 <= a <= 100 && 1 <= b <= 100){
        printf("%d %d\n", a * b, (a + b) * 2);
    }

    return 0;
}


Measured memory_bytes: 2040