akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#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 rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
using u32 = int32_t ;
using u64 = int64_t ;
//--------------------------------------------------------------

int main(int argc,char** argv){ fastio; myio;
  int n;
  cin>>n;
  vi a(n);
  cin>>a;
  rep(i,n) a[i]/=400;
  vi b(8,0); int va = 0;
  rep(i,n){
    if(a[i]<8){
      b[a[i]] = 1;
    }else{
      va++;
    }
  }
  int col = accumulate(rng(b),0);
  cout<<max(1,col)<<" ";
  cout<<va+col<<endl;
}

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

int main(){
  int n;
  cin >> n;
  std::vector<int> d(n);
  rep(i,n) cin >> d.at(i);
  sort(d.begin(), d.end());
  cout << d.at(n/2) - d.at(n/2-1) << endl;
}


Measured memory_bytes: 3752
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let K = buf_it.next().unwrap().parse::<usize>().unwrap();
    let P = (0..N).map(|_| buf_it.next().unwrap().parse::<usize>().unwrap()).collect::<Vec<_>>();

    let INF = 200010;
    let mut T_max = SegmentTree::new(N,max,0);
    let mut T_min = SegmentTree::new(N,min,INF);
    for i in 0..N{
        T_max.set(i,P[i]);
        T_min.set(i,P[i]);
    }
    let mut U = UnionFind::new(N);
    for i in 0..N-K{
        if T_min.get(i,i+K+1) == P[i] && T_max.get(i,i+K+1) == P[i+K]{
            U.merge(i,i+1);
        }
    }
    let mut L = (0..N).map(|_| 1).collect::<Vec<_>>();
    for i in 1..N{
        if P[i]>P[i-1]{L[i] = L[i-1]+1;}
    }
    for i in 0..N-K+1{
        if L[i+K-1] >= K {U.merge(i,N-1);}
    }
    let mut ans = HashSet::new();
    for i in 0..N-K+1{
        ans.insert(U.get_parent(i));
    }
    println!("{}",ans.len());
}

struct UnionFind{
    P: Vec<usize>,
}

impl UnionFind {
    fn new(n:usize) -> UnionFind{
        UnionFind {P:(0..n).collect()}
    }
    fn get_parent(&mut self,n:usize) -> usize{
        if self.P[n] == n{ return n;}
        let p = self.P[n];
        self.P[n] = self.get_parent(p);
        self.P[n]
    }
    fn is_unite(&mut self,x:usize,y:usize) -> bool{
        self.get_parent(x)==self.get_parent(y)
    }
    fn merge(&mut self,x:usize,y:usize){
        if self.is_unite(x,y) {return;}
        let i = self.get_parent(x);
        let j = self.get_parent(y);
        self.P[j] = i;
    }
}

struct SegmentTree<N>{
    n: usize,
    T: Vec<N>,
    func: fn(N,N) -> N,
    identity: N,
}

impl<N:Copy> SegmentTree<N> {
    fn new(n:usize,func:fn(N,N) -> N,identity:N) -> SegmentTree<N>{
        let mut T = SegmentTree { n:n,T:Vec::new(),func:func,identity:identity};
        T.init();
        T
    }
    fn init(&mut self){
        self.n = 1<<format!("{:b}",self.n-1).len();
        self.T = (0..(2*self.n-1)).map(|_| self.identity).collect();
    }
    fn set(&mut self,index:usize,value:N){
        let i = index + self.n - 1;
        self.T[i] = value;
        self._update_parent((i-1)/2);
    }
    fn _update_parent(&mut self,i:usize){
        self.T[i] = (self.func)(self.T[i*2+1],self.T[i*2+2]);
        if i>0 { self._update_parent((i-1)/2)}
    }
    fn get(&self,l:usize,r:usize) -> N{
    self._get(l,r,0,0,self.n)
    }
    fn _get(&self,l:usize,r:usize,i:usize,a:usize,b:usize) -> N{
        if l<=a && b<=r {
            self.T[i]
        } else if b<=l || r<=a {
            self.identity
        } else{
            (self.func)(self._get(l,r,2*i+1,a,(a+b)/2),
                        self._get(l,r,2*i+2,(a+b)/2,b))
        }
    }
}

Measured memory_bytes: 26876
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N;
set<pair<int, int>> ans;

int main() {

	scanf("%d", &N);

	if (N == 3) {
		printf("2\n1 3\n2 3\n");
		return 0;
	}
	else if (N == 4) {
		printf("4\n1 2\n2 4\n4 3\n3 1\n");
		return 0;
	}
	else if (N == 5) {
		printf("8\n1 2\n2 4\n4 3\n3 1\n5 1\n5 2\n5 3\n5 4\n");
		return 0;
	}
	else if (N % 2) {
		N--;
		vector<pair<int, int>> sub;
		rep(i, N / 2) sub.push_back({ i + 1, N - i });

		ans.insert({ sub[N / 2 - 1].first, N + 1 });
		ans.insert({ sub[N / 2 - 1].second, N + 1 });
		rep(i, N / 2) {
			if (!i) {
				ans.insert({ sub[i].first, N + 1 });
				ans.insert({ sub[i].second, N + 1 });
			}
			else {
				int to = (N / 2 + i - 1) % (N / 2);
				ans.insert({ sub[i].first, sub[to].first });
				ans.insert({ sub[i].first, sub[to].second });
				ans.insert({ sub[i].second, sub[to].first });
				ans.insert({ sub[i].second, sub[to].second });
			}
		}
	}
	else {
		vector<pair<int, int>> sub;
		rep(i, N / 2) sub.push_back({ i + 1, N - i });
		rep(i, N / 2) {
			int to = (N / 2 + i - 1) % (N / 2);
			ans.insert({ sub[i].first, sub[to].first });
			ans.insert({ sub[i].first, sub[to].second });
			ans.insert({ sub[i].second, sub[to].first });
			ans.insert({ sub[i].second, sub[to].second });
		}
	}

	printf("%d\n", ans.size());
	for (auto e : ans) {
		printf("%d %d\n", e.first, e.second);
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        boolean result = true;
        for(int i = 0;i < s.length();i++){
            if((i % 2 == 0 && s.charAt(i) == 'L') || (i % 2 == 1 && s.charAt(i) == 'R')){
                result = false;
                break;
            }
        }

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

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

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

  vector<int> A(N, 0);
  vector<int> num(200001, 0);
  rep(i, N) {
    cin >> A[i];
    num[A[i]]++;
  }

  ll sum = 0;
  for (int i = 1; i <= 200000; i++) {
    sum += (pow(num[i], 2) - num[i]) / 2;
  }

  rep(i, N) cout << sum - num[A[i]] + 1 << endl;
}

Measured memory_bytes: 4824
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]!=b[j]){
				cout<<b[j]<<endl;
				break;
			}
			else{
				cout<<b[j+1]<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 6720
from operator import itemgetter

n = int(input())
lesser = [list(map(int, input().split())) + [0] for _ in range(n)]
greater = [list(map(int, input().split())) for _ in range(n)]

g = sorted(greater, key=itemgetter(0))

ans = 0
for i in range(n):
	y_max = -1
	for j in range(n):
		if lesser[j][0] < g[i][0] and y_max < lesser[j][1] < g[i][1] and lesser[j][2] == 0:
			y_max = lesser[j][1]
			y_max_index = j

	if y_max != -1:
		ans += 1
		lesser[y_max_index][2] = 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define pp pair<ll,ll>
typedef long long int ll;
typedef long double ld;
#define MP make_pair

#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++)     
void fastIO(void);

void decimal(int);
ll modmulti(ll, ll, ll);
ll modadd(ll, ll, ll);
ll modpower(ll, ll, ll);
ll gcd(ll, ll );
ll modinv(ll, ll);







int main()
{
   
   string s;
   cin>>s;
   ll n = s.length();
   ll last = 1;
   ll k = 1;
   rep1(i,n){
      if(s[i]!=s[i-1]){
         last = 1;
         k++;
      }
      else{
         if(last==1){
            i++;
            if(i<n) k++;
            last = 2;
         }
         else{
            last = 1;
            k++;
         }
      }
      
   }
   cout<<k<<endl;


}























void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}

void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b, ll m){
   return ((a%m)*(b%m))%m;
}
ll modadd(ll a, ll b, ll m){
   return ((a%m)+(b%m))%m;
}
ll modpower(ll a, ll n, ll m){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a,m);
      a = modmulti(a,a,m);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a, ll m){
   return modpower(a,m-2,m);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long double,long double>
#define pb               push_back
#define ll               long double
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
using Real=double;
using Point=complex<Real>;
const Real EPS=1e-10;
const int N=60+1;
Point x[N];
Real c[N];
int n,k;

inline bool eq(Real a,Real b){
    return fabs(a-b)<EPS;
}

Real dis(Point a,Point b){
    return abs(a-b);
} 

struct Circle{
    Point center;
    Real r;
    Circle(Point center,Real r):center(center),r(r){}
};

bool intersect(Circle c,Point p){
    return abs(abs(p-c.center)-c.r)<EPS;
}

int intersect(Circle c1,Circle c2){
    if(c1.r<c2.r) swap(c1,c2);
    Real d=abs(c1.center-c2.center);
    if(c1.r+c2.r<d)     return 4;
    if(eq(c1.r+c2.r,d)) return 3;
    if(c1.r-c2.r<d)     return 2;
    if(eq(c1.r-c2.r,d)) return 1;
                        return 0;
}


vector<Point> crosspoint(Circle c1,Circle c2){
    vector<Point> ret;
    int isec=intersect(c1,c2);
    if(isec==0 or isec==4) return ret;
    Real d=abs(c1.center-c2.center);
    Real a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
    Real t=atan2(c2.center.imag()-c1.center.imag(),c2.center.real()-c1.center.real());
    ret.push_back(c1.center+Point(cos(t+a)*c1.r,sin(t+a)*c1.r));
    ret.push_back(c1.center+Point(cos(t-a)*c1.r,sin(t-a)*c1.r));
    return ret;
}


bool solve(Real tme)
{
	vector<Point>v;
	for(int i=0;i<n;i++)
	{
		v.push_back(x[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			vector<Point> inter = crosspoint(Circle(x[i],tme/c[i]),Circle(x[j],tme/c[j]));
			for(Point xx:inter)
			{
				v.push_back(xx);
			}
		}
	}
	//cerr<<v.size()<<endl;
	for(Point xx:v)
	{
		int f=0;
		for(int i=0;i<n;i++)
		{
			Real r = tme/c[i];
			if(abs(x[i]-xx)<r+EPS) f++;
		}
		//cout<<f<<endl;
		if(f>=k)
		{
			return true;
		}
	}
	return false;
}

int main()
{
    IOS
    cout<<fixed<<setprecision(12);
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
	cin>>n>>k; 		
	for(int i=0;i<n;i++)
	{
		Real a,b;
		cin>>a>>b;
		x[i]=Point(a,b);
		cin>>c[i];
	}
	Real l=0,r=1000000000;
	int itr=0;
	for(int itr=0;itr<=100;itr++)
	{
		Real mid=(l+r)/2;
		bool ver=solve(mid);
		//cout<<mid<<" "<<ver<<endl;
		if(ver)
		{
			r=mid;
		}
		else
		{
			l=mid;
		}
	}
	cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>

using namespace std;

string char_to_str(char *c) {
	string ret = "";

	for (; *c; ++c)
		ret += *c;

	return ret;
}

int main() {
	map<string, vector<int> > m;
	vector<string> words;

	char word[50]; int page;
	while (scanf("%s%d\n", word, &page) != EOF) {
		string str = char_to_str(word);
		m[str].push_back(page);
		words.push_back(str);
	}

	sort( words.begin(), words.end() );
	words.erase( unique( words.begin(), words.end() ), words.end() );

	for (int i = 0; i < words.size(); ++i) {
		vector<int> v = m[words[i]];
		sort( v.begin(), v.end() );

		cout << words[i] << endl;
		for (int j = 0; j < v.size(); ++j) {
			cout << v[j];
			if (j+1 < v.size()) cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define srt(v)  if(!v.empty())sort(v.begin(),v.end())
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
 ll n,l;
 
 cin>>n>>l;
 
 ll a[n+1];
 
 for(ll i=1;i<=n;i++)
 cin>>a[i];
 
 ll len=0;
 
 for(ll i=1;i<=n;i++)
 len+=a[i];
 
 
 vector<ll>v;
    ll id=-1;
    
    for(ll i=1;i<n;i++){
        if(a[i]+a[i+1]>=l){
            id=i;
            break;
        }
    }
    
    if(id==-1){
        cout<<"Impossible\n";
        return;
    }
    
    cout<<"Possible\n";
    
    for(ll i=1;i<id;i++)
    cout<<i<<"\n";
    
    for(ll i=n-1;i>id;i--)
    cout<<i<<"\n";
    
    cout<<id<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  vector<int> a(n, 0);
  for(int i = 0; i < m; i++)
  {
    int li, ri;
    cin >> li >> ri;
    li--;
    ri--;
    a[li] = max(a[li], ri);
  }
  for(int i = 1; i < n; i++)
  {
    a[i] = max(max(a[i], a[i - 1]), i);
  }
  vector<int> pref(n);
  pref[0] = s[0] - '0';
  for(int i = 1; i < n; i++)
  {
    pref[i] = pref[i - 1] + s[i] - '0';
  }
  vector<vector<int>> dp(n + 1, vector<int> (n + 1, 0));
  dp[n][0] = dp[n - 1][0] = dp[n - 1][1] = 1;
  for(int i = n - 2; i >= 0; i--)
  {
    int offset = pref[a[i + 1]] - pref[a[i]], lim = min(n, a[i] - i + 1);
    for(int j = 0; j <= lim; j++)
    {
      if(j == 0)
      {
        (dp[i][j] += dp[i + 1][j + offset]) %= MOD;
      }
      else if(j == lim)
      {
        (dp[i][j] += dp[i + 1][j - 1 + offset]) %= MOD;
      }
      else
      {
        (dp[i][j] += dp[i + 1][j + offset]) %= MOD;
        (dp[i][j] += dp[i + 1][j - 1 + offset]) %= MOD;
      }
    }
  }
  cout << dp[0][pref[a[0]]] << endl;
  return 0;
}


Measured memory_bytes: 35584
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>


int main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  ll n, k;
  cin >> n >> k;
  vector<ll> vc(n);
  for (int i = 0; i < n; i++) {
    cin >> vc[i];
  }
  sort(vc.begin(), vc.end());
  n -= k;
  ll c = 0;
  for (int i = 0; i < n; i++) {
    c += vc[i];
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  rep(i, n){
    int now = i + 1;
    double add = (double)1/n;
    while(now < k){
      now *= 2;
      add /= 2;
    }
    ans += add;
  }
  printf("%.10f\n", ans);
  return 0;
}

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

#define MOD 1000000007

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


	if(b%2)return (a*powM(a,b-1))%MOD;
	else return (powM( (a*a)%MOD,b/2 ))%MOD;

}

long long fact[1000001];

int main(){
	fact[0]=fact[1]=1;
	for(int i=2; i<=1000000; i++){
		fact[i]=(fact[i-1]*i)%MOD;
	}

	long long x,y;	cin>>x>>y;

	int R=-1,U=-1;

	for(R=0; R<=1000000; R++){
		int leftX=x-(R*2), leftY=y-(R*1);
		if(leftX<0 || leftY<0)continue;

		if(leftX*2==leftY){
			U=leftX;
			break;
		}
	}
	//printf("(->, ^) = (%d,%d)\n",R,U);

	if(R==-1 || U==-1){
		cout<<"0"<<endl;
		return 0;
	}

	// ans= nCr
	long long ans=(fact[R+U]* powM((fact[R]*fact[U])%MOD,MOD-2))%MOD;

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


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if (a == b){
		if (a != c){
			cout << "Yes";
		}
		else{
			cout << "No";
		}
	}// ac
	else{//a!=b
		if (a == c){
			cout << "Yes";
		}
		else{
			if (c == b)
				cout << "Yes";
			else
			cout << "No";
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.at(1)==s.at(2)){
		if(s.at(0)==s.at(1)||s.at(3)==s.at(1)){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}


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

namespace test
{
    public class Queue
    {

        struct pros
        {
            public string name;
            public int num;
        }
        public static void Main(string[] args)
        {
            var queue = new Queue<pros>();
            var str1 = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            var N = int.Parse(str1[0]);
            var unit = int.Parse(str1[1]);
            var resList = new List<string>();
            var currentTIme = 0;
            for (int i = 0; i < N; ++i)
            {
                string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
                queue.Enqueue(new pros { name = str[0], num = int.Parse(str[1]) });
            }
            while (queue.Count != 0)
            {
                var p = queue.Dequeue();
                var time = Math.Min(p.num, unit);
                currentTIme += time;
                if (p.num <= unit)
                {
                    resList.Add(string.Format("{0} {1}", p.name, currentTIme));
                }
                else
                {
                    p.num -= time;
                    queue.Enqueue(p);
                }
            }
            foreach (var a in resList)
            {
                Console.WriteLine(a);
            }
        }

    }
}



Measured memory_bytes: 19444
#include <stdio.h>

int main() {
  char s[10];
  
  scanf("%s", s);
  if(s[0] == '1' && s[1] == '1' && s[2] == '1')
    printf("3\n");
  else if(s[0] == '0' && s[1] == '0' && s[2] == '0')
    printf("0\n");
  else if((s[0] == '1' && s[1] == '0' && s[2] == '0')
          ||(s[0] == '0' && s[1] == '1' && s[2] == '0')
          ||(s[0] == '0' && s[1] == '0' && s[2] == '1'))
    printf("1\n");
  else
    printf("2\n");
  
  return 0;
}
   

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
	int n;
	cin>>n;
	n %= 10;
	switch(n)
	{
		case 2:
			cout<<"hon"<<endl;
			break;
		case 4:
			cout<<"hon"<<endl;
			break;
		case 5:
			cout<<"hon"<<endl;
			break;
		case 7:
			cout<<"hon"<<endl;
			break;
		case 9:
			cout<<"hon"<<endl;
			break;
		case 0:
			cout<<"pon"<<endl;
			break;
		case 1:
			cout<<"pon"<<endl;
			break;
		case 6:
			cout<<"pon"<<endl;
			break;
		case 8:
			cout<<"pon"<<endl;
			break;
		case 3:
			cout<<"bon"<<endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 3636
def totalcost_dp(cost,N,k):
    dp = [float('inf')]*(N+1)
    dp[1] = 0
    
    
    for i in range(1,N+1):
        
        for j in range(i+1,k+i+1):
            if j < N+1:
                dp[j] = min(dp[j],dp[i]+abs(cost[i]-cost[j]))
                
    return dp[N]


n ,k= map(int,input().split())
cost = list(map(int,input().split()))
cost = [0]+cost
print(totalcost_dp(cost,n,k))

Measured memory_bytes: 86580
///============================================================================
/// Name        : Faisal.cpp
/// Author      : Faisal Ahmed
/// Version     :
/// Copyright   : Your copyright notice
/// Description : C++, Ansi-style
///============================================================================

#include <bits/stdc++.h>

using namespace std;

#define M 1000000007

typedef long long int ll;
typedef long double ld;

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

	string str;

	cin >> str;

	int len = str.size(), o = 0;
	for(int i = 0; i < len; i++){
        if(str[i] == 'o'){
            o++;
        }
	}

	if(o + 15 - len >= 8){
        cout << "YES" << endl;
	}
	else{
        cout << "NO" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N=0;
    int D=0;
    long long ans=0;
    int X=0;
    int tmp=0;

    vector<int> A(105);

    cin>>N>>D>>X;

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

    for(int i=0;i<N;i++){
        tmp=A[i];
        ans++;
        A[i]++;
        while(A[i]<=D){
            A[i]=A[i]+tmp;
            ans++;
        }
    }


    cout<<ans+X<<endl;



}

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

int main(){
    int n;
    cin >> n; 
    int a[n];
    long long ans=0;
    int b[n];
    int j=1;
    for(int i=0;i<n;i++){
        cin >> a[i];
        b[i]=a[i]-j;
        j++;
    }
    sort(b,b+n);
    int b_mid=b[n/2];
    //cout << b_mid << endl;
    for(int i=0;i<n;i++){
        ans+=abs(b[i]-b_mid);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
INF = float("inf")

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()

ans = 0
for i in range(N):
    l = bisect.bisect_left(A,B[i])
    r = bisect.bisect_right(C,B[i])
    ans += l*(N-r)

print(ans)


Measured memory_bytes: 23516
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 

signed main(){
  ll n;
  	cin>>n;
  FOR(i,1,10){
    FOR(j,1,10){
      if(n==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
    cout<<"No"<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
int n;
int a[100007],par[100007],cur[100007],cnt[100007];
int u,v;
vector <int> edge[100007];
void dfs(int u){
	int sum=0,ct=0,mx=0;
	for(int i=0;i<(int)edge[u].size();i++){
		int v=edge[u][i];
		if(v==par[u]) continue;
		par[v]=u;
		dfs(v);
		sum+=a[v];
		mx=max(mx,a[v]);
		ct++;
	}
	if(ct==1 && a[u]!=sum){
		cout<<"NO";
		exit(0);
	}
	else if(ct==1 && a[u]==sum){
		a[u]=sum;
		return;
	}
	else if(ct==0){
		return;
	}
	else if(ct>1 && (sum<a[u] || a[u]*2LL<sum || (mx*2LL>sum && sum-mx<sum-a[u]))){
		cout<<"NO";
		exit(0);
	}
	else if(ct>1){
		a[u]=sum-((sum-a[u])*2LL);
	}
}
signed main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		cin>>u>>v;
		edge[u].pb(v);
		edge[v].pb(u);
		cnt[u]++;
		cnt[v]++;
	}
	if(n==2){
		if(a[1]==a[2]) cout<<"YES";
		else cout<<"NO";
		return 0;
	}
	for(int i=1;i<=n;i++){
		if(cnt[i]==1){
			par[i]=0;
			dfs(i);
			break;
		}
	}
	cout<<"YES";
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;

int main()
{
    int N, tmp = 0, ans = 0;
    cin >> N;
    vector <int> a(N+2, 0);
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        ans += abs(a[i-1] - a[i]);
    }
    ans += abs(a[N] - 0);
    for (int i = 1; i <= N; i++) {
        cout << ans - (abs(a[i] - a[i-1]) + abs(a[i] - a[i+1])) + abs(a[i-1] - a[i+1]) << endl;
    }
    return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var m1 = cin.nextInt();
            var d1 = cin.nextInt();
            var m2 = cin.nextInt();
            var d2 = cin.nextInt();

            Console.WriteLine(m1 != m2 ? "1" : "0");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


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

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

    int n, sum = 0, minV = 101;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int s; cin >> s;
        sum += s;
        if (s % 10 != 0) minV = min(minV, s);
    }

    if (sum % 10 != 0) cout << sum << endl;
    else if (minV != 101) cout << sum - minV << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
#include <climits>
using namespace std;
using Int = long long;

int main()
{
    int N; cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for (int i = 0; i < N - 1; i++) cin >> C[i] >> S[i] >> F[i];
    for (int i = 0; i < N - 1; i++) {
        int elapsed = 0;
        for (int j = i; j < N - 1; j++) {
            elapsed = max(S[j], elapsed);
            elapsed = (elapsed + F[j] - 1) / F[j] * F[j];
            elapsed += C[j];
        }
        cout << elapsed << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 10;

struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(20);
  }
}IO;

// ref : Vivek_1998299 submission
pii getFL(int n){
  int last = n % 10;
  int curr = last;
  while (n){
    curr = n % 10;
    n /= 10;
  }
  return {curr, last};
}

int32_t main(){
 int n;
 cin >> n;
 pii arr[n + 5];
 map<pii, int> m;
 for (int i = 1; i <= n; i++){
  arr[i] = getFL(i);
  m[arr[i]]++;
 }
 int ret = 0;
 for (int i = 1; i <= n; i++){
  pii curr = arr[i];
  swap(curr.first, curr.second);
  if (m.find(curr) != m.end())
    ret += m[curr];
 }
 cout << ret << endl;
}

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


int main(){
  string s;
  cin >> s;
  bool ha=true;
  for(int i=0;i<s.size();++i){
    if(i%2==0){
      if(s[i]!='h'){
        ha=false;
      }
    }else{
      if(s[i]!='i'){
        ha=false;
      }
    }
  }
  if(s.size()%2==1){
    ha=false;
  }
  if(ha==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main()
{
   string s,t;
   int counter=0;
   cin>>s>>t;
   for(int i=0;i<3;i++)
   {
       if(s[i]==t[i])
        counter++;
   }
   cout<<counter;
    return 0;
}

Measured memory_bytes: 256
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def get_rank(L):
    D = {x:i for i,x in enumerate(sorted(L))}
    return [D[x] for x in L]
def calc(Z):
    Z.sort()
    l, r = -1<<28, 1<<28
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l+r)/2
        A = get_rank([s*m+t for s, t in Z])
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
        else:
            r = m
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

Measured memory_bytes: 132628
#include <bits/stdc++.h>
using namespace std;
using mp = map<string, long long>;

bool sort2(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second > b.second);
}

int main() {
  long long N;
  cin >> N;
  vector<string> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];

  map<string, long long> counter;

  for (long long i = 0; i < N; i++) {
    auto it = counter.find(A[i]);
    if (it == counter.end()) {
      counter[A[i]] = 1;
    }
    else {
      counter[A[i]] += 2;
    }
  }

  vector<pair<string, long long>> vec;
  mp:: iterator it2;
  for (it2 = counter.begin(); it2!=counter.end(); it2++) {
    vec.push_back(make_pair(it2->first, it2->second));
  }

  sort(vec.begin(), vec.end(), sort2);

  vector<string> maxs;

  long long maxCount = vec[0].second;
  long long j = 0;
  while (j < vec.size()) {
    if (maxCount == vec[j].second) {
      maxs.push_back(vec[j].first);
    }
    j++;
  }

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

  for (long long k = 0; k < maxs.size(); k++) {
    cout << maxs[k] << endl;
  }

  return 0;
}


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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(c)     for(bool p=1;p;p=next_permutation(ALL(c)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll inf = 1e15;
const ll mod = 1e9+7;
const double eps = 1e-10;

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

struct edge { ll from, to, cost; };

int main() {
    ll N; cin >> N;
    
    map<ll, vector<edge>> mp;
    REP(i, N-1) {
        ll a, b, c; cin >> a >> b >> c;
        mp[b].push_back((edge){b, a, c});
        mp[a].push_back((edge){a, b, c});
    }
    
    ll Q, K; cin >> Q >> K;
    
    vector<ll> dist(N+1, 0);
    queue<edge> que;
    for (edge e : mp[K]) que.push(e);
    
    while (!que.empty()) {
        edge e1 = que.front(); que.pop();
        if (dist[e1.to] != 0) continue;
        
        dist[e1.to] = e1.cost + dist[e1.from];
        for (edge e2 : mp[e1.to]) que.push(e2);
    }
    
    REP(i, Q) {
        ll x, y; cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 20144
#include <iostream>
#define mxn 100010
using namespace std;

int ar[mxn], dp[mxn];

//return minim cost to reach at n
int go(int n) {
    if(n == 1) return 0;
    if(n == 2) return abs(ar[2] - ar[1]);

    if(dp[n] != -1) return dp[n];

    int cost1 = go(n-1) + abs(ar[n] - ar[n-1]);
    int cost2 = go(n-2) + abs(ar[n] - ar[n-2]);
    return dp[n] = min(cost1, cost2);
}

int main() {
    int n; cin >> n;
    fill(dp, dp+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];
    cout << go(n);
    return 0;
}

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

#define int long long int

int power(int x,int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

signed main()
{
    string s;
    cin>>s;
    int i,n=s.size();
    int rem[2020]={0};
    int res=0,p=0;
    rem[0]=1;
    for(i=n-1;i>=0;i--)
    {
        int m=power(10,n-1-i,2019);
        p = p + ((s[i]-'0')*m)%2019;
        p%=2019;
        res+=rem[p];
        rem[p]++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3748
fun main(args : Array<String>) {
    val (a, v) = readLine()!!.split(" ").map { it.toInt() }
    val (b, w) = readLine()!!.split(" ").map { it.toInt() }
    val t = readLine()!!.toInt()

    if (v <= w) {
        println("NO")
        return
    }

    val diff = Math.abs(b - a)
    val fill = v - w

    println(if (Math.ceil(diff.toDouble() / fill.toDouble()).toInt() <= t) "YES" else "NO")
}

Measured memory_bytes: 36288
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,max_f;
  cin >> n >> k;
  vector<P> ans;
  max_f = ((n-2)*(n-1))/2;
  if(max_f<k){
    cout <<"-1\n";
    return 0;
  }
  for(int i=1;i<n;i++){
    ans.push_back(P(0,i));
  }
  k = max_f - k;
  for(int i=1;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(k>0){
        ans.push_back(P(i,j));
        k--;
      }
    }
  }
  cout << ans.size()<<endl;
  for(auto p:ans){
    cout << p.first+1<<" "<<p.second+1<<endl;
  }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {


    public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int r = scan.nextInt();//r?????¨?????????
		int c = scan.nextInt();//c?????¨????¨????
		
		int numlist[][] = new int[r + 1][c + 1];//????¨???¨?????????????????????

		//???????????????????????????????????????????´???¨????¨???¨?????????????¨?????????????
		for (int cnt_r = 0; cnt_r < r; cnt_r++){
			for (int cnt_c = 0; cnt_c < c ; cnt_c++) {
				numlist[cnt_r][cnt_c] = scan.nextInt();//????????????????´?
				numlist[cnt_r][c] += numlist[cnt_r][cnt_c];//????????¨???????¨?????¨????
				numlist[r][cnt_c] += numlist[cnt_r][cnt_c];//????????¨???????¨?????¨????
				numlist[r][c] += numlist[cnt_r][cnt_c];//??¨??????????¨?????¨????
			}
		}
		for (int cnt_r = 0; cnt_r < r + 1; cnt_r++){
			for (int cnt_c = 0; cnt_c < c + 1 ; cnt_c++) {
				System.out.print( numlist[cnt_r][cnt_c]);
				if(cnt_c != c)//?????????????????°?????§???????????°?????????????????\??????
					System.out.print(" ");
			}
			System.out.print("\n");
		}
		scan.close();
	}
}

Measured memory_bytes: 42152
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i <= x ; i --) 
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
const int inf = 0x3f3f3f3f ;
const int maxn = 5005 ;
const int maxm = 5005 ;
char s[maxn] ;
int main()
{
	scanf("%s" , s) ;
	if(s[2] == s[3] && s[4] == s[5])  puts("Yes") ;
	else  puts("No") ;
	return 0 ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i*i<=n; i++) {
    if(n%i==0) {
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}


void solve(long long N){
  ll ans = 0;
  vector<ll> v = divisor(N);
  for(auto val : v) {
    if(val == 1)continue;
    ll n = N;
    while(n%val == 0)
      n/=val;
    if(n % val == 1) ans++;
  }
  vector<ll> vv = divisor(N-1);
  std::cout << ans + vv.size() - 1<< std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#define N 10000

int main(void){
  int i,num;
  char ch[N]={0};

  for(i=0;;i++){
    scanf("%c",&ch[i]);
    if(ch[i]<' ' || 'z'<ch[i]){
      break;
    }
  }
  for(i=0;ch[i]!=0;i++){}
  num=i;
  for(i=0;i<num;i++){
    if('a'<=ch[i] && ch[i]<='z'){
      ch[i]-='a'-'A';
    }else if('A'<=ch[i] && ch[i]<='Z'){
      ch[i]+='a'-'A';    
    }
  }
  printf("%s",ch);
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  rrep(i, s.size()) {
    bool c = true;
    rep(j, i / 2) { c = c && (s[j] == s[j + i / 2]); }
    if (c) {
      cout << i / 2 * 2 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable.PriorityQueue
import scala.collection.mutable.Set
import scala.util.Sorting

object Main {
  val pq = PriorityQueue[(Long, (Int, Int, Int))]()(scala.math.Ordering.by(v => v._1))
  val lines = scala.io.Source.stdin.getLines.toStream
  val Array(num_x, num_y, num_z, num_k) = lines(0).split(" ").map(_.toLong)
  val xs = lines(1).split(" ").map(_.toLong)
  val ys = lines(2).split(" ").map(_.toLong)
  val zs = lines(3).split(" ").map(_.toLong)
  Sorting.quickSort[Long](xs)(Ordering[Long].reverse)
  Sorting.quickSort[Long](ys)(Ordering[Long].reverse)
  Sorting.quickSort[Long](zs)(Ordering[Long].reverse)
  val checked = Set[(Int, Int, Int)]()
  pq.enqueue((xs(0) + ys(0) + zs(0)) -> (0, 0, 0))

  def main(args: Array[String]) = {
    bfs(num_k)
  }

  def bfs(max: Long = 3000, count: Long = 1): Unit = {
    val (value, (lx, ly, lz))  = pq.dequeue
    println(value)
    if (xs.length > lx+1 && !checked.contains((lx + 1, ly, lz))) {
      checked += ((lx+1, ly, lz))
      pq.enqueue((value - xs(lx) + xs(lx + 1)) -> (lx + 1, ly, lz))
    }
    if (ys.length > ly+1 && !checked.contains((lx, ly+1, lz))) {
      checked += ((lx, ly+1, lz))
      pq.enqueue((value - ys(ly) + ys(ly+1)) -> (lx, ly+1, lz))
    }
    if (zs.length > lz+1 && !checked.contains((lx, ly, lz+1))) {
      checked += ((lx, ly, lz+1))
      pq.enqueue((value - zs(lz) + zs(lz+1)) -> (lx, ly, lz+1))
    }
    if (count < max && (zs.length > lz+1 || ys.length > ly+1 || xs.length > lx+1)) {
      bfs(max, count + 1)
    }
  }
}


Measured memory_bytes: 41696
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
ULL gcd(ULL a, ULL b){ if(b==0){ return a; }else{ return gcd(b, a%b); } }
int main(){ 
ULL A, B, ans; cin >> A >> B; ans=(A*B)/gcd(A, B);
cout << ans << "\n";
}

Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)
let rec for_iterr_ a b f = if a <= b then () else (f a; for_iterr_ (a-1) b f)

let gen_table ubound =
  let res = Array.make ubound 1 in
  res.(0) <- 0; res.(1) <- 0;
  for_iter_ 2 ubound (fun i ->
    if res.(i) > 0 then for_iter_ 2 (ubound / i) @@ fun j -> res.(i*j) <- 0);
  for_iterr_ ((ubound+1)/2) 1 (fun a ->
    let i = 2*a-1 in
    res.(i) <- if res.(i) = 1 && res.((i+1)/2) = 1 then 1 else 0);
  res.(2) <- 0;
  for_iter_ 1 ubound (fun i -> res.(i) <- res.(i) + res.(i-1));
  res

let () =
  let q = read_int () in
  let rs = for_iter 0 q (fun _ -> let l = read_int () in let r = read_int () in (l, r)) in
  let table = gen_table 200010 in
  flip List.iter rs (fun (l, r) -> printf "%d\n" (table.(r) - table.(l-1)))




Measured memory_bytes: 14592