akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int64_t i=ini;i<n;i++)
#define _rep(i,ini,n) for(int64_t i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int64_t FastPow(int64_t n, int64_t m){
    if(m==0) return 1;
    if(m==1) return n;

    int64_t v=FastPow(n,m/2);
    v*=v;
    v%=MOD;
    if(m%2){
        v*=n;
        v%=MOD;
    }
    return v;
}

int64_t RevS(int64_t n,int64_t m){
    return FastPow(n,m-2);
}

int64_t Factr(int64_t n,int64_t m){
    int64_t v=1;
    rep(i,n-m+1,n+1){
        v*=i;
        v%=MOD;
    }
    return v;
}

int64_t Comb(int64_t n,int64_t m){
    //m=min(m,n-m);
    return (Factr(n,m)*RevS(Factr(m,m),MOD))%MOD;
}

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

    rep(i,1,K+1){
        int64_t ans=Comb(K-1,i-1);
        ans*=Comb(N-K+1,i);
        ans%=MOD;
        cout<<ans<<endl;
    }
}

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

int main(){
    int n, k, i, s;
    double p, pt;
    cin >> n >> k;
    for(i=0; i<n; i++){
        s = i+1;
        pt = 1.0/(double)n;
        while(s < k){
            s *= 2;
            pt *= 0.5;
        }
        p += pt;
    }
    printf("%12.12lf", p);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  n *= 100;
  int a = (n + 107) / 108;
  if (a * 108 / 100 != n / 100) std::cout << ":(" << std::endl;
  else std::cout << a << std::endl;
  return 0;
}


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

int main(){

int ans=0;
string s, t;
cin >> s >> t;
int cnt=0;

for(int a=0; a<s.size()-t.size()+1; a++){
    int c=0;
    for(int i=0; i<t.size(); i++){
        if(s[a+i]==t[i]) c++;
    }
    cnt = max(cnt, c);
}

cout << t.size()-cnt << endl;


}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 200200;
const long double PI = acos(-1);

ll n, m, k;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, m, x, ans = oo;
    cin >> n >> m >> x;

    vector<ll> c(n+1);
    vector<vector<ll>> a(n+1, vector<ll>(m+1));

    for (int i=0; i<n; i++){
        cin >> c[i];
        for (int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    for (int mask=1; mask<(1 << n); mask++){
        vector<ll> check(n+1, 0);
        ll cost = 0;
        bool can;

        for (int j=0; j<n; j++){
            if (not ((1 << j) & (mask))) continue;

            cost+=c[j];
            can = true;

            for (int k=0; k<m; k++){
                check[k] += a[j][k];

                if (check[k] < x) can = false;
            }

        }
        if (can){
            ans = min(ans, cost);
        }
    }

    if (ans == oo){
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  ll maxi = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
  }
  ll l = 0, r = (ll)1e9 + 10;
  ll mid = (l + r) / 2;
  ll cnt = 0;
  while(r - l > 1) {
    mid = l + (r - l) / 2;
    cnt = 0;
    for(int i = 0; i < n; i++) {
      cnt += (a[i] + mid - 1) / mid - 1;
    }
    if(cnt <= k) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4756
# coding: utf-8
def q0():
    while True:
        data=[]
        n=int(input())
        if n==0:
            return
        for i in range(n):
            data.append(int(input()))
        print((sum(data)-max(data)-min(data))//(n-2))

def q1():
    while True:
        n,r=map(int,input().split())
        if n==0:
            return
        deck=[n-i for i in range(n)]
        for i in range(r):
            p,c=map(int,input().split())
            deck=deck[p-1:p-1+c]+deck[0:p-1]+deck[p-1+c:]
        print(deck[0])


question=[q0,q1]

question[1]()


Measured memory_bytes: 5628
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

Int count_fun(string temp,Int n,char c)
{
    Int count=0,i=0;
    if(n==0)
        return 0;
    for(Int i=0;i<n;++i)
    {
        if(temp[i]==c)
            count++;
    }
    return count;
}

Int helper(Int n,string temp)
{
    Int count=0,pos=n-1;
    Int fun=count_fun(temp,n,'R');
    Int fun2=count_fun(temp,fun,'W');
    return fun2;
}

int main()
{
    FAST_IO;

    Int n,count=0;
    string str;
    cin >> n;
    cin >> str;
    count=helper(n,str);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <climits>
#include <numeric>

#define el '\n'
typedef long long ll;

using namespace std;



void sol(){
	string s;
	cin >>s;
	if (s[s.length() - 1] == 's')
		s+= "es";
	else 
		s+="s";
	cout << s<<el;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t = 1;
	while(t--){
	//	cout << t<<el;
		sol();
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace::std;
#define int long long

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}



void _main() {
        int n, k; cin >> n >> k;
        vector<int> vec(n); cin >> vec;
        sort(all(vec));
        int ans = 0;
        for (int i = 0; i < k; i++) ans += vec[i];
        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

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

#define ll       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(x)    (int) x.size()
#define all(v)   v.begin(), v.end()

template <typename T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <typename T> inline void smax(T &a, T b) {a = a > b ? a : b;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

template <typename T> inline void Int(T &n) {
    n = 0; int f = 1; register int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l); }

const int mod = (int) 1e9 + 7;

inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll) a * b % mod;}

const int inf = (int) 2e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int N   = (int) 2e5 + 5;



int solve() {
    string s;
    cin >> s;
    int one = 0, two = 0;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'A') one++;
        else two++;
    }
    if(one > two) swap(one, two);
    if(one == 1 and two == 2) printf("Yes\n");
    else printf("No\n");
    return 0;
}

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test = 1, tc = 0;
    //Int(test);
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

string solve() {
    int a,b,v,w;
    cin >> a >> v >> b >> w;
    ll t; cin >> t;
    if (w >= v) return "NO";
    if ((v-w)*t >= abs(b-a)) return "YES";
    return "NO";
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    cout << solve() << endl;

    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << "a ";
    if (a == b) {
        cout << "==";
    } else if (a < b) {
        cout << "<";
    } else {
        cout << ">";
    }
    cout << " b" << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int to[N],nex[N],beg[N],dep[N],son[N],maxdep[N],id[N],val[N][3],Num[N];
struct node{
	int Zero,One;
};
vector <node> dp[N];
int e,cnt;
inline int read(){
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + ch - '0',ch = getchar();
	return x * flag;
}
inline int fpm(int a,int b){
	int res = 1;
	while(b){
		if(b & 1)res = 1ll * res * a % mod;
		a = 1ll * a * a % mod,b /= 2;
	}
	return res;
}
inline int Mod(int Val){
	if(Val >= mod)Val -= mod;
	if(Val < 0)Val += mod;
	return Val;
}
inline void add(int x,int y){
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}
void dfs(int x){
	Num[dep[x]]++,maxdep[x] = dep[x];
	for(int i = beg[x];i;i = nex[i]){
		dep[to[i]] = dep[x] + 1;
		dfs(to[i]);
		if(maxdep[to[i]] > maxdep[son[x]])son[x] = to[i];
		maxdep[x] = max(maxdep[x],maxdep[to[i]]);
	}
}
inline void Dp(int x){
	int Dep = 0,tot = 0;bool flag = 0;
	for(int i = beg[x];i;i = nex[i]){
		Dp(to[i]);
		if(to[i] == son[x])continue;
		Dep = max(Dep,maxdep[to[i]] - dep[x]);
	}
	if(son[x])id[x] = id[son[x]];
	Fordown(i,dp[id[x]].size() - 1,dp[id[x]].size() - Dep){
		val[++tot][0] = dp[id[x]][i].Zero;
		val[tot][1] = dp[id[x]][i].One;
		val[tot][2] = Mod(dp[id[x]][i].Zero + dp[id[x]][i].One);
	}
	for(int i = beg[x];i;i = nex[i]){
		flag = 1;
		if(to[i] == son[x])continue;
		For(j,0,dp[id[to[i]]].size() - 1){
			int pos = dp[id[to[i]]].size() - j;
			val[pos][1] = (1ll * val[pos][0] * dp[id[to[i]]][j].One + 1ll * val[pos][1] * dp[id[to[i]]][j].Zero) % mod;
			val[pos][0] = 1ll * val[pos][0] * dp[id[to[i]]][j].Zero % mod;
			val[pos][2] = 1ll * val[pos][2] * (dp[id[to[i]]][j].Zero + dp[id[to[i]]][j].One) % mod;
		}
	}
	For(i,1,Dep)dp[id[x]][dp[id[x]].size() - i] = (node){Mod(val[i][2] - val[i][1] + mod),val[i][1]};
	if(!flag)id[x] = ++cnt;
	dp[id[x]].push_back((node){1,1});
}
int main(){
	int n = read() + 1;
	For(i,2,n){
		int x = read() + 1;
		add(x,i);
	}
	dfs(1),Dp(1);
	int ans = 0;
	For(i,0,dp[id[1]].size() - 1)
		ans = (ans + 1ll * dp[id[1]][i].One * fpm(2,n - Num[maxdep[1] - i])) % mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 25076
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

group :: Int -> Int
group x | x `elem` [1,3,5,7,8,10,12] = 1
group x | x `elem` [4,6,9,11] = 2
group _ = 3

main :: IO ()
main = do
    [a, b] :: [Int] <- map read . words <$> getContents
    putStrLn $ if group a == group b then "Yes" else "No"

Measured memory_bytes: 380
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
void func(int);
int main(void)
{
	int i,p,a[200],x,len;
	char buf[8];
	p=0;
	while(scanf("%s",buf)!=EOF)	{
		if(buf[0]=='+')	{
			a[p-2]=a[p-2]+a[p-1];
			p--;
		}
		else if(buf[0]=='-')	{
			a[p-2]=a[p-2]-a[p-1];
			p--;
		}	
		else if(buf[0]=='*')	{
			a[p-2]=a[p-2]*a[p-1];
			p--;
		}	
		else {
			len=strlen(buf);
//			printf("buf=%s\n",buf);
			x=0;
			for(i=0;i<len;i++)	{
				x*=10;
				x+=buf[i]-'0';
			}
			a[p]=x;
//			printf("x=%d\n",x);
			p++;
			
		}
	}
	printf("%d\n",a[0]);
	return 0;
}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL vector<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<string,LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
  cin>>n;
      string a;
  while(n--)
  {
      cin>>a;
      v[a]++;
  }
  cin>>m;
  while(m--)
  {
      cin>>a;
      v[a]--;
  }
  k=0;
  for(MSL it=v.B;it!=v.E;it++)
  {
      k=max(k,it->SE);
  }
  cout<<k<<endl;
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n, q;
  cin >> n >> q;
  string st;
  cin >> st;
  vector<ll> s(n + 1, 0);
  FOR(i, 1, n) {
    if (st[i - 1] == 'A' && st[i] == 'C') {
      s[i] = s[i - 1] + 1;
    } else {
      s[i] = s[i - 1];
    }
  }
  REP(i, q) {
    ll l, r;
    cin >> l >> r;
    --l, --r;
    cout << s[r] - s[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
    a[i]--;
  }
  vector<int> cnt(n, -1);
  cnt[0]=0;
  int next=a[0], pre=0;
  while(cnt[next]==-1){
    cnt[next]=cnt[pre]+1;
    pre=next;
    next=a[next];
  }
  ll cycle=cnt[pre]-cnt[next]+1;
  int ans;
  if(k-cnt[next]<0){
    ans=0;
    while(k!=0){
      ans=a[ans];
      k--;
    }
  } else {
    k-=cnt[next];
    k%=cycle;
    ans=next;
    while(k!=0){
      ans=a[ans];
      k--;
    }
  }
  cout << ans+1 << endl;
  return 0;
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int mod = 998244353;

int main() {
	int n = nxt();
	string s;
	cin >> s;

	vector<long long> deg(n + 1, 1);
	for (int i = 1; i <= n; ++i) {
		deg[i] = deg[i - 1] * 2 % mod;
	}
	vector<long long> cnt(n + 1);
	for (int d = 1; d <= n; d += 2) {
		if (n % d) {
			continue;
		}
		int l = n / d;
		long long tmp = 0;
		for (int i = 0; i < l; ++i) {
			if (s[i] == '1') {
				tmp += deg[l - 1 - i];
			}
		}
		string t = s;
		for (int i = l; i < n; ++i) {
			t[i] = t[i - l] == '0' ? '1' : '0';
		}
		if (t <= s) {
			tmp += 1;
		}
		tmp %= mod;
		cnt[d] = tmp;
		// ans += 2 * l * tmp % mod;
	}

	long long ans = 0;
	for (int i = n; i > 0; --i) {
		for (int j = i * 2; j <= n; j += i) {
			cnt[i] -= cnt[j];
		}
		cnt[i] %= mod;
		if (cnt[i] < 0) {
			cnt[i] += mod;
		}
		ans += (n / i) * 2 * cnt[i] % mod;
	}

	cout << ans % mod << "\n";

	return 0;
}


Measured memory_bytes: 3844
#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;
}

const long long MOD = 1000000007;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(ll n, ll k) {
  mint x = 1, y = 1;
  for(ll i=0; i<k; i++) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}



void solve(long long N, long long K){
  mint n = mint(N);
  mint k = mint(K);
  mint ans = mint(0);
  mint ma=mint(0);
  mint mi=mint(0);
  for(ll i=0; i<K; i++) {
    ma+=mint(N-i);
  }
  for(ll i=0; i<K; i++) {
    mi+=mint(i);
  }
  
  for(ll i=K; i<=N+1; i++) {
    mint ii=mint(i);
    // mint y;
    // if(i==N+1)
    //   y = m;
    // else
    //   y = m-(ii*(n-ii)/mint(2));
    //std::cout << ma.x << ", " << mi.x << std::endl;
    ans += ma-mi+mint(1);
    ma+=(n-ii);
    mi+=(ii);
    //std::cout << y.x << std::endl;
    //std::cout << (ii*(ii-1)/2).x << std::endl;
    //std::cout << (((y-ii*(ii-1))/2) + mint(1)).x << std::endl;
    //ans += (y-ii*(ii-1)/mint(2)) + mint(1);
  }
  std::cout << ans.x << std::endl;
  
}

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



Measured memory_bytes: 3256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_4D
{
    class Program
    {
        private static Boolean EOF = false;

        public static string word(char delimita)
        {
            string inString = "";
            int inInt;
            char inChar;

            //Console.WriteLine("DEBUG: -" + delimita + "-");
            if (EOF == true) return null;
            while (true)
            {
                inInt = Console.Read();
                
                if (inInt == -1)
                {
                    EOF = true;
                    break;
                }
                inChar = Convert.ToChar(inInt);
                //Console.WriteLine("DEBUG: -" + inChar + "-");
                //Console.WriteLine("DEBUG: -" + Convert.ToString(inChar) + "-");
                if (inChar == delimita) break;
                else if (inChar.ToString() == "\n") break;

                inString = inString + inChar;
            }

            //Console.WriteLine("DEBUG rc: " + inString);
            return inString;

        }

        static void Main(string[] args)
        {
            int Max, Min, current;
            double Sum = 0.0;
            int count = int.Parse(word(' '));
            Max = Min = int.Parse(word(' '));
            Sum = (double)Max;
            for (int i = 1; i < count; i++)
            {
                current = int.Parse(word(' '));
                if (Max < current) Max = current;
                if (Min > current) Min = current;
                Sum += (double)current;
                //Console.WriteLine("DEBUG sum: " + Sum.ToString("F0"));
            }
            Console.WriteLine(Min + " " + Max + " " + Sum.ToString("F0"));

        }
    }
}

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

int main(){
    string a;
    cin >> a;
    for (int i=0; i<a.size();i++){
        if (a[i] == '9'){
            cout << 1;
        }
        else if (a[i] == '1'){
            cout << 9;
        }
    }cout << endl;
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, M, X;
    cin >> N >> M >> X;
    int C[N];
    int A[N][M];
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }
    int sum[M];
    int price = 0;
    int cnt = 0;
    int ans = INT32_MAX;
    for (int bit = 0; bit < (1 << N); ++bit)
    {
        fill(sum, sum + M, 0);
        price = 0;
        for (int i = 0; i < N; ++i)
        {
            if (bit & (1 << i))
            {
                price += C[i];
                for (int j = 0; j < M; j++)
                {
                    sum[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for (int k = 0; k < M; k++)
        {
            if (sum[k] < X)
            {
                ok = false;
            }
        }
        if (ok == true)
        {
            ans = min(ans, price);
        }
    }
    if (ans != INT32_MAX)
    {
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3548
import fractions
a, b, c, d = list(map(int, input().split()))


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def search(n, i, j):
    l = lcm(i, j)
    return n - n // i - n // j + n // l


print(search(b, c, d) - search(a - 1, c, d))


Measured memory_bytes: 5048
#include <stdio.h>

typedef struct{
  char value;
  char mark;
}Card;

int main(){
  int i, j, length, mini, flag = 0;
  char emp; 
  Card C1[36],C2[36],swap;

  scanf("%d%c",&length, &emp);
  for(i = 0; i < length; i++){
    scanf("%c%c%c",&C1[i].mark, &C1[i].value, &emp);
    C2[i] = C1[i];
  }
    /*BubbleSort*/
  for(i = 0; i < length; i++){
    for(j = length-1; j > i; j--){
      if(C2[j].value < C2[j-1].value){
	swap = C2[j];
	C2[j] = C2[j-1];
	C2[j-1] = swap;
      }
    }
  }
  for(i = 0; i < length; i++){
    printf("%c%c",C2[i].mark,C2[i].value);
    if(i <= length-2) printf(" ");
  }
  printf("\n");
  printf("Stable\n");

  /*SelectionSort*/
  for(i = 0; i < length; i++){
    mini = i;
    for(j = i; j < length; j++){
      if(C1[j].value < C1[mini].value){
      	mini = j;
      }
    }
    swap = C1[i];
    C1[i] = C1[mini];
    C1[mini] = swap;
  }
  for(i = 0; i < length; i++){
    printf("%c%c",C1[i].mark, C1[i].value);
    if(i <= length-2) printf(" ");
    if(C1[i].mark != C2[i].mark || C1[i].value != C2[i].value) flag = 1;
  }
  printf("\n");
  if(flag == 1) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}

Measured memory_bytes: 612
from sys import stdin
import math
import fractions
from collections import deque
import sys

# 再起の上限を変更
sys.setrecursionlimit(100000)

INF = 10 ** 10

# 深さ優先探索
def dfs(i):
    global is_visited
    global tsort_res

    if is_visited[i]:
        return 

    is_visited[i] = True
    for j in nextl[i]:
        dfs(j)
    
    # 帰りがけ順で追加
    # 追加は先頭に行う
    tsort_res.appendleft(i)


# トポロジカルソート
def tsort():
    for i in range(1, N+1):
        dfs(i)

if __name__ == "__main__":

    N, M = [int(x) for x in stdin.readline().rstrip().split()]

    # トポロジカルソートで頂点iより後ろのパスの最大長
    dp = [0] * (N+1)

    # 頂点xから頂点vへの有向辺
    nextl = [[] for _ in range(N+1)]
    for _ in range(M):
        x, v = list(map(int, stdin.readline().rstrip().split()))
        nextl[x].append(v)
    
    # トポロジカルソートされた結果の入るリスト
    tsort_res = deque([])

    is_visited = [False] * (N+1)

    # トポロジカルソートの実行
    tsort()

    # 今回は逆順に使うのでリバースする
    # つまり、トポロジカルオーダーの最後の番号に該当する頂点から処理を行う
    # 汎用性のため、dfsでは先頭に追加するようにしている
    #tsort_res = list(tsort_res)[::-1]

    """
    for x in tsort_res:
        for v in nextl[x]:
            dp[x] = max(dp[x], dp[v] + 1)
    """
    for x in tsort_res:
        for v in nextl[x]:
            dp[v] = max(dp[v], dp[x] + 1)


    # for DEBUG
    #print(dp)
    print(max(dp))

Measured memory_bytes: 149304
#include <iostream>

using namespace std;

bool isACGT(char c)
{
    return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}

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

    int count = 0;
    int max = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (isACGT(s[i]))
        {
            count++;
            if (count > max) max = count;
        }
        else
        {
            count = 0;
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
m = 0
 
for i in range(n):
  m += b[a[i]-1]
  if i==0:
    continue
  if a[i] == a[i-1]+1:
    m += c[a[i]-2]
    
print(m)

Measured memory_bytes: 38256
using System;

class Program
{
    static void Main(string[] args){
        string[] str = Console.ReadLine().Split(' ');
        int h1, m1, h2, m2, k;
        h1 = int.Parse(str[0]);
        m1 = int.Parse(str[1]);
        h2 = int.Parse(str[2]);
        m2 = int.Parse(str[3]);
        k = int.Parse(str[4]);

        DateTime time1 = new DateTime(2000,1,1,h1,m1,0);
        DateTime time2 = new DateTime(2000,1,1,h2,m2,0);
        
        if(time1 > time2){
            time2.AddDays(1);
        }

        TimeSpan time3 = time2 - time1;

        int m = time3.Hours * 60 + time3.Minutes;

        Console.WriteLine(m-k);
    }
}

Measured memory_bytes: 18048
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String x = "";
        for (int i = 0; i < s.length(); i++) {
            x += 'x';
        }
        System.out.println(x);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
main()
{
  int A[101], i, j, length, key;

  scanf("%d",&length);
  for(i=1; i <= length; i++){
    scanf("%d", &A[i]); 
  }
  
  for(i=1; i <= length; i++){
    printf("%d", A[i]);
    if(i != length)printf(" ");
  }
  printf("\n");

 for(j = 2 ; j <= length; j++){
   key = A[j];
   /* insert A[j] into the sorted sequence A[1,...,j-1] */
   i = j - 1;
   
   while( i > 0 && A[i] > key ){
     A[i+1] = A[i];
     i = i - 1;
     A[i+1] = key;
   }
     for(i=1; i <= length; i++){
       printf("%d", A[i]);
       if(i != length)printf(" ");
			}
     printf("\n");
 }
 return 0;
}

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

using namespace std;
int main() {
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int result = 0;

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int sum = 0;
      for (int k = 0; k < d; k++) {
        int diff = abs(x[i][k] - x[j][k]);
        sum += diff * diff;
      }
      bool flag = false;
      for (int k = 0; k <= sum; k++) {
        if (k * k == sum) {
          // cout << "i:" << i << " j:" << j << " sum:" << sum << endl;
          flag = true;
        }
      }
      if (flag) ++result;
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val inputs = StdIn.readLine().split(" ")
  val P = inputs(0).toInt
  val Q = inputs(1).toInt
  val R = inputs(2).toInt

  val C = Seq((P,Q), (P, R), (Q, R))
  val min = C.map{case (_1, _2) => _1 + _2}.min

  println(min)
}

Measured memory_bytes: 27212
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>

#define mod 1000000007
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOREACH(i, v) for(auto i = v.begin(); i != v.end(); i++)

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

int gcd(int a, int b) {
    int x = max(a, b);
    int y = min(a, b);
    int z = x % y;
    if(z == 0){
        return y;
    }else{
        return gcd(y, z);
    }
}

int lcm(int a, int b) {
    return (a*b)/gcd(a, b);
}

void solve() {
    string a, b;
    cin >> a >> b;
    a += b;
    int x = atoi(a.c_str());
    if(sqrt(x) != floor(sqrt(x))){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

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

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int h, w, k;

char str[810][810];

int d[810][810];

PII operator + (const PII &a, const PII &b) { return mp(a.fi + b.fi, a.se + b.se); }

bool check(const PII &a) { return a.fi >= 1 && a.fi <= h && a.se >= 1 && a.se <= w && str[a.fi][a.se] != '#'; }

int main()
{
	memset(d, 63, sizeof d);
	giii(h, w, k);
	for (int i = 1; i <= h; ++i) scanf("%s", str[i] + 1);
	int l = 0, r = 0;
	static PII q[810 * 810];
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j)
			if (str[i][j] == 'S')
				q[r++] = mp(i, j), d[i][j] = 0;
	while (l < r)
	{
		PII u = q[l++];
		if (check(u + mp(1, 0)))
		{
			PII v = u + mp(1, 0);
			if (d[v.fi][v.se] > d[u.fi][u.se] + 1)
			{
				d[v.fi][v.se] = d[u.fi][u.se] + 1;
				q[r++] = v;
			}
		}
		if (check(u + mp(-1, 0)))
		{
			PII v = u + mp(-1, 0);
			if (d[v.fi][v.se] > d[u.fi][u.se] + 1)
			{
				d[v.fi][v.se] = d[u.fi][u.se] + 1;
				q[r++] = v;
			}
		}
		if (check(u + mp(0, 1)))
		{
			PII v = u + mp(0, 1);
			if (d[v.fi][v.se] > d[u.fi][u.se] + 1)
			{
				d[v.fi][v.se] = d[u.fi][u.se] + 1;
				q[r++] = v;
			}
		}
		if (check(u + mp(0, -1)))
		{
			PII v = u + mp(0, -1);
			if (d[v.fi][v.se] > d[u.fi][u.se] + 1)
			{
				d[v.fi][v.se] = d[u.fi][u.se] + 1;
				q[r++] = v;
			}
		}
	}
	int ans = d[0][0];
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			int v = min(min(i - 1, h - i), min(j - 1, w - j));
			if (!v && d[i][j] <= k) ans = 1;
			if (d[i][j] <= k) ans = min(ans, 1 + (v - 1) / k + 1);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8448
n,m=( int(x) for x in  input().split())
#print(n,m)
st=[]
for i in range(n):
  st.append('a')
#print(st)
ng=0
for i in range(m):
  s,c=(int(x) for x in input().split())
  if st[s-1]=='a':
    st[s-1]=str(c)
  elif st[s-1]==str(c):
    pass
  else:
    ng=ng+1
#print(st,ng)
if ng>0:
  print(-1)
else:
  for i in range(n):
#    print(n,i,st[i])
    if i==0:
      if st[0]=='a':
        st[0]='1'
        if n==1:
          st[0]='0'
        
    if st[i]=='a':
      st[i]='0'
#  print(st)
  ans=0
  for i in range(n):
  	ans+= 10**(n-1-i) * int(st[i])
  if n>1:
    if st[0]=='0':
      print(-1)
    else:
      print(ans)
  else:
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
using ll = long long;

/*
例えば1から100の間に3で割り切れる数がいくつあるかを考えたとき, 100/3=33.333で33個だと分かる.
1からbの間にあるxで割り切れる数の個数から, 1からaの間にあるxで割り切れる数の個数を引けば,
aからbの間にあるxで割り切れる数の個数が求められる. ただし, aがxで割り切れるならaを個数に含み,
割り切れないなら含まない.
*/

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  cout << (b / x) - (a / x) + !(a % x) << endl;
}

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

int main(void){
int n,m;
cin  >> n >> m;
if (n+1<m){ cout << 0 << endl; return 0; }
if (m+1<n){ cout << 0 << endl; return 0; }
long long sn=1;
for (int i=1;i<n+1;i++){
sn = ( sn * i ) % ( 1000000007 );
}
long long sm=1;
for (int i=1;i<m+1;i++){
sm = ( sm * i ) % ( 1000000007 );
}
//cout << sn << "," << sm;
long long smn = (sn*sm)% ( 1000000007 );
if (m==n){cout << (smn*2)% ( 1000000007 ) << endl; }else{
cout << (smn)% ( 1000000007 ) << endl;
}
return 0; 
  
}

Measured memory_bytes: 256
xx, kk, d = map(int, input().split())


def do_solve(x, k):
    if -d == x == d:
        return 0 if k % 2 != 0 else x
    elif -d < x < d:
        return x if k % 2 == 0 else (x - d if x > 0 else x + d)

    ax = abs(xx) // d
    dd = d * ax
    if x > 0:
        return do_solve(x - dd, k - ax)
    else:
        return do_solve(x + dd, k - ax)

    # if x > 0:
    #     return do_solve(x - d, k - 1)
    # else:
    #     return do_solve(x + d, k - 1)


def solve():
    if xx == 0:
        return d

    ax = abs(xx) // d
    if kk < ax:
        if xx > 0:
            return xx - d * kk
        else:
            return xx + d * kk
        # return xx - (d * ax) if xx > 0 else xx + (d * ax)}

    return do_solve(xx, kk)


print(abs(solve()))
#


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

int x() {
  int a, b;
  cin >> a >> b;
  for(int i = 1;i < 1009;i++) {
    if((int)(i * 0.08) == a && (int)(i / 10) == b) return i;
  }
  return -1;
}
int main() {
  cout << x() << endl;
}

Measured memory_bytes: 3584
n=int(input())
L=list(map(int,input().split()))
L.sort(reverse = True)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        cnt = 0
        start=j+1
        goal=n
        while goal!=start:
            half = (start + goal)//2
            if L[i] < L[j] + L[half]:
                start = half + 1
                cnt = max(half-j,cnt)
            else:
                goal = half
        ans += cnt
print(ans)

Measured memory_bytes: 73604
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)
		cin >> a.at(i) >> b.at(i);
	int sum = 0;
	for (int i = 0; i < n; i++)
		sum += b.at(i) - a.at(i) + 1;

	cout << sum << endl;
}

Measured memory_bytes: 256
#include<complex>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<deque>
#include<queue>
#include<climits>
#include<list>
#include<stack>
#include<ctime>
#define all(n) n.begin(),n.end()
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define Iter(c) __typeof__((c).begin())
#define foreach(i,c) for(Iter(c) i = (c).begin();i != (c).end();++i)
#define pb push_back
#define INF (1<<27)
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)

using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef unsigned long long ull;
typedef long long ll;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int Clock(int h,int m,int s)
{
  return h*3600+m*60+s;
}

string itos(int i)
{
  stringstream ss;
  ss << i;
  return ss.str();
}

void print(int Time)
{
  int h,m,s;
  h = Time/3600;
  Time -= Time/3600*3600;
  m = Time/60;
  Time -= Time/60*60;
  s = Time;
  string ele[3];
  ele[0] = itos(h);
  ele[1] = itos(m);
  ele[2] = itos(s);
  cout << string(2-ele[0].length(),'0') << ele[0] << ":" << string(2-ele[1].length(),'0') << ele[1] << ":" << string(2-ele[2].length(),'0') << ele[2] << endl; 

}

int main(){

  int h,m,s;
  while(true)
    {
      cin >> h >> m >> s;
      if(h+m+s == -3)
	break;
      int TimeX = Clock(2,0,0);
      int Time = Clock(h,m,s);
      print(TimeX-Time);
      print((TimeX-Time)*3);
    }

  return 0;
}

Measured memory_bytes: 1220
class UnionFind :
    def __init__(self, size) :
        """
        Parameters
        ---
        size : int
            頂点数
        """
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index) :
        """
        親のインデックスの取得

        Parameters
        ---
        index : int
            取得する頂点のインデックス

        Returns
        ---
        rootIndex : int
            指定した頂点の根のインデックス
        """
        if self.parent[index] == index :  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2) :  # 結合
        """
        木の結合

        Parameters
        ---
        index1 : int
        index2 : int
            結合する頂点のインデックス
        """
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2 :  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2] :
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else :
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2] :
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2) :
        """
        同じ木に属するかを判定する

        Parameters
        ---
        index1 : int
        index2 : int

        Returns
        ---
        boolean
        """
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index) :
        """
        指定した頂点の属する木の大きさを取得する
        """
        return self.size[self.root(index)]

    def getComponent(self) :
        """
        連結成分数を取得する
        """
        return self.component

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

ans = float('inf')
for x, y in XY:
    for u, v in XY:
        p = x - u
        q = y - v

        tree = UnionFind(N)
        for i, (a, b) in enumerate(XY):
            for j, (c, d) in enumerate(XY):
                if a - c == p and b - d == q:
                    tree.union(i, j)

        ans = min(ans, tree.getComponent())

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int a,b,c,d,m,n,x=0,y;

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

    m=abs(a-b);

    n=abs(b-c);

    y=abs(a-c);

    if((m<=d && n<=d == 1)||y <= d)
    {
       printf("Yes\n");
    }

    else
    {
       printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>

using namespace std;

int main()
{
   string days[] = {"SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" };
    string x ;
    cin >> x ;
    int i , res = 0;
    for (i=0 ; i<7 ; i++){
        if(x == days[i])
                res = (7-i) ;
    }
    cout << res << endl ;
    return 0;

}


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

int main(){
	ios::sync_with_stdio(false);

	int n, p;
	string s;
	cin >> n >> p >> s;
	long long ans = 0;
	if(10 % p == 0){
		for(int i = 0; i < n; ++i){
			if((s[i] - '0') % p == 0){
				ans += i + 1;
			}
		}
	}
	else{
		vector<int> hist(p);
		int a = 0;
		int t = 1;
		for(int i = n - 1; i >= 0; --i){
			a = (a + t * (s[i] - '0')) % p;
			++hist[a];
			t = t * 10 % p;
		}

		a = 0;
		t = 1;
		for(int i = n - 1; i >= 0; --i){
			ans += hist[a];
			a = (a + t * (s[i] - '0')) % p;
			--hist[a];
			t = t * 10 % p;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int N, M, inf=1e9;
typedef pair<int, int> P;
typedef pair<int, P> PP;
map <P, vector<PP>> mp;
map <P, int> cost;

void dijkstra(P start){
    priority_queue < PP, vector<PP>, greater<PP> > q;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) cost[itr->first] = inf;
    cost[start] = 0;
    q.push(PP(0, start));
    while (q.size()) {
        P current_station = q.top().second;
        q.pop();
        for (PP next : mp[current_station]) {
            P next_station = next.second;
            int c = next.first;
            if (cost[next_station] > cost[current_station] + c) {
                cost[next_station] = cost[current_station] + c;
                q.push(PP(cost[next_station], next_station));
            }
        }
    }
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int p, q, c;
        cin >> p >> q >> c;
        mp[P(p, 0)].push_back(PP(1, P(p, c))); // 駅pで路線cに入る
        mp[P(p, c)].push_back(PP(0, P(q, c))); // 路線cでp->q
        mp[P(q, c)].push_back(PP(0, P(q, 0))); // 駅qで路線cから出る
        mp[P(q, 0)].push_back(PP(1, P(q, c))); // 駅qで路線cに入る
        mp[P(q, c)].push_back(PP(0, P(p, c))); // 路線cでq->p
        mp[P(p, c)].push_back(PP(0, P(p, 0))); // 駅pで路線cから出る
    }

    dijkstra(P(1, 0));

    int ans = cost[P(N, 0)] == 0 || cost[P(N, 0)] == inf ? -1 : cost[P(N, 0)];
    cout << ans << "\n";
    return 0;
}

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

from collections import defaultdict

d1 = defaultdict(int)

for i in input().split():
    d1[int(i)] += 1

ans = [0]*(10**5+2)

for i in d1.keys():
    ans[i-1] += d1[i]
    ans[i]   += d1[i]
    ans[i+1] += d1[i]
print(max(ans))

Measured memory_bytes: 55468
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;


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

	ll v[50];
	for(int i=0;i<n;i++) cin >> v[i];

	ll ans = 0;
	for(int i=0;i<=min(n,k);i++){
		for(int j=0;j<=i;j++){
			vector<ll> get;
			for(int l=0;l<j;l++) get.push_back(v[l]);
			for(int l=0;l<i-j;l++) get.push_back(v[n-1-l]);

			sort(get.begin(),get.end());
			for(int j=0;j<k-i&&j<get.size();j++){
				if(get[j]>0) break;
				else get[j] = 0;
			}
			ll tmp = 0;
			for(int j=0;j<get.size();j++) tmp += get[j];
			//if(ans < tmp){
			//	for(int j=0;j<get.size();j++) cout << get[j];
			//	cout << "\n";
			//}
			
			ans = max(ans,tmp);
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
using namespace std;

int main(){
  string s,t;
  cin >>s >>t;
  s+=s;
  if(s.find(t)!=std::string::npos){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
a,b,c,d=map(int,input().split())
if a<=c<b<=d:
    print(b-c)
elif c<=a<d<=b:
    print(d-a)
elif a<=c<d<=b:
    print(d-c)
elif c<=a<b<=d:
    print(b-a)
else:
    print(0)

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;
LL N, K;
int main() {
	cin >> N >> K;
	N %= K;
	cout << min(abs(N - K), N);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int A[n][m],B[m][l];
    long long int C[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            scanf("%d",&B[i][j]);
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int k = 0; k < l; k++){
            for(int j = 0; j < m; j++){
                C[i][k] += A[i][j]*B[j][k];
            }
        }
    }
 
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l-1; j++){
            printf("%lld ",C[i][j]);
        }
        printf("%lld\n",C[i][l-1]);
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> W(N);
  rep(i,N) cin >> W.at(i);
  
  int ans = 10000;
  rep(T,N) {
    int S1 = 0, S2 = 0;
    repm(i,0,T+1) S1 += W.at(i);
    repm(i,T+1,N) S2 += W.at(i);
    ans = min(ans, abs(S1 - S2));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)
	 {
	 	cout<<"hon"<<endl;
	 	return 0;
	  } 
	  if(a==0||a==1||a==6||a==8)
	  {
	  	cout<<"pon"<<endl;
	  	return 0;
	  }
	  else
	  {
	  	cout<<"bon"<<endl;
	  	return 0;
	  }
} 

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


public class A
{
	public static void Main()
	{
		string c1 = Console.ReadLine();
		string c2 = Console.ReadLine();
		bool ans = true;
		for(int i = 0; i < 3; i++)
		{
			if(c1[i] != c2[2 - i])
			{
				ans = false;
				break;
			}
		}

		Console.WriteLine(ans ? "YES" : "NO");
	}
}





Measured memory_bytes: 13140
using System;

public class lec01_A
   {
      public static void Main(){
        int[] A;
        var n = int.Parse(Console.ReadLine());
        A = new int[n];
        string[] str = Console.ReadLine().Split(' ');
        for(int i = 0; i < n;i++){
        A[i] = int.Parse(str[i]);
        }
        for(int i = 0;i < n - 1;i++){
          int v = A[i + 1];
          int j = i;
          for(int k = 0;k < n - 1;k++){
          Console.Write(A[k] + " ");
          }
          Console.Write(A[n - 1]);
          Console.WriteLine();
          while(j >= 0 && A[j] > v){
               A[j + 1] = A[j];
               j--;
               A[j + 1] = v;
          }
        }
       for(int k = 0;k < n - 1;k++){
        Console.Write(A[k] + " ");
      }
      Console.Write(A[n - 1]);
      Console.WriteLine("");
      }
  }


Measured memory_bytes: 9264