akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int INF = 1000000007;
    public static void Main()
    {
        int N = Input.Cin<int>();
        int[] f = Input.Line<int[]>();
        int ans = 0;
        while (true)
        {
            int c = 1;
            bool seach = true;
            bool skip = false;
            for (int i = 0; i < N; i++)
            {
                if (seach && f[i] != 0) { seach = false; skip = true; }
                if (skip && f[i] == 0)
                {
                    skip = false;
                    seach = true;
                    ans += 1;
                }
                if (skip) f[i]--;
            }
            if (skip) ans++;

            if (f.All(v => v == 0)) break;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    public static T Cin<T>()
    {
        if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s);
        if (typeof(T) == typeof(int)) return (T)(object)int.Parse(queue.Dequeue());
        else if (typeof(T) == typeof(long)) return (T)(object)long.Parse(queue.Dequeue());
        else if (typeof(T) == typeof(string)) return (T)(object)(queue.Dequeue());
        else if (typeof(T) == typeof(double)) return (T)(object)double.Parse(queue.Dequeue());
        else return (T)(object)(0);
    }
    public static T Line<T>()
    {
        foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s);
        int c = queue.Count();
        if (typeof(T) == typeof(int[]))
        {
            int[] ret = new int[c];
            for (int i = 0; i < c; i++) ret[i] = Cin<int>();
            return (T)(object)ret;
        }
        else if (typeof(T) == typeof(long[]))
        {
            long[] ret = new long[c];
            for (int i = 0; i < c; i++) ret[i] = Cin<long>();
            return (T)(object)ret;
        }
        else if (typeof(T) == typeof(string[]))
        {
            string[] ret = new string[c];
            for (int i = 0; i < c; i++) ret[i] = Cin<string>();
            return (T)(object)ret;
        }
        else if (typeof(T) == typeof(double[]))
        {
            double[] ret = new double[c];
            for (int i = 0; i < c; i++) ret[i] = Cin<double>();
            return (T)(object)ret;
        }
        else return (T)(object)(0);
    }
}

Measured memory_bytes: 13524
H,W=map(int,input().split())
ans=H*W
if(W%3==0):
  ans=0
else:
  ans=min(ans,H)
x=W//3
s1=x*H
s2=(W-x)*(H//2)
s3=(W-x)*H-s2
ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)))

x=W//3+1
s1=x*H
s2=(W-x)*(H//2)
s3=(W-x)*H-s2
#print(s1,s2,s3)
ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)))

a=H
H=W
W=a
if(W%3==0):
  ans=0
else:
  ans=min(ans,H)
x=W//3
s1=x*H
s2=(W-x)*(H//2)
s3=(W-x)*H-s2
ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)))

x=W//3+1
s1=x*H
s2=(W-x)*(H//2)
s3=(W-x)*H-s2
ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)))

print(ans)

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

int main(){
  int a,b,c,k;	cin >> a >> b >> c >> k;
  if(a<b&&b<c){
    cout << "Yes";
    return 0;
  }
  while(a>=b){
    b=b*2;
    k--;
  }
  while(b>=c){
    c*=2;
    k--;
  }
  if(k<0)	cout <<"No";
  else if(!(a<b&&b<c)) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

bool intersect(LL p1, LL q1, LL p2, LL q2) {
	return !( (q1 < p2) || (p1 > q2) );
}

int main() {
  ios_base::sync_with_stdio(false);
	LL n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	for(LL x = 0; x <= n - 1; x++) {
		LL y = n - 1 - x;
		LL lol = b - a;
		LL lower = c * y, upper = d * y;
		lower += b - a, upper += b - a;
		LL l1 = c * x, u1 = d * x;
		if(intersect(l1, u1, lower, upper)) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
  return 0;
}


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

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    N, x = map(int, input().split())
    A = sorted(map(int, input().split()))

    for a in A:
        if a > x:
            yield 0
            return
        elif x > 0:
            x -= a
            yield 1
        else:
            yield 0
            return

    if x > 0:
        yield -1

print(sum(main()))


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int K = GetInt();
		long[] a = new long[N];
		for(int i = 0; i < N; i++)
			a[i] = GetLong();

		long[] A = new long[N + 1];
		long[] B = new long[N + 1];
		for(int i = 0; i < N; i++)
		{
			A[i + 1] = A[i] + a[i];
			B[i + 1] = B[i] + Math.Max(0, a[i]);
		}

		long ans = 0;
		for(int left = 1; left + K - 1 <= N; left++)
		{
			int right = left + K - 1;
			long score = Math.Max(0, A[right] - A[left - 1]);
			score += B[left - 1] - B[0];
			score += B[N] - B[right];	
			ans = Math.Max(ans, score);		
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 30940
#include <vector>
#include <iostream>
#include <limits>
#include <queue>

using namespace std;


struct edge {
    int v;
    int weight;

    edge(int v, int w) : v(v), weight(w) {}
};

bool operator < (const edge &a, const edge &b) {
  return a.weight > b.weight;
}


int main() {
    auto const INF = numeric_limits<int>::max();

    int V, E, r;
    cin >> V >> E >> r;

    vector<vector<edge>> G(V);
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].emplace_back(t, d);
    }

    // Dijkstra's algorithm
    vector<int> d(V, INF);
    vector<bool> visited(V, false);
    priority_queue<edge> Q;

    Q.emplace(r, 0);
    d[r] = 0;
    while (!Q.empty()) {
        auto e = Q.top(); Q.pop();
        visited[e.v] = true;
        if (d[e.v] < e.weight)
            continue;

        for (auto& u : G[e.v]) {
            int w = u.weight + d[e.v];
            if (!visited[u.v] && w < d[u.v]) {
                d[u.v] = w;
                Q.emplace(u.v, w);
            }
        }
    }

    for (auto x : d) {
        if (x != INF) {
            cout << x << endl;
        } else {
            cout << "INF" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 13044
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a, b = map(int, input().split())
    if a>=10 or b>=10:
        print(-1)
    else:
        print(a*b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
total = 0
MIN = 9999
amari = False
for i in range(5):
    s = int(input())
    smod = int(s % 10)
    if smod == 0:
        total += s
    else:
        total += s - smod + 10
        MIN = min(MIN,smod)
        amari = True
if MIN == 9999:
    MIN = 0
elif amari:
    total -= 10
print(total + MIN)

Measured memory_bytes: 3060
from collections import deque

n,m = map(int,input().split())

edges = {}
ins = [0 for i in range(n)]
for i in range(n+m-1):
    a,b = map(int,input().split())
    if a not in edges:
        edges[a] = [b]
    else:
        edges[a].append(b)
    ins[b-1] += 1

# print(root.pop())

root = -1
for i in range(n):
    if ins[i] == 0:
        root = i+1
        break
que = deque()
que.append(root)
parent = [0 for i in range(n)]
pbuf = [[] for i in range(n)]
counts = [0 for i in range(n)]
while True:
    p = que.popleft()
    if p in edges:
        nex = edges[p]
        edges.pop(p)
    else:
        nex = []
    for n in nex:
        counts[n-1] += 1
        if counts[n-1] == ins[n-1]:
            parent[n-1] = p
            que.append(n)
    if len(que) == 0:
        break

for p in parent:
    print(p)



Measured memory_bytes: 74912
import java.io.*;
import java.util.StringTokenizer;

public final class Main{
    public static void main(String[] args){
        FastScanner stdIn = new FastScanner(System.in);
        String s = stdIn.next();
        char[] sc = s.toCharArray();
        long[] ans = new long[sc.length];

        boolean preIsR = true;
        int preTargetIndex = 0;

        for(int i=0; i<sc.length; i++){
            if(sc[i] == 'L'){
                if(i%2==0){
                    ans[i]++;
                }else{
                    ans[i-1]++;
                }
                preIsR = true;
                preTargetIndex = i;
                break;
            }
        }

        for(int i=1; i<sc.length; i++){
            if(preIsR && (sc[i] == 'R')){
                if((preTargetIndex-i)%2 == 0){
                    ans[preTargetIndex]++;
                }else{
                    ans[preTargetIndex-1]++;
                }
            }else if(preIsR && (sc[i] == 'L')){
                ans[i]++;
                preIsR = false;
            }else if(!preIsR && (sc[i] == 'R')){
                for(int j=i; j<sc.length; j++){
                    if(sc[j] == 'L'){
                        preTargetIndex = j;
                        break;
                    }
                }

                if((preTargetIndex-i)%2 == 0){
                    ans[preTargetIndex]++;
                }else{
                    ans[preTargetIndex-1]++;
                }
                preIsR = true;
            }else{
                if((i-preTargetIndex)%2 == 0){
                    ans[preTargetIndex]++;
                }else{
                    ans[preTargetIndex-1]++;
                }
            }
        }

        for(int i=0; i<ans.length-1; i++){
            System.out.print(ans[i] + " ");
        }
        System.out.println(ans[ans.length-1]);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public long nextInt() {
        return Integer.parseInt(next());
    }

}


Measured memory_bytes: 47796
#include<bits/stdc++.h>
using namespace std;
#define N 5005
#define M 202
 
int n,m,l[N],r[N];
stack<int> q;
long long a[N],b[N][M],f[N][N],ans;
 
int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	n=read();m=read();
	for (int i=2;i<=n;i++)
		a[i]=a[i-1]+read();
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			b[i][j]=read();
	for (int j=1;j<=m;j++){
		b[0][j]=b[n+1][j]=0x3fffffff;
		while (!q.empty()) q.pop();q.push(0);
		for (int i=1;i<=n;i++){
			while (b[q.top()][j]<b[i][j]) q.pop();
			l[i]=q.top()+1;q.push(i);
		}
		while (!q.empty()) q.pop();q.push(n+1);
		for (int i=n;i>=1;i--){
			while (b[q.top()][j]<=b[i][j]) q.pop();
			r[i]=q.top()-1;q.push(i);
		}
		for (int i=1;i<=n;i++){
			f[l[i]][i]+=b[i][j];
			f[l[i]][r[i]+1]-=b[i][j];
			f[i+1][i]-=b[i][j];
			f[i+1][r[i]+1]+=b[i][j];
		}
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
	for (int i=1;i<=n;i++)
		for (int j=i;j<=n;j++)
			ans=max(ans,f[i][j]-a[j]+a[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 203904
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

//Main
var sc = bufio.NewScanner(os.Stdin)
var s string

func main() {
	sc.Split(bufio.ScanWords)
	s = nextStr()
	n := 4
	test := false
	var ans int

	for i := 0; i < (1 << uint(n-1)); i++ {
		sum := str2Int(string(rune(s[0])))
		var w rune
		//l: sの位置
		for l := 1; l < n; l++ {
			//1が出るまで、wに文字列をためていく
			w = rune(s[l])
			//パターンiについて、l番目のしきりが有効であるとき
			if (i & (1 << uint(3-l))) != 0 {
				//ここまでの文字列を数字として足す
				sum += str2Int(string(w))
			} else {
				sum -= str2Int(string(w))
			}
		}
		//残ったAを足す
		//fmt.Println(i, sum)
		if sum == 7 {
			test = true
			ans = i
			break
		}
	}

	if test {
		b := fmt.Sprintf("%03b", ans)
		buf := bufio.NewWriter(os.Stdout)
		//fmt.Println(b)
		for i := 0; i < n-1; i++ {
			var ope string
			if string(b[i]) == "1" {
				ope = "+"
			} else {
				ope = "-"
			}
			buf.Write([]byte(fmt.Sprintf("%s%s", string(s[i]), ope)))
		}
		buf.Write([]byte(fmt.Sprintf("%s=7\n", string(s[3]))))
		buf.Flush()
	}
}


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

class Program {
    static Scanner cin = new Scanner();
    static int N = cin.Int();
    static int K = cin.Int();
    static int[] D = cin.ArrayInt(K);
    static List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    static List<int> ANS = new List<int>();
    static void Main() {
        foreach (var x in D) {
            list.Remove(x);
        }
        foreach (var x in list) {
            if(x != 0) hoge(x);
        }

        ANS = ANS.Where(x => x >= N).ToList();
        Console.WriteLine(ANS.Min());
        Console.ReadLine();
    }

    static void hoge(int n) {
        ANS.Add(n);
        if (n >= 20 * N) return;
        foreach (var x in list) {
            hoge(10 * n + x);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 27688
N=int(input())
sum=0

while N>0:
  if (N%3==0) and (N%5)==0:
    i='FizzBuzz'
  elif (N%3==0):
    i='Fizz'
  elif (N%5==0):
    i='Buzz'
  else:
    i=N
    sum=sum+i
  N=N-1
  
print(sum)

Measured memory_bytes: 9088
#include <iostream>

class A {
public:
    void solve();
};

void A::solve() {
    int a, b, c;
    std::cin >> a >> b >> c;

    int ans = b / a > c ? c : b / a;
    std::cout << ans << std::endl;
}

int main() {
    A solver = A();
    solver.solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
using namespace std; 
typedef long long ll; 
ll ans, fact[25]; 
int arr[25]; 
inline void chk(int len)
{
	ll res = 9 - my_abs(arr[0]); 
	for (int i = 1; i <= len - 1 >> 1; i++)
		res *= 10 - my_abs(arr[i]); 
	ans += res; 
}
void dfs(int cur, int len, ll rem)
{
	if (cur == len >> 1)
	{
		if (!rem)
		{
			arr[cur] = 0; 
			chk(len); 
		}
		return; 
	}
	ll diff = fact[len - cur - 1] - fact[cur]; 
	ll r = ceil((double)rem / diff), l = floor((double)rem / diff); 
	if (-9 <= r && r <= 9)
	{
		arr[cur] = r; 
		dfs(cur + 1, len, rem - diff * r); 
	}
	if (l != r && -9 <= l && l <= 9)
	{
		arr[cur] = l; 
		dfs(cur + 1, len, rem - diff * l); 
	}
}
int main()
{
	// freopen("ARC075-D.in", "r", stdin); 
	ll d;
	scanf("%lld", &d); 
	fact[0] = 1; 
	for (int i = 1; i <= 18; i++)
		fact[i] = fact[i - 1] * 10; 
	for (int cnt = 1; cnt <= 18; cnt++)
	{
		memset(arr, 0, sizeof(arr)); 
		dfs(0, cnt, d);
	}
	printf("%lld\n", ans);
	return 0; 
}


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

int main() {
	int N;
	cin >> N;
	int colors[9] = { 0,0,0,0,0,0,0,0,0 };
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		colors[(a >= 3200 ? 8 : a / 400)]++;
	}
	int min = 0;
	for (int i = 0; i < 8; i++) min += (colors[i] > 0);
	cout << (min==0 && colors[8]>0 ? 1 : min) << " " << min + colors[8] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	string s, t;
	cin>> s>> t;
	int n = s.size(), ans = 0;
	rep(i, 0, n)
		if(s[i] != t[i])
			ans++;
	cout<< ans<< "\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    map<string, int> balls;
    balls[S] = A;
    balls[T] = B;
    balls[U] -= 1;
    cout << balls[S] << " " << balls[T] << endl;
    return 0;
}

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

signed main() {
    ll N;
    cin >> N;
    ll DP[N + 1][4][4][4], res = 0;
    rep(i, N + 1) rep(j, 4) rep(k, 4) rep(l, 4) DP[i][j][k][l] = 0;
    DP[0][3][3][3] = 1;
    rep(i, N) {
        rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4) {
            if (j == 0 && k == 1 && m == 2) continue;
            if (j == 0 && l == 1 && m == 2) continue;
            if (k == 0 && l == 1 && m == 2) continue;
            if (k == 0 && l == 2 && m == 1) continue;
            if (k == 1 && l == 0 && m == 2) continue;
            DP[i + 1][k][l][m] += DP[i][j][k][l];
            DP[i + 1][k][l][m] %= MOD;
        }
    }
    rep(i, 4) rep(j, 4) rep(k, 4) res += DP[N][i][j][k];
    cout << res % MOD << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
b = []

for i in range(n):
    x , y = map(int,input().split());
    a.append(x + y)
    b.append(x - y)

aa = max(a)-min(a)
bb = max(b)-min(b)

if aa >= bb:
    print(aa)
else:
    print(bb)

Measured memory_bytes: 24832
prim=[True]*1000000
prim[0],prim[1]=False,False
for i in range(2,1000):
    if prim[i]:
        for j in range(i*2,1000000,i):
            prim[j]=False
prime=[i for i,j in enumerate(prim) if j==True]

while True:
    n=int(input())
    if n==0:
        break
    print(sum(prime[:n]))

Measured memory_bytes: 18368
#include"stdio.h"
#include"string.h"
#include"stack"
#include"map"
#include"math.h"
#include"iostream"
#include"vector"
#include"queue"
#include"algorithm"
using namespace std;
#define OK printf("\n");
#define Debug printf("this_ok\n");
#define INF 1e18
typedef long long ll;
#define scanll(a,b) scanf("%lld%lld",&a,&b);
#define scanl(a) scanf("%lld",&a);
#define printl(a,b) if(b == 0) printf("%lld ",a); else printf("%lld\n",a);
#define print_int(a,b) if(b == 0) printf("%d ",a); else printf("%d\n",a);
typedef pair<int,int> PII;

inline int read(){
    int s = 0, w = 1; char ch = getchar();
    while(ch < '0' || ch > '9')   { if(ch == '-') w = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') { s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar(); }
    return s * w;
}
const ll mod = 1e9+7;
const int N = 5000010,M = 300010;
const  double pi = acos(-1);
const int inf = 1 << 29;
const int dirx[4] = {-1,0,1,0};

int n,a[N],b[N];

int main(){
    n = read();
    int mark = 1;
    for(int i = 1; i <= n; i ++){
        a[i] = read(); int x = a[i];
        for(int j = 2; j * j <= x; j ++){
           if(x % j) continue;
           if(b[j]) mark = 0;
           b[j] = 1;
            while(x % j == 0){
              x /= j;
            }
        }
        if(x > 1) if(b[x]) mark = 0;
        b[x] = 1;
    }
    int sum = a[1];
    for(int i = 2; i <= n; i ++){
         sum = __gcd(sum,a[i]);
    }
    if(mark == 1) printf("pairwise coprime\n");
    else if(sum == 1) printf("setwise coprime\n");
    else printf("not coprime\n");
}
/*
3
1 2 3
2
2 6
*/



Measured memory_bytes: 11348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define mp make_pair
#define int long long
using namespace std;





int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

typedef pair<int, int> P;

vector<P>x;
signed main() {
	int N, K; cin >> N >> K;
	REP(i, N) {
		int a, b; cin >> a >> b;
		x.pb(mp(a, b));
	}
	VSORT(x);
	ll cnt = 0;
	int i = 0;
	while (cnt < K) {
		cnt += x[i].second;
		i++;
	}
	ll ans = x[i-1].first;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2420
# -*- coding:utf-8 -*-

def solve():
    """
    スカーフをそれぞれs[1]...s[N]とする
    Nは偶数より、
    必ず a[1]^...^a[N] = s[1]^...^s[N] (=Sと置く) になる。

    よって、s[1]が求めたかったら、s[1] = S ^ a[1]で求められる。
    """
    import sys
    N = int(sys.stdin.readline())
    As = list(map(int, sys.stdin.readline().split()))

    S = 0
    for a in As:
        S ^= a

    # 答え
    anss = []
    for i in range(N):
        anss.append(str(S^As[i]))

    ans = " ".join(anss)
    print(ans)


if __name__ == "__main__":
    solve()


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

bool compare(pair< string, pair< int, int > > a, pair< string, pair< int, int > > b){
	if(a.second.first != b.second.first){
		return a.second.first > b.second.first;
	}
	
	return a.second.second < b.second.second;
}

int main(){
	int n;
	vector< pair< string, pair< int, int > > > team;
	
	while(cin >> n, n){
		team.clear();
		team.resize(n);
		
		string str;
		int s, w, l;
		
		for(int i = 0; i < n; ++i){
			cin >> str;
			w = l = 0;
			for(int j = 0; j < n - 1; ++j){
				cin >> s;
				if(s == 0) ++w;
				else if(s == 1) ++l;
			}
			
			team[i] = make_pair< string, pair< int, int > >(str, make_pair< int, int >(w, l) );
		}
		
		sort(team.begin(), team.end(), compare);
		
		for(vector< pair< string, pair< int, int > > >::iterator it = team.begin(); it != team.end(); ++it){
			cout << it->first << endl;
		}
		
	}
	
	return 0;
}

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

int main() {
	vector<bool> v(26,false);
	string s;
	cin >> s;
	for (int i=0;i<s.size();i++) {
		v[s[i]-'a']=!v[s[i]-'a'];
	}
	for (int i=0;i<26;i++) {
		if (v[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
'''
Created on 2020/08/17

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  P=list(map(int,pin().split()))
  ans=0
  m=P[0]
  for i in range(N):
    if m>=P[i]:
      m=P[i]
      ans+=1
  print(ans)
  return 

main()

Measured memory_bytes: 31088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    string S, ans = "None", alp = "abcdefghijklmnopqrstuvwxyz";
    bool found = true;
    cin >> S;
    vector<int> a(26);
    for(char i : S){
        a[i - 'a']++;
    }
    for(int j; j < 26; j++){
        if(a[j] == 0){
            cout << alp[j] << endl;
            found = false;
            break;
        }
    }
    if(found) cout << ans << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

bool visited[200001];

int main()
{
    int n, m;
    cin >> n >> m;
    vector<set<int>> edges(n);
    FROM_0(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a != b)
        {
            edges[a].insert(b);
            edges[b].insert(a);
        }
    }
    FROM_0(i, n)
    {
        visited[i] = false;
    }
    // search
    int maxSize = 0;
    FROM_0(i, n)
    {
        if (visited[i])
            continue;
        int size = 0;
        vector<int> buffer;
        buffer.push_back(i);
        while (!buffer.empty())
        {
            int now = buffer.back();
            buffer.pop_back();
            if (visited[now])
                continue;
            size++;
            visited[now] = true;
            ITER_BEGIN_END(pNext, edges[now])
            {
                if (!visited[*pNext])
                {
                    buffer.push_back(*pNext);
                }
            }
        }
        maxSize = max(size, maxSize);
    }
    cout << maxSize << endl;

    return 0;
}


Measured memory_bytes: 31496
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var score = 0;
var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
//console.log(score);

function main(){
  const d = next();//365
  const n = 26;
  const c = nexts(n);
  var a = xArray(0,n);
  var ans = [];
  for(var i = 0; i < d; i++){
    var s = nexts(n);
    var t = -1e9, id = 0;
    for(var j = 0; j < n; j++){
      a[j] -= c[j];
      var u = s[j] - a[j] + c[j];
      if(t < u)t = u, id = j;
    }
    ans[i] = id+1;
    a[id] = 0;
    score += s[id];
    for(var j = 0; j < n; j++)score += a[j];
  }
  return ans.join("\n");
}

Measured memory_bytes: 33592
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    cout << (A - 1)*(B - 1) << endl;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] nm = br.readLine().split(" ");
    int n = Integer.parseInt(nm[0]);
    int m = Integer.parseInt(nm[1]);
    
    String[] data;
    int[][] switchList = new int[m][n];
    int k;
    int temp;
    for (int i=0; i<m; i++){
      data = br.readLine().split(" ");
      k = Integer.parseInt(data[0]);
      for (int j=0; j<k; j++){
        temp = Integer.parseInt(data[1+j]) - 1;
        switchList[i][temp] = 1;
      }
    }
    int[] p = new int[m];
    String[] ps = br.readLine().split(" ");
    int num;
    boolean allOn;
    for (int i=0; i<m; i++){
      p[i] = Integer.parseInt(ps[i]);
    }
    int[] switches = new int[n];
    int result = 0;
    for (int i=0; i<Math.pow(2, n); i++){
      for (int j=0; j<n; j++){
        switches[j] = (i%(int)Math.pow(2, j+1))/(int)Math.pow(2, j);
      }
      allOn = true;
      for (int j=0; j<m; j++){
        num = 0;
        for (int l=0; l<n; l++){
          num += switchList[j][l]*switches[l];
        }
        if (num%2 != p[j]) allOn = false;
      }
      if (allOn) result++;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 23252
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
*/

		int cnt = b[0];
		for(int i=1; i<a[0]; i++){
			if(0<(b[i]-b[i-1])) cnt += b[i]-b[i-1];
			
			
		}

		string ans = (cnt).ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define mod 1000000007
bool isPrime[1000001];
ll power(ll a,ll b)
{
    ll result = 1;
    while(b>0)
    {
        if(b%2)
        {
            result = (a*result)%mod;
        }
        a = (a*a)%mod;
        b = b/2;
    }
    return result;
}
int gcd(int a,int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
void sieve()
{
    memset(isPrime,1,sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for(int i=2;i*i<=1000000;i++)
    {
        if(isPrime[i])
        {
            for(int j=i*i;j<=1000000;j+=i)
            {
                isPrime[j] = 0;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int t,n;
    string s;
    cin>>s;
    int count = 0;
    bool x =  0;
    int maxi = 0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
        {
            count++;
        }
        else
        {
            count = 0;
        }
        maxi = max(maxi,count);
    }
    cout<<maxi;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
DPっぽいな
あまりはK以上。
組み合わせ数はN*Nで間に合わない
K未満を出すか、

12　4
4-5 4-6 4-7 4-8 4-9 4-10...
5,5-4=1でわりきれ5-5,5-6,5-7...
6-2で2がわりきれ、6-7,6-8...
8-4NG
9-5
あまりが4になるのは、Nが3以下ではありえない
Nが4のときに、5以上で全て
Nが5以上のときの該当がクセ
N-4が、Nの約数でないとき＋１
だめな奴をさがすとして、
かたほうがK以下ならOUT
NとKが互いに素で、N-K
17-6 17%9>KならOK
N*N全部みるけど、規則的にやればN*N/2,ぎりだめ？
全部作るか。
TLEか
100%1=0
100%2=0
100%3=1
100%4=2
100%5=0
100%6=4
100%7=2
100%8=0
100%9=1
100%10=0
100%11=1
100%12=4
100%13=9

1%100=1
2%100=2
...
100%100=0
101%100=1
これっぽいな
108まで、%100
0,9~99まで＋1 1~8 +2
余り0、N+
8なら
8%1=0 8/1=8 8
8%2=0 8/2=4 4,4
8%3=2 8/3=2 2,3,3
            2,2,2,2
            1,2,2,2,1
            1,2,2,1,1,1
            1,2,1,1,1,1,1
            1,1,1,1,1,1,1,1
8 3だった場合
i=4から考え始め
8%4=0 8/4=2 4-3)*2=2
8%5=3 8/5=1 5-3)*1=2
if(8%5>=K) 8%5-(K-1)をプラス、
8%6=2 8/6=1 6-3)*1=3
(i-K)*N/i;
if(N%i>=K)
N%i-K;
でNで計算いける。
*/
int main(){
  ll N,K,ans=0; cin>>N>>K;
  if(K==0){
    cout<<N*N<<endl;
    return 0;
  }
  vector<ll> A(N,0);
  for(int i=K+1; i<=N; i++){
    ans+=(i-K)*(N/i);
    if(N%i>=K)
      ans+=N%i-(K-1);
//        cout<<"i:"<<i<<" ans:"<<ans<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
Int n, l, t;
Int x[216000], w[216000];
Int ans[216000];

int main(){
  cin >> n >> l >> t;
  for(Int i = 0;i < n;i++){
    cin >> x[i] >> w[i];
  }
  Int start = 0;
  Int crush = 0;
  while(start < n && w[start] == 2)start++;
  if(start == n){start = 0;goto calc;}
  for(Int i = 0;i < n;i++){
    if(w[start] == w[i])continue;
    Int dist = x[i] - x[start];
    if(dist < 0)dist += l;
    if(dist > t*2)continue;
    crush += 1 + (2*t-dist) /l;
  }
 calc:
  for(Int i = 0;i < n;i++){
    if(w[i] == 1)
      x[i] = (x[i] + t) % l;
    else
      x[i] = ((x[i] - t) % l + l) % l;
  }
  Int pos = x[start];
  sort(x, x + n);
  Int k = 0;
  while(x[k] != pos)k++;
  if(k < n-1 && x[k+1] == x[k])k++;
  for(Int i = 0;i < n;i++){
    ans[(start + crush + i) % n] = x[(k+i)%n];
  }
  for(Int i = 0;i < n;i++)cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 4480
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';
int dp[50000];
int find(int sum){
    if(dp[sum] >= 0)return dp[sum];
    
    if(sum == 0)return 1;
    else if(sum < 0) return 0;
    
    int ans=0;
    for(int i  =3  ; i<= 3000 ; i ++ ){
        if(sum-i < 0)break;
        int val = find(sum-i);
        if(val > 0)
            dp[sum-i] = val;
        ans = (ans + val)%MOD;
    }
    
    return ans;
    
}
int32_t main(){
    boost;
    for(int i =0 ; i <50000 ; i++ )dp[i]=-1;
    
    int n;
    cin>>n;
    int ans = find(n);
    cout<<ans<<endl;
}

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

using namespace std;

const int maxn = 3e5 + 5;

int n, a[maxn], b[maxn];
string s;

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

  a[0] = (s[0] == 'W' ? 1 : 0);
  b[0] = (s[0] == 'E' ? 1 : 0);
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1];
    b[i] = b[i - 1];
    if (s[i] == 'W') a[i]++;
    else b[i]++;
  }

  int ans = 1e9;
  for (int i = 0; i < n; i++) {
    int res = 0;
    if (i) {
      res += a[i - 1];
    }
    if (i != n - 1) {
      res += b[n - 1] - b[i];
    }
    ans = min(ans, res);
  }

  cout << ans;
  return 0;
}


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

int even[100010], odd[100010];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int v;
    cin >> v;
    if (i % 2 == 0) {
      even[v]++;
    } else {
      odd[v]++;
    }
  }
  int max_even = 0, max_odd = 0, ans = n;
  for (int i = 0; i < 100010; i++) {
    if (even[max_even] < even[i]) max_even = i;
    if (odd[max_odd] < odd[i]) max_odd = i;
  }
  for (int i = 0; i < 100010; i++) {
    if (i != max_odd)
      ans = min(ans, n / 2 - odd[max_odd] + (n - n / 2) - even[i]);
    if (i != max_even)
      ans = min(ans, n / 2 - odd[i] + (n - n / 2) - even[max_even]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
bool A[200001];
inline int read(){
  int ans=0,c=getchar_unlocked();
  while(c<'0'||c>'9')c=getchar_unlocked();
  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}
  return ans;
}
int main(){
  int n,m,a,b;n=read();m=read();
  while(m--){a=read();b=read();
    if(a==1){
      if(A[b]==true)return puts("POSSIBLE"),0;
      A[b]=true;
    }
    if(b==n){
      if(A[a]==true)return puts("POSSIBLE"),0;
      A[a]=true;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  int H,i,A[251];

 scanf("%d",&H);
 
 for(i=1;i<=H;i++){
   scanf("%d",&A[i]);
 }
for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    
    if(i/2>0)  printf("parent key = %d, ",A[i/2]);
 
    if(2*i >0 && 2*i<=H)    printf("left key = %d, ",A[2*i]);
 
    if(2*i+1>1 && 2*i+1 <=H)    printf("right key = %d, ",A[2*i+1]);
     
    printf("\n");
  }
 

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <fstream>
using namespace std;

string s, tar = "CODEFESTIVAL2016";
int ans;
int main() {
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != tar[i]) ans++;
	}
	cout << ans << endl;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;


int64_t power(int64_t n, int64_t p, int64_t m){
  int64_t ret = 1;
  while(p > 0){
    if(p & 1) (ret *= n) %= m;
    (n *= n) %= m;
    p >>= 1;
  }
  return ret;
}


int main(){
  int N, P;
  string S;

  while(cin >> N >> P >> S){
    i64 ans = 0;

    if(P == 2 or P == 5){
      REP(i,N){
        int d = S[i] - '0';
        if(d % P == 0){
          ans += i + 1;
        }
      }
    }else{

      vector<int> U(N+1);
      REV(i,N-1,0){
        U[i] = (U[i+1] + power(10, N-i-1, P) * (S[i]-'0')) % P;
      }

      dump(U);
      
      map<int, i64> count;
      count[0] = 1;

      REV(i,N-1,0){
        ans += count[U[i]];
        count[U[i]] += 1;
      }
    }

    puts_all(ans);
  }


  return 0;
}


Measured memory_bytes: 1812
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))

dp = [sys.maxsize]*n
dp[0]=0

for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))

      
print(dp[n-1])


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

int main() {
  int n; cin >> n;
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  
  sort(s.begin(), s.end());
  int x=1;
  for(int i=0; i<n-1; i++){
    if(s[i]!=s[i+1]) x++;
  }
  
  cout << x << endl;
  
}

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

int main(){
  int k;cin>>k;
  vector<bool> f(k,false);

  int t=7%k;f.at(t)=true;
  REP(i,k){
    if(t==0){
      cout<<i+1;
      return 0;
    }
    t=(t*10+7)%k;
    if(f.at(t)) break;
  }
  cout<<-1;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;

int main(void)
{
	int n;
	int x;
	cin >> n >> x;
	if (n == 2) {
		if (x == 2) {
			cout << "Yes" << endl;
			rep(i, 3) cout << i + 1 << endl;
		} else cout << "No" << endl;
		return 0;
	}
	if (x != 2 * n - 1 && x != 1) {
		cout << "Yes" << endl;
		vector<int> ans(2 * n - 1);
		ans[n - 1] = x;
		if (x < n) {
			ans[n - 2] = 1;
			ans[n - 3] = x + 1;
			ans[n] = x + 2;
			int ind = 1;
			rep(i, 2 * n - 1) {
				if (n - i >= 0 && n - i <= 3) continue;
				if (ind == 1) ind = 2;
			   	if (ind == x || ind == x + 1 || ind == x + 2) ind = x + 3;
				ans[i] = ind;
				ind++;
			}
		} else {
			ans[n - 2] = 2 * n - 1;
			ans[n - 3] = x - 1;
			ans[n] = x - 2;
			int ind = 1;
			rep(i, 2 * n - 1) {
				if (n - i >= 0 && n - i <= 3) continue;
			   	if (ind == x - 2 || ind == x - 1 || ind == x) ind = x + 1;
				ans[i] = ind;
				ind++;
			}
		}
		rep(i, 2 * n - 1) cout << ans[i] << endl;
	} else cout << "No" << endl;
	return 0;
}


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

int main() {
	int n, count=0;
	std::cin>>n;
	int ara[n];
	int arb[n];

	for(int i=0; i<n; i++){
        std::cin>>ara[i];
        arb[i]=ara[i];
    }

	std::sort(ara, ara+n);

	for(int i=0; i<n; i++) if(ara[i]!=arb[i]) count++;

	if(count==2 || count==0) std::cout<<"YES";
	else std::cout<<"NO";
}


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

int main() {
    int N, sum = 0;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++){
        cin >> B.at(i);
        sum += B.at(i);
    }
    for (int i = 0; i < N - 1; i++){
        cin >> C.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        if (A.at(i) + 1 == A.at(i + 1)) {
            sum += C.at(A.at(i) - 1);
        }
    }
    cout << sum << endl;
}

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

int main() {
	long a;
	long b;
	long d;
	long r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f\n", d, r, f);
	return 0;
}

Measured memory_bytes: 1188