akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

vector<pi> ar;

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

    ll n;
    cin>>n;
    for(ll i=0;i<n;++i)
    {
        ll x,l;
        cin>>x>>l;
        ar.pb(mp(x-l,x+l));
    }
    sort(ar.begin(),ar.end());

    ll ans=0;
    ll end=ar[0].second;
    for(ll i=1;i<n;++i){
        if(ar[i].first<end){
            end=min(end,ar[i].second);
            ++ans;
        }
        else{
            end=ar[i].second;
        }
    }
    ans=n-ans;
    cout<<ans;

    return (0);
}


Measured memory_bytes: 2420
using System;

namespace ConsoleApp__ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            double radiusr = double.Parse(Console.ReadLine());
            double circumference = 2 * radiusr * Math.PI;
            double area = radiusr * radiusr * Math.PI;

            Console.WriteLine("{0:F6} {1:F6}", area, circumference);
        }
    }
}



Measured memory_bytes: 9316
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#include <iterator>
#define ll long long
#define mp make_pair

using namespace std;

const int M = 1000000007;

ll pot(ll A, ll B){
   ll R = 1;
   while (B){
		 if (B&1) R *= A;
		 R %= M;
		 A *= A; A %= M;
		 B >>= 1;
   }
   return R;
}

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int a, b, c;
	
	cin >> a >> b >> c;
	
	if (a+b+c >= 22) cout << "bust";
	else cout << "win";
	
	
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200][200];
int main()
{
    int n;
    cin>>n;
    string s;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=0;j<s.length();j++)
        {
            a[i][s[j]-'a']++;
        }
    }
    string str="";
    for(int i=0;i<=25;i++)
    {
        int cnt = 1000010;
        for(int j=1;j<=n;j++)
        {
            cnt = min(cnt,a[j][i]);
        }
        if(cnt){
            for(int j=1;j<=cnt;j++){
                str += i+'a';
            }
        }
    }
    cout<<str<<endl;
    return 0;
}


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

int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int flag;
    a + b > c + d ?cout << "Left" << endl : a+b==c+d?cout << "Balanced" << endl:cout<<"Right"<<endl;
    
    
    return 0;
}

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

string s;

int main()
{
	cin >> s;
	bool ok = s[0] == 'A';
	int got = 0;
	int ind = -1;
	for (int i = 2; i + 1 < s.length(); i++) {
		got += s[i] == 'C';
		if (s[i] == 'C') ind = i;
	}
	if (got != 1) ok = false;
	for (int i = 1; i < s.length(); i++)
		if (i != ind && !islower(s[i])) ok = false;
	printf("%s\n", ok? "AC": "WA");
	return 0;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

template <typename Arg1>
void bug(Arg1&& arg1)
{ cout<<"->"<<arg1<<endl; }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll powmod(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return powmod(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

void yes(){pn("Yes");}
void no(){pn("No");}
void bug(){cout<<"here"<<endl;}

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vs vector<string>
#define vvl vector<vl>
#define vvs vector<vs>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

void solve()
{
	ll i,j;
	ll n,k;
	cin>>n>>k;
	ll l=1,r=0;
	vl v(n);
	f0(i,n)
	{
		cin>>v[i];
	}
	sort(all(v));
	r=v[n-1];
	ll ans = r;
	while(l<=r)
	{
		ll mid = l+(r-l)/2;
		// bug(mid);
		ll temp=0;
		f0(i,n)
		{
				temp += (v[i]+mid-1)/mid;
				temp--;
		}
		// bug(temp);
		if(temp<=k)
		{
			ans=min(ans,mid);
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	pn(ans);
}

int main()
{
	#ifdef Deeksha
		// freopen("../Downloads/validation_input.txt", "r", stdin);
		freopen("../Downloads/_input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



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

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

    n = n - (n / 10) * 10;
    
    if (n == 3) cout << "bon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

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

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

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int xorValue = 0;
  rep(i, n) {
    xorValue ^= a[i];
  }
  cout << (xorValue == 0 ? "Yes" : "No") << endl;

  return 0;
}


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

int can[50][50][101];
typedef pair<int, int> P;
vector<int> G[50];

void bfs(int s){
	queue<P> q;
	q.push({ s, 0 });
	can[s][0][0] = 1;
	while(q.size()){
		int v = q.front().first, d = q.front().second;
		q.pop();
		if(d >= 101) return;
		for(auto c : G[v]){
			if(!can[s][c][d + 1]){
				can[s][c][d + 1] = 1;
				q.push({ c, d + 1 });
			}
		}
	}
}

int N, M;
int a[3];
int dp[50];
const int INF = 1 << 25;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N >> M;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	for(int i = 0; i < M; i++){
		int u, v;
		cin >> u >> v;
		u--, v--;
		G[u].push_back(v);
	}

	for(int i = 0; i < N; i++){
		bfs(i);
		dp[i] = INF;
	}
	dp[N - 1] = 0;

	bool update = true;
	while(update){
		update = false;
		for(int i = 0; i < N; i++){
			int maxd = 0;
			for(int j = 0; j < 3; j++){
				int d = a[j];
				int mind = 1e9;
				for(int k = 0; k < N; k++){
					// i -> k
					if(can[i][k][d]){
						mind = min(mind, dp[k] + 1);
					}
				}
				maxd = max(maxd, mind);
			}
			if(dp[i] > maxd){
				dp[i] = maxd;
				update = true;
			}
		}
	}

	int res = dp[0];
	if(res >= INF){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		cout << res << endl;
	}
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int INF = 1e9;
int MOD=10000;
int dp[110][3][2];
int main(){
	int N,K,a,b;
	int d[110];
	memset(d,-1,sizeof(d));
	cin>>N>>K;
	REP(i,K){
		cin>>a>>b;a--;b--;
		d[a]=b;
	}
	if(d[0]==-1){
		dp[0][0][0]=dp[0][1][0]=dp[0][2][0]=1;
	}else{
		dp[0][d[0]][0]=1;
	}
	for(int i=1;i<N;i++){
		if(d[i]!=-1){
			REP(j,3)if(j!=d[i])dp[i][d[i]][0]+=dp[i-1][j][0]+dp[i-1][j][1];
			dp[i][d[i]][1]+=dp[i-1][d[i]][0];
		}else{
			REP(j,3)REP(k,3)if(j!=k)dp[i][j][0]+=dp[i-1][k][0]+dp[i-1][k][1];
			REP(j,3)dp[i][j][1]+=dp[i-1][j][0];
		}
		REP(j,3)REP(k,2)dp[i][j][k]%=MOD;
	}
	int ans=0;
	REP(i,3)REP(k,2)ans+=dp[N-1][i][k];
	cout<<ans%MOD<<endl;
}

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



int main() {
	long long int R, D, X;
	cin >> R >> D >> X;
	for(size_t i = 0; i < 10; i++) {
		X = R * X - D;
		cout << X << endl;
	}
}



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

int main() {
	char a;
	cin >> a;
	if (islower(a)) {
		cout << 'a' << endl;	
	}
	else{
		cout << 'A' << endl;
	}

	return 0;
}


Measured memory_bytes: 3556
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0555?year=2011

#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        string t;
        cin >> t;
        t += t;

        for (int j = 0; j < t.size() - s.size(); ++j) {
            if (s == t.substr(j, s.size())) {
                ans++;
                break;
            }
        }
    }

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

/*
 *
 */


Measured memory_bytes: 3164
use std::cmp;

const INF: u64 = std::u64::MAX / 2;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut keys = vec![];
    for _ in 0..m {
        let a: u64 = sc.read();
        let b: usize = sc.read();
        let mut mask = 0;
        for _ in 0..b {
            let c = sc.read::<usize>() - 1;
            mask |= (1 << c);
        }
        keys.push((a, mask));
    }

    let mut dp = vec![INF; 1 << n];
    dp[0] = 0;
    for (price, key_mask) in keys.into_iter() {
        for mask in 0..(1 << n) {
            let next = mask | key_mask;
            dp[next] = cmp::min(dp[next], dp[mask] + price);
        }
    }

    let ans = dp[(1 << n) - 1];
    if ans == INF {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
   
    int n;
    cin>>n;
    int ans=0;
    
    if(n>3){
        
        for(int i=0;n>0;i++){
            
            if(n%4==0||n%7==0){
                ans=1;
                break;
            }
            n=n-7;
        }
        
    }
    
    if(ans==1){
        cout<<"Yes"<<endl;
    }else{cout<<"No"<<endl;}
    
    return 0;
    }


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  int A[N];
  pint res[N-1];
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  int ans=A[N-1];
  int mini=A[0],maxi=A[N-1];
  if(maxi<0){
    rep(i,N-1){
      res[i].first=ans,res[i].second=A[i];
      ans-=A[i];
    }
  }
  else if(mini>0){
    rep(i,N-2){
      res[i].first=A[0],res[i].second=A[i+1];
      A[0]-=A[i+1];
    }
    res[N-2].first=A[N-1],res[N-2].second=A[0];
    ans-=A[0];
  }
  else{
    int np=1,pp=N-2,count=0;
    while(A[np]<=0 && count<N-1){
      res[count].first=ans,res[count].second=A[np];
      ans-=A[np];
      np++;
      count++;
    }
    while(A[pp]>0 && count<N-1){
      res[count].first=A[0],res[count].second=A[pp];
      A[0]-=A[pp];
      pp--;
      count++;
    }
    res[N-2].first=ans,res[N-2].second=A[0];
    ans-=A[0];
  }
  cout << ans << endl;
  rep(i,N-1) cout << res[i].first << " " << res[i].second << endl;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};


int main(){
    int N,M;
    cin >> N >> M;
    int check[M][N];
    for(int i = 0 ; i < M; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int s;
            cin >> s;
            s--;
            check[i][s] = 1;
        }
    }
    vector<int> bi(M);
    for(int i = 0; i < M; i++) cin >> bi[i];
    int cnt = 0;
    for(int bit = 0; bit < 1 << N; bit++){
        int temp = bit;
        vector<int> swi;
        int ind = 0;
        while(temp > 0){
            if(temp & 1) swi.emplace_back(ind);
            ind++;
            temp >>= 1;
        }
        vector<int> on(M,0);
        for(auto m : swi){
            for(int i = 0; i < M; i++){
                if(check[i][m] == 1) on[i]++; 
            }
        }
        bool res = true;
        for(int i = 0; i < M; i++){
            if(on[i] % 2 != bi[i]) res = false;
        }
        if(res) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {

  int N;
  cin >> N;
  
  bool unko = false;
  for(int i = 0; i < 100; i++) {
    for(int j = 0; j < 100; j++) {
      if(4 * i + 7 * j == N) {
        unko = true;
        break;
      }
    }
  }
  if(unko) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/* FUCK U*/
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
using namespace std;
void solve(){
    int n,k,count;
   
    cin>>n>>k;
    for(int i=n;i<=k;++i){
       string str=to_string(i);
        if(str.at(0)==str.at(4) && str.at(1)== str.at(3))
            count++;
    }
    cout<<count<<endl;    

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

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
typedef pair<int,int> par;
map<int,set<par> >a,b;
map<int,vector<par> >vx,vy;
int x[maxn],q[maxn],l,r,y[maxn],n,A,B;
long long ans;
void del(int x,int y,int bh){
	a[x].erase(par(y,bh)),b[y].erase(par(x,bh));
}
void insx(int p,int l,int r){
	ans+=upper_bound(vx[p].begin(),vx[p].end(),par(r,n+1))-lower_bound(vx[p].begin(),vx[p].end(),par(l,0));
	set<par>::iterator bg=a[p].lower_bound(par(l,0));
	set<par>::iterator ed=a[p].upper_bound(par(r,n+1));
//	printf("[%d,%d,(%d,%d)]",bg->second,ed->second,l,r);
	while(bg!=ed){
//		printf("[ok,%d]",r);
		set<par>::iterator it=bg;it++;
		q[::r++]=bg->second,del(p,bg->first,bg->second),bg=it;
	}
}

void insy(int p,int l,int r){
	ans+=upper_bound(vy[p].begin(),vy[p].end(),par(r,n+1))-lower_bound(vy[p].begin(),vy[p].end(),par(l,0));
	set<par>::iterator bg=b[p].lower_bound(par(l,0));
	set<par>::iterator ed=b[p].upper_bound(par(r,n+1));
	while(bg!=ed){
		set<par>::iterator it=bg;it++;
		q[::r++]=bg->second,del(bg->first,p,bg->second),bg=it;
	}
}
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x[i],&y[i]);
		a[x[i]+y[i]].insert(par(x[i]-y[i],i));
		b[x[i]-y[i]].insert(par(x[i]+y[i],i));
	}
	for(map<int,set<par> >::iterator mit=a.begin();mit!=a.end();mit++)
		for(set<par>::iterator it=mit->second.begin();it!=mit->second.end();it++)
			vx[mit->first].push_back(*it);
	for(map<int,set<par> >::iterator mit=b.begin();mit!=b.end();mit++)
		for(set<par>::iterator it=mit->second.begin();it!=mit->second.end();it++)
			vy[mit->first].push_back(*it);
	q[r++]=A,del(x[A]+y[A],x[A]-y[A],A);
	int d=abs(x[A]-x[B])+abs(y[A]-y[B]);
	while(l<r){
		int nw=q[l++];
//		printf("[(%d,%d)]\n",x[nw],y[nw]);
		insx(x[nw]+y[nw]+d,x[nw]-y[nw]-(d-1),x[nw]-y[nw]+(d-1));
		insx(x[nw]+y[nw]-d,x[nw]-y[nw]-(d-1),x[nw]-y[nw]+(d-1));
		insy(x[nw]-y[nw]+d,x[nw]+y[nw]-d,x[nw]+y[nw]+d);
		insy(x[nw]-y[nw]-d,x[nw]+y[nw]-d,x[nw]+y[nw]+d);
//		printf("{%d,%d}",l,r);
	}
	printf("%lld",ans/2);
}

Measured memory_bytes: 78080
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        t: chars,
    }
    let mut result = 0;
    let mut checked = vec![false; n];
    for i in 0..n {
        if checked[i] {
            continue;
        }
        let mut j = i;
        let mut count = 0;
        while j < n && t[i] == t[j] {
            checked[j] = true;
            count += 1;
            j += k;
        }
        let count = (count + 1) / 2;
        if t[i] == 'r' {
            result += count * p;
        } else if t[i] == 's' {
            result += count * r;
        } else {
            result += count * s;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	string s;
	cin>>s;
	int d;
	cin>>d;
	int n = s.length();
	ll dp[n][2][d];
	int i,j,k;
	for(i=n-1;i>=0;i--)
	{
		for(j=0;j<d;j++)
		{
			if(i==n-1)
			{
				dp[n-1][0][j] = 0;
				dp[n-1][1][j] = 0;
				for(k=0;k<=9;k++)
					dp[n-1][0][j] += (k%d==j);
				for(k=0;k<=s[n-1]-'0';k++)
					dp[n-1][1][j] += (k%d==j);
			}
			else
			{
				dp[i][0][j] = 0;
				for(k = 0;k<=9;k++)
				{
					dp[i][0][j] += dp[i+1][0][((j-k)%d+d)%d];
					dp[i][0][j] %= M;
				}
				dp[i][1][j] = 0;
				for(k = 0;k<s[i]-'0';k++)
				{
					dp[i][1][j] += dp[i+1][0][((j-k)%d+d)%d];
					dp[i][1][j] %= M;
				}
				dp[i][1][j] += dp[i+1][1][((j-k)%d+d)%d];
				dp[i][1][j] %= M;
			}
		}
	}


	cout<<(dp[0][1][0]-1+M)%M;

	return 0;

}


Measured memory_bytes: 19196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int h,w,k;
  cin >>h>>w>>k;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h){
    rep(j,w)
      cin >> c.at(i).at(j);
  }
  int ans=0;
  for (int tmp = 0; tmp < (1 << h); tmp++) {
    bitset<6> s(tmp);
    for(int ksk=0;ksk<(1<<w);ksk++){
      bitset<6> ss(ksk);
      int now=0;
      rep(i,h){
        if(s.test(i)==0)continue;
        rep(j,w){
          if(ss.test(j)==0)continue;
          if(c.at(i).at(j)=='#')now++;
        }
      }
      if(now==k)ans++;
    }
  }
  cout << ans << endl;
          
          
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
    return 0;
}

Measured memory_bytes: 3604
import sys

num_of_data = 1
while True:
    if num_of_data > 200:
        break

    try:
        a, b = input().split()
         
    except EOFError:
        sys.exit()
        
    a = int(a)
    b = int(b)
    if a >= 0 and a <= 1000000000:
        if b >= 0 and b <= 1000000000:     
            num_of_data += 1
            sum = a+b
            cnt = 1
            while True:
                if sum < 10:
                    break
                sum /= 10
                cnt += 1
            print(cnt)


Measured memory_bytes: 5604
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import queue
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = deque()
q.append(0)
d_f[0] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 63132
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	int last;
	cin>>last;
	n--;
	int op = 3;
	int ans = 1;
	while(n--) {
		int val;
		cin>>val;
		switch(op) {
			case 1:
				if(last>val) {
					op=3;
					ans++;
				}
				break;
				case 2:
				if(last<val) {
					op=3;
					ans++;
				}
				break;
				case 3:
					if(last<val)op = 1;
					else if(last>val)op=2;
				}
				last =val;
			}
			cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  int a;

  cin>>a;
  for(int i=1; i<=a; i++){
    int x=i;
    if(x%3==0)cout<<" "<<i;
    else{
    while(x>0){
      if(x%10==3){
        cout<<" "<<i;
        break;
      }
        x/=10;
    }
  }
}
  cout<<endl;
}

Measured memory_bytes: 3092
import scala.io.StdIn

object Main {
	def main(args: Array[String]): Unit ={
		val N = StdIn.readLine.toInt

		val result = (0 to N/7 ).exists{ n =>
			(N - 7 * n ) % 4 == 0
		}
		println( if (result) "Yes" else "No")
	}
}


Measured memory_bytes: 27180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        if (n%2==1) {
            System.out.println("No");
            return;
        }
        String s1 = s.substring(0,n/2);
        String s2 = s.substring(n/2,n);
        System.out.println(s1.equals(s2) ? "Yes" : "No");
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprecision;

int main(){

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    if(s[k - 1] == 'A'){
        s[k - 1] = 'a';
    }else if(s[k - 1] == 'B'){
        s[k - 1] = 'b';
    }else{
        s[k - 1] = 'c';
    }

    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
S = ['S', 'H', 'C', 'D']
D = map(str, range(1, 14))
n = input()
T = [tuple(raw_input().split()) for _ in xrange(n)]

for t in [(s, d) for s in S for d in D]:
    if t not in T:
        print ' '.join(t)

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, A, B;
ll i, j, k;
int main(){
    scanf("%lld%lld%lld", &N,&A,&B);
    ll b = N / (A + B);
    ll a = min(A, N - b * (A + B));
    printf("%lld", b * A + a);
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = S.size() - T.size(); 0 <= i; i--) {
    bool ok = true;
    for (int j = 0; j < T.size(); j++) {
      if (S[i+j] != '?' && S[i+j] != T[j]) {
        ok = false;
        break;
      }
    }
    if (!ok) continue;
    for (int j = 0; j < S.size(); j++) {
      if (i <= j && j < i + T.size()) {
        cout << T[j-i];
      } else {
        cout << (S[j] == '?' ? 'a' : S[j]);
      }
    }
    cout << endl;
    return 0;
  }
  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

//dp[l][r][bool] [l,r)を(bool)が先手のときの得点
ll dp[401][401]={0};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::vector<ll> a(n),sum(n+1,0);
  rep(i,0,n)std::cin>>a[i];
  rep(i,1,n+1)sum[i]=sum[i-1]+a[i-1];

  rep(len,2,n+1){
    rep(i,0,n-len+1){
      ll min=LLONG_MAX;
      rep(j,i+1,i+len){
        min=std::min(min,dp[i][j]+dp[j][i+len]);
      }
      dp[i][i+len]=min+sum[i+len]-sum[i];
    }
  }

  std::cout<<dp[0][n];

  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};
struct Node T[MAX];
int n,H,D[MAX];

int Depth(int u){
  int d=0;

  for(;T[u].p != NIL;d++)u = T[u].p;
  return d;
}


int main(){
  int i,j,d,v,c,l,a,b;

  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j == 0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  H = 0;
  for(i=0;i<n;i++){
    D[i] = Depth(i);
    if(D[i] > H)H = D[i];
  }

  for(i=0;i<n;i++){/*print*/
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("depth = %d, ",D[i]);

    if(T[i].p == NIL)printf("root, ");
    else if(T[i].l == NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(a = 0,b = T[i].l;b != NIL;a++,b = T[b].r){
      if(a)printf(", ");
            printf("%d",b);
    }
    printf("]\n");
  }

  return 0;
}




Measured memory_bytes: 3304
/*
  AUTHOR:SOURABH
  CREATED:19:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,i,n,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        ans=0;
        fs(i,1,n)
        ans+=(n-1)/i;
        cout<<ans;
    }
}








Measured memory_bytes: 3644
N=int(input())

flag=0
cnt=0
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
       cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=1
        break
if flag==1:
    print("Yes")
else:
    print("No")

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

struct matrix {
    long long H;
    long long W;
    vector<vector<long long>> data;
    matrix(vector<vector<long long>> v) : data(v), H(v.size()), W(v[0].size()) {}
    matrix(long long H, long long W) : H(H), W(W) {
        data = vector<vector<long long>>(H, vector<long long>(W, 0));
    }
};

namespace Matrix {
matrix Identity(const long long &n) {
    matrix ans(n, n);
    for (long long i = 0; i < n; i++)
        for (long long j = 0; j < n; j++) {
            ans.data[i][j] = (i == j ? 1 : 0);
        }
    return ans;
}
matrix plus(const matrix &m1, const matrix &m2) {
    matrix ans(m1.H, m1.W);
    for (long long i = 0; i < m1.H; i++)
        for (long long j = 0; j < m1.W; j++) {
            ans.data[i][j] = m1.data[i][j] + m2.data[i][j];
        }
    return ans;
}
matrix multiple(const matrix &m1, const matrix &m2, const long long mod) {
    matrix ans(m1.H, m2.W);
    for (long long i = 0; i < m1.H; i++)
        for (long long j = 0; j < m2.W; j++) {
            ans.data[i][j] = 0;
            for (long long k = 0; k < m1.H; k++) ans.data[i][j] += m1.data[i][k] * m2.data[k][j], ans.data[i][j] = (ans.data[i][j] % mod + mod) % mod;
        }
    return ans;
}
matrix multiple(matrix m, long long n, const long long mod) {
    n %= mod;
    for (long long i = 0; i < m.H; i++)
        for (long long j = 0; j < m.W; j++) m.data[i][j] *= n, m.data[i][j] = (m.data[i][j] % mod + mod) % mod;
    return m;
}
matrix pow(matrix m, long long n, long long mod) {
    matrix ans = Identity(m.H);
    while (n) {
        if (n % 2) ans = multiple(m, ans, mod);
        m = multiple(m, m, mod);
        n >>= 1;
    }
    return ans;
}
void debug(const matrix &m) {
    for (long long i = 0; i < m.H; i++) {
        for (long long j = 0; j < m.W; j++) cerr << m.data[i][j] << ' ';
        cerr << endl;
    }
}
}  // namespace Matrix

int main() {
    long long N, M, A, B, C, T;
    while (true) {
        cin >> N >> M >> A >> B >> C >> T;
        if (N == 0) break;
        matrix S(N, 1);
        for (int i = 0; i < N; i++) {
            cin >> S.data[i][0];
        }
        matrix trans(N, N);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (j - i == 1) {
                    trans.data[i][j] = C;
                }
                if (j - i == 0) {
                    trans.data[i][j] = B;
                }
                if (j - i == -1) {
                    trans.data[i][j] = A;
                }
            }
        }
        matrix transT = Matrix::pow(trans, T, M);
        matrix ans = Matrix::multiple(transT, S, M);
        for (int i = 0; i < N; i++) {
            cout << ans.data[i][0] << (i == N - 1 ? '\n' : ' ');
        }
    }
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

vi adj[200005];
int N;

pair<int, int> getFarthest(int node) {
    vi dis(N, 1e9);
    queue<int> q;
    dis[node] = 0;
    q.push(node);
    int best = node;
    int bestdis = 0;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        best = cur;
        bestdis = dis[best];
        for (int to : adj[cur]) {
            if (dis[to] <= dis[cur]+1)
                continue;
            dis[to] = dis[cur]+1;
            q.push(to);
        }
    }
    return make_pair(bestdis, best);
} 

int main(){
	ios::sync_with_stdio(0);
    cin >> N;
    rep(i,0,N-1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int node = getFarthest(0).second;
    node = getFarthest(node).second;
    int diameter = getFarthest(node).first;
    if (diameter%3 == 1) {
        cout << "Second" << endl;
    }
    else {
        cout << "First" << endl;
    }
}


Measured memory_bytes: 13600
import java.io.{BufferedReader, IOException, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.util.Sorting

object Main {
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val K = sc.nextInt()
    val m = 2 * K
    val c = Array.ofDim[Int](m, m)

    (0 until N) foreach { _ =>
      val x = sc.nextInt()
      val y = sc.nextInt()
      sc.nextChar() match {
        case 'W' => c(x % m)(y % m) += 1
        case 'B' => c((x % m + K) % m)(y % m) += 1
      }
    }

    val sums = Array.ofDim[Int](m, m)    // (x, y)から(x+K, y)までのsum
    (0 until m) foreach { y =>
      sums(0)(y) = ((0 until K) map (x => c(x)(y))).sum
    }
    for {
      x <- 1 until m
      y <- 0 until m
    } {
      sums(x)(y) = sums(x - 1)(y) + c((x + K - 1) % m)(y) - c(x - 1)(y)
    }

    def w1(x: Int, y: Int) = sums(x % m)(y % m)
    def w2(x: Int, y: Int) = sums((x + K) % m)((y + K) % m)

    var ans = 0
    (0 until m) foreach { x =>
      var sum1 = ((0 until K) map (y => w1(x, y))).sum
      var sum2 = ((0 until K) map (y => w2(x, y))).sum
      ans = math.max(ans, sum1 + sum2)
      (1 until m) foreach { y =>
        sum1 -= w1(x, y - 1)
        sum1 += w1(x, y + K - 1)
        sum2 -= w2(x, y - 1)
        sum2 += w2(x, y + K - 1)
        ans = math.max(ans, sum1 + sum2)
      }
    }
    println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
  }

  class InputReader(val stream: InputStream) {
    val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextChar(): Char = next.charAt(0)
  }
}


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


int main(int argc, char const *argv[])
{
    int a;
    int b;
    int c;
    cin>>a>>b>>c;

   
   if (a+b<c||b+c<a||c+a<b) {
       cout<<"No";
   }else
    if (a+b==c||b+c==a||c+a==b) {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    
    return 0;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let K = scan.word::<usize>();
    let mut S = scan.word::<String>();
    if S.len() > K {
        S.truncate(K);
        S += "...";
    }

    println!("{}", S);
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

int main() {
    double a, b;
    cin >> a >> b;
    
    double x;
    x = (a + b) / 2;
    
    cout << ceil(x) << endl;
    return 0;
}

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

int judge(int p, int q, int x, int y){
  int L;
  
  if(p <= x){
    if(q <= x) L = q - p;
    
    else if(x < q && q < y){
      if(q <= x + ( y - x ) / 2 + ( y - x ) % 2) L = q - p;
      else L = y - q + 1 + x - p;
    }
    
    else L = x - p + 1 + q - y;
  }
  
  else if(x < p && p < y){
    if(x < q && q < y) L = min(q-p, p-x+y-q+1);
    else{
      if(p < x + ( y - x ) / 2)  L = p - x + 1 + q - y;
      else L = q - p;
    }
  }
  
  else L = q-p;
  
  return L;
  
}

int main() {
  
  int n,x,y;
  cin>>n>>x>>y;
  
  int ans[n];
  int count=0;
  for(int i=0; i<n; i++) ans[i] = 0;
  
  for(int i=1; i<n; i++){
    for(int j=i+1; j<=n; j++){
      ans[judge(i,j,x,y)]++;
      count++;
    }
  }

  for(int i=1; i<n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
s = input()

ans = 10**13
for si in s:
    t = s
    for j in range(len(t)):
        tt = ''
        if len(set(t)) == 1:
            ans = min(ans, j)
            break
        for k in range(len(s)-j-1):
            if t[k] == si or t[k+1] == si:
                tt += si
            else:
                tt += '*'
        t = tt

print(ans)


Measured memory_bytes: 73428
def juge_2(a,b,c)
  (b!= [a,b,c].max && b!=[a,b,c].min) ? true : false
end
 
n=gets.chomp.to_i
a=gets.chomp.split.map(&:to_i)
 
cnt=0
for i in 0..a.length-3
  if juge_2(a[i],a[i+1],a[i+2])
    cnt+=1
  end
end
 
puts cnt
 

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for(int i=0; i<k; ++i){
        ans.insert(a+i);
        ans.insert(b-i);
    }
    for(auto x: ans)
        if(x>=a && x<=b)
            cout << x << endl;
    return 0;
}


Measured memory_bytes: 3604
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long int n,a[10][10],i,ans=0,sd,ed;
	cin>>n;
	memset(a,0,sizeof(a));
	for(i=1;i<=n;++i)
	{
		if(i < 10)
		{
			++a[i][i];
			++ans;
		}
		else
		{
			sd = i/pow(10,(floor((log10(i)+1)*1.0)-1));
			ed = i%10;
			//cout<<sd<<" "<<ed<<"\n";
			if(ed == 0)
				ans = ans;
			else if(sd == ed)
				ans += (2*a[ed][sd] + 1);
			else
				ans += (2*a[ed][sd]);
			++a[sd][ed];
			//cout<<i<<" "<<ans<<"\n";
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int h, w; cin >> h >> w;
  vector<vector<int> > c(10, vector<int>(10)); REP(i, 10) REP(j, 10) cin >> c[i][j];
  vector<int> cost(10, INF);
  cost[1] = 0;
  REP(i, 10) if (i != 1) {
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int>> > que;
    REP(j, 10) if (j != i) que.emplace(c[i][j], j);
    while (!que.empty()) {
      auto p = que.top(); que.pop();
      if (p.first > cost[i]) continue;
      if (p.second == 1) {
        cost[i] = p.first;
        continue;
      }
      REP(j, 10) if (j != p.second) que.emplace(p.first + c[p.second][j], j);
    }
  }
  long long ans = 0;
  int a;
  REP(i, h) REP(j, w) {
    cin >> a;
    if (a == -1) continue;
    ans += cost[a];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
h,w,k = map(int, input().split())
s = [input() for _ in range(h)]

def out(l,ll):
    for z in range(ll):
        if l[z] > k:
            return True
    return False

def A(lt, hon):
    noww = [0] * (hon + 1)
    yoko = 0
    for j in range(w):
        kari = [0] * (hon + 1)
        for x in range(hon + 1):
            for y in range(lt[x], lt[x+1]):
                if s[y][j] == "1":
                    kari[x] += 1
        if out(kari, hon+1):
            return h * w
        
        neww = []
        for x in range(hon + 1):
            neww.append(noww[x] + kari[x])
        if out(neww, hon+1):
            yoko += 1
            noww = kari
        else:
            noww = neww
    return yoko + hon

ans = h * w

for i in range(2 ** (h-1)):
    tate = [0]
    honsu = 0
    for j in range(h-1):
        if ((i >> j) & 1):
            tate.append(j + 1)
            honsu += 1
    tate.append(h)
    ans = min(ans, A(tate, honsu))

print(ans)

Measured memory_bytes: 48604