akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
	
	public Main() {
		FastScanner scanner = new FastScanner();
		PrintWriter PW = new PrintWriter(System.out);
		
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		HashSet<Integer> D = new HashSet<>();
		int a = 1, b = N;
		for (int i = 1; i <= M; i++) {
			PW.print(a);
			PW.print(" ");
			PW.println(b);
			
			D.add( Math.abs(a-b) );
			D.add( Math.abs(N+a-b) );
			
			a += 1;
			b -= 1;
			
			if ( Math.abs(a-b) == Math.abs(N+a-b)
				|| D.contains(Math.abs(a-b))
				|| D.contains(Math.abs(N+a-b))){
				
				b -= 1;
			}
			
		}
		
		PW.flush();
		PW.close();
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 58400
def solve(n):
    mod = 10 ** 9 + 7
    return (pow(10, n, mod) - 2 * pow(9, n, mod) + pow(8, n, mod)) % mod


def main():
    n = int(input())
    res = solve(n)
    print(res)


def test():
    assert solve(2) == 2
    assert solve(1) == 0
    assert solve(869121) == 2511445


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9176
# ABC123 C - Five Transportations
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
min_num = 10**16
ans = 5
n = 0
for i in range(6):
    t = int(input())
    if i==0:
        n = t
    min_num = min(min_num,t)

if n==min_num:
    print(ans)
    exit()

a = n%min_num
if a == 0:
    ans += (n//min_num)-1
else:
    ans += (n//min_num)

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin >> N;
    
    vector<ll> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    sort(A.begin(), A.end());

    auto neg_begin = A.begin();
    auto neg_end = A.begin();
    while(*(neg_end) < 0 && neg_end != A.end())
        neg_end++;
    auto pos_begin = neg_end;
    auto pos_end = A.end();

    vector<ll>::iterator a, b;
    if(neg_begin==neg_end) {
        a = pos_begin;
        b = pos_end-1;
    } else if(pos_begin==pos_end) {
        a = neg_begin;
        b = neg_end-1;
    } else {
        a = neg_begin;
        b = pos_end-1; 
    }

    vector<pair<ll,ll>> log;
    ll x = *a;
    for(auto i=pos_begin; i!=pos_end; i++){
        if(i==a || i==b)
            continue;
        log.push_back(make_pair(x, *i));
        x = x - *i;
    }
    log.push_back(make_pair(*b, x));
    x = *b - x;

    for(auto i=neg_begin; i!=neg_end; i++) {
        if(i==a || i==b)
            continue;
        log.push_back(make_pair(x, *i));
        x = x - *i;
    }

    cout << x << endl;
    for(auto& l : log)
        cout << l.first << ' ' << l.second << endl;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    REP(i,N){
        int p = i + 1;
        double res = 1;
        while(p < K){
            res /= 2;
            p *= 2;
        }
        ans += res;
    }
    ans /= N;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("#");
			}
			printf("\n");
			if(i==H){
				printf("\n");
			}
		}
	}
	
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int n;
    cin >> n;

    string s;
    cin >> s;

    string f = s.substr(0, n / 2);
    string sec = s.substr(n / 2, n - n / 2);

    //cout << f << " " << sec << endl;

    if(f == sec) cout << "Yes";
    else cout << "No";

}









Measured memory_bytes: 256
A, B = map(int ,raw_input().split())
  
result = 0
for i in range(A,B+1):
    r = str(i)
    flg = True
    for j in range(int(len(r)/2)):
        if r[j] != r[len(r) - j - 1]:
            flg = False
    if flg:
        result += 1

print(result)

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a % b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    int i, j, k, n, m, t, x=0, y=0, s=0, c=0, l=0, h;
    cin >> x >> y;
    cout << x*y << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){
   
    int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	rep(i,n-1){
		if(s[i] != s[i+1])ans++;
	}
	cout << ans << endl;
	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc143.contest.atcoder.jp/tasks/abc143_a

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int n;
int ans = 0;

void rec(int cur, int digit, int x, int y, int z) {
  if (digit == 0) {
    if (cur <= n and cur >= 1 and x>0 and y>0 and z>0) ++ans;
    return;
  }
  int base = 1;
  rep(j, digit-1) base *= 10;
  if (cur == 0) rec(cur, digit-1, x, y, z);
  rec(cur+7*base, digit-1, x+1, y, z);
  rec(cur+5*base, digit-1, x, y+1, z);
  rec(cur+3*base, digit-1, x, y, z+1);
}

int main() {
  cin>>n;
  int digit = 0;
  for (int m = n; m != 0; m /= 10) ++digit;
  rec(0, digit, 0, 0, 0);
  print(ans);

  return 0;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
c=Counter(A)
Q=int(input())
for i in range(Q):
    B,C=map(int, input().split())
    if B in c:
        ans+=(C-B)*c[B]
        print(ans)
        if c[C] !=0:
            c[C]=c[C]+c[B]
        else:
            c[C]=c[B]
        del c[B]
    else:
        print(ans)

Measured memory_bytes: 21440
import java.util.*;
public class Main{

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		n %= 10;
		if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
			System.out.print("hon");
		}else if (n == 3){
			System.out.print("bon");
		}else{
			System.out.print("pon");
		}
	}
}



Measured memory_bytes: 35632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))


#define NUM_MAX 100000

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

int main(void) {
    static char str[NUM_MAX];
    get_str(str, NUM_MAX);
    int len = strlen(str);

    int i;
    int point = 0;
    int pa = 0;
    for(i = 1; i < len; i++) {
        char cur = str[i];
        int gu = i-pa;
        if(cur == 'g') {
            if(gu > pa) {
                pa++; point++;
            }
        } else {
            if(gu <= pa) {
                // AtCodeer takes gu only
                point--;
            } else {
                // aiko
                pa++;
            }
        }
#ifdef DEBUG
        printf("round #%d -> %d %d\n", i+1, pa, point);
#endif
    }
    printf("%d\n", point);
    return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    s = input()

    if len(s) % 2 == 1:
        print('No')
        exit()

    if s == 'hi':
        print('Yes')
        exit()
    if s == 'hihi':
        print('Yes')
        exit()
    if s == 'hihihi':
        print('Yes')
        exit()
    if s == 'hihihihi':
        print('Yes')
        exit()
    if s == 'hihihihihi':
        print('Yes')
        exit()

    print('No')


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

int main()
{
    ll N = 0;cin >> N;
    ll arr[N];
    for(ll i = 0;i < N; i++) cin >> arr[i];
    
    ll ans1 = 0;
    for(ll i = 0;i < N;i++)
       ans1 = (ans1^arr[i]);
       
      for(ll i = 0;i < N;i++)
      {
          cout << (ans1^arr[i]) <<" ";
      }
    
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int cnt;
  for (int i = A; i <= B; i++) {
    if (i / 10000 == i % 10 ) {
      if ((i / 1000) % 10 == (i / 10) % 10) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
A=input()
LA=A.split()
K=int(LA[0])
N=int(LA[1])

B=input()
LB=B.split()

C=0
samax=0
start=0

for n in LB:
  sa=int(int(n)-int(C))
  C=n
  if samax < sa:
    samax=sa
    start=int(n)-int(samax)
    goal=int(n)
ans1=int(LB[N-1])-int(LB[0])
ans2=int((K-goal)+int(start))

if ans2 > ans1:
  ans=ans1
else :
  ans=ans2
print(ans)

Measured memory_bytes: 19032
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	int n, x, t, ans, xx;
	cin >> n >> x >> t;
	ans = (n + x - 1) / x * t;
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3192
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int n, k;

int main(){
	scanf("%d%d", &n, &k);
	printf("%d\n", (k != 1) ? (n - k) : 0);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

bool isok(ll num) {
    int c3 = 0, c5 = 0, c7 = 0;
    while (num > 0) {
        ll mod = num % 10;
        switch(mod) {
            case 3:
                c3++;
                break;
            case 5:
                c5++;
                break;
            case 7:
                c7++;
                break;
            default:
                return false;
        }
        num /= 10;
    }
    return (c3 && c7 && c5);
}

int main()
{
    ll n; cin >> n;
    ll count = 0;
    vector<ll> nums{3, 5, 7};
    queue<ll> q;
    for (auto elem : nums) {
        q.push(elem);
    }

    set<ll> cands;

    while (!q.empty()) {
        ll num = q.front();
        q.pop();
        if (num <= n) {
            if (isok(num)) cands.insert(num);
            q.push(num * 10 + 3);
            q.push(num * 10 + 5);
            q.push(num * 10 + 7);
        }
    }
    cout << cands.size() << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
long long d=1e9+7;
int main()
{
	long long a,res=1,res1=1,res2=1;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		res=(res*10)%d;
		res1=(res1*9)%d;
		res2=(res2*8)%d;
	
	}
//	cout<<res<<" "<<res1<<" "<<res2<<endl;
	res=res-res1-res1+res2;
	while(res<0)
		res+=d;
	res=res%d;
	cout<<res;
	return 0;
}

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

int main() {
	int N;

	cin >> N;

	int ans = 0;
	while( N > 0 ) {
		if( N % 10 == 2 ) {
			ans++;
		}
		N /= 10;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
def main():
    N,M = map(int,input().split())
    P = defaultdict(list)
    for i in range(M):
        p,y = map(int,input().split())
        P[p].append([y,i])
    for t in P.keys():
        P[t].sort()
    ans = ['' for _ in range(M)]
    for v in P.items():
        pre = str(v[0])
        l = len(pre)
        while l < 6:
            pre = '0'+pre
            l += 1
        lis = v[1]
        for i,u in enumerate(lis):
            num = str(i+1)
            q = len(num)
            while q < 6:
                num = '0'+num
                q += 1
            ans[u[1]] = pre+num
    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

ll big = 1000000007ll;
ll big2 = 1000000009ll;
int n,m,q,T,k;

vector<vector<ll> > C(100001 , vector<ll>());
vector<ll> deg;
vector<ll> col;
vector<ll> mind;

vector<ll> A;
vector<ll> D;
vector<ll> C2;

void bfs(ll i){

ll a = A[i];
ll d = D[i];
ll c = C2[i];

queue<pair<ll,ll> > Q;
Q.push({a,0});

while(!Q.empty()){

    pair<ll,ll> P = Q.front();
    Q.pop();
    a = P.first;
    ll d2 = P.second;
    mind[a] = max(mind[a],d-d2);
    if(col[a] == 0){
        col[a] = c;
    }

    if(d2 < d){
        for(ll c1 = 0; c1 < deg[a]; c1++){
            ll b = C[a][c1];
            if(mind[b] < d-d2-1){
                mind[b] = max(mind[b],d-d2-1);
                Q.push({b,d2+1});
            }
        }
    }
}



}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c;

    cin >> n >> m;

    for(ll c1 = 0; c1 < n; c1++){
        deg.push_back(0);
        col.push_back(0);
        mind.push_back(-1);
    }
    for(ll c1 = 0; c1 < m; c1++){
        cin >> a >> b;
        a--;
        b--;
        deg[a]++;
        deg[b]++;
        C[a].push_back(b);
        C[b].push_back(a);
    }
    cin >> q;

    for(ll c1 = 0; c1 < q; c1++){
        cin >> a >> b >> c;
        a--;
        A.push_back(a);
        D.push_back(b);
        C2.push_back(c);
    }
    for(ll c1 = 0; c1 < q; c1++){
        ll c2 = q-c1-1;
        bfs(c2);
    }

    for(ll c1 = 0; c1 < n; c1++){
        cout << col[c1] << "\n";
    }

    return 0;
}


Measured memory_bytes: 12896
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int i=a;i<b;i++)

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n+1];
    int cnt=0;
    double ans=0;
    int sum=0,max=0;
    int l=0,r=k-1;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(cnt<k)
        {
            sum+=a[i];
            cnt++;
            max=sum;
        }
        else{
            sum+=a[i];
            sum-=a[i-k];
            if(sum>max)
            {
                max=sum;
                l=i-k+1;
                r=i;
                /*for(int i=0;i<k;i++)
                {
                    int s=(a[i-k+1]*(a[i-k+1]+1))/2;
                    ans+=((double)s)/a[i-k+1];
                }*/
            }
        }

    }
    //cout<<"l="<<l<<" r="<<r<<endl;
    for(int i=l;i<=r;i++)
    {
        int s=(a[i]*(a[i]+1))/2;
        ans+=((double)s)/a[i];
        //cout<<ans<<" ";
    }
    //printf("%0.12lf\n",ans);
    cout<<setprecision(12)<<ans<<endl;

    return 0;
}



Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = II()
    P = LI()

    cnt = 0
    for i, p in enumerate(P):
        if (i+1) != p:
            cnt += 1
    if cnt <= 2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int N,K;
string S;

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

    bool s1Left=S[0]=='L'?1:0;
    bool snRight=S[N-1]=='R'?1:0;

    char t=S[0];
    int rl=0;
    int ans=0;
    for(int i=1;i<N;i++){
        if(t==S[i]){
            ans++;
        }else if(t=='R' && S[i]=='L'){
            rl++;
        }
        t=S[i];
    }

    ans+=2*min(rl,K);
    if(K>rl){
        if(s1Left && snRight){
            ans=min(ans+1,N-1);
        }else{
            ans=min(ans+2,N-1);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

int main(){
    long n, q;
    std::string s;
    std::set<long> pos[26];
    scanf("%ld", &n);
    std::cin >> s;
    scanf("%ld", &q);
    for(int i = 0; i < n; i++){
        pos[s[i] - 'a'].insert(i);
    }
    for(int i = 0; i < q; i++){
        long x;
        scanf("%ld", &x);
        if(x == 1){
            long ind;
            char c;
            scanf("%ld %c", &ind, &c);
            ind--;
            //printf("%ld %c\n", ind, c);
            pos[s[ind]-'a'].erase(pos[s[ind]-'a'].find(ind));
            s[ind] = c;
            pos[c-'a'].insert(ind);
            /*
            for(char c = 'a'; c <= 'z'; c++){
                printf("  %c : (", c);
                for(auto it = pos[c-'a'].begin(); it != pos[c-'a'].end(); it++){
                    printf("%ld ", *it);
                }
                printf(")\n");
            }
            //*/
        }else{
            long l, r;
            scanf("%ld%ld", &l, &r);
            l--;
            r--;
            long ans = 0;
            for(int j = 0; j < 26; j++){
                if(pos[j].lower_bound(l) != pos[j].lower_bound(r+1)){
                    ans++;
                }
            }
            printf("%ld\n", ans);
        }

    }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string s;
	ll K;
	cin >> s >> K;
	REP(i, s.size()){
		ll tmp = 'z' - s[i];
		if(K>=tmp+1 && s[i]!='a'){
			K -= (tmp+1);
			s[i] = 'a';
		}
		if(K==0){
			break;
		}
	}
	if(K>0){
		s[s.size()-1] = char(((s[s.size()-1] - 'a') + K)%26 + 'a');
	}
	cout << s << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  for(int i=0; i<N/2; i++){
    if(S[i]==S[N-i-1]) continue;
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<(N-1)/4; i++){
    if(S[i]==S[(N-1)/2-i-1]) continue;
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<(N+1)/4; i++){
    if(S[(N+3)/2-1+i]==S[N-1-i]) continue;
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll c(ll a,ll b)
{
  if(a==0)return b==0?1:0;

if(b>a)return 0;

  ll val=1;
ll fac=1;
for(int i=1;i<=b;i++)fac*=i;
for(int i=a;i>=a-b+1;i--)val*=i;

  return val/fac;

}

ll f(ll n)
{
  ll ans=1LL;
  while(ans<=n)ans<<=1;

return ans;
}

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


ll n,k;
cin>>n>>k;
ll ans=0;
if(n%k)ans=1;


cout<<ans<<"\n";


return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int K, S;
  int X, Y, Z;
  int ans = 0;
  
  scanf("%d %d", &K, &S);
  for(X = 0; X <= K; X++) {
    for(Y = 0; Y <= K; Y++) {
      Z = S - X - Y;
      if(0 <= Z && Z <= K) ans++;
    }
  }
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	int T, K;
	scanf ("%d %d", &T, &K);
	
	for (int i = T; i <= K; i++){
		if (i % n == 0){
			puts("OK");
			return 0;
		}
		else continue;
	}
	puts("NG");
}

Measured memory_bytes: 1640
import itertools
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
    A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
    B[i]=int(B[i])
l=[0,1]
p=[]
k=0
D=[]
for v in itertools.product(l,repeat=n):
    sum=0
    for i in range(n):
        if v[i]==1:
            sum=sum+A[i]
    D.append(sum)
    k+=1
for i in range(q):
    if B[i] in D:
        C.append("yes")
    else:
        C.append("no")
for i in range(q):
    print(C[i])



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

typedef struct{
  int maps[11][11];
  int c;
}DAT;

typedef pair<int,int>P;

DAT tmp;
int x,y;
int dy[4] = {1,0,-1,0};
int dx[4] = {0,1,0,-1};
string str;

int solve(DAT);

int change_color(DAT,int);

int main(){
  
  char moji;
  while(cin >> x >> y,x|y){
    
    DAT a;
    
    for(int i = 0; i < y; i++){
      for(int j = 0; j < x; j++){
	cin >> moji;
	if(moji == 'R'){
	  a.maps[i][j] = 1;
	}else if(moji == 'G'){
	  a.maps[i][j] = 2;
	}else{
	  a.maps[i][j] = 3;
	}
      }
    }

    a.c = 0;
    int cnt = 0;
    int f = 0;
    for(int k = 1; k <= 3; k++){
      for(int i = 0 ; i < y; i++){
	for(int j = 0; j < x; j++){
	  if(a.maps[i][j] == k)cnt++;
	}
      }
      if(cnt == y*x){
	cout << 0 << endl;
	f = 1;
      }
      cnt = 0;
    }
    if(f == 0){
      cout << solve(DAT(a)) << endl;
    }
  }
}
 

int solve(DAT data){
  queue<DAT> que;
  map<string,int> check;
  que.push(data);
  while(!que.empty()){
    DAT d = que.front();que.pop();
    for(int i = 1; i <= 3; i++){
      if(i != d.maps[0][0]){
	if(change_color(d,i)){
	  return d.c + 1;
	}   
	if(check.count(str) == 0){
	  check[str] = 1;
	  que.push(tmp);
	}
      }
    }
  }
  return -1;
}

int change_color(DAT data,int color){
    //隣接する場所の色を変える(tmpを操作)
  for(int i = 0; i < y; i++){
    for(int j = 0; j < x; j++){
      tmp.maps[i][j] = data.maps[i][j];
    }
  }
  //cnt++
  tmp.c = data.c + 1;
  int same = tmp.maps[0][0];
  queue<P> que;
  que.push(P(0,0));
  while(!que.empty()){
    P p = que.front();que.pop();
    tmp.maps[p.first][p.second] = color;    
    for(int i = 0; i < 4; i++){
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];
      if(tmp.maps[ny][nx] == same && ny >= 0 && ny < y && nx >= 0 && nx < x ){
	que.push(P(ny,nx));
      }
    }
  }
  //stringにする
  str = "";
  for(int i = 0; i < y; i++){
    for(int j = 0; j < x; j++){
      str += tmp.maps[i][j] + '0';
    }
  }
  int cnt = 0;
  for(int i = 0 ; i < y; i++){
    for(int j = 0; j < x; j++){
      if(tmp.maps[i][j] == color)cnt++;
    }
  }
  //マップをみてそろってたら1を返す 
  if(cnt == y * x)return 1;
  else return 0;
}

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	cout << x2 + (y1 - y2) << " " << y2 - (x1 - x2) << " " <<
		x1 + (y1 - y2) << " " << y1 - (x1 - x2) << " " << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		int[] month=new int[12];
		int youbi=3;		// 2004 1 1 ha mokuyoubi    nichiyoubi 0
		int nissuu=0;
		String str="";
		StringTokenizer stk;
		int tsuki=0,nichi=0;
		int motomeru=0;
		month[0]=31;
		month[1]=29;
		month[2]=31;
		month[3]=30;
		month[4]=31;
		month[5]=30;
		month[6]=31;
		month[7]=31;
		month[8]=30;
		month[9]=31;
		month[10]=30;
		month[11]=31;

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			try {
				nissuu=0;
				str=bfr.readLine();
				stk=new StringTokenizer(str," ");
				tsuki=Integer.parseInt(stk.nextToken());
				nichi=Integer.parseInt(stk.nextToken());
				if(tsuki==0 && nichi==0) {
					System.exit(0);
				}
				if(tsuki==1) {
					nissuu=nichi;
				}
				else {
					for(int i=0; i<=tsuki-2; i++) {
						nissuu+=month[i];
					}
					nissuu+=nichi;
				}

				motomeru=(youbi+nissuu)%7;

				if(motomeru==0) {
					System.out.println("Sunday");
				}
				else if(motomeru==1) {
					System.out.println("Monday");
				}
				else if(motomeru==2) {
					System.out.println("Tuesday");
				}
				else if(motomeru==3) {
					System.out.println("Wednesday");
				}
				else if(motomeru==4) {
					System.out.println("Thursday");
				}
				else if(motomeru==5) {
					System.out.println("Friday");
				}
				else if(motomeru==6) {
					System.out.println("Saturday");
				}

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 24460
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
  int n;
  double sum,m,s[1000],var,tmp;

  while(true)
  {
    cin >> n;
    if (n==0) break;

    sum=0.0;
    for (int i=0;i<n;i++)
    {
      cin >> s[i];
      sum += s[i];
    }
    m = sum / n;

    tmp=0.0;
    for (int i=0;i<n;i++)
    {
      tmp += (s[i]-m)*(s[i]-m);
    }
    tmp /= n;

    var = sqrt(tmp);

    cout << fixed;
    cout << var << endl;


    for (int i=0;i<n;i++)
    {
      s[i] = 0;
    }
  }

  return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N - 1);
  vector<int> C(N - 2);
  cin >> A.at(0);
  int ans = abs(A.at(0));
  for (int i = 1; i < N; i++) {
    cin >> A.at(i);
    B.at(i - 1) = abs(A.at(i) - A.at(i - 1));
    ans += B.at(i - 1);
  }
  ans += abs(A.at(N -1));
  for (int i = 0; i < N - 2; i++) {
    C.at(i) = abs(A.at(i + 2) - A.at(i));
  }
  cout << ans - B.at(0) - abs(A.at(0)) + abs(A.at(1)) << endl;
  for (int i = 1; i < N - 1; i++) {
    int memo = ans;
    memo -= (B.at(i - 1) + B.at(i));
    memo += C.at(i - 1);
    cout << memo << endl;
  }
  cout << ans - B.at(N - 2) - abs(A.at(N - 1)) + abs(A.at(N - 2)) << endl;
}
    

Measured memory_bytes: 4580
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto p = new int[][](n, 2);
  auto q = new int[][](m, 2);
  foreach (i; 0..n) {
    p[i] = readln.chomp.split.to!(int[]);
  }
  foreach (j; 0..m) {
    q[j] = readln.chomp.split.to!(int[]);
  }
  foreach (i; 0..n) {
    int index;
    auto dist = int.max;
    foreach (j; 0..m) {
      auto dx = abs(p[i][0] - q[j][0]).to!int;
      auto dy = abs(p[i][1] - q[j][1]).to!int;
      if (dx + dy < dist) {
        dist = dx + dy;
        index = j.to!int + 1;
      }
    }
    index.writeln;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#ifdef DEBUG
#define debug(x) cerr << #x << " " << x << '\n'
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 0x3f3f3f3f, N = 3e5 + 5;
int n, a[N], cnt[N], suf[N], cnt2[N], cnt3[N], pre[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1;i<=n;i++)
 	{
 		cin >> a[i];
 		cnt[a[i]]++;
 	}
 	for(int i=1;i<=n;i++)
 	{
 		if(cnt[i])
 		{
 			cnt2[cnt[i]] += cnt[i];
 			cnt3[cnt[i]]++;
 		}
 	}
 	for(int i=1;i<=n;i++) pre[i] = pre[i-1] + cnt2[i];
 	for(int i=n;i>=1;i--) suf[i] = suf[i+1] + cnt3[i];
 	for(int k=1;k<=n;k++)
 	{
 		int l = 1, r = n, ans = 0;
 		while(l<=r)
 		{
 			int mid = (l+r) >> 1;
 			if(suf[mid]+pre[mid-1]/mid>=k) ans = mid, l = mid + 1;
 			else r = mid - 1;
 		}
 		cout << ans << '\n';
 	}
	return 0;
}


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

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
    
}


Measured memory_bytes: 3100
n = int(input())
NUM_LIST = list(map(int, input().split()))

k = int(input())
keys = list(map(int, input().split()))

check = [False]*2001
def recursive(index, sum_value):
    if index == n:
        check[sum_value] = True
        return
    
    recursive(index+1, sum_value)
    
    if sum_value + NUM_LIST[index] <= 2000:
        recursive(index+1, sum_value+NUM_LIST[index])

recursive(0, 0)

for key in keys:
    if check[key]:
        print("yes")
    else:
        print("no")
    


Measured memory_bytes: 5632
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A==B) {
			System.out.println(2*A);
		} else {
			System.out.println(Math.max(A,B)*2-1);
		}
	}
}

Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int c = Integer.parseInt(a + b);
        for (int i = 1; ; i++) {
            int tmp = i * i;
            if(tmp == c) {
                System.out.println("Yes");
                return;
            } else if(tmp > c) {
                System.out.println("No");
                return;
            }
        }
    }
}

Measured memory_bytes: 39276
fun main(args: Array<String>) {
  val (K,X) = readLine()!!.split(" ").map(String::toInt)
  for (i in X-K+1..X+K-1) {
    if (i != X+K-1) {
      print("$i ")
    } else {
      println(i)
    }
  }
}

Measured memory_bytes: 37916
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, min int
	fmt.Scan(&n, &min)
	xs := make([]int, 4)
	for i := range xs {
		fmt.Scan(&xs[i])
		if xs[i] < min {
			min = xs[i]
		}
	}
	fmt.Println(int(math.Ceil(float64(n)/float64(min))) + 4)
}


Measured memory_bytes: 512
def resolve():
  a, b, x = map(int, input().split(" "))

  diff = b - a
  result = diff // x
  if not x - a%x + b%x >= x or a%x == 0 or b%x == 0:
    result += 1

  print(result)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 61924
N, M= map(int, input().split()) 
A = list(map(int, input().split())) 
sum_A=0
for i in range (0,N):
  sum_A=sum_A+A[i]
pop=0
for i in range(0,N):
  if A[i]>=sum_A/(4*M):
    pop=pop+1
if pop>=M:
  print("Yes")
else:
  print("No")
   
  

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var X = F;
		var ps = new HashSet<int> { 1 };
		for (var n = 2; n <= 40; n++)
		{
			var a = n * n;
			while (a <= X)
			{
				ps.Add(a);
				a *= n;
			}
		}
		WriteLine(ps.Max());
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  for(int i=0; i<4; i++){
    cout << S.at(i);
  }
  cout << " ";
  for(int i=4; i<12; i++){
    cout << S.at(i);
  }
  cout << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
vector<ll> divisor(ll x){
	vector<ll> div;
	for(int i=1;i*i<=x;i++){
		if(i*i!=x && x%i==0){
			div.pb(i);
			div.pb(x/i);
		}
		else if(x%i==0) div.pb(i);
	}
	return div;
}
vector<ll> vectorprime(ll x){
	vector<bool> is_prime(x+1);
	vector<ll> prime;
	rep(i,x+1) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=x;i++){
		if(is_prime[i]){
			prime.pb(i);
		}
		for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
	}
	return prime;
}

//a,b x
int main(){
	ll H,W; cin>>H>>W;
	char field[100][100];
	rep(i,H){
		string tmp; cin>>tmp;
		rep(j,W){
			field[i][j]=tmp[j];
		}
	}
	rep(i,H*2){
		rep(j,W){
			cout<<field[i/2][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define inf (1<<30)
#define mod 1000000007
using namespace std;
typedef long long LL;
int read()
{
	char c=getchar();int f=1,sum=0;
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int n,m,k,ans;
int nex[1<<21][25],lim[25][25];
void init()
{
	n=read()-1;m=read();k=read();
	for(int i=0;i<(1<<n);i++)
	{
		int pos=-1;
		for(int j=n-1;j>=0;j--)
		{
			if(i&(1<<j)) pos=j;
			nex[i][j]=pos;
		}
	}
	memset(lim,-1,sizeof(lim));
	for(int i=1;i<=k;i++)
	{
		int a=read(),b=read(),c=read();
		lim[a][b-1]=c;	
	}
}
int dp[2][25][(1<<21)];
int main()
{
	init();
	dp[0][n][0]=1;
	int now=1;
	for(int i=1;i<=m;i++)
	{
		for(int sta=0;sta<(1<<n);sta++) dp[now][0][sta]=dp[1-now][n][sta];
		for(int j=0;j<=n;j++)
        for(int sta=0;sta<(1<<n);sta++)
        dp[1-now][j][sta]=0;
        for(int j=0;j<n;j++)
        for(int sta=0;sta<(1<<n);sta++)
        if(dp[now][j][sta])
		{
            for(int k=0;k<=1;k++)
			{
            	if(lim[i][j]!=-1 && lim[i][j]!=k) continue;
            	int t=(bool)(sta&(1<<j));
                if(k==0 && t) continue;
                if(k==t) (dp[now][j+1][sta]+=dp[now][j][sta])%=mod;
                else
				{
                    int r=nex[sta][j];
                    if (r==-1) (dp[now][j+1][sta+(1<<j)]+=dp[now][j][sta])%=mod;
                    else (dp[now][j+1][sta+(1<<j)-(1<<r)]+=dp[now][j][sta])%=mod;
                }
            }
        }
        now=1-now;
	}
	for(int sta=0;sta<(1<<n);sta++)
	ans=(ans+dp[1-now][n][sta])%mod;
    printf("%d\n",ans);
	return 0;
}


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

int main(){
    while(1){
        int d, w;
        cin >> d >> w;
        if(d==0) break;
        vector<vector<int> > e(d, vector<int>(w));
        for(int i=0; i<d; i++){
            for(int j=0; j<w; j++){
                cin >> e[i][j];
            }
        }

        int ans = 0;
        for(int i=0; i<d; i++){
            for(int j=0; j<w; j++){
                for(int k=i+2; k<d; k++){
                    for(int l=j+2; l<w; l++){
                        int limit = 10;
                        for(int x=i; x<=k; x++){
                            limit = min(limit, min(e[x][j], e[x][l]));
                        }
                        for(int x=j; x<=l; x++){
                            limit = min(limit, min(e[i][x], e[k][x]));
                        }
                        int sub = 0;
                        for(int x=i+1; x<k; x++){
                            for(int y=j+1; y<l; y++){
                                if(e[x][y] >= limit){
                                    sub = 0;
                                    x = k;
                                    break;
                                }
                                sub += limit -e[x][y];
                            }
                        }
                        ans = max(ans, sub);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 


int main(){

	string s;
	cin>>s;

	int cnt[26]={};
	for(int i=0;i<s.size();i++){
		cnt[s[i]-'a']++;
	}

	for(int i=0;i<26;i++){
		if(cnt[i]%2){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll x;
	cin >> x;
	if(x >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

signed main(){
	int N, i, j;
	string a[4] = {"AC", "WA", "TLE", "RE"};
	vector<int> ans(4, 0);
	scanf("%d", &N);
	for(i = 0; i < N; i++){
		string sub;
		cin >> sub;
		for(j = 0; j < 4; j++){
			if(sub == a[j]){
				ans[j]++;
			}
		}
	}
	for(j = 0; j < 4; j++){
		cout << a[j];
		printf(" x %d\n", ans[j]);
	}
	return 0;
}

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

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

  vector<double> p(n);
  double sum = 0.0;
  for (int i = 0; i < n; i++)
  {
    int m;
    cin >> m;
    p[i] = (m+1)/2.0;
    if(i<k) sum+=p[i];
  }

  double ans = sum;
  for (int i = 0; i < n-k; i++)
  {
    sum-=p[i];
    sum+=p[i+k];
    ans = max(ans,sum);
  }
  printf("%.10lf\n",ans);  
}

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

int  A, B, C, D;

int main(){
  cin >> A >> B >> C >> D;
  
  if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c) = getLongs()

    val x = 4 * a * b
    val y = (c - a - b)
    if (y < 0) {
        println("No")
        return
    }
    if (x < y * y) {
        println("Yes")
    }
    else {
        println("No")
    }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

Measured memory_bytes: 38072
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	if(x-a<=b&&x-a>=0) printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   long long int N,sum=0;
   cin>>N;
   for(long long int i=1;i<=N;i++){
   if(i%3!=0 && i%5!=0){
       sum+=i;
   }
   }
cout<<sum<<endl;
return 0;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a;
    cin >> a;
    
    string s;
    cin >> s;
    
    if ( a >= 3200 ) cout << s << endl;
    else cout << "red" << endl;

    return 0;
}


Measured memory_bytes: 256