akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=1e9+7;
#define N 200000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int n,l,t,x[N]={},w[N]={};
    cin>>n>>l>>t;
    rep(i,n){
        scanf("%d %d",&x[i],&w[i]);
    }
    ll int y[N]={};
    rep(i,n){
        if(w[i]==1){
            y[i]=(x[i]+t)%l;
        }
        else {
            y[i]=(x[i]+l-t%l)%l;
    }
    }
    sort(y,y+n);

    ll int count=0;
    ll int flag=0;
    rep2(i,1,n-1){
        if(w[i]!=w[0]){
            if(w[0]==1){
                count+=(t*2-x[i]+x[0]+l)/l;
                if((t*2-x[i]+x[0]+l)%l==0){
                    flag=1;
                }
            }
            if(w[0]==2){
                count+=(t*2+x[i]-x[0])/l;
            }
        }
    }
    count=count%n;
    if(w[0]==2) count=(n-count)%n;
    ll int pos;
    if(w[0]==1){
        pos=(x[0]+t)%l;
    }
    else{
        pos=(x[0]+l-(t%l))%l;
    }
    ll int m;
    if(w[0]==2) m=lower_bound(y,y+n,pos)-y;
    else {
        m=lower_bound(y,y+n,pos)-y;
        if(flag) m++;
    }
    m=(m+n-count)%n;
    rep(i,n){
        cout<<y[m]<<endl;
        m++;
        if(m==n) m=0;
    }
    return 0;
    
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;


int main(void){
    int n; cin >> n;
    string s; cin >> s;
    REP(i, s.size()){
        if(s[i] + n > 'Z'){
            cout << char(s[i] + n - 'Z' + 'A' - 1);
        }
        else cout << char(s[i] + n);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 200000

void swap(int* a,int* b){
  int c=*a;
  *a=*b;
  *b=c;
}

#define d_flag 1

char s[MAX+1];
int flag=1;

void naka(int a,int b){
  int i;
   flag=0;
  for(i=a;i<=b;i++){
    if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
      flag=1;
      break;
    }
  }
}

int judge(int a,int b){
  int i;
  for(i=a;i<b;i++){
    if(s[i]=='#' && s[i+1]=='#'){
      flag=0;
      break;
    }
  }
}

int main(){
  int n,a,b,c,d;

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

  scanf(" %s",s);


  if(a>b){
    swap(&a,&b);
    swap(&c,&d);
  }

  if(c>d){
    naka(b,d);
  }
  judge(a,c);
  judge(b,d);

  printf("%s",flag?"Yes":"No");
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

vector<ll> v[28];
vector<ll> v2;

int d[100001]={};
int num[100001]={};
const ll INF=1000000000000000001;
int main() {
	string s;
	cin>>s;
	int ls=s.length();
	string s2=s.substr(0,ls-8);
	cout<<s.substr(0,ls-8)<<endl;
	return 0;
}


Measured memory_bytes: 256
import heapq

N = int(input())
h = []
ax = []
for _ in range(N):
    a = int(input())
    heapq.heappush(h,a* (-1))
    ax.append(a)

m1 = heapq.heappop(h) * (-1)
m2 = heapq.heappop(h) * (-1)

for a in ax:
    if m1 == a:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 20528
def examB():
    N, K = LI()
    ans = K*((K-1)**(N-1))
    print(ans)

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 3060
n,p=map(int,input().split())

gomi=p

kojisho={}
for i in range(int(p**0.5)+1):
	kojisho[i]=0


for i in range(2,int(p**0.5)+1):
	while gomi % i== 0:
		gomi //=i
		kojisho[i] += 1
kojisho[gomi] = 1

output=1

for i in kojisho.keys():
	if kojisho[i] >= n:
		output *= i ** (kojisho[i] // n)

print(output)


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

using namespace std;

const long long INF = 1ll << 61;
const int MAX = 2500;

struct Node{
  long long time;
  int money;
  int node;
  
  bool operator>(const Node& t) const{
    return time > t.time;
  }
};

int main(){
  int N, M, S;
  cin >> N >> M >> S;
  
  vector<vector<Node>> to(N);
  for(int i = 0; i < M; i++){
    int U, V, A, B;
    cin >> U >> V >> A >> B;
    --U; --V;
    
    to[U].push_back({B, A, V});
    to[V].push_back({B, A, U});
  }
  
  vector<int> C(N), D(N);
  for(int i = 0; i < N; i++) cin >> C[i] >> D[i];
  
  vector<vector<long long>> dp(N, vector<long long>(MAX + 1, INF));
  priority_queue<Node, vector<Node>, greater<Node>> pq;
  
  S = min(S, MAX);
  pq.push({0, S, 0});
  dp[0][S] = 0;
  while(!pq.empty()){
    auto [time, money, node] = pq.top();
    pq.pop();
    
    if(dp[node][money] < time) continue;
    
    for(auto [t, m, next] : to[node]){
      if(money >= m && time + t < dp[next][min(money - m, MAX)]){
        dp[next][min(money - m, MAX)] = time + t;
        pq.push({time + t, min(money - m, MAX), next});
      }
    }
    
    if(money < MAX){
      if(time + D[node] < dp[node][min(money + C[node], MAX)]){
        dp[node][min(money + C[node], MAX)] = time + D[node];
        pq.push({time + D[node], min(money + C[node], MAX), node});
      }
    }
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < MAX; j++){
      dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
    }
  }
  
  for(int i = 1; i < N; i++){
    cout << dp[i][MAX] << endl;
  }
  
  return 0;
}

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

int main()
{
	int mi = 1145141919, ma = 0, n;
	cin >> n;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin >> a;
		mi = min(a, mi);
		ma = max(a, ma);
	}
	cout << ma - mi << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        ArrayList<Integer> square = new ArrayList<>();
        for(int i = 0; i < 1000; i++) {
            square.add(i * i);
        }
        int N = scanner.nextInt();
        int D = scanner.nextInt();
        int[][] pts = new int[N][D];
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < D; j++) {
                pts[i][j] = scanner.nextInt();
            }
        }
        int ans = 0;
        for(int i = 0; i < N; i++) {
            for(int j = i+1; j < N; j++) {
                int tot = 0;
                for(int k = 0; k < D; k++) {
                    tot += (pts[i][k] - pts[j][k])*(pts[i][k] - pts[j][k]);
                }
                if (square.contains(tot)) ans++;
            }
        }
        out.println(ans);
        
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int x;
	int box[6]={1,5,10,50,100,500};
	int sum;
	int i;
	sum=0;
	for(i=0;i<6;i++){
		cin>>x;
		sum+=x*box[i];
	}
	if(sum>=1000)	cout<<1<<endl;
	else			cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;

int n,m;
bool ok(vector<int> v,vector<int>p){
    int n = v.size();
    for(int i=0;i<n;i++){
        if(v[i]%2!=p[i]){return false;}
    }
    return true;
}

int main(){
    cin >> n >> m;
    vector<int> k(m);

    Graph s(m);
    for(int i=0;i<m;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            int a;
            cin >> a;
            a--;
            s[i].push_back(a);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++){
        cin >> p[i];
    }
    /*
    for(int i=0;i<m;i++){
        for(auto x:s[i]){
            cout << x << " ";
        }
        cout << endl;
    }
    */
   Graph swit(n);
   for(int i=0;i<m;i++){
       for(auto x:s[i]){
           swit[x].push_back(i);
       }
   }
   /*
   for(int i=0;i<n;i++){
       cout << "スイッチ" << i << " ";
       for(auto x:swit[i]){
           cout << x << " ";
       }
       cout << endl;
   }*/
    int cnt = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        
        vector<int> on(m,0);
        bitset<10> s(bit);
        //cout << s << endl;
        for(int i=0;i<n;i++){
            if(s[i]){
                    for(int j=0;j<swit[i].size();j++){
                        on[swit[i][j]]++;
                    }
            }      
        }
        if(ok(on,p)) cnt++;
    }
    cout << cnt << endl;

    
}

Measured memory_bytes: 256
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin = open("input.txt","r")  # <<<  Comment this line  >>> #
    sys.stdout = open("output.txt","w")  # <<<  Comment this line  >>> #
    sys.stderr = open("output.txt","w")  # <<<  Comment this line  >>> #

a, v = get_ints()
b, w = get_ints()
t = int(input())
if a < b:
    f1 = a + (v*t)
    f2 = b + (w*t)
else:
    f2 = a - (v * t)
    f1 = b - (w * t)
if f2 > f1:
    print("NO")
else:
    print("YES")

# for _testcases_ in range(int(input())):

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 62120
import java.util.*;

class Main{
  static int n=0;
  static long fibonacci[];
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    n = sc.nextInt();
    fibonacci = new long[n];
    if(n >= 1){
      fibonacci[0] = 1;
    }
    if(n >=2){
      fibonacci[1] = 2;
    }
    for(int i = 2; i<n; i++){
      fibonacci[i] = (long)(fibonacci[i-1]+(long)fibonacci[i-2]);
    }
    // System.out.println(Fibonacci(n-1));
    System.out.println(fibonacci[n-1]);

  }

}


Measured memory_bytes: 26156
#include <iostream>
#include <vector>

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H.at(i);
	}


	for (int i = 0; i < N - 1; i++)
	{
		H.at(i) -= H.at(i + 1);
	}

	int startIndex = 0, endIndex;
	int maxCount = 0;

	for (int i = 0; i < N; i++)
	{
		if (H.at(i) < 0)
		{
			endIndex = i;

			if (maxCount < endIndex - startIndex)
			{
				maxCount = endIndex - startIndex;
			}

			startIndex = endIndex + 1;
		}
	}

	if (maxCount < N - 1 - startIndex)
	{
		maxCount = N - 1 - startIndex;
	}

	cout << maxCount << endl;


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  ll ar[4];
//  rep(i,0,4) {cin>>ar[i];k=max(k,ar[i]);l=min(l,ar[i]);}
  cin>>n;
  cin>>s>>r;
  rep(i,0,n)
  {
    cout<<s[i]<<r[i];
  }
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

int A[200010];
int B[200010];

int main() {
  int N;
  cin >> N;
  REP(i,N) cin >> A[i];
  REP(i,N) cin >> B[i];

  int ans = 0;
  REP(bit, 30) {
    vector<int> AM(N),BM(N);
    int mask = ( 1 << (bit+1)) - 1;
    REP(i,N) {
      AM[i] = A[i] & mask;
      BM[i] = B[i] & mask;
    }
    sort(BM.begin(), BM.end());
    ll c = 0;
    REP(i,N) {
      int c01 = lower_bound(BM.begin(), BM.end(), (1<<bit) - AM[i] ) - BM.begin();
      int c10 = lower_bound(BM.begin(), BM.end(), (2<<bit) - AM[i] ) - BM.begin();
      int c11 = lower_bound(BM.begin(), BM.end(), (3<<bit) - AM[i] ) - BM.begin();
      c += (N-c11)+(c10-c01);
    }
    if (c % 2 == 1) ans |= (1 << bit);
//    cout << bit << " : " << c << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3424
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
int const inf = 1<<29;

struct MCF {
    typedef int Weight;
    typedef int Capacity;
    struct Edge;
    int n;
    vector<vector<Edge> > g;
    vector<int> level, iter;

    struct Edge {
        int dst;
        Capacity cap, cap_orig;
        int revEdge;
        bool isRev;
        Edge(int dst, Capacity cap, int revEdge, bool isRev)
        :dst(dst), cap(cap), cap_orig(cap), revEdge(revEdge), isRev(isRev) {}
    };

    MCF(int n_)
    : n(n_), g(vector<vector<Edge> >(n_)), level(n_), iter(n_) {}

    void add_edge(int src, int dst, Capacity cap) {
        g[src].emplace_back(Edge(dst, cap, g[dst].size(), false));
        g[dst].emplace_back(Edge(src, 0, g[src].size() - 1, true));
    }

    void bfs(int s) {
        fill(all(level), -1);
        queue<Weight> q;
        level[s] = 0;
        q.emplace(s);
        while (q.size()) {
            int v = q.front(); q.pop();
            for(int i = 0; i < (int)g[v].size(); i++){
                Edge& e = g[v][i];
                if (e.cap > 0 && level[e.dst] < 0) {
                    level[e.dst] = level[v] + 1;
                    q.emplace(e.dst);
                }
            }
        }
    }

    Capacity dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < (int)g[v].size(); i++) {
            Edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.dst]) {
                int d = dfs(e.dst, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.dst][e.revEdge].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    // src->dstへの最大フローを流す
    Capacity max_flow(int src, int dst) {
        int flow = 0;
        while(1){
            bfs(src);
            if (level[dst] < 0) return flow;
            fill(all(iter), 0);
            int f;
            while ((f = dfs(src, dst, inf)) > 0) {
                flow += f;
            }
        }
    }
};

int main(){
    int n,m;
    while(cin>>n>>m && n|m){
        vector<int> a(n), b(m);
        rep(i,n)cin>>a[i];
        rep(i,m)cin>>b[i];
        MCF mcf(n+m+2);
        int s=n+m, t=n+m+1;
        rep(i,m)mcf.add_edge(i+n,t,1);
        rep(i,n){
            mcf.add_edge(s,i,1);
            rep(j,m)if(__gcd(a[i],b[j])!=1)mcf.add_edge(i,n+j,1);
        }
        cout << mcf.max_flow(s,t) << endl;
    }
}

Measured memory_bytes: 8316
import sys
input = sys.stdin.readline

import numpy as np

"""
0,1の配置は関係ない。文字列長だけが問題。
"""

MOD = 10**9 + 7
N = int(input())
S = input().rstrip()

LS = len(S)

# 長さ、何通り
dp = np.zeros(N+1, dtype=np.int64)
dp[0] = 1
for _ in range(N):
    prev = dp
    dp = np.zeros_like(prev)
    # 文字の追加
    dp[1:] += 2*prev[:-1]
    # 文字の削除
    dp[:-1] += prev[1:]
    dp[0] += prev[0]
    dp %= MOD

x = dp[LS]
answer = x * pow((1+MOD)//2,LS,MOD) % MOD
print(answer)

Measured memory_bytes: 14412
class FactMod:

    def __init__(self, n, mod):
        self.mod = mod
        self.f = [1] * (n + 1)
        for i in range(1, n + 1):
            self.f[i] = self.f[i - 1] * i % mod

        self.inv = [pow(self.f[-1], mod - 2, mod)]
        for i in reversed(range(1, n + 1)):
            self.inv.append(self.inv[-1] * i % mod)
        self.inv.reverse()

    def fact(self, n):
        """
        :return: n!
        """
        return self.f[n]

    def comb(self, n, r):
        """
        :return: nCr
        """
        return self.f[n] * self.inv[n - r] * self.inv[r] % self.mod


N, K = map(int, input().split())

mod = 10 ** 9 + 7

fc = FactMod(3000, mod)

for i in range(1, K + 1):
    if N - K + 1 < i:
        print(0)
        continue

    if i == 1 or i == K:
        print(fc.comb(N - K + 1, i) % mod)
    else:
        print(fc.comb(N - K + 1, i) * fc.comb(K - 1, i - 1) % mod)


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

namespace Hello
{
  class Hello
  {
    static void Main()
    {
    
      int number = int.Parse(Console.ReadLine());
      
      var p = Array.ConvertAll(Console.ReadLine().Split(' ') , int.Parse);
      
    var list = new List<int>();
      
      list.AddRange(p);
      
list.Sort((a, b) => b - a);
      
      for(int i=0;i<number-1;i++){
        
        if(list[i] == list[i+1]){
      Console.Write("NO");
      break;
      }else if(i == number-2){
      
      Console.Write("YES");
      }
        
      
      }
      

      
      
      
    }
  }
}


Measured memory_bytes: 33100
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll INF = 1145141919810364364;

vector<ll> calc(vector<ll> &c_sum, int mi, int ma) {
    int ok = ma, ng = mi;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;

        if (c_sum[ma] - c_sum[mid] <= c_sum[mid] - c_sum[mi])ok = mid;
        else ng = mid;
    }

    ll p = c_sum[ma] - c_sum[ok], q = c_sum[ok] - c_sum[mi]; // p <= q
    ll r = c_sum[ma] - c_sum[ng], s = c_sum[ng] - c_sum[mi]; // r > s
    return {p, q, r, s};
}

int main() {
    int n;
    cin >> n;
    vector<ll> c_sum(n + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        c_sum[i + 1] = a + c_sum[i];
    }

    ll ret = INF;
    for (int i = 2; i <= n - 2; i++) { // [0, i) [i,n)
        auto front = calc(c_sum, 0, i), back = calc(c_sum, i, n);
        ret = min(ret, max(front[1], back[1]) - min(front[0], back[0]));
        ret = min(ret, max(front[1], back[2]) - min(front[0], back[3]));
        ret = min(ret, max(front[2], back[1]) - min(front[3], back[0]));
        ret = min(ret, max(front[2], back[2]) - min(front[3], back[3]));
    }

    cout << ret << endl;
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int x; cin >> x;
    cout << (!x) << endl;
}

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


int main()
{
	string s;
	cin>>s;
	rep(i,s.size()) cout<<"x";
	cout<<endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



int main(){
    int n;
    cin >> n;
    V<P> p(n);
    rep(i,n) cin >> p[i].fi >> p[i].se;
    double ans = 0;
    rep(i,n)rep(j,n) {
        if(i == j) continue;
        ans += sqrt((p[i].fi-p[j].fi)*(p[i].fi-p[j].fi) + (p[i].se-p[j].se)*(p[i].se-p[j].se)) * (n-1);
    }
    ans /= n*(n-1);
    printf("%.10f", ans);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define int long long
 
// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
 
int n, m;
int a[N];
int res = 1;
int b[N];
int d[N];

int lcm(int a, int b)
{
	return a * b / __gcd(a, b);
}
 
main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n >> m;
	for(int i = 1; i <= n; i++) 
	{
		cin >> a[i];
		b[i] = a[i] / 2;
		int cnt = 0;
		while(a[i] % 2 == 0) a[i] /= 2, cnt++;
		d[i] = cnt;
	}	 
	for(int i = 1; i <= n; i++)
	{
		res = lcm(res, b[i]);
		if(res > m) cout << 0, exit(0);
	}
	int tmp = d[1];
	for(int i = 2; i <= n; i++)
		if(tmp != d[i]) cout << 0, exit(0);
	int j = m / res;
	j++, j /= 2;
	cout << j;                                
}    

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int X, Y;
    cin >> X >> Y;
    
    if (Y - 2 * X >= 0 && (Y - 2 * X) % 2 == 0){
        int a = (Y - 2 * X)/2;
        if (a >= 0 && X - a >= 0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}



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

#define NIL -1

struct Node {
    int key;
    struct Node *parent, *left, *right;
};

struct Node *root = NULL;

void insertNode(struct Node *insertTarget, struct Node *insertedTarget) {
    if (insertedTarget->key > insertTarget->key) {
        if (insertedTarget->left == NULL) {
            insertedTarget->left = insertTarget;
            insertedTarget->parent = insertedTarget;
        } else {
            insertNode(insertTarget, insertedTarget->left);
        }

    } else {
        if (insertedTarget->right == NULL) {
            insertedTarget->right = insertTarget;
            insertedTarget->parent = insertedTarget;
        } else {
            insertNode(insertTarget, insertedTarget->right);
        }
    }
}

void insertTree(struct Node *target) {
    if (root == NULL) root = target;
    else insertNode(target, root);
}

void printInOrderTree(struct Node *target) {
    if (target->left != NULL) printInOrderTree(target->left);
    printf(" %d", target->key);
    if (target->right != NULL) printInOrderTree(target->right);
}

void printPreOrderTree(struct Node *target) {
    printf(" %d", target->key);
    if (target->left != NULL) printPreOrderTree(target->left);
    if (target->right != NULL) printPreOrderTree(target->right);
}

struct Node* createNode(int key) {
    struct Node *node = (struct Node *)malloc(sizeof(struct Node));
    node->key = key;
    node->parent = NULL;
    node->left = NULL;
    node->right = NULL;
    return node;
}

int main() {
    int n;
    scanf("%d", &n);

    char command[10];
    int key;
    for (int i = 0; i < n; i++) {
        scanf("%s", command);

        if (command[0] == 'i') {
            scanf("%d", &key);
            insertTree(createNode(key));

        } else {
            printInOrderTree(root);
            printf("\n");
            printPreOrderTree(root);
            printf("\n");
        }
    }

    return 0;
}



Measured memory_bytes: 25156
<?php
$n = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));

$sum = $b[0];
for ($i = 1; $i < $n-1; $i++) {
    $sum += min($b[$i], $b[$i-1]);
}
echo $sum + $b[$n-2];

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
int N, K;
vector<vector<int> > g;
vector<vector<pair<int, int> > > dp;
int add(int &a, const int &b) {
	a += b;
	if (a >= MOD)a -= MOD;
}
pair<int, int> zero = make_pair(0, 0);
void merge(vector <pair<int, int> > &A, const vector <pair<int, int> > &B) {
	vector<pair<int, int> > res(min(K + 1, (int)A.size() + (int)B.size() - 1), zero);
	for (int i = 0; i < A.size(); i++) {
		for (int j = 0; j < B.size(); j++) {
			if (i + j > K)break;
			add(res[i + j].first, (A[i].first * B[j].first) % MOD);
			add(res[i + j].first, (A[i].first * B[j].second) % MOD);
			add(res[i + j].second, (A[i].second * B[j].first) % MOD);
			add(res[i + j].second, (A[i].second * B[j].second) % MOD);
			if(i + 1 < (int)A.size())add(res[i + j].second, (A[i + 1].second * B[j].second) % MOD);
		}
	}

	swap(res, A);
}

void dfs(int a, int p) {
	dp[a].resize(2);
	dp[a][0].first = 1;
	dp[a][0].second = 0;
	dp[a][1].first = 0;
	dp[a][1].second = 1;
	//cerr << a << endl;
	for (int b : g[a]) {
		if (b != p) {
			dfs(b, a);
			merge(dp[a], dp[b]);
		}
	}

}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> K;
	g.resize(N);
	dp.resize(N);
	int a, b;
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	int res = (dp[0][K].first + dp[0][K].second) % MOD;
	cout << res << endl;
}


Measured memory_bytes: 486888
#include<iostream>

int main(){
    int N;
    std::cin >> N;
    int keta[3];
    for(int i = 0; i < 3; i++){
        keta[i] = N % 10;
        N /= 10;
    }

    int val = keta[0] + keta[1] * 10 + keta[2] * 100;
    std::cout << "ABC" << val << std::endl;
    return 0;
}


Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int n, k, x, y;

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

  solve();

  return 0;
}

void solve() {
  int sum = 0;

  for(int i=1; i<=n; ++i) {
    if(i<=k) sum += x;
    else sum += y;
  }

  cout << sum << endl;

  return;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  long N;
  long k;
  long ans[4];
  vector<long> edge;

  cin >> N;

  for(int i=0;i<N;++i){
    cin >> k;
    edge.push_back(k);
  }

  sort(edge.begin(),edge.end(),greater<long>());

  long count = 0;
  for(int i=0;i<N-1;++i){
    if(count > 1) break;
    if(edge[i]==edge[i+1]){
        ans[count] = edge[i];
        ++count;
        ++i;
    }
  }

  if(count > 1){
    cout << ans[0]*ans[1] << endl;
  }else{
    cout << 0 << endl;
  }
}


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

int main() {
    int n, T;
    cin >> n >> T;
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t.at(i);
    }

    long long ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans += min(T, t.at(i + 1) - t.at(i));
    }
    ans += T;
    cout << ans << endl;
}   

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

using namespace std;

int main(){
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> A(n);
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    sort(A.begin(), A.end());

    vector<int64_t> N, P;
    for (const auto &a: A)
        (a >= 0 ? P : N).push_back(a);
    vector<int64_t> NR(N.size()), PR(P.size());
    copy(P.rbegin(), P.rend(), PR.begin());
    copy(N.rbegin(), N.rend(), NR.begin());

    auto count = [&](auto &A, auto &B, auto m){
        int64_t cnt = 0;  // mより小さい数が何個か
        int i = B.size() - 1;
        for (const auto &a : A){
            while (i >= 0 and m < B[i] * a)
                i--;
            cnt += i + 1;
        }
        return cnt;
    };

    auto check = [&](auto m){
        int64_t cnt = 0;  // mより小さい数が何個か
        cnt += count(P, P, m);
        cnt += 2 * count(PR, N, m);
        cnt += count(NR, NR, m);
        for (const auto &a: A){
            if (a * a <= m)
                cnt--;
        }

        return k <= cnt / 2;
    };

    const int64_t INF = 1e18 + 1;
    int64_t l = -INF, r = INF;

    while (r - l > 1){
        auto mid = (l + r) / 2;
        (check(mid) ? r : l) = mid;
    }

    cout << r << endl;
}

Measured memory_bytes: 5108
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 500

ll dp[N][N];

int main(){
	ll n, ma, mb;
	cin>>n>>ma>>mb;
	rep(i, N) fill(dp[i], dp[i]+N, INF);
	dp[0][0] = 0;
	rep(i, n){
		int a, b, c;
		cin>>a>>b>>c;
		for(int i = N-1; i >= a; i--) for(int j = N-1; j >= b; j--) chmin(dp[i][j], dp[i-a][j-b]+c);
	}
	ll res = INF;
	for(int i = 1; i*max(ma, mb)<N; i++) chmin(res, dp[i*ma][i*mb]);
	cout<<(res==INF?-1:res)<<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a = gi();
    int b = gi();
    int c = a+b;
    int d = a-b;
    int e = a*b;

    printf("%d\n", MAX(MAX(c, d), e));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0);
int r[300001];
int c[300001];
ll ans;
int h,w,m;
int x,y;
int mxr,mxc;
int rr,cc;
set<pi<int,int>> s;
vector<int> vr,vc;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> h >> w >> m;
    mxr = mxc = -10;
    rep1(i,0,m){
        cin >> x >> y;
        r[x]++;
        c[y]++;
        s.insert({x,y});
    }    

    rep2(i,1,h) mxr = max(mxr,r[i]);
    rep2(i,1,w) mxc = max(mxc,c[i]);
    ans = mxr + mxc - 1;

    rep2(i,1,h) if(mxr == r[i]) vr.PB(i);
    rep2(i,1,w) if(mxc == c[i]) vc.PB(i);

    rep1(i,0,(int)vr.size())
        rep1(j,0,(int)vc.size())
            if(!s.count({vr[i],vc[j]})){
                cout << ans + 1 << '\n';
                return 0;
            }
    cout << ans;
    return 0;
}

Measured memory_bytes: 23740
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := newScanner(bySpace)
	d := scanner.nextInt()
	t := scanner.nextInt()
	s := scanner.nextInt()
	if d <= t*s {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

type splitter int

const (
	bySpace splitter = iota
	byLine
)

func newScanner(sp splitter) *sc {
	scanner := bufio.NewScanner(os.Stdin)
	if sp == bySpace {
		scanner.Split(bufio.ScanWords)
	}
	return &sc{
		s: scanner,
	}
}

type sc struct {
	s *bufio.Scanner
}

func (s *sc) nextInt() int {
	if s.s.Scan() {
		val := s.s.Text()
		v, err := strconv.Atoi(val)
		if err != nil {
			panic(err)
		}
		return v
	}
	panic("no more stdin")
}


Measured memory_bytes: 1772
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    ll N; cin>>N;
    ll K; cin>>K;
    ll a[1000];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    ll sum[1001]={};
    for(int i=1;i<=N;i++){
        sum[i]=sum[i-1]+a[i-1];
    }
    ll M=N*(N+1)/2;
    ll b[500501];
    int ma=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<=N;j++){
            b[ma]=sum[j]-sum[i];
            ma++;
        }
    }
    ll ans=0;
    ll x[41]; x[0]=1;
    for(int i=1;i<41;i++){
        x[i]=x[i-1]*2;
    }
    for(int i=40;i>=0;i--){
        int tmp=0;
        ll tes=ans+x[i];
        for(int j=0;j<M;j++){
            if((b[j]&tes)==tes) tmp++;
        }
        if(tmp>=K) ans=tes;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    string s;
    cin >> s;
    show(s[2] == s[3] && s[4] == s[5]);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  string s;
  cin>>s;

  char c = s[s.length()-1];
  if (c == '3')
    cout<<"bon"<<endl;
  else if (c == '0' || c == '1' || c == '6' || c == '8')
    cout<<"pon"<<endl;
  else
    cout<<"hon"<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

int main() {
    ll N, K, ans = 0, csum[200001] = {0, 1};
    cin >> N >> K;
    FOR(i, 2, 200001) csum[i] = csum[i - 1] + i;
    FOR(i, K, N + 1) {
        ans += (csum[N] - csum[N - i]) - csum[i - 1] + 1;
        ans %= MOD;
    }
    ans++;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5200
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
	val n = readInt()
	val roads = Array(n) { readListOfLong().toLongArray() }
	val distances = Array(n) { Array(n) { (1e+10).toLong() } }
	for(k in 0 until n) {
		for(i in 0 until n) {
			for(j in 0 until n) {
				distances[i][j] = Math.min(distances[i][j], roads[i][j])
				distances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j])
			}
		}
	}

	var cnt = 0L
	var notAble = false
	for(i in 0 until n-1) {
		for(j in i+1 until n) {
			if(distances[i][j] != roads[i][j]) {
				notAble = true
				break
			}
			var found = false
			for(w in 0 until n) {
				if(w == i || w == j) continue
				if(distances[i][j] == distances[i][w] + distances[w][j]) {
					found = true
					break
				}
			}
			if(!found) {
				cnt += distances[i][j]
			}
		}
		if(notAble) {
			cnt = -1L
			break
		}
	}
	println(cnt)

	pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

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

int main(){
  string a;
  cin >> a;
  bool good = true;
  
  for(int i = 0; i < a.size(); i++){
    if(i % 2 == 0 && a.at(i) == 'L'){
      good =false;
      break;
    }
    else if(i % 2 == 1 && a.at(i) == 'R'){
      good = false;
      break;
    }
  }
  
  if(good){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}




Measured memory_bytes: 256
import fractions
n=int(input())
a=list(map(int, input().split())) 
b=[0]
c=[0]
ans=[]
for i in range(n):
    b.append(fractions.gcd(b[i],a[i]))
    c.append(fractions.gcd(c[i],a[-i-1]))
del b[n]
del c[n]
 
for i in range(n):
    d=b[i]
    e=c[n-1-i]
    ans.append(fractions.gcd(d,e))
print(max(ans))

Measured memory_bytes: 16132
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N, D = MAP()
    XY = ZIP(N)
    count = 0
    for x, y in XY:
        if (x**2 + y**2)**0.5 <= D:
            count += 1
    print(count)
    return


if __name__ == '__main__':
    main()


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

int main(){
    string s,t;
    cin >> s >> t;
    int len = s.length();
    int count = 0;
    for(int i=0; i<len; i++){
        if(s.at(i) != t.at(i)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    while(1){
      cin >> h >> w;
      if(h==0 && w==0) break;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(i==0 || i==h-1 || j==0 ||j==w-1){
            cout << '#' ;
          }else{
            cout << ".";
          }
        }
        cout << endl;
      }
     cout << endl;
    }
    
}


Measured memory_bytes: 3072
using System;
using System.Collections.Generic;
using System.Text;
 
class Program
{
    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        int[] numList = new int[itemCount];
 
        for(int i=0; i<inpt.Length; i++)
        {
            numList[i] = int.Parse(inpt[i]);
        }
        // ??????????????????
        int left = 0;
        int convCount = 0;
         
        while(true)
        {
            bool isMatch = false;
            for(int i=numList.Length -2; i>=left; i--)
            {
                if(numList[i] > numList[i+1])
                {
                    int v = numList[i];
                    numList[i] = numList[i + 1];
                    numList[i + 1] = v;
                    convCount++;
                    isMatch = true;
                    if(i==left)
                    {
                        left++;
                    }
                }
            }
            if(!isMatch)
            {
                break;
            }
        }
        StringBuilder ans = new StringBuilder();
        for(int i=0; i<numList.Length; i++)
        {
            if(ans.Length > 0)
            {
                ans.Append(" ");
            }
            ans.Append(numList[i]);
        }
 
        Console.WriteLine(ans.ToString());
        Console.WriteLine(convCount);
    }
 
 
    static void Main(string[] args)
 
    {
 
        Program prg = new Program();
        prg.Proc();
 
    }
}

Measured memory_bytes: 9136
/*
http://chaste.web.fc2.com/Reference.files/Algo.html
fukumen.c -- 覆面算 (slightly modified)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
enum {FALSE, TRUE};

#define N 15  /* 最大の行数 */

int imax, jmax, solution, digit[128], low[128], ok[N];
char word[N][128];
void found(void)  /* 解の表示 */
{
	int i, j, c;
	for (i = 0; i <= imax; i++){
		if(strlen(word[i])>1&&digit[word[i][strlen(word[i])-1]]==0)return;
	}
	++solution;
/*
	printf("\n解 %d\n", solution);
	for (i = 0; i <= imax; i++) {
		for (j = jmax; j >= 0; j--) {
			c = word[i][j];
			if (c != '\0') printf("%d", digit[c]);
			else           printf(" ");
		}
		printf("\n");
	}
*/
}

void try(int sum)  /* 再帰的に試みる */
{
	static int i = 0, j = 0, carry;
	int c, d;

	c = word[i][j];
	if (i < imax) {
		i++;
		if ((d = digit[c]) < 0) {  /* 定まっていないなら */
			for (d = low[c]; d <= 9; d++)
				if (ok[d]) {
					digit[c] = d;  ok[d] = FALSE;
					try(sum + d);  ok[d] = TRUE;
				}
			digit[c] = -1;
		} else try(sum + d);
		i--;
	} else {
		j++;  i = 0;  d = sum % 10;  carry = sum / 10;
		if (digit[c] == d) {
			if (j <= jmax) try(carry);
			else if (carry == 0) found();
		} else if (digit[c] < 0 && ok[d] && d >= low[c]) {
			digit[c] = d;  ok[d] = FALSE;
			if (j <= jmax) try(carry);
			else if (carry == 0) found();
			digit[c] = -1;  ok[d] = TRUE;
		}
		j--;  i = imax;
	}
}

int main()
{
	int i, j, k, c;
	static unsigned char buffer[128];

	jmax = 0;
loop:
	memset(word,0,sizeof(word));
	memset(digit,0,sizeof(digit));
	//memset(low,0,sizeof(low));
	memset(ok,0,sizeof(ok));
	//printf("行数? ");
	scanf("%d", &imax);
	if(!imax)return 0;
	imax--;
	for (i = 0; i < N && i <= imax; i++) {
		//printf("%2d: ", i + 1);
		scanf("%s", buffer);
		//low[buffer[0]] = strlen(buffer)>1;
		k = strlen((char *)buffer) - 1;
		if (k > jmax) jmax = k;
		for (j = 0; j <= k; j++) {
			c = word[i][j] = buffer[k - j];
			if (isalpha(c)) digit[c] = -1;
			else if (isdigit(c)) digit[c] = c - '0';
		}
	}
	for (i = 0; i <= 9; i++) ok[i] = TRUE;
	solution = 0;  try(0);
	//if (solution == 0) printf("解はありません.\n");
	printf("%d\n",solution);
	goto loop;
}

Measured memory_bytes: 600