akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	scanner := makeScanner(1024)
	n := eGetInt(scanner)
	a := eGetInt(scanner)
	if n%500 <= a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}

func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cctype>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#define LL long long
#define ULL unsigned  long long
#define maxn (LL)1e5
#define INF 0x3f3f3f3f
#define inf 0x7fffffff
#define PI  acos(-1.0)
#define pb push_back
#define re register LL
const double eps = 0.0000001;
using namespace std;
typedef pair<LL,LL> pii;
inline LL sgn(double x)
{
    return (x > eps) - (x < -eps);
}
const LL N=1e6+2;
const LL mod=1e9+7;
int f[2010];
LL mul(LL a,LL b,LL mod)
{
    LL ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main()
{
   int n;
   LL k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
       cin>>f[i];
   int num1=0;
   for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
           if(f[i]>f[j]) num1++;
   int num=0;
   for(int i=1;i<=n;i++)
       for(int j=i+1;j<=n;j++)
       if(f[j]<f[i]) num++;
   cout<<(LL)(mul((LL)num,k,mod)+mul(k*(k-1)/2,(LL)num1,mod))%mod;
}

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    long long ans = 0;
    cin >> n;
    for(int i = 1 ; i < n ; i++) ans += (long long)i;
   	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 1163: Cards
// 2017.9.15 bal4u@uu
// 2018.3.12

#include <stdio.h>
#include <string.h>

#define MAX 1004
short hi[MAX], to[MAX][MAX];
char  seen[MAX];
short match[MAX];

int bipartiteMatching(int m, int n)
{
	int u, max;
	int bpm(int u);

	memset(match, -1, (m+n) << 1);
	max = 0;
	for (u = 0; u < m; u++) {
		if (match[u] < 0) {
			memset(seen, 0, m+n);
			if (bpm(u)) max++;
		}
	}
	return max;
}

int bpm(int u)
{
	int i, v, w;

	seen[u] = 1;
	for (i = 0; i < hi[u]; i++) {
		v = to[u][i], w = match[v];
		if (w < 0 || !seen[w] && bpm(w)) { match[u] = v, match[v] = u; return 1; }
	}
	return 0;
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int gcd(int a, int b)
{
	int r;
if (!((a | b) & 1)) return 2;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int b[501], r[502];

int main()
{
	int i, j, m, n;

	while (m = in()) {
		n = in();
		for (i = 0; i < m; i++) b[i] = in();
		for (j = 0; j < n; j++) r[j] = in();

		memset(hi, 0, (m+n) << 2);
	    for (i = 0; i < m; i++) for (j = 0; j < n; j++) {
			if (gcd(b[i], r[j]) > 1) to[i][hi[i]++] = m + j;
		}			

		printf("%d\n", bipartiteMatching(m, n));
	}
	return 0;
}



Measured memory_bytes: 2660
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    string a;
    cin >> a;
    if (a[1]==a[2]&&a[2]==a[3]) cout << "Yes" << endl;
    else if (a[1]==a[2]&&a[0]==a[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
        return 0;
}



Measured memory_bytes: 256
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Mar 28 21:40:07 2018
//
package main

import (
	"fmt"
)

var X string

func main() {
	fmt.Scan(&X)

	count := 0
	ss := 0
	for i := range X {
		if X[i] == 'S' {
			ss++
		} else {
			if ss > 0 {
				ss--
			} else {
				count++
			}
		}
	}

	ts := 0
	for i := range X {
		if X[len(X)-1-i] == 'T' {
			ts++
		} else {
			if ts > 0 {
				ts--
			} else {
				count++
			}
		}
	}
	fmt.Println(count)
}


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

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

    long long int count = 0;
    vector<int> v_count;
    for(int i = 0; i < s.size(); i++ ){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
            count++;
            if(i == s.size()-1){
                v_count.push_back(count);
            }
        }
        else {
            v_count.push_back(count);
            count = 0;
        }
        
    }

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

    if(v_count.size() == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << v_count[v_count.size()-1] << endl;


}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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() {
	
	int n;
	vector<ll> a;
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll N = a[n-1];

	ll search = (N + 1) / 2;
	ll x = N;
	ll ans = N;
	rep(i, n-1) {
		ll tmp = abs(search - a[i]);
		if (x >= tmp) {
			ans = a[i];
			x = tmp;
		}
	}
	cout << N << " " << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
/*
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
*/
using namespace std;

typedef long long ll;

#define sqr(x) (x)*(x)
#define pb push_back
#define fst first
#define snd second

const ll mod=1000000007;
const int maxn=100005,maxm=505;
const double eps=1e-9;
const double pi=acos(-1.0);

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

ll a,b;

int main()
{
	int i,j,T;
	while(scanf("%lld %lld",&a,&b)!=EOF)
	{
		ll g=gcd(a,b);
		printf("%lld %lld\n",g,a/g*b);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
constexpr uint64_t L1 = 1ull;
constexpr ull bit(int n){ return 1ull << n;}

constexpr ll INF       = 1000000000;/* 1e+9a */

void solve(istream& cin) {
    ll N, K;
    while(cin >> N >> K){
        map<ll, ll> ab;
        for (int i = 0; i < N; ++i) {
            ll a, b;
            cin >> a >> b;
            ab[a] += b;
        }
        ll count = 0;
        auto it = ab.begin();
        while(count < K){
            auto&& b = it->second;
            if(count + b < K) count += b;
            else break;
            it++;
        }
        cout << it->first << endl;
    }
}

int main(int argc, char *argv[]) {
    string FileName("C"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    if(sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size()-ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        solve(cin);
    }
    else {    
	    cerr << sub << endl;
        string inFile = "sample.txt";
        auto fs = fstream(inFile, fstream::in);
        solve(fs);
    }
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

string s, t;

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  string s, t;
  cin >> s >> t;
  cout << (t + s);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

struct W {
    int income, time; string s;
    W(int i, int j, string &s) : income(i), time(j), s(s) {};
};

int main() {
    int n;
    while(cin >> n, n){
        vector<W> v;
        for (int i = 0; i < n; ++i) {
            string l; int p, a, b, c, d, e, f, s, m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            int X = a+b+c, Y = d+e;
            int income = f*s*m-p, time = X+Y*m;
            v.emplace_back(income, time, l);
        }
        sort(v.begin(),v.end(), [](W a, W b){
            int x = a.income*b.time, y = b.income*a.time;
            if(x != y) return x > y;
            else return a.s < b.s;
        });
        for (int i = 0; i < n; ++i) {
            cout << v[i].s << "\n";
        }
        puts("#");
    }

    return 0;
}


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

using namespace std;
string str;
int i, j, n;
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    cin >> str; i = str.size();
    str = '0' + str;
    if (i%2) i--; else i -= 2;
    while (i >= 0) {
        bool ok = 1;
        for (int j = 1; j <= i/2 && ok; j++)
        if (str[j] != str[j+i/2]) ok = 0;
        if (ok) {
            cout << i;
            return 0;
        }
        i -= 2;
    }
    cout << 0;
    return 0;
}
/**/



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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    ans += s[i] - '0';
  }
  if(ans % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


#define int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define mp  make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a; i<=b;i++)
#define F first 
#define S second
#define ccM 1000000007

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int32_t main()
{
	fastio;
    ios::sync_with_stdio(0);
 #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
 #endif
    int n;
   string s;

   cin >> s;

   if(s[2]==s[3] && s[4]==s[5]){

    cout << "Yes" << " ";
   }
   else{
    cout << "No";
}
return 0;
}



Measured memory_bytes: 3576
/* Justin Choi */
#include <bits/stdc++.h>
using namespace std;

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forl(V, N) for(int V = 0; V < N; V++)
#define for1(V, N) for(int V = 1; V <= N; V++)
#define fore(E, X) for(auto &E:X)
#define newl cout << endl
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)

#define graph unordered_map<int, unordered_set<int>>
#define um unordered_map
#define us unordered_set
#define vi vector<int>
#define pi pair<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define ins insert

int main() {
    qio; int n; cin >> n;
    map<string, int> poll; forl(i, n) { string s; cin >> s; poll[s]++; }
    int maxn = 0;
    for(auto it: poll) setmax(maxn, it.second);
    for(auto it: poll) {
        if(it.second == maxn) println(it.first);
    }

}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std ;
int main () {
// input
int N; cin >> N ;
vector <int > V ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> V [ i ];
}
vector <int > C ( N );
for ( int i = 0; i < N ; ++ i ) {
cin >> C [ i ];
}
// compute
int ans = 0;
for ( int i = 0; i < N ; ++ i ) {
if ( V [ i ] > C [ i ]) {
ans += V [ i ] - C [ i ];
}
}
// output
cout << ans << endl ;
}

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
p = sorted(x)
lef = p[n//2 - 1]
rig = p[n//2]
for i in range(n):
    if x[i] <= lef:
        print(rig)
    elif x[i] >= rig:
        print(lef)

Measured memory_bytes: 25224
#include<cstdio>
#include<cstring>
const int MAXN = 1000000;
bool f[MAXN + 5]; char s[MAXN + 5];
bool check(int a, int b) {
	f[a-1] = false, f[a] = true;
	for(int i=a+1;i<=b;i++)
		if( s[i] != '#' ) f[i] = f[i-1] || f[i-2];
		else f[i] = false;
	return f[b];
}
int main() {
	int n, a, b, c, d;
	scanf("%d%d%d%d%d%s", &n, &a, &b, &c, &d, s + 1);
	if( c < d ) {
		if( check(a, c) && check(b, d) )
			puts("Yes");
		else puts("No");
	}
	else {
		if( check(a, c) && check(b, d) ) {
			int p = -1;
			for(int i=b;i<=d;i++)
				if( s[i] == '.' && s[i-1] == '.' && s[i+1] == '.' )
					p = i;
			if( p == -1 ) puts("No");
			else puts("Yes");
		}
		else puts("No");
	}
}// a < b, a < c, b < d, not equal

Measured memory_bytes: 512
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSString *answer = @"No";
        
        int a=0,b=0,c=0;
        for(int i=0;i<3;i++){
            NSString *buf = [s substringWithRange:NSMakeRange(i,1)];
            if ([buf isEqualToString:@"a"]){
                a++;
            }
            else if ([buf isEqualToString:@"b"]){
                b++;
            }
            else{
                c++;
            }
        }
        if (a==1 && b==1 && c==1) {
            answer = @"Yes";
        }
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    
    return 0;
}


Measured memory_bytes: 2404
n = int(input())
s = input()
a = [0] * n
if s[0] == 'W': a[0] = 1
for i in range(1, n):
    c = s[i]
    if c == 'E':
        a[i] = a[i - 1]
    else:
        a[i] = a[i - 1] + 1
b = [0] * n
if s[n - 1] == 'E': b[n - 1] = 1
for i in range(n - 2, -1, -1):
    c = s[i]
    if c == 'W':
        b[i] = b[i + 1]
    else:
        b[i] = b[i + 1] + 1
m = n
for i in range(n):
    m = min(m, a[i] + b[i])
print(m - 1)


Measured memory_bytes: 17916
let xs = stdin.ReadLine().ToCharArray()
let mutable i = 0
let mutable cnt = 0
let mutable cash = ""
while i < xs.Length do
    cnt <- cnt + 1
    if cash = string xs.[i] then
        if i = xs.Length - 4 && System.String.Concat [xs.[i];xs.[i+1]] = System.String.Concat [xs.[i+2];xs.[i+3]] then
            cash <- ""
            i <- i + 3
        else
            cash <- ""
            i <- i + 2        
    else
        if i = xs.Length - 2 && xs.[i] = xs.[i+1] then
            cnt <- cnt - 1
        cash <- string xs.[i]
        i <- i + 1
printfn "%d" cnt

Measured memory_bytes: 19284
import java.util.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
         
        long A = sc.nextLong();
      
      	double B = sc.nextDouble();
      		
      	BigDecimal bd_A = new BigDecimal(A);
      	BigDecimal bd_B = new BigDecimal(String.valueOf(B));
	
      	BigDecimal bd_C = bd_A.multiply(bd_B);
       
      	long l = bd_C.longValue();

      	System.out.println(l);
      

    }
}

Measured memory_bytes: 37636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ll D;
    cin >> D;
    vl c(26);
    rep(i,26){
        cin >> c[i];
    }
    ll s[D][26];
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    vl latest_t(26,0);
    ll k=0;
    FOR(i,1,D+1){
        vl nt=latest_t;
        ll nk=k;
        ll MX=-INF;
        ll ans;
        rep(j,26){
            nk=k;
            nk+=s[-1+i][j];
            nt[j]=i;
            rep(l,26){
                nk-=c[l]*(i-nt[l]);
            }
            if(nk>MX){
                MX=nk;
                ans=j;
            }
            if(j==25){
                k=MX;
            }
        }
        cout << ans+1 << endl;
        latest_t[ans]=i;
        //cout << k << endl;
    }
}

Measured memory_bytes: 3708
// Sorted Arrays
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main () {
    int N;
    cin >> N;
    vector<long int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    if (N == 1) {cout << 1 << endl; return 0;}

    bool up = A[0] < A[1];
    int count = 1;
    vector<bool> x;
    for (int i = 0; i < N-1; i++) {
        if (A[i] == A[i+1]) continue;
        x.push_back(A[i] < A[i+1]);
    }
    for (int i = 0; i < x.size()-1; i++) {
        if (x[i] != x[i+1]) {
            i++;
            count++;
        }
    }
    cout << count << endl;
}


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

int main() {
    string s;
    int cnt=0;
    cin>>s;
    for (int i = 0; i < 4; ++i) {
        for (int j = i+1; j < 4; ++j) {
            if(s[i]==s[j])cnt++;
        }
    }
    cout<<(cnt==2?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
# B
N, M, X, Y = map(int, input().split())
lst_x =  list(map(int, input().split()))
lst_y =  list(map(int, input().split()))

ans = 'War'
for i in range(X+1, Y+1):
    if (max(lst_x) < i and min(lst_y) >= i):
        ans = 'No War'
print(ans)

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

int main(){
  int sx, sy, tx, ty;
  int tate, yoko;

  cin >> sx >> sy >> tx >> ty;

  tate = ty-sy; yoko = tx-sx;

  string s1(tate,'U');
  string s2(yoko,'R');
  string s3(tate,'D');
  string s4(yoko,'L');

  cout << s1+s2+s3+s4 << "LU" << s1+s2 << "RDRD" << s3+s4 << "LU" << endl;

								     return 0;
}
  


Measured memory_bytes: 256
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
 
 
N = int(input())
A = list(map(int,input().split()))
ans = gcd_list(A)
print(ans)

Measured memory_bytes: 16304
n = int(input())
l = list(map(int,input().split()))
l.sort()


ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        sum=l[i]+l[j]
        left=j
        right=n-1
        mid=(left+right)//2
        while right-left>1:
            if l[mid]>=sum:
                right = mid
            else:
                left = mid
            mid = (left+right)//2
        if l[mid+1]<sum:
            mid+=1
        ans+=mid-j
print(ans)


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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int k=0;
        while(a>0 && c>0){
            if(k%2==0){
                c-=b;
                k++;
            }
            else{
                a-=d;
                k++;
            }
        }
        if(a<=0)
            cout<<"No";
        else
            cout<<"Yes";
        return 0;
    }


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <list>
#include <sstream>
#include <numeric>

#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;

const ld PI = acosl(-1.0);
const ll mod = 1000000007;
const ll inf = 9223372036854775803;
const int maxN = 6;//1000000;

int main() {
    cout.precision(10);
    cout << fixed;
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;             // 0     1      2      3      4      5      6      7      8      9
    vector<string> arr = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
    cout << arr[s.back()-'0'];
    return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }

int cnt[1000000];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		
		for (ll i = 1; i <= 400; i++) {
			for (ll j = 1; j <= 400; j++) {
				for (ll k = 1; k <= 400; k++) {
					cnt[i*i + j*j + k*k + i*j + j*k + i*k]++;
				}
			}
		}
		int n;
		cin >> n;
		lop(i, n) cout << cnt[i + 1] << endl;
	}


	return 0;
}


Measured memory_bytes: 7332
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;

int read()
{
	int a = 0,x = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0'){
		if(ch == '-') x = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a*x;
}
const int N=2e5+7,P=998244353;

int n,k;
int l[11],r[11];
ll f[N],s[N];

ll query(int x)
{
	ll ret = 0;
	for(int i = x;i >= 1;i -= i&-i) {
		(ret += s[i])%P;
	}
	return ret;
}

ll as(int a)
{
	if(a < 1) return 0;
	else return query(a)%P;
}

ll find(int a,int b)
{
	return ((as(b)%P-as(a)%P)%P+P)%P;
}

void add(int u,ll x)
{
	for(int i = u ;i <= n;i += i&-i) (s[i] += x) %= P;
}

int main()
{
	n = read(),k = read();
	for(int i = 1;i <= k;i ++) l[i] =read(),r[i] = read();
	add(1,1);
	for(int i = 2;i <= n;i ++) {
		for(int j = 1;j <= k;j ++){
			(f[i] += find(i-r[j]-1,i-l[j])%P) %= P;
		}
	//	printf("%lld \n",f[i]%P);
		add(i,f[i]%P);
	}
	printf("%lld",f[n]);
	return 0;
}

Measured memory_bytes: 4724
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int   
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

int const mod = 1e9+7;
// int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = (res*a)%m;
            res %= m;
        }
        a=(a*a)%m;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x,int m){
    return power(x,m-2,m);
}

int const N = 2e6+55;
int const inf = 1e18;
ld pi = 3.14159265359;


int fact[N];
int ifact[N];

void precompute_factorials(){
    fact[0] = 1;
    for(int i=1;i<N;i++) {
        fact[i] = i*fact[i-1]; fact[i] %= mod;
    }
    ifact[N-1] = inverse(fact[N-1] , mod);
    for(int i=N-2;i>=0;i--){
        ifact[i] = (i+1)*ifact[i+1];
        ifact[i] %= mod;
    }
}

int ncr(int n,int r){
    if(n < r || r < 0) return 0;
    if(n == r) return 1;

    int res = fact[n];
    res *= ifact[r];
    res %= mod;
    res *= ifact[n-r];
    res %= mod;
    return res; 
}

void solve(){   
    int i,j,l;
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();

    int ans = 0;

    for(i=n;i<=n+k;i++){
        int rem = n+k-i;
        int tmp = power(26LL , rem , mod);
        tmp = tmp * power(25LL , i-n , mod);
        tmp %= mod;
        tmp = tmp * ncr(i-1,n-1);
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }

    cout<<ans<<endl;
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    precompute_factorials();
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){   
        // cout << "Case #"<<tt<<": ";
        solve();
    }
    return 0;
}


/*


*/

Measured memory_bytes: 35496
#include <algorithm>
#include <iostream>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

const int INF = INT_MAX / 2;

struct Discount {
    int x;
    int y;
    int c;
};

vector<int> as;
vector<int> bs;
vector<struct Discount> ms;

int main(void) {
    int A, B, M;
    cin >> A >> B >> M;

    int min_a = INF;
    as.resize(A);
    for (int i = 0; i < A; i++) {
        cin >> as[i];
        chmin(min_a, as[i]);
    }

    int min_b = INF;
    bs.resize(B);
    for (int i = 0; i < B; i++) {
        cin >> bs[i];
        chmin(min_b, bs[i]);
    }

    ms.resize(M);
    for (int i = 0; i < M; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ms[i] = {x, y, c};
    }

    int cand = min_a + min_b;
    for (int i = 0; i < M; i++) {
        chmin(cand, as[ms[i].x] + bs[ms[i].y] - ms[i].c);
    }

    cout << cand << endl;

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  string n;
  int count = 0;
  cin >> n;
  for (int i=0; i<n.size(); i++) {
    count += (int)(n[i]-'0');
    count %= 9;
  }
  if (count) printf("No\n");
  else printf("Yes\n");
}

Measured memory_bytes: 3372
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 100000
#define MAXL 100
typedef long long int lli;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = ((a + b) % 2 == 0)? (a + b) / 2 : (a + b) / 2 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int main() {
	int A, B, C;
	LL K;
	scanf("%d%d%d", &A, &B, &C);
	scanf("%lld", &K);
	if(K & 1) {
		printf("%d\n", B - A);
	}
	else printf("%d\n", A - B);
}

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

typedef long long ll;

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

	list<int> b;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			b.push_front(a[i]);
		}
		else {
			b.push_back(a[i]);
		}
	}

	if (N % 2 == 0) {
		reverse(b.begin(), b.end());
		for (auto itr = b.begin(); itr != b.end(); itr++) {
			cout << *itr <<" ";
		}
		cout << endl;
	}
	else {
		for (auto itr = b.begin(); itr != b.end(); itr++) {
			cout << *itr << " ";
		}
		cout << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ans = 0, mx = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] >= a[i + 1])
      ++ans;
    else
      ans = 0;
    mx = max(mx, ans);
  }
  cout << mx;

  return 0;
}



Measured memory_bytes: 4036
def main():
    n = int(input())
    s = input()

    wcount = s.count("W")
    rcount = s.count("R")

    ans = 0

    for i in range(rcount):
        if s[i] == "W":
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65080
MOD = 10 ** 9 + 7
k = input()
d = int(input())
dp = [0] * d
now = 0
for i in map(int, k):
    ndp = [0] * d
    for t in range(i):
        ndp[(now+t) % d] = (ndp[(now+t) % d] + 1) % MOD
    for j in range(d):
        for t in range(10):
            ndp[(j+t) % d] = (ndp[(j+t) % d] + dp[j]) % MOD
    now = (now + i) % d
    dp = ndp
print((dp[0] - 1 + (now == 0)) % MOD)

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

int main() {
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    t[0] = x[0] = y[0] = 0;
    for(int i = 1; i <= n;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    
    for(int i = 0; i < n; i++){
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        int distT = t[i+1] - t[i];
        if ((distT < dist) || (distT%2 != dist%2)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main()
{
	string charcters;

	int m;

	int h;

	while (1)
	{
		cin >> charcters;

		if (charcters == "-")break;

		cin >> m;

		for (int i = 0; i < m; i++)
		{
			cin >> h;

			string Char = charcters.substr(0, h);

			charcters += Char;

			charcters.erase(charcters.begin(), charcters.begin() + h);

		}

		cout << charcters << endl;

	}

	return 0;
}

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

int n, x[200000];
bool out;

struct S{
	pair<int, int> a, b;
	S(){}
	S(int x, int y, int z, int w):a(x, y), b(z, w) {}
	S operator +(S o){
		S an;
		an.a = min(a, o.a);
		an.b = min(b, o.b);
		return an;
	}
}s[800000];

void bld(int l = 0, int r = n, int id = 1){
	if (l + 1 == r) { s[id] = S(1e6, l, 1e6, l); if (l & 1)s[id].b.first = x[l]; else s[id].a.first = x[l]; return; }
	int m = l + r >> 1, a = id << 1, b = a | 1;
	bld(l, m, a);
	bld(m, r, b);
	s[id] = s[a] + s[b];
}

S gt(int x, int y, int l = 0, int r = n, int id = 1){
	if (l >= y || r <= x)return S(1e6, 1e6, 1e6, 1e6);
	if (l >= x && r <= y)return s[id];
	int m = l + r >> 1, a = id << 1, b = a | 1;
	return gt(x, y, l, m, a) + gt(x, y, m, r, b);
}

S gtint(int l, int r){
	S an, t = gt(l, r);
	if (l & 1)an.a = t.b; else an.a = t.a;
	t = gt(an.a.second, r);
	if (l & 1)an.b = t.a; else an.b = t.b;
	return an;
}

void go(){
	priority_queue<pair<int, pair<int, int> > > q;
	q.push(make_pair(0, make_pair(0, n)));
	while (!q.empty()){
		int l = q.top().second.first, r = q.top().second.second;
		q.pop();
		S z = gtint(l, r);
		if (out)printf(" ");
		out = true;
		printf("%d %d", z.a.first, z.b.first);
		if (l !=  z.a.second)q.push(make_pair(-gtint(l, z.a.second).a.first, make_pair(l, z.a.second)));
		if (z.a.second + 1 != z.b.second)q.push(make_pair(-gtint(z.a.second + 1, z.b.second).a.first, make_pair(z.a.second + 1, z.b.second)));
		if (z.b.second + 1 != r)q.push(make_pair(-gtint(z.b.second + 1, r).a.first, make_pair(z.b.second + 1, r)));
	}
}

int main(){
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	bld();
	go();
	printf("\n");
}

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

using namespace std;
typedef long long LL;

int main()
{
	int N;
	cin >> N;
	vector<int> v(N);
	map<int,int> c;
	for (int i = 0; i < N; i++) {
		scanf("%d", &v[i]);
		c[v[i]]++;
	}
	int m1 = -1, m2 = -1;
	for (auto z : c) {
		int len = z.first, cnt = z.second;
		if (cnt < 2) continue;
		if (cnt < 4) {
			if (len >= m2) {
				m1 = m2;
				m2 = len;
			}
			else if (len >= m1) {
				m1 = len;
			}
		}
		else {
			if (len >= m2) {
				m1 = len;
				m2 = len;
			}
			else if (len > m1) {
				m1 = len;
			}
		}
	}
	if (m1 == -1 || m2 == -1) {
		cout << 0 << endl;
	}
	else {
		LL area = LL(m1)*LL(m2);
		cout << area << endl;
	}
	exit(0);
}



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

if __name__ == '__main__':
  n=int(input())
  S=list(map(int,input().strip("\n").split()))
  q=int(input())
  T=set(map(int,input().strip("\n").split()))

  def binarySearch(x):
    left=0
    right=n
    while left<right:
      if right-left==1:
        if S[left]==x:
          return True
        else:
          return False
      
      p=(right-left)//2
      if S[left+p]==x:
        return True
      elif x<S[left+p]:
        right=left+p
      else:
        left=left+p+1
    return False
#  def binarySearch(x,s,e):
    #print(x,s,e)
#    if s>e or e<s:
#      return False
#    elif e-s==1:
#      if S[s]==x:
#        return True
#      else:
#        return False

#    p=(e-s)//2
#    if S[s+p]==x:
#      return True
#    elif x<S[s+p]:
#      return binarySearch(x,s,s+p)
#    else:
#      return binarySearch(x,s+p+1,e)

  ans=0
  for t in T:
    #print('start:',t)
    if binarySearch(t)==True:
      ans+=1
  print(ans)



Measured memory_bytes: 17140
n = gets.chomp.to_i
char = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ans = []
while(true)
    n = n - 1
    shou = n/26
    amari = n%26
    ans.push(char[amari])
    n = shou 
    if n == 0
        break
    end
end

ans.reverse!
ans.each do |moji|
    print moji
end

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


//I love math.

int	main(void)
{
	int l, r, d;
	scanf("%d %d %d", &l, &r, &d);
	int i = l;
	int cnt = 0;
	while (i <= r)
	{
		if (i%d == 0)
			cnt++;
		i++;
	}
	printf("%d\n", cnt);
}


Measured memory_bytes: 1736
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    char[] c=s.toCharArray();
    if(c[c.length-1]=='s'){
      System.out.println(s+"es");
    }else{
      System.out.println(s+"s");
    }
  }
}


Measured memory_bytes: 38480
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll>> v;
	if(m % 2){
		ll val = m / 2;
		ll diff = m - 2;
		REP(i,1,m/2 + 1){
			v.push_back({i,i + diff + 1});
			diff -= 2;
		}
		diff = m - 1;
		REP(i,1,m - m/2 + 1){
			v.push_back({m+i,m+i+diff+1});
			diff -= 2;
		}
	}
	else {
		ll val = m / 2;
		ll diff = m - 1;
		REP(i,1,m/2 + 1){
			v.push_back({i,i + diff + 1});
			diff -= 2;
		}
		diff = m - 2;
		REP(i,1,m - m/2 + 1){
			v.push_back({m+i+1,m+i+diff+1+1});
			diff -= 2;
		}
	}
	for(auto it:v){
		cout<<it.first<<" "<<it.second<<endl;
	}
	return 0;
}  


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N;
list<int> edge [100001];

int bfs(int v)
{
	queue< pair<int,int> > q;
	q.push(make_pair(v,0));

	int res = 0;
	while(q.empty() == false){
		int curr = q.front().first;
		int dist = q.front().second;
		q.pop();

		if(dist == 2 && curr == v){
			res++;
		}
		if(dist >= 2) continue;
		for(auto&& it : edge [curr]){
			q.push(make_pair(it,dist + 1));
		}
	}

	return res;
}

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

	cin >> N;
	FOR(i,1,N + 1){
		int A;
		cin >> A;
		edge [i].push_back(A);
	}

	int ans = 0;
	FOR(i,1,N + 1){
		ans += bfs(i);
	}
	ans /= 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int cnt[200];
main()
{
    int a,b;
    while(cin>>a>>b)
    {
        for(int i=1;i<=100;i++)cnt[i]=0;
        cnt[a]++,cnt[b]++;
        while(cin>>a>>b,a)cnt[a]++,cnt[b]++;
        int c=0;
        for(int i=3;i<=100;i++)
        {
            c+=cnt[i]%2;
        }
        cout<<(c==0&&cnt[1]%2==1&&cnt[2]%2==1?"OK":"NG")<<endl;
    }
}


Measured memory_bytes: 3008
#include <stdio.h>

int main(){

    char s[10];
    int i,cnt,max=0;
    scanf("%s",&s);

    for(i=0;i<10;i++){
        if((s[i] == 'A')||(s[i] == 'T')||(s[i] == 'C')||(s[i] == 'G')){
            cnt++;
            if(cnt > max){
                max = cnt;
            }
        } else {
            cnt = 0;
        }
    }
    
    printf("%d",max);

    return 0;

}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
ll inf = 1e18;


ll N, M;
int main() {
	while (cin >> N >> M && N > 0) {
		ll sum_max[10101] = {};
		ll sum_min[10101] = {};
		ll S[1010] = {};
		vector<ll> C[1010];
		REP(i,0,M){
			ll k;
			cin >> S[i] >> k;
			REP(j,0,k){
				ll c;
				cin >> c;
				C[i].push_back(c-1);
			}
		}
		REP(i,0,M){
			if(C[i].size() == 1){
				sum_max[C[i][0]] += S[i];
				sum_min[C[i][0]] += S[i];
			}else{
				REP(j,0,C[i].size()){
					sum_max[C[i][j]] += S[i];
				}
			};
		}
		ll ans = 0;
		REP(i,0,N){
			REP(j,0,N){
				if(i==j) continue;
				ans = max(ans, sum_max[i] - sum_min[j]+1);
			}

		}
		p(ans);
	}

	return 0;
}


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

long long solve(int i,int j,long long a[])
{
    if(i==j) return a[i];
    if(dp[i][j]!=LLONG_MAX) return dp[i][j];
    long long ans;
    ans=max(a[i]-solve(i+1,j,a),a[j]-solve(i,j-1,a));
    dp[i][j]=ans;
    return ans;
}

int main()
{
    long long n;
    cin>>n;
    long long a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            dp[i][j]=LLONG_MAX;
    cout<<solve(0,n-1,a)<<endl;
    return 0;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <algorithm>
int n, a[55];
bool check(){
	for (register int i = 2; i <= n; ++i)
		if (a[i] < a[i - 1]) return 0;
	return 1;
}
int main(){
	scanf("%d", &n);
	for (register int i = 1; i <= n; ++i) scanf("%d", a + i);
	if (check()) return printf("YES\n"), 0;
	for (register int i = 1; i <= n; ++i)
		for (register int j = i + 1; j <= n; ++j){
			std :: swap(a[i], a[j]);
			if (check()) return printf("YES\n"), 0;
			std :: swap(a[i], a[j]);
		}
	printf("NO\n");
}

Measured memory_bytes: 128
#include <assert.h>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const int INF = 100000000;
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod) {
  if (y == 0) return 1;
  if (y % 2) {
    return (x * pow_mod(x, y - 1, mod)) % mod;
  } else {
    return pow_mod(x * x, y / 2, mod);
  }
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,ans=0;
  std::cin >> n;
  std::vector<ll> a(n + 1), b(n);
  rep(i, 0, n + 1) std::cin >> a[i];
  rep(i, 0, n) std::cin >> b[i];
  rep(i,0,n){
    if(a[i]>=b[i]){
      ans += b[i];
    }else if(a[i]+a[i+1]>=b[i]){
      a[i + 1] -= (b[i] - a[i]);
      ans += b[i];
    }else{
      ans += (a[i] + a[i + 1]);
      a[i + 1] = 0;
    }
  }
  std::cout << ans;
  return 0;
}

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

#define endl '\n'

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

    long long a, b;
    cin >> a >> b;
    long long res = 0;
    while(a <= b) {
        res++;
        a *= 2;
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100008
ll expo(ll base, ll exponent, ll mod) {                                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}


int main()
{
    
    io    
    ll n,k;
    cin>>n>>k;
    ll res=0;
    ll tc=0;    
    ll arr[N];
    for(ll i=k;i>=1;i--)
    {                    
        ll cnt=0;
        ll curr=0;
        arr[i]=expo(k/i,n,hell);
        for(ll j=2*i;j<=k;j+=i)
        {
            arr[i]=(arr[i]-arr[j]+hell)%hell;

        }
        // cout<<cnt<<endl;    
        cnt=arr[i];
        cnt=(cnt*i)%hell;        
        res=(res+cnt)%hell;
    }    
    cout<<res;

}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int n,a=0,m;
    string s;
    cin>>n>>m>>s;
    for(int i=0;i<SZ(s);i++)
    {
        if(s[i]=='-')
        {
            a++;
        }
    }
    if(a==1&&(s[n]=='-'))
    {
        cout<<"Yes"<<NL;
        return 0;
    }
    cout<<"No"<<NL;
    return 0;
}


Measured memory_bytes: 256