akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int mod = 1e9 + 7, N = 20000;
ll fact[N], inv[N];
ll fp(ll base, ll exp){
    if (exp == 0) return 1;
    ll ans = fp(base, exp / 2);
    if (exp % 2 == 0) return (ans * ans) % mod;
    else return (((ans * ans)% mod) * base)% mod;
}
void calcFacAndInv(ll n){
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++){
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r){
    if(r > n) return 0;
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

int main(){
    Hello
    calcFacAndInv(N - 5);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        ll ans = ((ncr(n - k + 1, i) % mod) * (ncr(k - 1, i - 1) % mod))% mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3904
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//N = number of atoms

int main()
{
  int N,M;
  scanf("%d %d",&N,&M);
  
  int n,m;
  n = N*(N-1)/2;
  m = M*(M-1)/2;
  
  if( n<=0 ){
    n = 0;
  }
  if( m<=0 ){
    m = 0;
  }
  
  if( n>=0 && m>=0 ){
    printf("%d\n",n+m);
  }

  
  return 0; 
  
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = false;
#else
const bool testing = false;
#endif

    static void program(TextReader input)
    {
        //var n = int.Parse(input.ReadLine());
        var data = input.ReadLine().Split(' ').Select(long.Parse).ToList();
        var n = data[0];
        var a = data[1];
        var b = data[2];
        
            Console.WriteLine((b - a) % 2 == 0 ? "Alice": "Borys");
            return;
        
    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("2\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("4 3\n2 1 1\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("1\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("3 9\n1 1 3\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(3) => expected :");
        Console.WriteLine("2147483648\n");
        Console.WriteLine("Test Case(3) => found    :");
        program(new StringReader("12345678 87654321\n43043751 1000000000 53798715\n"));
        Console.WriteLine();

    }
}


Measured memory_bytes: 11220
pnt=[]
n=int(input())
for i in range(n):
  pnt.append(list(map(int,input().split())))

z=[]
w=[]

for i in pnt:
  z.append(i[0]+i[1])
  w.append(i[0]-i[1])
print(max(max(z)-min(z),max(w)-min(w)))


Measured memory_bytes: 61056
// An Ordinary Game
#include <iostream>
#include <string>
using namespace std;

string s;

int main(){
    cin>>s;
    int n=s.size();
    if((n%2==1&&s[0]==s[n-1])||(n%2==0&&s[0]!=s[n-1]))
        cout<<"Second\n";
    else cout<<"First\n";
    return 0;
}

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

int main(){

  int n,k;
  long ans;
  cin >> n >> k;
  vector<long> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  sort(h.begin(),h.end());
  for(int i=0;i<n-k;i++){
	ans+=h[i];
  }
  cout << ans;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    string s;
    cin >> s;
    rep(i, 5) cout << s.at(i);
    cout << " ";
    rep(i, 7) cout << s.at(i + 5 + 1);
    cout << " ";
    rep(i, 5) cout << s.at(i + 12 + 2);
    cout << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
// UPD1: no, just sparse table :/

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const int inf=1e9;
const int MX=2e5+5;
int n,L,x[MX],q,nxt[35][MX];

int get(int a,int k){
	for(int i=0;i<30&&a!=-1;++i) if(k>>i&1) a=nxt[i][a];
	return a==-1?n:a;
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	for(int i=0;i<n;++i) cin>>x[i];
	cin>>L;
	memset(nxt,-1,sizeof nxt);
	nxt[0][n-1]=n;
	for(int l=n-2,r=n-1;~l;--l){
		while(x[r]-x[l]>L) --r;
		nxt[0][l]=r;
	}
	for(int i=1;(1<<i)<=n;++i) for(int j=0;j<n;++j) if(nxt[i-1][j]!=-1) nxt[i][j]=nxt[i-1][nxt[i-1][j]];
	cin>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		--a,--b;
		int l=1,r=n;
		while(l<=r){
			int m=(l+r)>>1;
			if(get(a,m)>=b) r=m-1;
			else l=m+1;
		}
		cout<<l<<'\n';
	}
}

Measured memory_bytes: 28544
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new long[1000];
        Dictionary<BigInteger, int> dict = new Dictionary<BigInteger, int>();
        for (int i = 0; ; i++)
        {
            var bigi = (BigInteger)i;
            var pow = bigi * bigi * bigi * bigi * bigi;
            var t = (pow) - n;
            var sign = t < 0 ? -1 : 1;
            var abs = BigInteger.Abs(t);
            if (dict.ContainsKey(abs))
            {
                Console.WriteLine($"{i} {sign * dict[abs]}");
                return;
            }
            dict.Add(pow, i);
        }
    }
}

Measured memory_bytes: 28080
#include <bits/stdc++.h>
 
using namespace std;
 
//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
 
#ifdef LUCARIO
#define deb(...) fprintf(stderr,_VA_ARGS_)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
 
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
 
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define f first 
#define s second 
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define mp make_pair    
#define endl "\n"
 
#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = b - 1; i >= a; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define trans(a,b) trasform(a.begin(),a.end(),a.begin(),b)
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)
 
#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-10
 
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
 
#define MAXN 100100
 
int ft[MAXN +1]; // for more dimensions, make ft multi-dimensional
void upd(int i0, int v){ // add v to i0th element (0-based)
        // add extra fors for more dimensions
        for(int i=i0+1;i<=MAXN;i+=i&-i)ft[i]= (ft[i] + v)%mod;
}
int get(int i0){ // get sum of range [0,i0)
        int r=0;
        // add extra fors for more dimensions
        for(int i=i0;i;i-=i&-i)r= (r +ft[i])%mod;;
        return r;
}
int get_sum(int i0, int i1){ // get sum of range [i0,i1) (0-based)
        return (get(i1)-get(i0)+mod)%mod;
}
int a[101];
int dp[100001][2];
 
int32_t main(int32_t argc, char const *argv[]){
    FIN;
 
    int n ,k;cin>>n>>k;
    fore(i,0,n)cin>>a[i];
    bool b = true;
    fore(i,0,a[n-1]+1){
        dp[i][b] =1;
        upd(i,1);
    }
 
    rfore(i,0,n-1){
        b = !b;
        fore(j,0,k+1){
            dp[j][b] = get_sum(max(j-a[i],0ll),j+1);
         //   cout<<dp[j][b]<<" ";
        }
        mm(ft,0);
        fore(j,0,k+1){
            upd(j,dp[j][b]);
        }
    }
    cout<<dp[k][b];
 
 
    return 0;
}

Measured memory_bytes: 2560
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = IR(m)
dp = [0]*(n+3)
dp[0] = 1

A.sort(reverse=True)
if len(A) > 0:
    tmp = A.pop()
else:
    tmp = -1
if tmp == 1:
    dp[1] = 0
    if len(A) > 0:
        tmp = A.pop()
else:
    dp[1] = 1

for i in range(n+1):
    if tmp == i+2:
        dp[i+2] = 0
        if len(A) > 0:
            tmp = A.pop()
    else:
        dp[i+2] += dp[i+1] + dp[i]

print(dp[n] % MOD)


Measured memory_bytes: 479200
H,W,D=map(int,input().split())
A = [[0]*(W+1)]
A += [[0] + list(map(int,input().split())) for _ in range(H)]
# n2idx = [None]*(H*W + 1)
routes = [[] for _ in range(D)]
for h in range(1, H+1):
    for w in range(1, W+1):
        # n2idx[A[h][w]] = (h, w)
        routes[A[h][w]%D].append((A[h][w], h, w))
        #(num, x-idx, y-idx)

Q = int(input())
costs = [[0] for _ in range(D)]
for d in range(D):
    routes[d].sort()
    # now = routes[d][0]
    for i in range(1, len(routes[d])):
        v1, h1, w1 = routes[d][i-1]
        v2, h2, w2 = routes[d][i]
        costs[d].append(costs[d][i-1] + abs(h1-h2)+abs(w1-w2))

for _ in range(Q):
    L, R = map(int, input().split())
    amari = L%D
    start = L//D
    end = R//D
    if amari == 0:
        start -= 1
        end -= 1
    print(costs[amari][end] - costs[amari][start])

Measured memory_bytes: 105768
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var k     = int.Parse(spl[1]);

        var c = 0;
        spl   = input.ReadLine().Split(' ');
        for(int i=0; i<n; i++) {
            var h = int.Parse(spl[i]);
            if (h >= k) c++;
        }

        return c;
    }
}

Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = n - 1; i >= 0; --i)

ll gcd(ll a, ll b) {
    if(a < b){
        return gcd(b, a);
    }
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll k;
    cin >> k;
    ll ans = 0;
    for(ll a = 1; a <= k; ++a){
        for(ll b = 1; b <= k; ++b){
            const ll gab = gcd(a,b);
            for(ll c = 1; c <= k; ++c){
                ans += gcd(c, gab);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

char in[100050];
int main() {
	scanf("%s", in);

	int i;
	for (i = 0; in[i]; i += 2) printf("%c", in[i]);
	return !printf("\n");
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int lim = 400;
    int ans = 8;
    while (true) {
      if ((lim <= x) && (x < (lim + 200))) {
        System.out.println(ans);
        return;
      } else {
        lim += 200;
        ans--;
      }
    }

  }
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;

const int mo=1000000007;
int power(int x,ll y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
const int N=105;
int a[N],mn[N][N];
int fxor[N][N];
int pre[N][N];
int suf[N][N];
int mx[N],g[N],n;
int main(){
	scanf("%d",&n); n++;
	For(i,2,n) scanf("%d",&a[i]);
	a[0]=a[1]=a[n+1]=a[n+2]=1;
	For(i,0,n+2) mn[i][i]=i;
	For(l,0,n+2) For(r,l+1,n+2)
		mn[l][r]=(a[r]<a[mn[l][r-1]]?r:mn[l][r-1]);
	For(i,1,n+2) fxor[i][i-1]=1;
	Rep(l,n+1,1) For(r,l,n+1){
		int dn=max(a[l-1],a[r+1]),md=mn[l][r];
		if (a[md]>=dn) fxor[l][r]=1ll*power(2,a[md]-dn)*fxor[l][md-1]%mo*fxor[md+1][r]%mo;
	}
	For(l,0,n+2){
		CLR(mx,0); mx[l]=a[l];
		For(i,l+1,n+2) mx[i]=min(a[i],mx[i-1]);
		int tmp=pre[l][l]=1,las=l;
		For(r,l+1,n+2){
			pre[l][r]=1ll*tmp*fxor[las+1][r-1]%mo;
			if (mx[r]>=a[r]) tmp=1ll*tmp*fxor[las+1][r-1]%mo,las=r;
		}
	}
	For(r,0,n+2){
		CLR(mx,0); mx[r]=a[r];
		Rep(i,r-1,0) mx[i]=min(a[i],mx[i+1]);
		int tmp=suf[r][r]=1,las=r;
		Rep(l,r-1,0){
			suf[l][r]=1ll*tmp*fxor[l+1][las-1]%mo;
			if (mx[l]>=a[l]) tmp=1ll*tmp*fxor[l+1][las-1]%mo,las=l;
		}
	}
	g[1]=1;
	For(i,2,n+2) For(j,1,i-1){
		int md=mn[j-1][i];
		UPD(g[i],1ll*g[j]*pre[j-1][md]%mo*suf[md][i]%mo);
	}
	printf("%d\n",1ll*g[n+2]*500000004ll%mo);
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
    int a, b;
    cin >> a >> b;

    if (a == 1) {
        a += 13;
    }

    if (b == 1) {
        b += 13;
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    ll n,a[400],sum=0,cnt=0;

    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    while(1){
        for(int i=0;i<n;i++){
            if(a[i]%2){
                goto END;
            }
            a[i]/=2;
        }
        cnt++;
    }
END:
    printf("%lld\n",cnt);
    return 0;

}

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

int main(){
	int n,m,A[100][1000],b[1000],c[1000];
	cin>>n>>m;
	for(int t=0;t<n;t++){
		for(int s=0;s<m;s++){
			cin>>A[t][s];
		}
	}
	for(int t=0;t<m;t++)
		cin>>b[t];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			c[i]+=A[i][j]*b[j];
		}
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1560
def solve(h):
    dp = [0, abs(h[0]-h[1])]
    for i in range(2, len(h)):
        one = dp[i-1] + abs(h[i-1]-h[i])
        two = dp[i-2] + abs(h[i-2]-h[i])
        dp.append(min(one, two))
    return dp[-1]



if __name__ == "__main__":
    n = int(input())
    h = [int(x) for x in input().split()]
    print(solve(h))

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

int main() {
  int a,b;
  cin >>a;
  if(a%2==0){
    cout<<(a/2)*(a/2)<<endl;
  }
  else if(a%2!=0){
    cout<<(a/2+1)*(a/2)<<endl;
  }

  

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a<b) {
    printf("a < b\n");
  }
  else if (a>b) {
    printf("a > b\n");
  }
  else if (a==b) {
    printf("a == b\n");
  }
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  ll num;
  if(N % 2 == 0) num = (N-1)/2;
  else num = N/2;

  ll odd = (num+1)/2;
  ll even = num/2;

  ll counter = 0;
  ll start = 1;
  for(int i = odd; i >= 1; i--){
    cout << start << ' ' << start + 2 * i - 1 << endl;
    start++;
    counter++;
    if(counter == M) return 0;
  }
  start = 2 * odd + 1;
  for(int i = even; i >= 1; i--){
    cout << start << ' ' << start + 2 * i << endl;
    start++;
    counter++;
    if(counter == M) return 0;
  }
}

Measured memory_bytes: 3664
/*
  ->->->->->-> Vora Mahammadasim <-<-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb push_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    map<pair<int,int>,vector<pair<int,int>>>mp;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        mp[{a[x],x}].pb({a[y],y});
        mp[{a[y],y}].pb({a[x],x});
    }
    int ans =0;
    for(int i=0;i<n;i++){
        bool ref = true;
        for(auto x : mp[{a[i],i}]){
            if(x.first >= a[i]){
                ref = false;
                break;
            }
        }
        if(ref) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 17176
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

dis_X = [(X[i+1] - X[i]) for i in range(0, M-1)]

dis_X.sort()

if len(dis_X) <= (N-1):
    print(0)
else:
    # print(dis_X)
    # print(dis_X[:M-(N-1)-1])
    print(sum(dis_X[:M-(N-1)-1]))

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define mod 1000000007
#define MAXN 15000001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
sl getFactorization(ll x);
void getZarr(string str, ll Z[]);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll x;
    cin>>x;
    if(x==3 || x==5 ||x==7) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

sl getFactorization(ll x) 
{ 
    sl ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 

ll ceil(ll a,ll b){
    return a/b+(a%b!=0);
}

void getZarr(string str, ll Z[]){
    ll n = str.length();
    ll L, R, k;
    L = R = 0;
    for (ll i = 1; i < n; ++i){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    int a,b;
    cin>>a>>b;
    if(a-2*b<=0) cout<<"0"<<endl;
    else cout<<a-2*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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 all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N, Q, l, r;
	string s;
	cin >> N >> Q >> s;
	vector<int> sum(N + 1, 0);
	REP(i,N-1){
		sum[i+1] = sum[i];
		if(s[i-1] == 'A' && s[i] == 'C')++sum[i+1];
	}
	rep(i,Q){
		cin >> l >> r;
		cout << sum[r] - sum[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
    int  n,m,s,d;
    scanf("%d\n%d\n%d\n%d",&n,&m,&s,&d);
    if(n<=m)
    printf("%d\n",n*s);
    else if(n>m)
    printf("%d\n",m*s+(n-m)*d);
    
    return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

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

	string s;
	cin >> s;
	int n = s.size();

	ll sum = 0 , res = 0;

	for(int i = 0; i < n; i++)
	{
		if(s[i] != '0')
			res = max(res , sum + s[i] - '0' - 1 + (n - i - 1) * 9);
		sum += s[i] - '0';
	}

	res = max(res , sum);
	
	cout << res << endl;

}


























Measured memory_bytes: 768
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N;cin>>N;vector<ll>A(N);cin>>A;sort(A.rbegin(),A.rend(),[](ll a,ll b){return abs(a)<abs(b);});for(int i=0;i<N-1;i++){if(A[i]<0)A[i]*=-1,A[i+1]*=-1;}cout<<accumulate(A.begin(),A.end(),0ll)<<endl;}


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

using namespace std;
using ll =long long;
using db = double;

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; }

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	db a,b,x;
	cin >> a >> b >> x;

	db s = x / a ;//二次元で見たときの水の量
	db mother, child;//tanの分母と分子

	if(2*s >= a * b){
		mother = a ;
		child = 2*(a*b-s)/a;
	}else {
		child = b;
		mother = s / b * 2.;
	}
	db rad = atan2(child,mother);
	db deg = rad * 180 /M_PI ;

	cout << deg << endl;
}


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

using namespace std;

main(){
  string in;
  int data[9];
  while(cin >> in){
    for(int i=0;i<9;i++){
      data[i]=0;
    }
    for(int i=0;i<13;i++){
      data[(int)in[i]-'1']++;
    }
    bool ans[9];
    int tmp[9];

    for(int i=0;i<9;i++){
      ans[i]=false;
    }
    for(int a=0;a<9;a++){
      if(data[a]==4) continue;
      data[a]++;
      for(int i=0;i<9;i++){
	if(data[i]>=2){
	  for(int k=0;k<9;k++){
	    tmp[k]=data[k];
	  }
	  tmp[i]-=2;
	  for(int j=0;j<9;j++){
	    if(tmp[j]>=3){
	      tmp[j]-=3;
	    }
	  }
	  for(int j=2;j<9;j++){
	    while(tmp[j-2]>=1 && tmp[j-1]>=1 && tmp[j]>=1){
	      tmp[j-2]--;
	      tmp[j-1]--;
	      tmp[j]--;
	    }
	  }
	  bool mentu=true;
	  for(int j=0;j<9;j++){
	    if(tmp[j]!=0){
	      mentu=false;
	    }
	  }
	  if(mentu){
	    ans[a]=true;
	  }
	  for(int k=0;k<9;k++){
	    tmp[k]=data[k];
	  }
	  tmp[i]-=2;
	  for(int j=2;j<9;j++){
	    while(tmp[j-2]>=1 && tmp[j-1]>=1 && tmp[j]>=1){
	      tmp[j-2]--;
	      tmp[j-1]--;
	      tmp[j]--;
	    }
	  }
	  for(int j=0;j<9;j++){
	    if(tmp[j]>=3) tmp[j]-=3;
	  }
	  mentu=true;
	  for(int j=0;j<9;j++){
	    if(tmp[j]!=0){
	      mentu=false;
	    }
	  }
	  if(mentu){
	    ans[a]=true;
	  }
	}
      }
      data[a]--;
    }
    bool f=true;
    for(int i=0;i<9;i++){
      if(ans[i]){
	if(!f) cout << ' ';
	cout << i+1;
	f=false;
      }
    }
    if(f) cout << 0;
    cout <<endl;
  }
  return 0;
}

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

int main() {
int A,B,C;
cin>>A>>B>>C;

if(A==B&&A!=C){cout<<"Yes"<<endl;}else if(A==C&&A!=B){cout<<"Yes"<<endl;}
  else if(B==C&&B!=A){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <numeric>
#include <cmath>

using namespace std;
using sl = signed long;
using sll = signed long long;
using ll = long long;

// For debug
template <class T> void print_vecotor(vector<T> v){
	for(auto itr=v.begin();itr<v.end();itr++){
		cout << *itr << " ";
	}
}

int main(int argc, char *argv[])
{
	int N;
	cin >> N;
	vector<int> v{0};
	vector<int> p{0};
	for(int i=0;i<N;i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		p.push_back(p[i]+tmp);
	}

	int ans = 0;
	for(int i=N;i>0;i--){
		ans += v[i]*p[i-1];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * 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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S, T;
	cin >> S >> T;
	int ans = INF;
	rep(i, (int)S.size() - (int)T.size() + 1) {
		int cnt = 0;
		rep(j, (int)T.size()) {
			if (S[i + j] != T[j])cnt++;
		}
		ans = min(ans, cnt);
	}
	cout << ans;
}

Measured memory_bytes: 3628
use proconio::{fastout, input};

fn main() {
    input! {
        n: usize,
        a_vec: [i64; n],
    };

    let a_fold = a_vec.iter().fold(0, |acc, a| acc ^ a);
    a_vec.iter().for_each(|a| {
        print!("{} ", a_fold ^ a);
    })
}


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

int n;
vector<int>E[200];
int d[200];
int cnt[200];

pair<int,ll>calc(int u,int v=-1){
	memset(d,-1,sizeof(d));
	queue<int>que;
	d[u]=0;que.push(u);
	if(v!=-1){d[v]=0;que.push(v);}
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int c:E[p]){
			if(d[c]==-1){
				d[c]=d[p]+1;
				que.push(c);
			}
		}
	}
	memset(cnt,0,sizeof(cnt));
	rep(i,n){
		cnt[d[i]+1]=max(cnt[d[i]+1],(int)E[i].size()-(d[i]==0&&v==-1?0:1));
	}
	cnt[0]=(v==-1?1:2);
	int dist=0;
	ll ans=1;
	rep(i,n){
		if(cnt[i]==0)break;
		ans*=cnt[i];
		dist=i;
	}
	return make_pair(dist+1,ans);
}
int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	pair<int,ll>ans(INT_MAX,0);
	rep(i,n){
		ans=min(ans,calc(i));
		for(int u:E[i]){
			ans=min(ans,calc(i,u));
		}
	}
	cout<<ans.first<<' '<<ans.second<<endl;
}


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

int64_t sigma(int64_t x){
  	return x*(x+1)/2;
}

int main(){
 	int n;
  	cin>>n;
	
	int64_t sum=sigma(n);
  
cout<<sum-3*sigma(n/3)-5*sigma(n/5)+15*sigma(n/15)<<endl;
}

Measured memory_bytes: 3640
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    N, A, B, C, D = map(int, input().split())
    S = input()

    ans = 'Yes'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        if '...' not in S[B-2:D+1]:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40816
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

// void time() {
//     #ifndef ONLINE_JUDGE
//     cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
//     #endif
// }
 



  int32_t main()
  {        


     IOS

    

     int n;
     cin >> n;
     string s;
     cin >> s;

     if(n%2 == 0 )
     {
        bool ok = true;

        for(int i = 0; i < s.length()/2; i++)
        {
          if(s[i] != s[i + s.length()/2])
          {
            ok = false;
            break;
          }
        }

        if(ok)
        {
          cout << "Yes";
        }
        else
        {
          cout << "No";
        }
     }
     else
     {
      cout << "No";
     }

    //time();
    return  0;
     }


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
          int n;
          cin>>n;
          int a[n];
          for(int i=0;i<n;i++)cin>>a[i];sort(a,a+n);
          int ans=0;
          for(int i=0;i<n;i++)ans+=a[i]*(2*(i&1)-1);
          cout<<abs(ans)<<endl;
      }

        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

int n, x, t;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << '\n';
    return 0;
}


Measured memory_bytes: 3604
n,m = map(int,input().split())
a=[]
for _ in range(n):
  a.append(list(map(int,input().split())))

x = [0]*m

for i in range(n):
  for k in range(1,a[i][0]+1):
    x[a[i][k]-1] += 1
count = 0
for i in range(m):
  if x[i] == n:
    count += 1
print(count)

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

int main(){
    char c[2][3];
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<3;i++){
        if(c[0][2-i]!=c[1][i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = a; i <= b; ++i) {
        string s = to_string(i);

        bool flag = true;
        rep(i, s.size() / 2) {
            if (s[i] != s[s.size() - i - 1]) {
                flag = false;
                break;
            }
        }

        if (flag)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;
const int mod = 1000000007;


ll solve2(ll N, vector<ll>A){

    ll ret = 0;
    for(int i=0; i<N-1; i++){
        for (int j=i+1; j<N; j++){
            ret += A[i]*A[j];
            ret %= mod;
        }
    }
    return ret%mod;
}


ll solve1(ll N, vector<ll>A){
    ll N_f = 1;
    ll sum_a = 0;
    vector<ll>cumsum(N+1);
    cumsum[0] = 0;

    for (ll i=0; i<N; i++){
        cumsum[i+1] = cumsum[i]+A[i];
        cumsum[i+1] %= mod;

        sum_a += A[i];
        sum_a %= mod;
    }

    ll ans = 0;

    for (ll i=0; i<N-1; i++){
        ans += (sum_a - cumsum[i+1])* A[i];
        ans %= mod;
        if (ans < 0)ans = mod +ans;
    }
    return ans;

}


int main() {
    ll N;
    cin >> N;
    vector<ll>A(N);
    for (ll i=0; i<N; i++)cin >> A[i];
    
    ll effective = solve1(N,A);
    cout << effective << endl;
    return 0;
    
    ll greedy = solve2(N,A);


    if (effective != greedy)cout << "WRONG !! Effective: "   << effective << ", Greedy: " << greedy << endl;
    else cout << "Good ! effective: " << effective << ", greedy: " << greedy << endl;
}

Measured memory_bytes: 7952
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>> d (n, vector<int> (2));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 2; j++){
      cin >> d[i][j];
    }
  }
  bool ans = false;
  for(int i = 0; i < n-2; i++){
    if((d[i][0] == d[i][1])&&(d[i+1][0] == d[i+1][1])&&(d[i+2][0] == d[i+2][1])){
      ans = true;
    }
  }
  if(ans == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
template<class T> inline bool chmax(T &a, T b){if(a<b){a=b; return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a>b){a=b; return true;}return false;}

int main(){
  ll n,rcnt=0,gcnt=0,bcnt=0,ans,J,K;
  cin >> n;
  string s;
  cin >> s;

  rep(i,0,n){
    if(s[i]=='R')rcnt++;
    if(s[i]=='G')gcnt++;
    if(s[i]=='B')bcnt++;
  }
  ans= rcnt*gcnt*bcnt;

  rep(i,0,n){
    rep(d,1,n){
      J= i+d;
      K= J+d;
      if(K>=n)break;
      if(s[i]!=s[J] && s[i]!=s[K] && s[J]!=s[K]){
        ans--;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll a,b,c;cin>>a>>b>>c;
    ll ans=0;
    fore(i,a,b)ans+=c%i?0:1;
    cout<<ans<<endl;
}

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



Measured memory_bytes: 3124
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void TriangularRelationship() {
	i64 N, K;
	cin >> N >> K;
	i64 res = 0;
	i64 kt = K;
	bool b[200001];
	for (size_t i = 0; i <= N; i++)
	{
		b[i] = false;
	}
	int t[200001];
	for (size_t i = 1; i <= N; i++)
	{
		
		t[i] = 0;
		if (b[i]) continue;
		if ((2 * i) % K == 0) {
			int ti = i;
			while (ti <= N)
			{
				t[i]++;
				b[ti] = true;
				ti += K;
			}
		}
	}

	for (size_t i = 1; i <= N; i++)
	{
		res += pow(t[i], 3);
	}
	cout << res << "\n";
}
 int main() {
	TriangularRelationship();
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
}

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

#define N_MAX 20
#define K_MAX 10
#define S_MAX 155

int dp[N_MAX + 1][K_MAX + 1][S_MAX + 1] = {};

int main() {
  
  for (int i = 0; i <= N_MAX; i++){
    dp[i][0][0] = 1;
  }

  for (int n = 1; n <= N_MAX; n++) {
    for (int k = 1; k <= K_MAX; k++) {
      for (int s = 1; s <= S_MAX; s++) {

	dp[n][k][s] +=
	  (s - n < 0 ? 0 : dp[n-1][k-1][s-n]) +
	  dp[n - 1][k][s];
	/*
	if(n <= 2 && k <= 1 && s <= 10){
	  cout << n << ", " << k << ", " << s << ", " << dp[n][k][s] << endl;
	}
	*/
      }
    }
  }

  while( true ) {

    int n, k, s;
    cin >> n >> k >> s;
    if ( n == 0 ) break;

    cout << dp[n][k][s] << endl;

  }

  return 0;

}

Measured memory_bytes: 1296
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{

    optimize_cin();
    int N, K;
    vector<string> D;
    cin >> N >> K;
    D.resize(K);
    rep (i, K) { cin >> D[i]; }

    for (int i = N; i < 10*N; ++i)
    {
        string ans = to_string(i);
        bool ok = false;
        for (int k = 0; k < SZ(D); ++k)
        {
            if (ans.find(D[k]) == -1) // 見つからなかったら
            {
                ok = true;
            }
            else
            {
                ok =false;
                break;
            }
        }

        if (ok)
        {
            cout << ans;
            break;
        }
    }

end:
    cout << "\n";

    return 0;
}


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

int a[200010];

int main () {

int n;
cin>>n;
for (int i=0; i<n; i++) {
	cin>>a[i];
}
int br=n-1;
while (br>=0) {
	cout<<a[br]<<" ";
	br-=2;
}
if (n%2==0) {br=0;} else {br=1;}
while (br<n) {
	cout<<a[br]<<" ";
	br+=2;
}

return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])
			cout<<"YES";
	else
		cout<<"NO";
	cout<<endl;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
#print(s)
if s[a]!="-":
    print("No")
    #print(1)
elif s.count("-")>1:
    print("No")
    #print(2)
else:
    s=s.replace("-","")
    #print(3)
    #print(s)
    if s.isdigit()==True:
        print("Yes")
    else:
        print("No")

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

int main()
{
  long N;
  scanf("%ld", &N);
  long sum = 0;
  for (long i=1;i<=N;i++) {
     if (i % 5 != 0 && i % 3 != 0) {
        sum += i;
     }
   }
 
  printf("%ld\n", sum);
  fflush(stdout);
  return 0;
}

Measured memory_bytes: 1700
function main(input) {
   input = input.trim();
  const a = input.split("\n");
   const b = a[0].split("");
   const c = a[1].split("");
 
 console.log(b[0]==c[2]&&b[2]==c[0]&&b[1]==c[1]?"YES":"NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29644