akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using mint = boost::multiprecision::cpp_int; //int1024_t etc...
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;

TPL<TNM T> inline bool chmin(T&a, T&b) { if (a > b) { a = b; return true; } return false; }
TPL<TNM T> inline bool chmax(T&a, T&b) { if (a < b) { a = b; return true; } return false; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value, void>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int A, B, T;
	cin >> A >> B >> T;
	int t = 0;
	int ans = 0;
	while (t + A <= T) {
		ans += B;
		t += A;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int n;
int nn;
int a[1100005];
int mv[1100005];
int sv[1100005];
int main()
{
	read(nn);
	n=(1<<nn);
	for(int i=0;i<n;i++)
		read(a[i]);
	for(int i=0;i<n;i++)
		mv[i]=a[i];
	for(int i=0;i<nn;i++)
		for(int j=0;j<n;j++)
			if((j>>i)&1)
			{
				sv[j]=max(sv[j],mv[j]+mv[j^(1<<i)]);
				mv[j]=max(mv[j],mv[j^(1<<i)]);
			}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		ans=max(ans,sv[i]);
		printf("%d\n",ans);
	}
	return 0;
}

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

namespace ITP1
{
    class ITP1_5_A
    {
        static void Main(string[] args)
        {
            int h, w;
            List<int> dataSet;

            while(true)
            {
                dataSet = Console.ReadLine().Split().Select(int.Parse).ToList();
                h = dataSet[0];
                w = dataSet[1];

                if (h == 0 && w == 0)
                {
                    break;
                }

                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 18264
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 998244353;
char s[100100];
int n,m,dp[4010][4010],sum[2010][2];
int main(){
    int i,j,k;
    scanf("%s",s+1);
    n=strlen(s+1);
    for(i=1;i<=n;i++){
      if(s[i]=='0')sum[i][0]+=2;
        else if(s[i]=='1')sum[i][0]++,sum[i][1]++;
        else sum[i][1]+=2;
      sum[i][0]+=sum[i-1][0],sum[i][1]+=sum[i-1][1];
	}
	if(sum[1][0])dp[1][0]=1;
	if(sum[1][1])dp[1][1]=1;
	for(i=2;i<=2*n;i++)
	  for(j=0;j<=i;j++){
	    if(j>sum[min(i,n)][1]||i-j>sum[min(i,n)][0])continue;
	    dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
	    if(j)dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
	  }
	cout<<dp[2*n][sum[n][1]];
	return 0;
}


Measured memory_bytes: 60544
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll n;
	cin >> n;
	cout << 800 * n - (n / 15 * 200) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod = 1e9+7;
const int N = 2e5+4;

int main()
{
	int n; scn(n);

	int a[n],b[n];

	vector<int> fa(n+1,0),fb(n+1,0);

	rep(i,0,n)
	scn(a[i]),fa[a[i]]++;

	rep(i,0,n)
	scn(b[i]),fb[b[i]]++;

	rep(i,1,n+1)
	if(fa[i]+fb[i] > n)
	{
		printf("No\n"); return 0;
	}

	printf("Yes\n");

	reverse(b,b+n);

	int cnt = 0,val = -1,st = -1;

	rep(i,0,n)
	if(a[i] == b[i])
	{
		cnt++, val = a[i];

		if(st == -1)
		st = i;
	}

	// cout<<cnt<<endl;

	// rep(i,0,n)
	// cout<<a[i]<<" "; cout<<endl;

	// rep(i,0,n)
	// cout<<b[i]<<" "; cout<<endl;

	if(cnt)
	{
		vector<int> v;

		rep(i,0,n)
		if(a[i] != b[i] and a[i] != val and b[i] != val)
		v.pb(i);

		assert((int)v.size() >= cnt);

		rep(i,0,cnt)
		swap(b[v[i]],b[st++]);
	}

	rep(i,0,n)
	assert(a[i] != b[i]);

	rep(i,0,n)
	printf("%d ",b[i]);

	return 0;
}

Measured memory_bytes: 7472
N, K = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(K):
    tmp = [0] * (N+1)
    for i in range(N):
        tmp[max(0, i-A[i])] += 1
        tmp[min(N-1, i+A[i]) + 1] -= 1

    ans = [0]*N
    A[0] = tmp[0]
    for i in range(1, N):
        A[i] = A[i-1] + tmp[i]

    # print(*A)
    if sum(A) == N*N:
        break
print(*A)


Measured memory_bytes: 168960
h,w = map(int, raw_input().split())
snuke = None
for j in range(h):
  fs = raw_input().split()
  assert len(fs) == w
  for i, f in enumerate(fs):
    if f == 'snuke':
      snuke = '%s%d' % (chr(0x41+i), 1+j)
print snuke


Measured memory_bytes: 2568
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        a: i32,
        b: i32,
    }
    if 1 > a || a > 9 || 1 > b || b > 9 {
        println!("-1");
    }
    else {
        println!("{}", a * b);
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef string::const_iterator State;
class ParseError {};

int num[3];

int formula(State &begin){
  int res,res2;
  if(*begin == '('){
    begin++;
    res=formula(begin);
    if(*begin=='*'){
      begin++;
      res2=formula(begin);
       begin++;
      return min(res,res2);
    }else if(*begin=='+'){
      begin++;
      res2=formula(begin);
       begin++;
      return max(res,res2);
    }
   
  }
  if(*begin=='-'){
    begin++;
    return 2-formula(begin);
  }
  if(isdigit(*begin)){
    res=(*begin)-'0';
    begin++;
    return res;
  }
  if('P'<=(*begin) && (*begin)<='R'){
    res=num[(*begin)-'P'];
    begin++;
    return res;
  }
  
}




signed main(){
  cin.tie(0);	
  //ios::sync_with_stdio(false);
  while(1){
    string s;
    cin>>s;
    if(s==".") break;
    int ans=0;
    rep(i,3){
      num[0]=i;
      rep(j,3){
	num[1]=j;
	rep(k,3){
	  num[2]=k;
	  State begin=s.begin();
	  if(formula(begin)==2){
	    // cout<<num[0]<<" "<<num[1]<<" "<<num[2]<<endl;
	    ans++;
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
    

  return 0;
}



Measured memory_bytes: 3180
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T; cin >> N >> T;
	vector<int>v(T + 1, 0);
	rep(i, 0, N) {
		int l, r; cin >> l >> r;
		v[l]++; v[r]--;
	}
	rep(i, 1, T + 1)v[i] += v[i - 1];
	cout << *max_element(all(v)) << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,n;cin>>x>>n;
    vector<int> p(105,true);
    rep(i,n){
      int t;cin>>t;
      p[t] = false;
    }
    int mini = 1000,pnt = -1;
    vector<int> a(105,-1);
    rep(i,105){
      if(!p[i])continue;
      a[i] = abs(x-i);
      if(a[i]<mini){
        mini = a[i];
        pnt = i;
      }
    }
    cout<< pnt << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vi cnt(256);
    ll ans=1;
    forn(i, s.size()) {
        ans += i - cnt[s[i]];
        cnt[s[i]]++;
    }
    cout << ans << '\n';
}


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N; ll K, Nr[MAX_N];
vector<ll> Co;
int ix(ll k) {return upper_bound(ALL(Co), k) - Co.begin() - 1;} // equal less (max index)
struct BIT {
	ll A[MAX_N];
	BIT() {
		for(int i=0; i<MAX_N; i++) A[i] = 0;
	}
	void update(int p, ll v) {
		for(; p < MAX_N; p += p &(-p)) A[p] += v;
	}
	ll getSum(int p) {
		ll rv = 0; for(; p; p -= p & (-p)) rv += A[p];
		return rv;
	}
};
int main() {
	cin >> N >> K; 
//	N = 1e5; K = 0;
	for(int i=1; i<=N; i++) {
		scanf("%lld", &Nr[i]);
		Nr[i] -= K;
	}
	Co.push_back(-LINF);
	Co.push_back(0);
	for(int i=1; i<=N; i++) Nr[i] += Nr[i-1], Co.push_back(Nr[i]);
	sort(ALL(Co)); Co.erase(unique(ALL(Co)), Co.end());

	BIT bit; bit.update(ix(0), 1);
	ll ans = 0;
	for(int i=1; i<=N; i++) {
		ans += bit.getSum(ix(Nr[i]));
//		printf("%d : %lld\n", i, ans);
		bit.update(ix(Nr[i]), 1);
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 5488
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  // #define MAX 100001
  #define md 998244353
  #define add accumulate
  #define ll long long int
  #define ld long double
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  #define repa(a,n) for(int i=a;i<n;i++)
  const int MAX=1e5+5;
  const int mod=1e9+7;
  const int N=3e5+9;
  const long double eps=1e-9;
  const ld PI=acos(-1.0);
    ll dx[]={1,0,-1,0};
	ll dy[]={0,1,0,-1};
  //
  //
  int main(){
  	hs;
  	int n;	cin>>n;
  	ll arr[n];
  	rep(i,0,n)
  		cin>>arr[i];
  	bool flag=false;
  	ll k=MAX,sm=0,cnt=0;
  	rep(i,0,n){
  		if(arr[i]<0)
  			++cnt;
  		if(arr[i]==0)
  			flag=true;
  		sm+=abs(arr[i]);
  		k=min(k,abs(arr[i]));
  	}
  	if(cnt%2==0||flag)
  		cout<<sm;
  	else
  		cout<<(sm-2*k);
  	return 0;
  }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int32_t main()
{
	IOS;
	int n;
	cin>>n;
	for (int i = -1000; i <= 1000 ; ++i)
	{
		for(int j = -1000; j<= 1000; j++)
		{
			if(pow(i, 5) - pow(j, 5) == n)
			{
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
		/* code */
	}
}

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

namespace ABC123A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var c = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());

            var antena = new[] { a, b, c, d, e };

            foreach (var i in Enumerable.Range(0, antena.Length))
                foreach (var j in Enumerable.Range(i, antena.Length - i))
                {
                    if (antena[j] - antena[i] > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }

            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

int main()
{
    char s[5] = {};
    std::cin >> s;

    int high = (s[0] - '0') * 10 + (s[1] - '0');
    int low = (s[2] - '0') * 10 + (s[3] - '0');

    bool highIsMonth = (high >= 1 && high <= 12);
    bool lowIsMonth = (low >= 1 && low <= 12);

    if (highIsMonth)
    {
        if (lowIsMonth)
        {
            std::cout << "AMBIGUOUS" << std::endl;
        }
        else
        {
            std::cout << "MMYY" << std::endl;
        }
    }
    else
    {
        if (lowIsMonth)
        {
            std::cout << "YYMM" << std::endl;
        }
        else
        {
            std::cout << "NA" << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 760
#include <cstdio>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 105;
long double ans;
priority_queue<double,vector<double>,greater<double> > que;
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		double x;
		scanf("%lf",&x);
		que.push(x);
	}
	for(int i=1;i<n;i++)
	{
		double x =que.top();que.pop();
		double y = que.top(); que.pop();
		que.push((x+y) * 1.0 /2);
	}	
	printf("%lf",que.top());
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int ans = 0;
  int a;
  cin >> a;
  if ((a - a % 100) / 100 * 111 >= a) ans = (a - a % 100) / 100 * 111;
  else ans = (a - a % 100) / 100 * 111 + 111;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n, m; cin >> n >> m;
    vector<ll> p(n, 0);
    ll xmin = 1, xmax = n;
    for(ll i=0; i<m; ++i){
        ll l, r; cin >> l >> r; 
        xmin = max(xmin, l);
        xmax = min(xmax, r);
    }
    ll res = max((ll)0, xmax-xmin+1);
    cout << res << endl;
    return 0;
}

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

using namespace std;
using vvi = vector<vector<int>>;

const int INF = 100000000;

int main()
{
    int N, M, X;
    cin >> N >> M >> X;

    vector<int> c(N);
 
    vvi a(N, vector<int>(M));

    for (int i = 0; i < N; i++) {
        cin >> c.at(i);
        for (int j = 0; j < M; j++) {
            cin >> a.at(i).at(j);
        }
    }

    int result = INF;

    for (int bit = 0; bit < (1 << N); bit++) {
        int cost = 0;
        vector<int> d(M);
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                cost += c.at(i);
                for (int j = 0; j < M; j++) {
                    d.at(j) += a.at(i).at(j);
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < M; j++) {
            if (d.at(j) < X) flag = false;
        }
        if (flag)
            result = min(result, cost);
    }
    if (result == INF)
        cout << -1 << endl;
    else
        cout << result << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

template <class T>
constexpr T modp(T x, T y)
{
    return (y + x % y) % y;
}
template <class T>
constexpr T sq(T x)
{
    return x * x;
}
template <class T>
constexpr double divd(T x, T y)
{
    static_cast<double>(x) / static_cast<double>(y);
}

template <class T>
T nextInput()
{
    T t;
    cin >> t;
    return t;
}

#define netint nextInput<ll>()
#define netstr nextInput<string>()

template <class T>
void print(T&& t)
{
    cout << forward<T&&>(t) << endl;
}

void print(double t) { cout << fixed << setprecision(14) << t << endl; }

//

ll isprime[200000];
ll S[200000];

int main()
{
    //
    cbuf(isprime, -1);
    isprime[0] = isprime[1] = 0;
    rep(i, 2, 200000)
    {
        if (isprime[i] != -1) continue;
        isprime[i] = 1;
        for (ll j = i * 2; j < 200000; j += i) {
            isprime[j] = 0;
        }
    }

    rep(i, 2, 200000)
    {
        S[i] = S[i - 1];
        if (!isprime[i]) continue;
        if (isprime[(i + 1) / 2]) S[i]++;
    }

    ll Q = netint;
    rep(i, 0, Q)
    {
        ll l = netint, r = netint;
        cout << S[r] - S[l - 1] << endl;
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(ll x=y;x<=z;x++)
#define Red(x,y,z) for(ll x=y;x>=z;x--)
using namespace std;
const ll MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;ll ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
ll n,a[MAXN],b[MAXN],tot,s;pint p[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)a[i]=read(),b[i]=read(),p[i]=mk(max(a[i],b[i]),b[i]),tot+=a[i];
	sort(p+1,p+n+1,[](pint x,pint y){return x>y;});
	ll k=0;while(s<tot&&k<n)s+=p[++k].fir;
	ll fz=1,fm=1;
	Rep(i,1,n){
		ll w=tot-(s-p[min(i,k)].fir);
		if(w<=p[i].sec)if(fz*p[i].sec>fm*w)fz=w,fm=p[i].sec;
	}fz=fm-fz+(n-k)*fm,fm*=n;
	cout<<fz/__gcd(fz,fm)<<" "<<fm/__gcd(fz,fm)<<'\n';
	return 0;
}




Measured memory_bytes: 6728
def calc(a, b, c, d) :
  if c < a and b < d :
    return b - a
  elif a <= c <= b : 
    if d < b : 
      return d - c
    else : 
      return b - c
  elif a <= d <= b :
    return d - a
  else : 
    return 0

a, b, c, d = tuple(map(int, input().split()))

print(calc(a, b, c, d))


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

def bfs(n, t, v):
    for p in t[n]:
        if p not in visited:
            visited.add(p)
            bfs(p, t, v)

ans = 0
for i in range(M):
    t = {i:[] for i in range(1, N+1)}
    visited = set()
    for j in range(M):
        if i == j:
            continue
        a, b = ab[j]
        t[a].append(b)
        t[b].append(a)
    bfs(1, t, visited)
    if len(visited) != N:
        ans += 1

print(ans)

Measured memory_bytes: 42220
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define MOD 1000000007
typedef long long ll;
int N;
ll dp[110][5][5][5];


// AGC ACG GAC
// A C G T 
ll solution(int pos, int b1, int b2,int b3) {
	ll &ret = dp[pos][b1][b2][b3];
	if (pos == N) {
		return 1;
	}
	if (ret != -1) return ret;
	ret = 0;
	if (b1 == 2 && b2 == 1) {
		for (int i = 1; i <= 4; i++) {
			if (i == 3) continue;
			ret += solution(pos + 1, i, b1,b2);
			ret %= MOD;
		}
	}
	else if ((b1 == 1 && b2 == 3) || (b1 == 3 && b2 == 1)) {
		for (int i = 1; i <= 4; i++) {
			if (i == 2) continue;
			ret += solution(pos + 1, i, b1, b2);
			ret %= MOD;
		}
	}
	else if ((b1 == 3 || b2 == 3) && b3==1) {
		for (int i = 1; i <= 4; i++) {
			if (i == 2) continue;
			ret += solution(pos + 1, i, b1, b2);
			ret %= MOD;
		}	
	}
	else {
		for (int i = 1; i <= 4; i++) {
			ret += solution(pos + 1, i, b1, b2);
			ret %= MOD;
		}
	}
	return ret;
}



int main() {
	memset(dp, -1, sizeof(dp));
	cin >> N;
	ll sol = 0;

	sol = solution(0, 0, 0, 0) % MOD;
	cout << sol << endl;


}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

int n, pos ;
vector<int> pre, in, post;

void rec(int l, int r){
  if(l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(),find(in.begin(), in.end(), root));
  rec(l, m);
  rec(m + 1, r);
  post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0, pre.size());
  for ( int i = 0; i < n; i++ ){
    if(i) cout << " ";
    cout << post[i];
  }
  cout << endl;
}

int main(){
  
  int k;
  cin >> n;

  for(int i = 0; i < n ; i++){
    cin >> k;
    pre.push_back(k);
  }
rep(i,n){
  cin >> k;
  in.push_back(k);
}

solve();

return 0;
}


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

int main() {
	// your code goes here
	int a[4];
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	sort(a,a+4);
	if(a[0]==a[1]&&a[2]==a[3]) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

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

int main() {
    long long int a, b;
    cin>>a>>b;
    if((a+b) % 2 != 0){
        cout<<"IMPOSSIBLE"<<endl;
    } else {
        long long int mid = (a + b)/2;
        cout<<mid<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
import math

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d == 0:
        return 0, 0, 0
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / (-d)
    r = (x - x1) ** 2 + (y - y1) ** 2
    return x, y, r

def get_circle_center_and_radius_two(x1, y1, x2, y2):
    x = (x1 + x2) / 2
    y = (y1 + y2) / 2
    r = (x - x1) ** 2 + (y - y1) ** 2
    return x, y, r

def check_if_all_included(x, y, r, points, v):
    for point in points:
        if point in v:
            continue
        
        dist = (x - point[0]) ** 2 + (y - point[1]) ** 2
        if dist > r:
            break
    else:
        return True
    
    return False
            

n = int(input())
points = []
for i in range(n):
    points.append(list(map(int, input().split())))

r_min = 1000000
    
for v in itertools.combinations(points, 2):
    x1, y1, x2, y2 = v[0][0], v[0][1], v[1][0], v[1][1]
    x, y, r = get_circle_center_and_radius_two(x1, y1, x2, y2)
    if check_if_all_included(x, y, r, points, v) and r < r_min:
        r_min = r
    
for v in itertools.combinations(points, 3):
    x1, y1, x2, y2, x3, y3 = v[0][0], v[0][1], v[1][0], v[1][1], v[2][0], v[2][1]
    x, y, r = get_circle_center_and_radius(x1, y1, x2, y2, x3, y3)
    if r == 0:
        continue
    
    if check_if_all_included(x, y, r, points, v) and r < r_min:
        r_min = r

print(math.sqrt(r_min))

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    string s;
    cin >> s;
    ll n = s.size();

    vl v(26);
    rep(i, n) {
        v[s[i] - 'a']++;
    }
    
    ll ans = n*(n-1)/2 + 1;
    rep(i, 26) {
        ans -= v[i]*(v[i]-1)/2;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){

    int L,R,d;
    int result = 0;
    scanf("%d %d %d",&L,&R,&d);

    for(int i=L; i<=R; i++){
        if(i%d==0)result++;
    }

    printf("%d",result);

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define rep(i,n) for(i=0;i<n;i++)
#define PI 3.14159265358979323846264338327950L
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int a,i,sum=0;
    rep(i,m){
        scanf("%d",&a);
        sum=sum+a;
    }
    if(n-sum<0) printf("-1");
    else printf("%d",n-sum);
    return 0;
}

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

using namespace std;

vector<int> lengths;


int bsearch(int value, int start, int end) {

   // cout << value << " (" << start << "," << end << "\n";

    if (end == start)
        return -1;
    
    if (end-start == 1) {
        if (lengths[start] < value)
            return start;
        return -1; 
    }

    int mid = (start+end) / 2;
    int mid_value = lengths[mid];

    if (mid_value >= value)
        return bsearch(value, start, mid);
    else 
        return bsearch(value, mid, end);
}

int main(){
    int N;
    cin >> N;

    lengths = vector<int>(N);

    for(int i = 0; i < N; i++) {
        cin >> lengths[i];
    }

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

    long long int count = 0;

    for (int i = 0; i < (int)lengths.size(); i++) {
        int one = lengths[i];
        for (int j = i+1; j < (int)lengths.size(); j++) {
            int two = lengths[j];
        
            int part = one+two;
//cout << "one=" << one << " two=" << two << "\n";
            int idx = bsearch(part, j+1, lengths.size());

            if (idx != -1) {
                int ways = idx - j;
                count += ways;
  //              cout << " ways=" << ways << "\n";
            }
            
        }
    }

    cout << count << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

bool f(string s) {
  sort(rng(s));
  return (s[0] == s.back());
}

int main() {
  string s;
  cin>>s;
  if (f(s.substr(0,3)) || f(s.substr(1,3))) puts("Yes");
  else puts("No");
  return 0;
}






















Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int cnt=0,A,B,C;
  scanf("%d%d",&A,&B);
  C=A+B;
  if(A%3==0)cnt++;
  else if(B%3==0)cnt++;
  else if(C%3==0)cnt++;
  if(cnt>0)printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}


Measured memory_bytes: 128
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strargs;
		int n, x, i, j, k, sum;
		
		do {
			sum = 0;			
			strargs = br.readLine().split("\\s+");
			n = Integer.parseInt(strargs[0]);
			x = Integer.parseInt(strargs[1]); 
			
			for (i = 1; i <= n; i++) {
				for (j = i; j <= n; j++) {
					for (k = j; k <= n; k++) {
						if ((i + j + k) == x && i != j && j != k && i != k) sum++;
					}
				}
			}
			
			if (n == 0 && x ==0) break;
			
			System.out.println(sum);

		} while (true);
	}
}

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

using namespace std;

int main() {
	int s, r;
	double x = 0, y = 0, rad = M_PI / 2.0;
	while (scanf("%d,%d", &s, &r), s || r) {
		x += s * cos(rad);
		y += s * sin(rad);
		rad -= r * M_PI / 180;   // 時計回り
	}
	cout << (int)x << endl << (int)y << endl;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
int main(){
	int a,b;
	char op;
	while(1){
		cin>>a>>op>>b;
		if(op=='+'){
			cout<<a+b<<endl;
		}else if(op=='-'){
			cout<<a-b<<endl;
		}else if(op=='*'){
			cout<<a*b<<endl;
		}else if(op=='/'){
			cout<<a/b<<endl;
		}else if(op=='?'){
			break;
		}
	}
	return 0;
}	

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

int main() {
  long long n, m;
  cin >> n >> m;
  priority_queue<long long> q;
  long long a;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    q.push(a);
  }
  long long b;
  for (long long i = 0; i < m; i++) {
    b = q.top() / 2;
    q.pop();
    q.push(b);
  }
  long long sum = 0;
  while (q.size() > 0 && q.top() > 0) {
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define MAXN 1100000
#define MOD 1000000007
using namespace std;
template <typename T> inline void read(T &s)
{
	s = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) s = ((s+(s<<2))<<1)+ch-'0',ch = getchar();
}
int f[MAXN][3],n,Ans,fac[MAXN],Inv[MAXN];
inline int Mod(int u){return u < MOD?u:u-MOD;}
inline int Fast_Power(int x,int k = MOD - 2)
{
	int Sum = 1;
	while(k)
	{
		if(k&1) Sum = 1ll * Sum * x %  MOD;
		x = 1ll * x * x % MOD,k >>= 1;
	}
	return Sum;
}
inline int C(int u,int v){return 1ll * fac[u] * Inv[v] % MOD * Inv[u-v] % MOD;}
int main()
{
	read(n),fac[0] = fac[1] = Inv[0] = Inv[1] = 1;
	for(int i = 2;i<=n;++i) fac[i] = 1ll * fac[i-1] * i % MOD,Inv[i] = 1ll * (MOD - MOD/i) * Inv[MOD%i] % MOD;
	for(int i = 2;i<=n;++i) Inv[i] = 1ll * Inv[i] * Inv[i-1] % MOD;
	f[0][0] = 1;
	for(int i = 1;i<=n;++i) for(int j = 0;j<3;++j) for(int k = 0;k<3;++k)
		if(j != k) f[i][j] = Mod(f[i][j] + f[i-1][k]);
	for(int i = 1;i<=n;++i) Ans = Mod(Ans + 1ll * Fast_Power(1ll*n*i%MOD) * f[i][2] % MOD * C(n,i) % MOD);
	printf("%lld\n",1ll * Ans * Fast_Power(Fast_Power(3,n)) % MOD);
	return 0;
}

Measured memory_bytes: 20736
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}*//*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*//*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}*//*
bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*//*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
	long double a;
	long double b;
	cin>>a>>b;
	ll ans=(ll)a*b;
	cout<<ans<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;

int main()
{
    int N, Q;
    cin>>N>>Q;
    vector<int> c(N);
    for (int i=0; i<N; i++)
        //cin>>c[i],
        scanf("%d", &c[i]),
        c[i]--;
    vector<int> L(Q), R(Q);
    for (int i=0; i<Q; i++)
        //cin>>L[i]>>R[i],
        scanf("%d%d", &L[i], &R[i]),
        L[i]--;

    //int N = 500000;
    //int Q = 500000;
    //vector<int> c(N);
    //for (int i=0; i<N; i++)
    //    c[i] = rand()%N;
    //vector<int> L(Q), R(Q);
    //for (int i=0; i<Q; i++)
    //{
    //    while (true)
    //    {
    //        L[i] = rand()%N;
    //        R[i] = rand()%N+1;
    //        if (L[i]<R[i])
    //            break;
    //    }
    //}

    int M = 0;
    while (M*M<N)
        M++;

    vector<int> QI(Q);
    for (int i=0; i<Q; i++)
        QI[i] = i;

    sort(QI.begin(), QI.end(), [&](int x, int y)
        {
            if (L[x]/M<L[y]/M)
                return true;
            if (L[x]/M==L[y]/M && R[x]<R[y])
                return true;
            return false;
        });

    //for (int i=0; i<Q; i++)
    //    cout<<" "<<L[QI[i]]<<" "<<R[QI[i]]<<endl;

    vector<int> A(Q);
    vector<int> C(N);
    int a = 0;
    int l = 0;
    int r = 0;
    for (int i=0; i<Q; i++)
    {
        int q = QI[i];
        while (l>L[q])
        {
            l--;
            C[c[l]]++;
            if (C[c[l]]==1)
                a++;
        }
        while (l<L[q])
        {
            C[c[l]]--;
            if (C[c[l]]==0)
                a--;
            l++;
        }
        while (r>R[q])
        {
            r--;
            C[c[r]]--;
            if (C[c[r]]==0)
                a--;
        }
        while (r<R[q])
        {
            C[c[r]]++;
            if (C[c[r]]==1)
                a++;
            r++;
        }
        A[q] = a;
    }
    for (int i=0; i<Q; i++)
        //cout<<A[i]<<endl;
        printf("%d\n", A[i]);
}


Measured memory_bytes: 15492
def gcd(a, b):
    """a, bの最大公約数(greatest common divisor:GCD)を求める"""
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める"""
    return (a * b) // gcd(a, b)


n, m = map(int, input().split())
s = input()
t = input()
gcd_nm = gcd(n, m)
s_num = n // gcd_nm
t_num = m // gcd_nm

for i in range(gcd_nm):
    if s[i*s_num] == t[i*t_num]:
        continue
    else:
        print(-1)
        break
else:
    print(lcm(n, m))

Measured memory_bytes: 39536
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    final int k = sc.nextInt();
    final String s = sc.next();
    if (s.length() <= k) {
      System.out.println(s);
    } else {
      System.out.println(s.substring(0, k) + "...");
    }
  }
}


Measured memory_bytes: 38660
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int grave = 0;

void solve(int p[], int num, char inp){
    if(inp == 'S'){
        grave+= p[num];
        grave++;
        p[num] = 0;
    }else if(inp == 'L'){
        p[num]+= grave;
        p[num]++;
        grave = 0;
    }else if(inp == 'M'){
        p[num]++;
    }
}

int main(){
    int n;
    while(cin >> n, n){
        int p[15] = {0};
        grave = 0;
        string str;
        cin >> str;
        rep(i,str.size()){
            solve(p,i % n, str[i]);
        }
        rep(i,n){
            for(int j = n - 1; j > i; j--){
                if(p[j] < p[j-1]){
                    int gar = p[j]; p[j] = p[j-1]; p[j-1] = gar;
                }
            }
        }
        rep(i,n){
            cout << p[i] << ' ';
        }
        cout << grave << endl;
    }
}

Measured memory_bytes: 1208
//・N - 1回で全部できる
//・N - 2回以下なら巡回シフト（自身除く. 1つの大きな輪っか.）以外はできる。
//〇N - 1回でできるかは、sort(A), sort(B)を下から比較すればよい。
//ここからが山場。即座にN - 2回以下の問題を考えると難しいので、N - 1回でできるか？の判定を利用する。
//
//☆重要な観察として、〇で作る対応を図示。具体的には、Ai, Biの小さいもの同士をペアにする。
//☆重要な考察として、この時点で輪が2つ以上ならOK. つまり、1つの大きな輪っかができた場合のみ問題。
//例えばA = [2 3 4 1] B = [2 2 4 4]はわっかができる例.
//・この場合は、どこか2つの行き先をswapできればOK. 逆にOKなら、swapの可換性・サイクル数の増減高々1より
//「OKな対応→1回操作→1つの輪」が存在するはずなので、2つの行き先をswapできる。(たぶん)
//
//・2つの選び方だが、Ai < AjとしてAiが同じならAjは小さい方が良いはずなので、Ai小さい順に並べたとき
//  隣り合う2つのAi, Ai+1の行き先交換だけを考えれば良い。
//・Ai昇順にペア(Ai, Bi)をソートしておけば、実装しやすく、ソートでO(NlogN), ソート以外はO(N).

#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
int a[100000], b[100000];

int main() {
	int i;
	
	cin >> n;
	
	vector<P> pa(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) pa[i] = P(a[i], b[i]);
	
	sort(pa.begin(), pa.end());
	rep(i, n) { a[i] = pa[i].first; b[i] = pa[i].second; }
	
	vector<P> bpos(n);
	rep(i, n) {
		bpos[i] = P(b[i], i);
	}
	sort(bpos.begin(), bpos.end());
	
	//小さい方から対応づけた場合のチェック. (N - 1回でできるか？)
	rep(i, n) {
		if (a[i] > b[bpos[i].second]) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	int pos = 0, cnt = 0;
	do {
		cnt++;
		pos = bpos[pos].second;
	} while (pos != 0);
	
	//既に2つ以上のサイクルになっている
	if (cnt < n) {
		cout << "Yes" << endl;
		return 0;
	}
	
	//入れ替えチェック
	for (i = 0; i + 1 < n; i++) {
		if (a[i + 1] <= b[bpos[i].second]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

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

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

    vector<int> xs(n, 0);
    vector<bool> solve(n, false);

    for (int i = 0; i < m; ++i) {
        int p; string s;
        cin >> p >> s;
        p--;

        if (!solve[p]) {
            if (s == "WA") xs[p]++;
            else solve[p] = true;
        }



    }

    int corrects = 0;
    int penalties = 0;

    for (int i = 0; i < n; ++i) {
        if (solve[i]) {
            corrects++;
            penalties += xs[i];
        }
    }

    cout << corrects << " " << penalties << '\n';

    return 0;
}


Measured memory_bytes: 640
N,M=map(int,input().split())
XYZ=[list(map(int,input().split())) for i in range(N)]
pm={'0':1,'1':-1}
ans=0
for i in range(2**3):
  ibin = format(i, '03b')
  tmp=sorted([pm[ibin[0]]*x+pm[ibin[1]]*y+pm[ibin[2]]*z for x,y,z in XYZ],reverse=True)
  ans=sum(tmp[:M]) if ans<sum(tmp[:M]) else ans
print(ans)

Measured memory_bytes: 3360
def Is_honest(x, honest, n):
    for i in range(n):
        honest[i] = (x%2 == 1)
        x //= 2


def checker(honest, da, n):
    for i in range(n):
        if honest[i]:
            size = len(da[i])
            for j in range(size):
                ok = (da[i][j][1] == 1)
                if honest[da[i][j][0]]^ok:
                    return False
    return True

def counter(honest):
    ret = 0
    for i in honest:
        if i:
            ret += 1
    return ret

n = int(input())
da = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        da[i].append(list(map(int,input().split())))
        da[i][-1][0] -= 1

ans = 0
honest = [False for i in range(n)]
m = 2 ** n

for i in range(m):
    Is_honest(i, honest, n)
    if checker(honest, da, n):
        ans = max(ans, counter(honest))

print(ans)

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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, ( $($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        T : usize,
        x : usize,
    }
    println!("{}", (T as f64/x as f64));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <vector>

int main() {
	int X;
	int Y;

	std::cin >> X >> Y;

	if (Y % 2 != 0) {
		printf("No");
	}
	else if (X * 4 < Y || Y < X * 2) {
		printf("No");
	}
	else {
		printf("Yes");
	}

	return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int leapyear(int year){
  return (year%4!=0||(year%100==0&&year%400!=0) ?0:1);
}
int main(){
int y1,m1,d1,y2,m2,d2;
while(cin>>y1>>m1>>d1>>y2>>m2>>d2,y1>0&&y2>0&&m1>0&&m2>0&&d1>0&&d2>0){
long long int sum=-d1;
while(1){
if(y1==y2&&m1==m2){sum+=d2;break;}
if(y1<=y2){
    switch(m1){
    case  1:
    case  3:
    case  5:
    case  7:
    case  8:
    case 10:
    case 12:sum+=31;break;
    case  4:
    case  6:
    case  9:
    case 11:sum+=30;break;
    case  2:sum+=28+leapyear(y1);break;
    }
	m1++;
	if(m1>12){y1++;m1=1;}
}
}
cout<<sum<<endl;
}
}

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

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

int main() {
#ifdef cute
	freopen("in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);


	int r;
	cin >> r;
	cout << r*r;

#ifdef cute
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]

w = 'abcdefghijklmnopqrstuvwxyz'
ans = ''

for i in w:
    c = 100
    for j in range(n):
        c = min(c, s[j].count(i))
    ans += i*c

print(ans)

Measured memory_bytes: 3060
a, b, n = gets.to_s.split.map{|t|t.to_i}

def f(x,a,b)
  ( a * x ) / b - a * ( x / b )
end

if b == 1
  puts 0
  exit
end

# 1.upto(n) do |i|
  
#   p [i,f(i,a,b)]
  
# end

m = [b-1, n].min
ans = f(m, a, b)

puts ans

Measured memory_bytes: 14340
/*
* @Author: kabbo
* @Date:   2020-06-14 17:50:39
* @Last Modified by:   kabbo
* @Last Modified time: 2020-06-14 18:40:22
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
void solve() {
	int k, n;
	cin >> k >> n;
	if (n == 0) {
		cout << k << endl;
		return;
	}
	vector<int>v(n);
	map<int, int>mp;
	for (auto& x : v)
		cin >> x, mp[x]++;
	vector<int>diff;
	for (auto& x : v) {
		diff.emplace_back(abs(k - x));
	}
	sort(diff.begin(), diff.end());
	int arr[105]; memset(arr, 0, sizeof(arr));
	for (auto& x : diff)
		arr[x] = 1;
	for (int i(0); i <= 100; ++i) {
		if (mp.count(k - i) == 0) {
			cout << k - i << endl;
			return ;
		}
		else if (mp.count(k + i) == 0) {
			cout << k + i << endl;
			return;
		}
	}


}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 3800