akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define sz(a) (long long)((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout<<"----------------------------------\n";
#define mp make_pair
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
            ans%=MOD;
        }
        base=base*base;
        base%=MOD;
        y=y>>1;
    }
    return ans;
}

int main()
{    
    fastinput;
    LL n,i,j,k,t,temp;
    cin>>n>>k;
    vector<LL> dp(k+1,0);

    for(i=k;i>=1;i--)
    {
       // debug(i);
        LL add=(k/i);
        dp[i]=POW(add,n);
        for(j=2*i;j<=k;j+=i)
        {
            //debug(j);
            dp[i]=(dp[i]-dp[j]+50*MOD)%MOD;
        }
       // part;
    }
    LL ans=0;
    for(i=1;i<=k;i++)
    {
        //debug(dp[i]);
        ans+=i*dp[i];
        ans%=MOD;
    }
    cout<<ans<<endl;
    


    
    return 0;
}



Measured memory_bytes: 3956
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXM = 1e5 + 5;

ll f[MAXM], sum[MAXM];

int main(void)
{
	ll n;
	int x,m;
	scanf("%lld%d%d",&n,&x,&m);
	
	ll ans = 0;
	for(int i=1; i<=n; ++i)
	{
		sum[i] = sum[i-1] + x;
		
		if(f[x])
		{
			ans += (sum[i] - sum[f[x]]) * ((n-i+1) / (i-f[x]));
			
			ll rem = (n-i+1) % (i-f[x]);
			while(rem--)
			{
				ans += x;
				x = (ll)x * x %m;
			}
			break;
		}
		
		f[x] = i;
		ans += x;
		x = (ll)x * x %m;
	}
	printf("%lld",ans);
	return 0;
}

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

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

    int a[26];
    for(int i = 0; i < 26; i++){
        a[i] = 0;
    }

    for(int i = 0; i < s.length(); i++){
        a[s[i] - 'a'] = 1;
    }

    int flag = 0;

    for(int i = 0; i < 26; i++){
        if(a[i] == 0){
            cout << char(i + 'a') << endl;
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        cout << "None" << endl;
    }

}

Measured memory_bytes: 512
#pragma optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 2 * (int)1e5 + 100;
int n, m;
string s;
int dp[maxN][2][2];
int f[maxN];
int pref[maxN][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cin >> n >> m >> s;
    if (s[0] == 'B') {
        for (int i = 0; i < m; i++) {
            s[i] = 'R' + 'B' - s[i];
        }
    }
    while (!s.empty() && s.back() == 'R') s.pop_back();
    if (s.empty()) {
        // 1 - B
        // 0 - R
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                if (i == 1 && j == 1) continue;
                dp[0][i][j] = 1;
            }
        }
        for (int i = 0; i + 1 <= n - 2; i++) {
            for (int was = 0; was < 2; was++) {
                for (int last = 0; last < 2; last++) {
                    for (int nlast = 0; nlast < 2; nlast++) {
                        if (nlast == 1 && last == 1) continue;
                        dp[i + 1][was][nlast] = sum(dp[i + 1][was][nlast], dp[i][was][last]);
                    }
                }
            }
        }
        int sm = 0;
        for (int last = 0; last < 2; last++) {
            for (int cur = 0; cur < 2; cur++) {
                if (last == 1 && cur == 1) continue;
                sm = sum(dp[n - 2][last][cur], sm);
            }
        }
        cout << sm << '\n';
        return 0;
    }
    int limR = 0;
    int cnt = 0;
    m = s.size();
    for (int i = 0; i < m; i++) {
        if (s[i] == 'B') break;
        cnt++;
    }
    if (cnt % 2 == 0) {
        limR = cnt + 1;
    }
    else {
        limR = cnt;
    }
    assert(s[m - 1] == 'B');
    for (int i = 0; i + 1 < m; i++) {
        if (s[i] == 'B' && s[i + 1] != 'B') {
            int tot = 0;
            for (int j = i + 1; ; j++) {
                if (s[j] == 'B') break;
                tot++;
            }
            if (tot % 2 == 0) continue;
            limR = min(limR, tot);
        }
    }
  //  cout << limR << endl;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 2; j++) {
            pref[i][j] = sum(pref[i][j], pref[i - 1][j]);
        }
        if (i % 2 == 1 && i <= limR) f[i] = sum(f[i], 1);
        if (i >= 2) {
            f[i] = sum(f[i], sub(pref[i - 2][i % 2], pref[max(0, i - limR - 2)][i % 2]));
        }
        pref[i][i % 2] = sum(pref[i][i % 2], f[i]);
    }
    int ans = 0;
    for (int red1 = 1; red1 <= limR; red1 += 2) {
        if (n == red1 + 1) {
            ans = sum(ans, n);
            continue;
        }
        int le = n - red1 - 2;
        if (le < 0) continue;
        ans = sum(ans, mult(f[le], red1 + 1));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4688
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d==25){
    cout << "Christmas" << endl;
  }else if(d==24){
    cout << "Christmas Eve" << endl;
  }else if(d==23){
    cout << "Christmas Eve Eve" <<endl;
  }else if(d==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}

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

using namespace std;

int main(void) {
  int N;
  cin >> N;
  string ans = "";
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans = "1" + ans;
    }
    else {
      ans = "0" + ans;
    }
    N /= -2;
  }

  if (ans == "") {
    ans = "0";
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static ArrayList<ArrayList<Edge>> g = new ArrayList<>();
  static int N, M, S, T;

  public static void main(String[] args) {
    N = sc.nextInt();
    M = sc.nextInt();
    S = sc.nextInt() - 1;
    T = sc.nextInt() - 1;
    for (int i = 0; i < N; i++) {
      g.add(new ArrayList<>());
    }
    for (int i = 0; i < M; i++) {
      int U = Integer.parseInt(sc.next()) - 1;
      int V = Integer.parseInt(sc.next()) - 1;
      int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());
      g.get(U).add(new Edge(V, A, B));
      g.get(V).add(new Edge(U, A, B));
    }
    long[] sd = shortest(S);
    long[] td = shortest(T);
    long[] ans = new long[N];
    ans[N - 1] = sd[N - 1] + td[N - 1];
    for (int i = N - 2; i >= 0; i--) {
      ans[i] = Math.min(ans[i + 1], sd[i] + td[i]);
    }
    PrintWriter writer = new PrintWriter(System.out);
    for (int i = 0; i < N; i++) {
      writer.println(1_000_000_000_000_000L - ans[i]);
    }
    writer.flush();
  }

  static long[] shortest(int from) {
    final long INF = (long) 1e17;
    long[] dist = new long[N];
    Arrays.fill(dist, INF);
    boolean[] visited = new boolean[N];
    PriorityQueue<State> q = new PriorityQueue<>();
    q.add(new State(0, from));
    while (!q.isEmpty()) {
      State s = q.poll();
      if (visited[s.p]) continue;
      dist[s.p] = s.d;
      visited[s.p] = true;
      for (Edge e : g.get(s.p)) {
        if (visited[e.to]) continue;
        long nd = s.d + (from == S ? e.a : e.b);
        if (dist[e.to] <= nd) continue;
        dist[e.to] = nd;
        q.add(new State(nd,e.to));
      }
    }
    return dist;
  }

  static class State implements Comparable<State> {
    long d;
    int p;

    public State(long d, int p) {
      this.d = d;
      this.p = p;
    }

    @Override
    public int compareTo(State o) {
      return Long.compare(this.d, o.d);
    }
  }

  static class Edge {
    int to;
    long a, b;

    public Edge(int to, int a, int b) {
      this.to = to;
      this.a = a;
      this.b = b;
    }
  }
}


Measured memory_bytes: 108092
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int64_t n, a, b, cnt;
    cin >> n >> a >> b;
    cnt = a*(n/(a+b));
    cnt += min(n%(a+b), a);
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(a, b, c) (a > b ? a > c ? a : c : b > c ? b : c)

int main(void) {
	int a, b, c, sum, max, dis;
	
	scanf("%d %d %d", &a, &b, &c);
	
	max = max(a, b, c);
	sum = a + b + c;
	dis = 3 * max - sum;
	
	printf("%d\n", dis / 2 + (dis % 2 ? 2 : 0));
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int n;ll m;
    cin>>n>>m;
    ll ret = 1;
    for(ll i=1;i*i<=m;++i){
        if(m%i == 0){
            if(n <= m/i)ret = max(ret,i);
            if(n <= i) ret = max(ret,(m/i));
        }
    }
    cout << ret << endl;
    return 0;
}



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

int main (){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i =0; i < N; i++){
    cin >> A[i];
  }
  
  int count = 0;
    while(true){
      bool flag = false;
      
      for(int i = 0; i < N; i ++){
        if (A[i] %2 != 0) flag = true;
      }
      
      if(flag) break;
      
      for(int j = 0 ; j < N; j ++){
        A[j] /= 2;
      }
      count++;
  	}
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vi dx = {-1, 0, 1, -1, 1, -1, 0, 1};
    vi dy = {-1, -1, -1,0, 0, 1, 1, 1 };

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == '#') continue;

            int count = 0;
            for(int d = 0; d < 8; d++) {
                int ni = i + dy[d];
                int nj = j + dx[d];
                if(ni < 0 || h <= ni) continue;
                if(nj < 0 || w <= nj) continue;
                if(s[ni][nj] == '#') count++;
            }
            s[i][j] = char(count + '0');
        }
    }
    for(int i = 0; i < h; i++) {
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD = 1000000007;
bool isdigit(char a) {
	return a >= '0' && a <= '9';
}
struct State {
	int rep;
	int sz;
	int pos;
	vector<int> child;
};
State tmp;
vector<State> s;
int readNumber(string &S, int &pos) {
	int res = 0;
	while (isdigit(S[pos])) {
		res *= 10;
		res += S[pos] - '0';
		pos++;
	}
	return res;
}
int sz(string &S, int &pos, int par) {
	//cerr << "pos=" << pos << endl;
	if (pos >= (int)S.size())return 0;
	if (S[pos] == '(') {
		//cerr << "par = " << par << endl;
		pos++;
		while (S[pos] != ')') {
			if (isdigit(S[pos])) {
				int a = readNumber(S, pos);
				s[par].child.push_back(s.size());
				tmp.rep = a;
				tmp.pos = pos;
				s.push_back(tmp);
				sz(S, pos, (int)s.size() - 1);
			}
			else {
				s[par].child.push_back(s.size());
				tmp.rep = 1;
				tmp.sz = 1;
				tmp.pos = pos;
				s.push_back(tmp);
				pos++;
			}
		}
		pos++;
	}
	else {
		s[par].child.push_back(s.size());
		tmp.rep = 1;
		tmp.sz = 1;
		tmp.pos = pos;
		s.push_back(tmp);
		pos++;
	}
	s[par].sz = 0;
	for (int i = 0; i < s[par].child.size(); i++) {
		s[par].sz = min((int)1 << 40, s[par].sz + s[s[par].child[i]].sz * s[s[par].child[i]].rep);
	}
	return s[par].sz;
}
int find(int p, int a) {
	if (a == 0 && (int)s[p].child.size() == 0) {
		return s[p].pos;
	}
	for (int i = 0; i < s[p].child.size(); i++) {
		if (a < s[s[p].child[i]].rep * s[s[p].child[i]].sz) {
			return find(s[p].child[i], a % s[s[p].child[i]].sz);
		}
		else {
			a -= s[s[p].child[i]].rep * s[s[p].child[i]].sz;
		}
	}
	return -1;
}
signed main() {
	while (true) {
		string S;
		int a;
		cin >> S >> a;
		if (S == "0" && a == 0) {
			break;
		}
		
		S = '(' + S + ')';
		//cerr << S << endl;
		s.clear();
		tmp.rep = 1;
		tmp.pos = 0;
		s.push_back(tmp);
		int p = 0;
		sz(S, p, 0);
		//cerr << s.size() << endl;

		int res = find(0, a);
		//while (S[res] == '(') res++;
		//cerr << res << endl;
		if (res == -1) {
			cout << '0' << endl;
		}
		else {
			cout << S[res] << endl;
		}
	}
}


Measured memory_bytes: 3024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main() {
    ll h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    ll ans=0;
    for(ll i=0;i<(1<<h);i++){
        for(ll j=0;j<(1<<w);j++){
            ll cnt=0;
            rep(k,h){
                rep(l,w){
                    ll u=(i>>k)%2;
                    ll v=(j>>l)%2;
                    if(c[k][l]=='#' && u==0 && v==0) cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
long long dp[100001][2];

long long dfs(vector<long long> adj[],int cur,vector<long long> &vis){
    vis[cur]=1;
    dp[cur][0]=1;
    dp[cur][1]=1;
    for(long long i=0;i<adj[cur].size();i++){
        if(!vis[adj[cur][i]]){
            dfs(adj,adj[cur][i],vis);
            dp[cur][0]=(dp[cur][0]*((dp[adj[cur][i]][1]+dp[adj[cur][i]][0])%1000000007))%1000000007;
            dp[cur][1]=(dp[cur][1]*dp[adj[cur][i]][0])%1000000007;
        }
    }return (dp[cur][1]+dp[cur][0])%1000000007;
}

int main() {
	long long n,x,y;
	cin>>n;
    vector<long long> adj[n+1];
    memset(dp,-1,sizeof(dp));
    for(long long i=0;i<n-1;i++){
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }vector<long long> vis(n+1,0);
    cout<<dfs(adj,1,vis);
}




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

int main() {
  // string text;
  // cin >> text;
  // if(text[text.size()-1] == 's'){
  //   text = text + "es";
  // }else{
  //   text = text + "s";
  // }
  // cout << text << endl;

  int n;
  int a,b;
  int ans = 0;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> a >> b;
    if(a == b)ans++;
    else ans = 0;

    if(ans == 3)break;
  }

  if(ans == 3)cout << "Yes" << endl;
  else cout << "No" << endl;



}

Measured memory_bytes: 3632
#!/usr/bin/env python3
N = int(input())
a = [int(input()) for _ in range(N)]
a.sort()

ans = 0
s = 0
for i, x in enumerate(a):
    x -= s
    if x == 0:
        continue
    ans ^= (x % 2) * (N - i)
    s += x

print(['second', 'first'][ans != 0])


Measured memory_bytes: 7508
fn main() {
    let n: i32 = read();
    let mut result = "No";

    if n % s(n) == 0 {
        result = "Yes";
    }

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

fn s(n: i32) -> i32 {
    let mut n1 = n;
    let mut r = 0;
    while n1 > 0 {
        r += n1 % 10;
        n1 /= 10;
    }
    r
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(void) {

  int w[10],k[10],wsum,ksum,i,j,n,m;
  n=0;
  m=0;

  for(i=0;i<10;i++){
    scanf("%d",&w[i]);
}
  for(i=0;i<10;i++){
    scanf("%d",&k[i]);
  }
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(w[i]<w[j]){
	n=w[i];
	w[i]=w[j];
	w[j]=n;
      }
    }
  }
  wsum=w[0]+w[1]+w[2];

  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(k[i]<k[j]){
	m=k[i];
	k[i]=k[j];
	k[j]=m;
      }
    }
  }
  ksum=k[0]+k[1]+k[2];

  printf("%d %d\n",wsum,ksum);

  return 0;
}

Measured memory_bytes: 0
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

int INF = 1<<25;
void main() {
    while(true) {
        int H, W;
        readf("%d %d\n", &H, &W);
        if (H==0 && W==0) break;
        bool[][] flag = H.iota.map!(_ => readln.chomp.map!(c=>c=='.').array).array;
        int[][] ary = new int[][](H, W);
        foreach(i; 0..H) {
            int s = 0;
            foreach_reverse(j; 0..W) {
                if (flag[i][j]) {
                    ary[i][j] = ++s;
                } else {
                    s = 0;
                }
            }
        }
        int ans = 0;
        foreach(i; 0..H) foreach(j; 0..W) {
            int m = INF;
            for(int _i=i; _i<H && flag[_i][j]; _i++) {
                m = min(m, ary[_i][j]);
                ans = max(ans, (_i-i+1)*m);
            }
        }
        ans.writeln;
    }
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E;
  string S;
  cin >> S;
  if(S.find("C")==string::npos||S.find("F")==string::npos)cout<<"No"<<endl;
  else{
    if(S.find("C")>S.find("F")){
      if(S.find("CF")!=string::npos)cout << "Yes"<<endl;
      else cout <<"No"<<endl;
    }
    else cout <<"Yes"<<endl;
  }
}


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


def main():
    N = int(input())
    S = input()

    cnt = [0] * 26
    for i in S:
        cnt[ord(i)-ord('a')] += 1

    ans = 1
    MOD = 10 ** 9 + 7
    for i in range(26):
        ans = ans * (cnt[i]+1) % MOD

    print(ans-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ll(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;


signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n, k;
  cin >> n >> k;

  ll ret = 0;
  REP_FROM(i, k, n + 2){
    ll lower = (i - 1)  * (i - 2) / 2 - 1;
    ll upper_a = n * (n - 1) / 2;
    ll upper_b = (n-i) * (n-i-1) / 2 - 1;
    ret = (ret + upper_a - upper_b - lower) % mod;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int d,r;
    double f;
    r = a%b;
    d = a/b;
    f = (double)a/(double)b;
    printf("%d %d %f\n",d,r,f);
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	
	if (b / a > c)
		cout << c << endl;
	else
		cout << b / a << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		double sum = 0;
		for(int i=0; i<n; i++){
			sum += 1.0 / Integer.parseInt(sc.next());
		}
		
		System.out.println(1 / sum);
	}
}


Measured memory_bytes: 35832
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main()
{
    ll N, R;
    cin >> N >> R;
    if (N >= 10)
    {
        cout << R << endl;
    }
    else
    {
        cout << R + 100 * (10 - N);
    }
    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
ans=[1]*n
for i in range(n):
 if s[i]=="R"and s[i+1]=="R":
  ans[i+2]+=ans[i]
  ans[i]=0
 m=n-i-1
 if s[m]=="L"and s[m-1]=="L":
  ans[m-2]+=ans[m]
  ans[m]=0
print(*ans)

Measured memory_bytes: 6400
s = input()

N = len(s)

i = 0
result = 0
count_a = 0
count_bc = 0

while i < N-2:
    if s[i] == 'A':
        while s[i] == 'A' and i < N-2:
            count_a += 1
            i += 1
        
        if i >= N-1:
            break
                        
        while s[i] == 'B' and s[i+1] == 'C':
            count_bc += 1
            i += 2
            if i >= N-1:
                break
        
        result += count_a * count_bc

        if i >= N-1:
            break
        
        if count_bc > 0 and s[i] == 'A':
            count_a = count_a
        else:
            count_a = 0
        
        count_bc = 0
                    
    else:
        i += 1
        
print(result)    

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
T LCM(T a, T b) {
	return a / GCD(a, b) * b;
}
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	vi t(N);
	rep(i, N) cin >> t[i];
	
	ll ans = 0;
	Rep(i, N) {
		ans += min(t[i] - t[i - 1], T);
	}
	cout << ans + T << endl;
}


Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[400] = {};
vector<long long> a[400];
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, n) {
		REP(q, m) {
			int b;
			cin >> b;
			a[i].push_back(b);
		}
	}
	int ans = n;
	for (int i = 0;i < m;++i) {
		int grid[400] = {};
		for (int q = 0;q < n;++q) {
			for (int j = 0;j < m;++j) {
				if (dp[a[q][j]] == false) {
					grid[a[q][j]]++;
					break;
				}
			}
		}
		int hogehoge = 0;
		int topper = 0;
		for (int j = 1;j <= m;++j) {
			if (hogehoge < grid[j]) {
				hogehoge = grid[j];
				topper = j;
			}
		}
		dp[topper] = true;
		ans = min(ans,hogehoge);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            for (int i = 0; i < h; i++){
                for (int j =0; j < w; j++){
                    if ((i+j) % 2 ==0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 34828
from collections  import defaultdict
d = defaultdict(lambda :0)
N = int(input())
blues =[(input()) for _ in range(N)]

M = int(input())
reds =[(input()) for _ in range(M)]

for blue in blues:
    d[blue] += 1
for red in reds:
    d[red] -= 1

print(max(0,max(d.values()  )))

Measured memory_bytes: 3316
S = input()
N = int(S)


def count753(s):
    is753 = "7" in s and "5" in s and "3" in s
    if len(s) == len(S):
        return 1 if int(s) <= N and is753 else 0
    return int(is753) + count753(s + "7") + count753(s + "5") + count753(s + "3")


print(count753("7") + count753("5") + count753("3"))


Measured memory_bytes: 45912
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, k = LI()
    a = LI()
    ans = 0
    num = 10**9 + 7

    for i in range(n):
        x = a[i]
        before = 0
        after = 0

        for j in range(i):
            if a[j] < x:
                before += 1

        for j in range(i+1, n):
            if a[j] < x:
                after += 1


        ans += (after*(k+1)+before*(k-1))*k // 2
        ans %= num

    ans = print(ans)
main()


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

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

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

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

	int x,y; cin>>x>>y;
	if(x%y==0) cout<<-1<<'\n';
	else cout<<1LL*x*(y+1)<<'\n';


	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);
        int N = sc.nextInt();
        double[] A = new double[N];
        double sum = 0;
        
        for (int i=0; i<N; i++) {
            A[i] = sc.nextDouble();
        }
        
        for (int j=0; j<N; j++) {
            sum += 1/A[j];
        }
        
        System.out.println(1/sum);
        
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	ll n, k;
	cin >> n >> k;

	n %= k;

	cout << min(k - n, n) << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def gcd(a, b):
    if(b==0):
        return a
    return gcd(b, a%b)

def main(N, A):
    L = [0]*(N+1)
    R = [0]*(N+1)
    M = [0]*(N+1)
    
    for i in range(N):
        L[i+1] = gcd(L[i], A[i])
        R[(-2-i)] = gcd(R[-1-i], A[-1-i])
    for i in range(N):
        M[i] = gcd(L[i], R[i+1])
        
    print(max(M))

if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    
    main(N, A)

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

uint64_t modpow(uint64_t a, uint64_t p, const uint64_t& mod)
{
  if (p == 0) return 1;
  if (p % 2 == 0) {
    uint64_t h = modpow(a, p / 2, mod);
    return h * h % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

uint64_t combination(uint64_t a, uint64_t b, const uint64_t& mod)
{
  if (a - b < b) return combination(a, a - b, mod);
  uint64_t ansmul = 1;
  uint64_t ansdiv = 1;
  for (uint64_t i = 0; i < b; i++) {
    ansmul *= a - i;
    ansdiv *= i + 1;
    ansmul %= mod;
    ansdiv %= mod;
  }
  uint64_t ans = ansmul * modpow(ansdiv, mod - 2, mod) % mod;
  return ans;
}

int main()
{
  const uint64_t mod = 1'000'000'007;
  uint64_t n, m;
  cin >> n >> m;
  uint64_t mm = m;
  uint64_t ans = 1;
  for (auto i = 2; i <= mm; i++) {
    if (mm % i == 0) {
      uint64_t count = 0;
      while (mm % i == 0) {
	count++;
	mm /= i;
      }
      ans *= combination(n + count - 1, count, mod);
      ans %= mod;
    }
  }
  if (mm != 1) {
    ans *= n;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 888
x, y = map(int, input().split())

g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]


if x == 2 and y == 2:
    print("Yes")
elif x in g1 and y in g1:
    print("Yes")
elif x in g2 and y in g2:
    print("Yes")
else:
 print("No")

Measured memory_bytes: 9000
from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import unittest
from io import StringIO
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:  # 平方数の場合n**0.5を1つだけにしてる
                    divisors.append(n//i)

        divisors.sort(reverse=True)  # ソートしたけりゃして
        return divisors

    M = make_divisors(sum(A))

    def main():
        for i in M:
            AA = [0]*N
            age = 0
            # delete = 0
            for j in range(N):
                AA[j] = A[j] % i
                #if AA[j] == 0:
                    # delete += 1
                    # age -= i
                age += i-AA[j]
            AA.sort()

            times = 10**9
            sage = 0
            for j in range(0,N-1):
                sage += AA[j]
                age -= i-AA[j]
                if sage % i == age % i:
                    times = min(max(sage, age), times)
            if times <= K:
                return i
    print(main())

resolve()

Measured memory_bytes: 54380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && c <= b) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <vector>
using namespace std;
typedef long long ll;

class SegmentTree {
    using F = function<ll(ll, ll)>;
    const F f;
    int n, init;
    vector<int> node;

public:
    SegmentTree(int sz, const F f, ll init) : f(f), init(init) {
        n = 1;
        while (n < sz) n <<= 1;
        node.assign(2 * n, init);
    }

    void update(int x, ll val) {
        x += n;
        node[x] = val;
        while (x >>= 1) {
            node[x] = f(node[2 * x + 0], node[2 * x + 1]);
        }
    }

    // [a:b)
    ll query(int a, int b) {
        ll l = init, r = init;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, node[a++]);
            if (b & 1) r = f(node[--b], r);
        }
        return f(l, r);
    }
};


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
void AOJ_DSL_2_A() {
    ll n, q, c, x, y;
    cin >> n >> q;
    SegmentTree seg(n, [](ll a, ll b) { return min(a, b); }, 2147483647LL);
    while (q--) {
        cin >> c >> x >> y;
        if (c) cout << seg.query(x, y + 1) << "\n";
        else seg.update(x, y);
    }
}


// verified
//   https://atcoder.jp/contests/abc125/tasks/abc125_c
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }
void AtCoder_2019_4_27_C() {
    int n, a;
    cin >> n;
    SegmentTree seg(n, gcd, 0);
    for (int i = 0; i < n; i++) { cin >> a; seg.update(i, a); }
    int ans = 1;
    for (int i = 0; i < n; i++) ans = max(ans, gcd(seg.query(0, i), seg.query(i + 1, n)));
    cout << ans << "\n";
}

int main() {
    // AOJ_DSL_2_A();
    AtCoder_2019_4_27_C();
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {

		UL N; cin >> N;
		UL A, B; cin >> A >> B;
		vector<ULL> V(N); rep(i, N) cin >> V[i];
		sort(V.rbegin(), V.rend());
		if (V[0] == V[A - 1]) {
			cout << V[0] << endl;
			UL M = A;
			while (M < V.size()) {
				if (V[M - 1] != V[M]) break;
				M++;
			}
			ULL C[51] = {};
			C[0] = 1;
			rep(i, M) {
				C[i + 1] = C[i] * (M - i) / (i + 1);
			}
			ULL ans = 0;
			for (UL i = A; i <= min(M, B); i++) ans += C[i];
			cout << ans << endl;
		}
		else {
			double av = 0.0; rep(i, A) av += V[i];
			cout << (av / A) << endl;
			UL L = A - 1, R = A;
			while (L != 0) { if (V[L - 1] != V[L]) break; L--; }
			while (R < N) { if (V[R - 1] != V[R]) break; R++; }
			ULL C[51] = {};
			C[0] = 1;
			rep(i, R - L) {
				C[i + 1] = C[i] * (R - L - i) / (i + 1);
			}
			cout << C[A - L] << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
a = list(input())
a = [int(x) for x in a]

cou = 0
cou2 = 0
b = [0]
c = [1]

if a[0] == 0:
    cou2 += 1
else:
    cou += 1
    
for i in range(len(a)-1):
    if b[i] == a[i+1]:
        cou += 1
        if b[i] == 1:
            x = 0
            b.append(x)
        else:
            x = 1
            b.append(x)
    else:
        b.append(a[i+1])
        
for i in range(len(a)-1):
    if c[i] == a[i+1]:
        cou2 += 1
        if c[i] == 1:
            x = 0
            c.append(x)
        else:
            x = 1
            c.append(x)
    else:
        c.append(a[i+1])
        
print(cou if cou < cou2 else cou2)

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

int main () {
      int n;
      cin >> n;
      int ac=0, wa=0, tle=0, re=0;
      for (int i=1; i<=n; i++) {
            char a[5];
            cin >> a;
            if (a[0]=='A') ac++;
            else if (a[0]=='W') wa++;
            else if (a[0]=='T') tle++;
            else if (a[0]=='R') re++;
      }
      cout << "AC x " << ac << endl;
      cout << "WA x " << wa << endl;
      cout << "TLE x " << tle << endl;
      cout << "RE x " << re << endl;
      return 0;
}


Measured memory_bytes: 3668
sel='E'

if sel=='A':
    S=input()
    if S[2]==S[3] and S[4]==S[5]:
        print('Yes')
    else:
        print('No')

if sel=='B':
    X=int(input())
    ans=0
    ans+=(X//500)*1000
    ans+=((X%500)//5)*5
    print(ans)

if sel=='C':
    K,N=map(int,input().split())
    A=[int(i) for i in input().split()]
    d=[A[0]+K-A[-1]]
    for i in range(N-1):
        d.append(A[i+1]-A[i])
    d.sort()
    print(K-d[-1])

if sel=='D':
    N,X,Y=map(int,input().split())
    cnt={}
    for k in range(1,N):
        cnt[k]=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            k=j-i # まっすぐ
            k=min(k,abs(i-X)+1+abs(j-Y)) # う回路１
            k=min(k,abs(i-Y)+1+abs(X-j)) # う回路２
            cnt[k]+=1

    for k in range(1,N):
        print(cnt[k])

if sel=='E':
    import heapq
    X,Y,A,B,C=map(int,input().split())
    P=[int(i) for i in input().split()]
    Q=[int(i) for i in input().split()]
    R=[int(i) for i in input().split()]
    P.sort(reverse=True)
    Q.sort(reverse=True)
    red=P[:X]
    gre=Q[:Y]
    heapq.heapify(red)
    heapq.heapify(gre)
    for r in R:
        if red[0]<=gre[0]:
            if red[0]<r:
                heapq.heapreplace(red,r)
        else:
            if gre[0]<r:
                heapq.heapreplace(gre,r)
    print(sum(red)+sum(gre))

Measured memory_bytes: 23232
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()
# ans = 0
# for b in range(1, 1000):
#     for p in range(2, 1000):
#         tmp = b ^ p
#         # print(tmp)
#         if tmp <= X:
#             ans = max(ans, tmp)
#             # print(tmp)
#         else:
#             break
# print(ans)
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

x = X
r = [1]
for i in range(2, x + 1):
    c = 2
    while i ** c <= x:
        r.append(i ** c)
        c += 1
ans = sorted(r)[-1]
print(ans)


exit()


for x in range(X, 0, -1):
    prime = prime_decomposition(x)
    c = Counter(prime)
    # print(c.values())
    value = c.values()
    # print(v)
    print(c)
    for v in value:
        d = v
    if len(c) == 1 and d >= 2:
        print(x)
        exit()
    elif x == 1:
        print(x)
        exit()
    



Measured memory_bytes: 3944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
#include<map>
#include<queue>
using namespace std;


int main(){

  int a, b;
  cin >> a >> b;
  if( a == 1 ) a = 14;
  if( b == 1 ) b = 14;
  
  if( a == b ) cout << "Draw" << endl;

  if( a > b ){
    cout << "Alice" << endl;
  }else if( a < b ){
    cout << "Bob" << endl;
  }

  return 0;
}








// EOF


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

int main() {
  int N;
  cin >> N;
    string S;
    cin >> S;
    
  for(int a = 0;a < N;a++){
    
    for(int b = 0;b < 10000;b++){
      
      if(S[b] == 'A'){
      S[b] = 'B';
      }else if(S[b] == 'B'){
      S[b] = 'C';
      }else if(S[b] == 'C'){
      S[b] = 'D';
      }else if(S[b] == 'D'){
      S[b] = 'E';
      }else if(S[b] == 'E'){
      S[b] = 'F';
      }else if(S[b] == 'F'){
      S[b] = 'G';
      }else if(S[b] == 'G'){
      S[b] = 'H';
      }else if(S[b] == 'H'){
      S[b] = 'I';
      }else if(S[b] == 'I'){
      S[b] = 'J';
      }else if(S[b] == 'J'){
      S[b] = 'K';
      }else if(S[b] == 'K'){
      S[b] = 'L';
      }else if(S[b] == 'L'){
      S[b] = 'M';
      }else if(S[b] == 'M'){
      S[b] = 'N';
      }else if(S[b] == 'N'){
      S[b] = 'O';
      }else if(S[b] == 'O'){
      S[b] = 'P';
      }else if(S[b] == 'P'){
      S[b] = 'Q';
      }else if(S[b] == 'Q'){
      S[b] = 'R';
      }else if(S[b] == 'R'){
      S[b] = 'S';
      }else if(S[b] == 'S'){
      S[b] = 'T';
      }else if(S[b] == 'T'){
      S[b] = 'U';
      }else if(S[b] == 'U'){
      S[b] = 'V';
      }else if(S[b] == 'V'){
      S[b] = 'W';
      }else if(S[b] == 'W'){
      S[b] = 'X';
      }else if(S[b] == 'X'){
      S[b] = 'Y';
      }else if(S[b] == 'Y'){
      S[b] = 'Z';
      }else if(S[b] == 'Z'){
      S[b] = 'A';
      };
      
      
    
    };
  
  };
  
  cout << S << endl;
};

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double pi=acos(-1);
  double da=2*pi*h/12+2*pi/12*m/60;
  double db=2*pi*m/60;
  cout<<fixed<<setprecision(16)<<sqrt(a*a+b*b-2*a*b*cos(da-db))<<endl;
}

Measured memory_bytes: 4192
from collections import defaultdict
def find(x, A):
    p = A[x]
    if p == x:
        return x
    a = find(p, A)
    A[x] = a
    find(a,A)
    return a

N, K, L = map( int, input().split())
V = [ i for i in range(N)]
W = [ i for i in range(N)]
for _ in range(K):
    p, q = map( int, input().split())
    p, q = p-1, q-1
    bp, bq = find(p,V), find(q,V)
    V[q] = bp
    V[bq] = bp

for _ in range(L):
    r, s = map( int, input().split())
    r, s = r-1, s-1
    br, bs = find(r,W), find(s,W)
    W[s] = br
    W[bs] = br

d = defaultdict(int)
for i in range(N):
    d[(find(i,V), find(i, W))] += 1
ANS = [0]*N
for i in range(N):
    ANS[i] = d[(find(i,V), find(i, W))]

print(' '.join( map( str, ANS)))

Measured memory_bytes: 61952
#include<iostream>
#include<string>
#include<unordered_map>

using namespace std;

int main()
{
	unordered_map<string, int> mp;
	mp["MON"] = 1;
	mp["TUE"] = 2;
	mp["WED"] = 3;
	mp["THU"] = 4;
	mp["FRI"] = 5;
	mp["SAT"] = 6;
	mp["SUN"] = 7;

	string s;
	cin >> s;
	int ans = (mp["SUN"] - mp[s] == 0) ? 7 : (mp["SUN"] - mp[s]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  int n, m;

  while(1){
    cin >> n >>  m;
    if(n == 0 && m == 0) break;

      int data[n+1];
      for(int i = 1; i <= n; i++) data[i] = 1;
      int sum = 0;
      int del = 0;
      int status = 0;
      while(1){
	for(int i = 1; i <= n; i++){
	  if(data[i] == 1){
	    sum++;
	  }
	  if(sum == m){
	    data[i] = 0;
	    del++;
	    sum = 0;
	  }
	  if(del == n-1){
	    status = 1;
	    break;
	  }
	}

	if(status == 1) break;
      }

      for(int i = 1; i <= n; i++){
	if(data[i] == 1){
	  cout << i << endl;
	  break;
	}
      }
  }
  return 0;
}

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-18;

using namespace std;



signed main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int d,t,s;
    cin>>d>>t>>s;
    
    if(t*s>=d){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[100005],b[100005],n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int t=a[1];
	for(int i=2;i<=n;i++){
		t=a[i]-t;
	}
	b[1]=t;
	cout<<b[1]<<" ";
	for(int i=2;i<=n;i++){
		b[i]=2*(a[i-1]-b[i-1]/2);
		cout<<b[i]<<" ";
	}
	
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int H,W,h,w;
	cin >> H >> W >> h >> w;
	int num = 1e5;
	if(H%h){
		cout << "Yes" << endl;
		rep(i,H){
			rep(j,W){
				if(i%h==h-1){
					output(-num*h+num-1);
				}else{
					output(num);
				}
			}
			outendl();
		}
	}else if(W%w){
		cout << "Yes" << endl;
		rep(i,H){
			rep(j,W){
				if(j%w==w-1){
					output(-num*w+num-1);
				}else{
					output(num);
				}
			}
			outendl();
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 2048
import math
a,b,h,m = map(int,input().split())
A = 30*h+m*30/60
B = 6*m
C = abs(A-B)
#print(C)
if C > 180:
    C = 360 - C
    #print(math.cos(C))
    #print(C)
    c = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
    print(c)
elif C < 180:
    c = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
    print(c)
else:
    print(a+b)


Measured memory_bytes: 9516
"use strict";

const main = arg => {
    const inputList = arg.trim().split("\n");
    // 回答を記述
    const N = parseInt(inputList[0].split(" ")[0]);

    const change = N % 1000;

    if (change === 0) {
        console.log(0);
    } else {
        console.log(1000 - change)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29672