akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> a(N);
  S += 'R';
  
  int even,odd,mark = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) even++;
    else odd++;
    if (S.at(i) == 'R' && S.at(i+1) == 'L') {
      mark = i;
    }
    if (S.at(i) == 'L' && S.at(i+1) == 'R') {
      if (mark % 2 == 0) {
        a.at(mark) = even;
        a.at(mark+1) = odd;
      } else {
        a.at(mark) = odd;
        a.at(mark+1) = even;
      }
      even = 0;
      odd = 0;
    }
  }

  for (int i = 0; i < N; i++) cout << a.at(i) << " "; 
  cout << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll a,b,c,k;
  cin >>a >>b>>c>>k;
  if(k<=a) cout << k<<endl;
  else if(a<k&&k<=a+b) cout << a <<endl;
  else cout << 2*a+b-k<<endl; 
  return 0;
}


Measured memory_bytes: 3636
<?php

for($i=0; $i<4; $i++){
  $nums[$i] = trim(fgets(STDIN));
}

if ($nums[0] > $nums[1]){
	echo $nums[1]*$nums[2] + ($nums[0]-$nums[1])*$nums[3];  
} else {
	echo $nums[0]*$nums[2];
}

?>

Measured memory_bytes: 4604
#include<iostream>
#include<vector>
#include<math.h>
#include <algorithm>
#include <functional>

using namespace std;


int main(){
  int K,S;
  cin>>K;
  cin>>S;
  int ans=0;
  for(int x =0;x<=K;x++){
    for(int y =0;y<=K;y++){
      int z=S-x-y;
      if(z>=0&&z<=K){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
      
  

    
      
  
  
  
  

Measured memory_bytes: 256
import sys

def main():
    lines = sys.stdin.readlines()

    for line in lines:
        if len(line) == 0:
            continue
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        elems = line.split(" ")
        # print elems
        if elems[0] == "0" or elems[1] == "0":
            continue
        for height_ind in range(int(elems[0])):
            width_str = ""
            for width_ind in range(int(elems[1])):
                width_str = width_str + "#"
            print width_str
        print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 6452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=42;

int n;
int a[maxn][maxn];

inline void init()
{
	n=read()<<1;
	REP(i,1,n)
	{
		static char str[22];
		scanf("%s",str+1);
		REP(j,1,n)a[i][j]=str[j]-'0';
	}
}

ll f[maxn][maxn][maxn];

ll solve(int l,int k,int r)
{
	if(l==k && k==r)return 1;
	if(l==k || k==r)return 0;
	if(~f[l][k][r])return f[l][k][r];
	ll &ans=f[l][k][r];
	ans=0;
	REP(p,l,k-1)DREP(q,r,k+1)if(a[p][q])
	{
		REP(a,p,k-1)REP(b,k+1,r)
			ans+=solve(l,p,a)*solve(a+1,k,b-1)*solve(b,q,r);
	}
	return ans;
}

inline void doing()
{
	memset(f,-1,sizeof(f));
	ll ans=0;
	REP(i,2,n)if(a[1][i])
	{
		//cerr<<i<<" "<<solve(2,i,n)<<endl;
		ans+=solve(2,i,n);
	}
	printf("%lld\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        int K,S; cin>>K>>S;
        int ans=0;
        for(int x=0;x<=S and x<=K;x++){
                for(int y=0;x+y<=S and y<=K;y++){
                        int z=S-(x+y);
                        if(z<=K) ans++;
                }
        }
        cout<<ans<<endl;
}


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

const int base=1<<17;

int t[base*2];

vector<pair<int,int>> v;

void prep()
{
    for(int i=base;i<base*2;i++)
        t[i]=i-base;
    for(int i=base-1;i>=1;i--)
        t[i]=max(t[i*2],t[i*2+1]);
}

int get(int a,int b)
{
    a+=base;
    b+=base;
    int ans=max(t[a],t[b]);
    while(a/2!=b/2)
    {
        if(a%2==0)
            ans=max(ans,t[a+1]);
        if(b%2==1)
            ans=max(ans,t[b-1]);
        a/=2;
        b/=2;
    }
    return ans;
}

void update(int a)
{
    a+=base;
    t[a]=0;
    while(a)
    {
        a/=2;
        t[a]=max(t[a*2],t[a*2+1]);
    }
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b,ans=0,p;
    cin>>n>>m;
    prep();
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v.emplace_back(make_pair(b,a));
    }
    sort(v.begin(),v.end());
    for(int i=v.size()-1;i>=0;i--)
    {
        p=get(0,max(0,m-v[i].second+1));
        if(p)
            ans+=v[i].first,update(p);
    }
    cout<<ans;
}


Measured memory_bytes: 2424
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]

cd = [tuple(map(int, input().split())) for i in range(M)]


for a, b in ab:
    ret = -1
    dis = 10**20
    for i, x in enumerate(cd):
        c, d = x
        if dis > abs(c-a) + abs(d-b):
            dis = abs(c-a) + abs(d-b)
            ret = i
    print(ret+1)


Measured memory_bytes: 3064
import sys
import math
from collections import Counter

input = sys.stdin.readline
sys.setrecursionlimit(100000)


def getN():
    return int(input())


def getList():
    return list(map(int, input().split()))


def solve():
    return


def main():
    n = getN()
    ans = n + 1
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = i + n // i
            if ans > tmp:
                ans = tmp



    print(ans-2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int a,b;
    cin>>a>>b;
    if(a*b==15){
        cout<<"*"<<endl;
    }
    else if(a+b==15){
        cout<<"+"<<endl;
    }
    else{
        cout<<"x"<<endl;
    }
}

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

using namespace std;

int main(){

    set<int> c_start;
    set<int> c_end;

    int N;
    int M;
    int a;
    int b;

    cin >> N;
    cin >> M;
    
    for(int i = 0; i<M; i++){
	cin >> a;
	cin >> b;

	if(a==1) c_start.insert(b);
	else if(b==N) c_end.insert(a);
    }
    
    bool v = false;
    
    for(set<int>::iterator cit=c_start.begin(); cit!=c_start.end(); cit++){
	if(c_end.count(*cit)>0){
	    v = true;
	}
    }

    if(v) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    
    return 0;
}


Measured memory_bytes: 9600
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    x, y = LI()
    G[x - 1] += [y - 1]

dist = [[INF] * n for _ in range(3)]
s, t = LI()
dist[0][s - 1] = 0
dq = deque([(0, s - 1)])
while dq:
    cost, u = dq.popleft()
    for v in G[u]:
        if cost + 1 < dist[(cost + 1) % 3][v]:
            dist[(cost + 1) % 3][v] = cost + 1
            dq += [(cost + 1, v)]


ans = dist[0][t - 1]
if ans == INF:
    print(-1)
else:
    print(ans // 3)





Measured memory_bytes: 60976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	string C = "";
	rep(i, N)
	{
		C += S.at(i);
		C += T.at(i);
	}
	cout << C << endl;
	return 0;
}


Measured memory_bytes: 256
char S[99];
int G(x,y){return y?G(y,x%y):x;}
main(g,X,Y,x,y,z,t,T,f){for(;~scanf("%d%d",&x,&y);){
for(g=0,X=x,Y=y;g<90;g++)S[g]=X*10/Y+'0',X=X*10%y;
g=G(x,y);x/=g;y/=g;
for(z=0;y%2==0;y/=2)z++;
for(f=0;y%5==0;y/=5)f++;
if(y==1)t=0;else{x=1;t=0;do{x=x*10%y;t++;}while(x!=1);}
if(z>f)f=z;
S[f+t]=0;puts(S);
if(t){
	for(;f>0;f--)putchar(' ');
	for(;t>0;t--)putchar('^');
	puts("");
}
}exit(0);}

Measured memory_bytes: 588
#include <map>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
map<ll,int> mp;
ll c[405][4];
ll h[405],v[4];
void upd(ll x,int d){
	for(int i=0;i<4;i++,x=((x&1023ll)<<30ll)|(x>>10ll)){
		mp[x]+=d;
	}
}
ll hash(ll *a){
	ll ans=0;
	for(int i=0;i<4;i++){
		ans|=(a[i]<<(i*10ll));
	}
	return ans;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld%lld",&c[i][0],&c[i][1],&c[i][2],&c[i][3]);
		h[i]=hash(c[i]);
		upd(h[i],1);
	}
	ll ans=0,res;
	for(int i=1;i<=n-5;i++){
		upd(h[i],-1);
		for(int j=i+1;j<=n;j++){
			upd(h[j],-1);
			for(int k=0;k<4;k++){
				res=1;
				for(int l=0;l<4;l++){
					ll tmp[]={c[i][(l+1)&3],c[i][l],c[j][(3-l+k)&3],c[j][(6-l+k)&3]};
					v[l]=hash(tmp);
					if(!mp.count(v[l])){
						goto to;
					}
				}
				for(int l=0;l<4;l++){
					res*=mp[v[l]];
					upd(v[l],-1);
				}
				ans+=res;
				for(int l=0;l<4;l++){
					upd(v[l],1);
				}
				to:;
			}
			upd(h[j],1);
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    if (n == k) cout << 1 << '\n';
    else {
        int ans = 1;
        int tmp = n - k;
        int div = tmp / (k - 1);
        int mod = tmp % (k - 1);
        if (mod) cout << ans + div + 1 << '\n';
        else cout << ans + div << '\n';
    }
    return 0;
}


Measured memory_bytes: 640
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil
(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (x (read))
         (end (- (* 2 n) 1))
         (seq (loop for i from 1 to end collect i))
         (res (make-array end :element-type 'uint32)))
    (declare (uint32 n x))
    (cond ((or (= x 1) (= x end))
           (println "No"))
          ((= n 2)
           (format t "Yes~%1~%2~%3~%"))
          (t
           (let ((fixed (if (> x 2)
                            (list (- x 2) x (+ x 1) (- x 1))
                            (list (+ x 2) x (- x 1) (+ x 1)))))
             (setf (aref res (- n 2)) (elt fixed 0)
                   (aref res (- n 1)) (elt fixed 1)
                   (aref res n) (elt fixed 2)
                   (aref res (+ n 1)) (elt fixed 3))
             (setf seq (set-difference seq fixed))
             (loop for i from 0 below (- n 2)
                   for a = (pop seq)
                   do (setf (aref res i) a))
             (loop for i from (+ n 2) below end
                   for a = (pop seq)
                   do (setf (aref res i) a))
             (println "Yes")
             (loop for a across res
                   do (println a)))))))

#-swank(main)


Measured memory_bytes: 18148
import sys
for s in sys.stdin:
    a,b,c=map(int,s.split())
    x=20-a-b
    f=3
    if x<a: f-=1
    if x<b: f-=1
    if x<c: f-=1
    if x-f>=4:print "YES"
    else: print "NO"

Measured memory_bytes: 4204
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
		//Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int ctr = 0;
	    for(int i=1;i<=n;++i) {
	    	if(sc.nextInt() != i) ++ctr;
	    }
	    if(ctr>2) out.print("NO");
	    else out.print("YES");
		out.close();
		}
	
	
	
}
	

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF
	char *ret=fgets(buf,n,fp);
	if(!ret)return NULL;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0;
	return ret;
}

char Q[99999];
char *q[999];
char L[99999];
int ind[9999];
int n;
dfs(depth){
	int cur_ind=0;
	if(!myfgets(L,sizeof(L),stdin)){puts("no such property");exit(0);}
	if(depth){
		for(;L[cur_ind]==' ';cur_ind++);
		if(ind[depth-1]>=cur_ind){puts("no such property");exit(0);}
	}
	char *name=strtok(L+cur_ind,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1){
			if(*value)
				printf("string \"%s\"\n",value+1),exit(0);
			else
				puts("object"),exit(0);
		}
		ind[depth]=cur_ind;
		dfs(depth+1);
	}
	dfs(depth);
}

main(depth){
	myfgets(Q,sizeof(Q),stdin);
	q[0]=strtok(Q+1,".");
	for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;
	dfs(0);
}

Measured memory_bytes: 588
/**
 *  author: mahfuzz
 *  created: 10.04.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << #x << ':' << x << "\n"
typedef long long ll;

int main(int argc, char* argv[]){

    ll n; cin >> n;
    ll sum = 0;
    for(ll i = 0; i <= n; i++){
        if(i % 5 == 0 || i % 3 == 0)
            continue;
        sum += i;
    }
    
    cout << sum << "\n";
    
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long long
#define N 40
using namespace std;

vector<int> A[21];
int coin[N];

int calc(int bit,int arr[],int n){
  int res = 0;
  for(int i=0;i<n;i++) if(bit>>i&1) res += arr[i];
  return res;
}

signed main(){

  int n,K,L,R;
  cin>>n>>K>>L>>R;
  for(int i=0;i<n;i++) cin>>coin[i];
  
  int a = n/2;
  int b = n-a;
  for(int i=0;i<(1<<a);i++){
    int cnt = __builtin_popcount(i);
    A[cnt].push_back(calc(i,coin,a));
  }

  for(int i=0;i<=20;i++)sort(A[i].begin(),A[i].end());
  
  int ans = 0;
  for(int i=0;i<(1<<b);i++){
    int cnt = __builtin_popcount(i);
    int br = calc(i,coin+a,b);
    if(cnt>K) continue;
    int l = lower_bound(A[K-cnt].begin(),A[K-cnt].end(),L-br) - A[K-cnt].begin();
    int r = upper_bound(A[K-cnt].begin(),A[K-cnt].end(),R-br) - A[K-cnt].begin();
    assert(l<=r);
    ans += r-l;
  }
  cout<<ans<<endl;

  return 0;
}

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

void solve(long long N){
    ll ans = 0;
    for (ll i=1; i<=N; i++) {
        ll a = N / i;
        ans += (i * a * (a+1) / 2);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    
    vector<int> n;
    
    for(int i=a; i<=b; i++){
        if(i<a+k) n.push_back(i);
        else if(i>b-k) n.push_back(i);
    }
    
    sort(n.begin(),n.end());
    n.erase(unique(n.begin(),n.end()),n.end());
    
    for(int i=0; i<n.size(); i++)
        cout << n[i] << endl;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
v1 = Counter(v[::2]).most_common(2)
v2 = Counter(v[1::2]).most_common(2)
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print(n - v1[0][1] - v2[0][1])
else:
    print(min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1]))

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int num=s.size();
  rep(i,n-1){
    if(s.at(i)==s.at(i+1))num--;
  }
  cout<<num<<endl;
}

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


void solve(std::vector<long long> A){
    int sum=accumulate(A.begin(),A.end(),0);
    cout<<(sum<22?"win":"bust")<<endl;
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
#define NUM	( 3 )

/*********************************
*function
*********************************/
int main( void )
{
	int ary[ NUM ];
	int min;
	int temp;
	int loop1;
	int loop2;
	char ch;
	
	scanf( "%d %d %d", &ary[ 0 ], &ary[ 1 ], &ary[ 2 ] );
	min = ary[ 0 ];

	for ( loop1 = 0; loop1 < NUM; loop1++ ) {
		for ( loop2 = loop1 + 1; loop2 < NUM; loop2++ ) {
			if( ary[ loop1 ] > ary[ loop2 ] ) {
				temp = ary[ loop1 ];
				ary[ loop1 ] = ary[ loop2 ];
				ary[ loop2 ] = temp;
			}
		}
	}

	loop1 = 0;

	while( loop1 < NUM ) {
		if( ( NUM - 1 ) == loop1 ) {
			printf( "%d\n", ary[ loop1 ] );			
		} else {
			printf( "%d ", ary[ loop1 ] );
		}
		loop1++;
	}
	while( EOF != ( ch = getchar() )) ;

	return ( 0 );
}

Measured memory_bytes: 600
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100005];
int main()
{
  ll n, k, min = 0, max = LLINF;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < k; i++)
  {
    ll l, r;
    scanf("%lld%lld", &l, &r);
    if (l > max || r < min)
    {
      printf("%d\n", 0);
      return 0;
    }
    min = MAX(min, l);
    max = MIN(max, r);
  }
  printf("%lld\n", max - min + 1);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const ll MOD = 924844033;
const ll G = 5;

int n,k,N,L1,L2,C1,C2;
int rev[MAXN << 2];

ll ans;
ll fac[MAXN];
ll inv[MAXN];
ll F1[MAXN << 2];
ll F2[MAXN << 2];
ll wn[2][MAXN << 2];

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

void init()
{
	fac[0] = 1;
	for (int i = 1;i <= n;i++)
		fac[i] = fac[i - 1] * i % MOD;
	inv[n] = power(fac[n],MOD - 2);
	for (int i = n;i >= 1;i--)
		inv[i - 1] = inv[i] * i % MOD;
}

ll C(int x,int y)
{
	return fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

void NTTinit(int l)
{
	N = 1;
	while (N < l)
		N <<= 1;
	for (int i = 1;i < N;i++)
		rev[i] = (rev[i >> 1] >> 1) + (i & 1) * (N >> 1);
	int half = N >> 1;
	for (int i = 0;i < half;i++)
		wn[1][i + half] = power(wn[0][i + half] = power(G,(MOD - 1) * i / N),MOD - 2);
	for (int i = half - 1;i >= 0;i--)
	{
		wn[0][i] = wn[0][i << 1];
		wn[1][i] = wn[1][i << 1];
	}
}

void NTT(ll *v,int inv)
{
	for (int i = 0;i < N;i++)
		if (i < rev[i])
			swap(v[i],v[rev[i]]);
	for (int i = 1;i < N;i <<= 1)
		for (int j = 0;j < N;j += (i << 1))
		{
			ll *l = v + j,*r = v + j + i,*w = wn[inv == -1] + i,V;
			for (int k = 0;k < i;k++,l++,r++,w++)
			{
				V = *r * *w;
				*r = (*l - V) % MOD;
				*l = (*l + V) % MOD;
			}
		}
	if (inv == -1)
	{
		ll Inv = power(N,MOD - 2);
		for (int i = 0;i < N;i++)
			(v[i] *= Inv) %= MOD;
	}
}

int main()
{
	cin >> n >> k;
	init();
	L1 = (n - 1) / k;
	L2 = L1 - 1;
	C1 = ((n - 1) % k + 1) << 1;
	C2 = (k << 1) - C1;
	for (int i = 0;i <= (L1 + 1) >> 1;i++)
		F1[i] = C(L1 - i + 1,i);
	for (int i = 0;i <= (L2 + 1) >> 1;i++)
		F2[i] = C(L2 - i + 1,i);
	int T = ((L1 + 1) >> 1) * C1 + ((L2 + 1) >> 1) * C2;
	NTTinit(T + 1);
	NTT(F1,1);
	NTT(F2,1);
	for (int i = 0;i < N;i++)
		F1[i] = power(F1[i],C1) * power(F2[i],C2) % MOD;
	NTT(F1,-1);
	for (int i = 0;i <= T;i++)
	{
		if (i & 1)
			(ans -= F1[i] * fac[n - i]) %= MOD;
		else
			(ans += F1[i] * fac[n - i]) %= MOD;
	}
	cout << (ans + MOD) % MOD << endl;
	return 0;
}

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

int main(){
  string s,t;
  cin >>s>>t;
  vector<string> _s(s.size());
  vector<string> _t(t.size());
  string __s="";
  string __t="";
  for(int i=0;i<s.size();i++){
    _s.at(i)=s[i];
  }
  sort(_s.begin(),_s.end());
  for(int i=0;i<t.size();i++){
    _t.at(i)=t[i];
  }
  sort(_t.begin(),_t.end(),greater<string>());
  for(int i=0;i<s.size();i++){
    __s+=_s[i];
  }
    for(int i=0;i<t.size();i++){
    __t+=_t[i];
  }
  
  if(__s<__t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, a, b, p[110];

    cin >> n >> a >> b;
    REP(i, n)
    cin >> p[i];

    int q[3] = {0};

    REP(i, n)
    {
        if (p[i] <= a)
            q[0]++;

        if (a < p[i] && p[i] <= b)
            q[1]++;

        if (b < p[i])
            q[2]++;
    }

    int res = min(q[0], q[1]);
    res = min(res, q[2]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int A[100][100];
	int b[100];
	int c = 0;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			c += A[i][j] * b[j];
		}
		cout << c << endl;
		c = 0;
	}
	return 0;
}


Measured memory_bytes: 3108
package main

import (
	"bytes"
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	s2 := append([]byte{}, []byte(s)...)
	ReverseBytes(s2)
	s3 := s[(len(s)+3)/2-1 : len(s)]
	s4 := append([]byte{}, []byte(s3)...)
	ReverseBytes(s4)
	if bytes.Equal([]byte(s), s2) && bytes.Equal([]byte(s3), s4) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func ReverseBytes(s []byte) {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]){
	int n;
	cin>>n;
	int arr[n+10];
	int ans = 0;
	for (int i = 1; i <= n; ++i){
		cin>>arr[i];
		ans += (i%2 && arr[i]%2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
S = str(input())

ans = []
for i in range(len(S)):
    for j in range(len(S)+1):
        if S[i:j].count('A') + S[i:j].count('C') + S[i:j].count('G') +S[i:j].count('T') == len(S[i:j]):
            ans.append((len(S[i:j]),S[i:j]))
print(sorted(ans, reverse=True)[0][0])

Measured memory_bytes: 3064
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <string.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << " = " << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)
#define rrep(i, n)        for (int i = (n) - 1; i > -1; --i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair<ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n);
    int a[n]; rep(i, n) in(a[i]);
    std::sort(a, a + n);
    int x = a[n/2] - a[n/2 - 1];
    out(x);
}

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

    //int t; in(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll h[100010];
    rep(i,0,N) cin >> h[i];
    ll dp[100010] = {};
    fill(dp, dp+N+1, INF);
    dp[0] = 0;
    rep(i,0,N){
        if(i >= 1){
            dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        }
        if(i >= 2){
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    print(dp[N-1]);


}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

// union by size + path having
class UnionFind {
public:
	vector <ll> par; // 各元の親を表す配列
	vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

void solve_abc098() {
	ll N, M;
	cin >> N >> M;

	// スワップグループをつくっていく
	// グループ内では自由に順番を決めれる
	// グループはくっつくことがあるので、UnionFind
	// 最終的にグループごとに、数列の順番ごとに一致できるかどうか、数え上げていく
	// グループごとの一致数の和がans

	vector<ll> p(N);
	rep(i, N) {
		cin >> p[i];
	}

	UnionFind uf(N+1);

	ll x, y;

	rep(i, M) {
		cin >> x >> y;
		uf.merge(x, y);
	}

	ll ans = 0;

	rep(i, N) {
		if (uf.issame(i + 1, p[i])) {
			ans++;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc098();

	return 0;
}


Measured memory_bytes: 2560
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def main():
    n, a, b = (int(i) for i in input().split())
    ans = modint(pow(2, n, MOD))
    c_a = modint(1)
    c_b = modint(1)
    for k in range(a):
        c_a *= (n-k)
    for k in range(1, a+1):
        c_a /= k
    for k in range(b):
        c_b *= (n-k)
    for k in range(1, b+1):
        c_b /= k
    ans -= c_a + c_b + 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            if(N % 1000 == 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(1000 - N % 1000);
            }
        }
    }
}

Measured memory_bytes: 27520
"use strict";
    
const main = arg => {
    const A = arg.split("\n")[0].split(" ")[0];
    const B = arg.split("\n")[0].split(" ")[1];
    console.log((A * B) % 2 === 0 ? "Even" : "Odd");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include "iostream"
#include "algorithm"
using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	while (x != 0 || y != 0)
	{
		cout << min(x, y) <<" "<< max(x, y) << endl;
		cin >> x >> y;
	}
	return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

template <class T> using max_heap = priority_queue<T>;
template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U> void chmax(T &a, U b) {
    if (a < b)
        a = b;
}
template <class T, class U> void chmin(T &a, U b) {
    if (b < a)
        a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(std::string S) {
    rep(i, S.size()) cout << "x";
    cout << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
 
  n = []
  for i in range(N):
    n.append(-1)
  s = 0
  c = -1
  d = A[1-1]
  r = [1]
  n[0] = 0
  for i in range(1, K+1):
    if n[d - 1] == -1:
      n[d - 1] = i
    else:
      s = n[d - 1]
      c = i - n[d - 1]
      break
    r.append(d)
    d = A[d - 1]
  if c == -1:
    print(r[-1])
  else:
    cr = r[s:s+c]
    k = (K - s)%c
    print(cr[k])
  exit()

if __name__ == '__main__':
  main()

Measured memory_bytes: 31108
package main

import (
	"fmt"
	"math"
	"sort"
)

func AbsInt(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}

func main() {
	var a1, a2, a3 int
	fmt.Scan(&a1, &a2, &a3)
	tasks := []int{a1, a2, a3}
	sort.Ints(tasks)
	fmt.Println(AbsInt(tasks[0], tasks[1]) + AbsInt(tasks[1], tasks[2]))
}


Measured memory_bytes: 512
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	h,w=MI()
	G=[[0]*(w+2)]
	for _ in range(h):
		G.append([0]+list(input())+[0])
	G.append([0]*(w+2))

	for i in range(h+2):
		for j in range(w+2):
			if G[i][j]==".":
				cnt=0
				for ii in range(i-1,i+2):
					for jj in range(j-1,j+2):
						if G[ii][jj]=="#":
							cnt+=1
				G[i][j]=cnt
	G=G[1:-1]

	for s in G:
		print(*s[1:-1],sep="")


if __name__ == "__main__":
	main()


Measured memory_bytes: 9216
#include <bits/stdc++.h>
  using namespace std;
  long long MOD=1000000007;
  #define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
  typedef long long ll;
  #define pb push_back
  typedef pair<ll,ll> pi;

int main()
{
  IOS();
    int n;
    int k;
    cin>>n>>k;
    int f[n+1];
    for(int i=1;i<=n;i++)
    cin>>f[i];

    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(f[2]-f[1]);

    for(int i=3;i<=n;i++)
    {
      dp[i]=INT_MAX;
    }
    for(int i=3;i<=n;i++)
    {
      for(int j=1;j<=std::min(k,i-1);j++)
        dp[i]=std::min(dp[i],dp[i-j]+abs(f[i]-f[i-j]));
    }
    cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
constexpr long long MAX = 1e15;

vector<long long> dijkstra(const vector<vector<pair<int, long long>>> &G, int s){
    struct RadixHeap {
        inline int bsr(long long x){ return (x == 0) ? -1 : 63-__builtin_clz(x); }
        vector<pair<long long, int>> v[65];
        long long last, sz;
        RadixHeap() : last(0), sz(0) { }
        bool empty () { return (sz == 0); }
        void push(long long x, int u) { sz++; v[bsr(x^last)+1].emplace_back(x, u); }
        inline pair<long long, int> pop () {
            if (!v[0].size()) {
                int i = 1;
                while (!v[i].size()) { i++; }
                last = min_element(v[i].begin(), v[i].end())->first;
                for (auto x : v[i]) { v[bsr(x.first^last)+1].emplace_back(x); }
                v[i].clear();
            }
            pair<long long, int> res = v[0].back();
            sz--;
            v[0].pop_back();
            return res;
        }
    };
    const long long inf = INT64_MAX;
    vector<long long> ret(G.size(), inf); ret[s] = 0;
    RadixHeap rh; rh.push(ret[s], s);
    while (rh.sz) {
        long long dist; int node;
        tie(dist, node) = rh.pop();
        if (ret[node] < dist) continue;
        for (auto &e : G[node]) {
            int next_node; long long next_dist;
            tie(next_node, next_dist) = e;
            if (ret[next_node] > ret[node] + next_dist){
                ret[next_node] = ret[node] + next_dist;
                rh.push(ret[next_node], next_node);
            }
        }
    }
    return ret;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<pair<int, long long>>> g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        long long c1, c2;
        cin >> a >> b >> c1 >> c2;
        a--; b--;
        g1[a].emplace_back(b, c1);
        g1[b].emplace_back(a, c1);
        g2[a].emplace_back(b, c2);
        g2[b].emplace_back(a, c2);
    }
    
    vector<long long> d1 = dijkstra(g1, s); // yen
    vector<long long> d2 = dijkstra(g2, t); // snuuk
    vector<long long> d(n);
    for (int i = 0; i < n; i++) d[i] = d1[i] + d2[i];
    for (int i = n-1; i > 0; i--) d[i-1] = min(d[i-1], d[i]);
    
    for (auto& ans : d) cout << MAX - ans << '\n';
    return 0;
}

Measured memory_bytes: 19108
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
string hoge = "CODEFESTIVAL2016";
int main() {
	string s;
	cin >> s;
	int a = 0;
	REP(i, s.length()) {
		if (hoge[i] != s[i]) a++;
	}
	cout << a << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  int b=1000000000;
  vector<int> dp(n+10,b);
  dp[0]=0;
  FOR(i,0,n-2){
    b=1000000000;
    for(int j=i;j>=max(i-k+1,0);j--){
      b=min(b,dp[j]+abs(v[i+1]-v[j]));
    }
    dp[i+1]=b;
  }
  //rep(i,n)cout<<dp[i]<<endl;
  cout<<dp[n-1];
}

Measured memory_bytes: 4020
import java.util.Scanner;

public 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) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}

Measured memory_bytes: 21844
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    string s, t; cin >> s >> t;

    string p = s + s;
    int N = p.size();
    vector< vector<int> > nxt(N, vector<int>(26));
    vector<int> last(26, -1);

    for(int i=N-1; i>=0; i--) {
        for(int k=0; k<26; k++) {
            nxt[i][k] = last[k];
        }
        last[ p[i] - 'a' ] = i;
    }

    ll M = s.size();
    vector< vector<int> > to(M, vector<int>(26));
    for(int i=0; i<M; i++) {
        for(int k=0; k<26; k++) {
            if(nxt[i][k] == -1) to[i][k] = -1;
            else to[i][k] = (nxt[i][k] % M);
        }
    }

    ll ans = 0, cur = 0; bool ok = true;
    for(size_t i=0; i<t.size(); i++) {
        bool match = false;
        if(i == 0 and t[i] == s[cur]) match = true;
        else {
            int c = t[i] - 'a';
            if(to[cur][c] < 0) {
                ok = false;
                break;
            }
            if(cur >= to[cur][c]) {
                ans++;
            }
            cur = to[cur][c];
        }
    }

    if(ok) cout << ans * M + cur + 1 << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 40448
#!/usr/bin/php
<?php
 
function judge($n){
  $ma=0;
  $mi=1000;
  $s=0;
  for($i=0;$i<$n;$i++){
    $x=fgets(STDIN)+0;
    if($x<$mi){$mi=$x;}
    if($x>$ma){$ma=$x;}
    $s+=$x;
  }
  print floor(($s-$ma-$mi)/($n-2));
  print "\n";
}
 
while(1){
  $n=fgets(STDIN);
  if($n==0){break;}
  judge($n);
}
?>

Measured memory_bytes: 6596
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int n, dp[N], h[N], k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
	{
		cin >> h[i];
		dp[i] = MOD;
	}
	dp[1] = 0;
	for (int cur = 2; cur <= n; ++cur)
	{
		for (int steps = 1; steps <= k; ++steps)
		{
			if(cur - steps > 0)
				dp[cur] = min(dp[cur], dp[cur - steps] + abs(h[cur] - h[cur - steps]));
		}
	}
	cout << dp[n];
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   string n;
   cin>>n;
   if((n[0]==n[1] && n[1]==n[2]) || (n[3]==n[1] && n[1]==n[2]))cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}

Measured memory_bytes: 256
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<utility>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)      for (int i = 1;i<=(int)(n);i++)
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         neli            printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define         pb             push_back
#define         pbk            pop_back
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef double                db;
typedef long double           ldb;

int pos(int arr[], int n, int x)
{
    for (int i = 0; i < n; i++)
        if (arr[i] == x)
            return i+1;
}

int fact(int n)
{
   if(n==0)
      return(1);

   return(n*fact(n-1));
}

int main()
{
    //Faysal;
    ll ans,cnt,mx,sum,n,q,x,y,mn;
    string s,t;

    cin>>x>>y;
    mx=max(x,y);
    mn=min(x,y);
    while(mx--)
        cout<<mn;

    neli;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 2018-04-08
 * https://beta.atcoder.jp/contests/abc085/tasks/abc085_a
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        System.out.println(s.replaceAll("2017","2018"));

    }
}


Measured memory_bytes: 23764