akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    int f = ((x * 2 == W) && (y * 2 == H))? 1 : 0;
    printf("%f %d\n", (double)W * (double)H / 2, f);

    return 0;
}


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

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

	int N;
	int i,j;
	int tmp;
	int ans=0;
	int ctr=0;

	vector<int> bi(9);
	rep(i,9)
		cin >> bi[i];

	cin >> N;
	rep(i,N){
		cin >> tmp;
		rep(k,9) if(bi[k]==tmp) bi[k]=0;
	}

	if(	bi[0]==bi[1] && bi[1]==bi[2] ||
		bi[3]==bi[4] && bi[4]==bi[5] ||
		bi[6]==bi[7] && bi[7]==bi[8] ||
		bi[0]==bi[3] && bi[3]==bi[6] ||
		bi[1]==bi[4] && bi[4]==bi[7] ||
		bi[2]==bi[5] && bi[5]==bi[8] ||
		bi[0]==bi[4] && bi[4]==bi[8] ||
		bi[6]==bi[4] && bi[4]==bi[2]  )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007


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

    bool colors[8] = {false};
    int result_max = 0;
    int result_min = 0;
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        if(a>=3200){
            result_max++;
        }else{
            for(int j = 1; j <= 8; j++){
                if(a < j*400 and (j-1)*400 <= a){
                    colors[j-1] = true;
                }
            }
        }
    }

    for(int i = 0; i < 8; i++){
        if(colors[i]){
            result_max++;
            result_min++;
        }
    }

    if(result_max > 0 and result_min == 0){
        result_min = 1;
    }

    cout << result_min << " " << result_max << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef vector<pii> vpii;
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
    tree_order_statistics_node_update> ost;

const int N=110000;
vi adj[N];
int m[N], mr[N];

void dfs(int x, int p) {
    mr[x]=1;
    for(int y: adj[x]) if(y!=p) {
        dfs(y, x);
        m[x]=(mr[x]&&mr[y]) || (m[x]&&m[y]);
        mr[x]=mr[x]&&m[y];
    }
}

int main() {
    int i, n, u, v;
    scanf("%d", &n);
    for(i=0; i<n-1; i++) {
        scanf("%d%d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1, 0);
    printf(m[1]? "Second\n" : "First\n");
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(M);
    map<pair<int,int>,int> mp;
    vector<P> vec,ins;
    REP(a,M){
        CIN(b);CIN(c);
        vec.push_back(make_pair(c,b));
    }
    ins = vec;
    sort(ALL(vec));
    I cou(N+1,1);
    for(int a = 0;a < M;a++){
        mp[vec.at(a)]=cou.at(vec.at(a).second);
        cou.at(vec.at(a).second)++;
    }
    for(int a = 0;a < M;a++){
        string s = to_string(ins.at(a).second);
        string num = to_string(mp[ins.at(a)]);
        while(s.size()!=6){
            s = "0"+s;
        }
        while(num.size() !=6){
            num = "0"+num;
        }
        COUT(s+num);
    }
}


Measured memory_bytes: 11248
package main

import "fmt"

func main() {
	var N, x int
	fmt.Scan(&N, &x)

	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}

	c := 0
	for i := 1; i < N; i++ {
		b := a[i-1] + a[i]
		n := b - x

		if n <= 0 {
			continue
		}

		c += n

		n -= a[i]
		if n < 0 {
			a[i] = -n
		} else {
			a[i] = 0
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 5504
import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals(".")==true) break;
			String[] line2 = line.split("");
			Stack<String> stack = new Stack<String>();
			boolean flag=true;
			for(int i=0;i<line2.length;++i){
				if(line2[i].matches("[(\\[]")==true){
					stack.add(line2[i]);
				}
				if(line2[i].equals(")")==true){
					if(!stack.isEmpty()&&stack.peek().equals("(")==true) stack.pop();
					else flag=false;
				}
				if(line2[i].equals("]")==true){
					if(!stack.isEmpty()&&stack.peek().equals("[")==true) stack.pop();
					else flag=false;
				}
				if(flag==false) i=line2.length;
			}
			if(stack.isEmpty()&&flag==true) System.out.println("yes");
			else System.out.println("no");
		}
	}
}



Measured memory_bytes: 104180
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;

int main(){
    IOS
    ll a , b ,c;
    cin >>a>>b>>c;
    if (c >= a){
        c-=a;
        a = 0;
        if(c >=b){
            c-=b;
            b =0;
        }else{
            b-=c;
            c =0;
        }

    }else {
        a-=c;
        c=0;
    }
    cout << a<< " "<< b ;
    return 0;
}

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<char> ans(s.size());
	
	rep(i, s.size()){
		if(90 < s.at(i)+n){
			ans.at(i) = (s.at(i)+n) - 90 + 64; 
		}else{
			ans.at(i) = s.at(i)+n;
		}
	}

	rep(i, ans.size()) cout << ans.at(i);
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char N[5];
int main(){
  int i;
  rd(N);
  for(i=0;i<3;i++){
    if(N[i]=='1'){
      N[i] ='9';
    }
    else{
      N[i] ='1';
    }
  }
  wt_L(N);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// char N[5];
// {
//   int i;
//   rd(N);
//   rep(i,3) N[i] = if[N[i]=='1', '9', '1'];
//   wt(N);
// }


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;

void main() {
  auto A = readln.chomp.to!int;
  auto B = readln.chomp.to!int;
  auto C = readln.chomp.to!int;
  auto D = readln.chomp.to!int;

  writeln(min(A, B) + min(C, D));
}


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

int main(){
  string s;
  cin >> s;
  vector<pair<int,int> > vp(26,pair<int,int>(-1,-1));
  int x;
  int N=s.size();
  for(int i=0;i<N;i++){
    x=s.at(i)-'a';
    vp.at(x).second=max(vp.at(x).second,i-vp.at(x).first-1);
    vp.at(x).first=i;
  }
  int ans=1e8;
  for(auto p:vp){
    if(p.first!=-1){
      ans=min(ans,max(p.second,N-p.first-1));
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>

struct Point{double x,y;};

void koch(int n,Point a,Point b){
  if(n==0) return;
  Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  Point a,b;
  int n;

  scanf("%d",&n);

  a.x=0;
  b.x=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

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

int cmp(const void *,const void *);

int
main()
{
  	int N;
  	scanf("%d",&N);
  	int L[N];
  	int i;
  	for (i=0;i<N;i++){
      	scanf("%d",&L[i]);
    }
  
  	qsort(L,sizeof(L)/sizeof(int),sizeof(int),cmp);
  	
  	int goukei=0;
  	for (i=1;i<N;i++){
      	goukei += L[i];
    }
  	
  	if(L[0]<goukei){
      	printf("Yes");
    }else{
      	printf("No");
    }
  
  	return 0;
 
}

int
cmp(const void *a,const void *b){
	return *(int *)b- *(int *)a;
}

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

using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 0 && a <= 9 && b >= 0 && b <= 9) {
		cout << a * b;
	}
	else {
		cout << -1;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

K, N = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(N-1):
    B.append(A[i+1] - A[i])
B.append(K - A[N-1] + A[0])
print(sum(B) - max(B))





Measured memory_bytes: 25880
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 3*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int sum(int n){
    if(n==0)return 0;
    else return n+sum(n-1);
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    int a,b;
    cin>>a>>b;
    cout<<(b-a)*(b-a-1)/2-a<<enl;



    return 0;
}


Measured memory_bytes: 3544
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, mut k) = (v[0], v[1]);
    let a = read_vec::<usize>();
    let a = a.iter().map(|&x| x - 1).collect::<Vec<_>>();

    let mut next = vec![vec![0; n]; 62];
    next[0] = a;

    for i in 1..62 {
        for j in 0..n {
            next[i][j] = next[i - 1][next[i - 1][j]];
        }
    }
    let mut cur = 0;
    for i in (0..62).rev() {
        if (1 << i) <= k {
            k -= 1 << i;
            cur = next[i][cur];
        }
    }
    println!("{}", cur + 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(){
  char str[210] = {0};
  int count = 0;
  int i, j, half;
  std::cin >> str;

  while(str[count]) count++;
  for(i = 2; i <= count; i+=2){
    half = (count - i) / 2;
    for(j = 0; j < half && str[j] == str[half+j]; j++);
    if(j == half) break;
  }

  std::cout << half * 2;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void print(int A[], int n)
{
	int i;
	for (i = 0; i < n; i++)
	{
		printf("%d", A[i]);
		if (i != n - 1)
			printf(" ");
	}
	printf("\n");
}

int main()
{
	int n;

	scanf("%d", &n);

	int i = 2;

	printf("%d:", n);

	while (i <=sqrt(n))
	{
		if (n % i == 0)
		{
			printf(" %d", i);
			n /= i;
		}
		else
			i++;
	}
	printf(" %d\n",n);
}


Measured memory_bytes: 2108
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int Main(string[] args) {
        List<string> list = new List<string>();

        string str = Console.ReadLine();

        int q = int.Parse(Console.ReadLine());

        for (int i = 0; i < q; i++) {
            string[] s = Console.ReadLine().Split(' ');

            int a = int.Parse(s[1]);
            int b = int.Parse(s[2]);

            if (s[0] == "print") {
                list.Add(str.Substring(a, b - a + 1));
            }
            else if (s[0] == "reverse") {
                str = StrReverse(str, a, b);
            }
            else if (s[0] == "replace") {
                str = StrReplace(str, a, b, s[3]);
            }
        }

        for (int i = 0; i < list.Count; i++) {
            Console.WriteLine(list[i]);
        }
        return 0;
    }

    static string StrReplace(string str, int a, int b, string p) {
        string v = string.Empty;

        if (a > 0) {
            v = str.Substring(0, a);
        }
        v += p;
        v += str.Substring(b + 1);
        return v;
    }

    static string StrReverse(string str, int a, int b) {
        string v = string.Empty;
        if (a > 0) {
            v = str.Substring(0, a);
        }

        for (int i = b; i >= a; i--) {
            v += str.Substring(i, 1);
        }

        v += str.Substring(b + 1);

        return v;
    }
}


Measured memory_bytes: 20092
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  if (A >= (B + C)) {
    cout << 0 << endl;
  } else {
    cout << (C - A) + B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_V = 2000;

struct union_find_tree{
    int par[MAX_V], rank[MAX_V], num[MAX_V];
    //要素数n(0〜n-1)の初期化されたUnion-Find木を構築
    union_find_tree(int N){
        rep(i, N){par[i] = i, rank[i] = 0, num[i] = 1;}
    }
    //ノードxの根を取得
    int find(int x){
        if(par[x] == x) return x;
        else return find(par[x]);
    }
    //xとyの属する集合を併合
    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return;
        elif(rank[x] < rank[y]){par[x] = y, num[y] += num[x];}
        else{
            par[y] = x, num[x] += num[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    //xの属する集合の要素数を取得
    int size(int x){
        return num[find(x)];
    }
    //xとyが同じ集合に属するか判定
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    set<int> es[N];
    rep(i, M){
        int u, v;
        cin >> u >> v;
        u--, v--;
        es[u].insert(v), es[v].insert(u);
    }
    union_find_tree uft(2*N);
    rep(i, N){
        rep(j, N){
            if(i == j) continue;
            //iとjがつながっていなかったら別のグループ
            if(!es[i].count(j)){
                if(uft.same(i, j)){
                    cout << -1 << endl;
                    exit(0);
                }
                uft.unite(i, N+j);
                uft.unite(N+i, j);
            }
        }
    }
    vector<int> vec;
    int sum = 0;
    rep(i, N){
        //すでにiの連結成分を考えているか
        bool used = false;
        rep(j, i){
            if(uft.same(i, j) || uft.same(i, N+j)) used = true;
        }
        if(used) continue;
        //iと同じ、別グループである必要がある頂点の数
        int a = 0, b = 0;
        rep(j, N){
            if(uft.same(i, j)) a++;
            if(uft.same(i, N+j)) b++;
        }
        vec.pb(abs(a-b));
        sum += a+b;
    }
    //vecの中身を足すか引くかしてどれだけ絶対値を小さくできるか
    int n = vec.size();
    bool dp[n+1][2000];
    fill(dp[0], dp[n+1], false);
    dp[0][0] = true;
    rep(i, n){
        rep(j, 1000){
            if(dp[i][j]){
                dp[i+1][j+vec[i]] = true;
                dp[i+1][abs(j-vec[i])] = true;
            }
        }
    }
    int m = inf;
    rep(i, 1000){
        if(dp[n][i]){m = i; break;}
    }
    int x = (sum+m)/2;
    x = max(x, N/2);
    cout << x*(x-1)/2 + (N-x)*(N-x-1)/2 << endl;
}

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

signed main()
{

	int n;
	cin>>n;

	int a[n];
	int dp[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	
	{
		dp[0]=0;
		dp[1]=abs(a[1]-a[0]);
		for(int i=1; i<n;i++)
		{
			dp[i]= min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i-2]-a[i]));
		}
		cout<<dp[n-1];
	}
}









Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define INF INT32_MAX
#define INFL INT64_MAX
using namespace std;

void solve()	{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans=-INF;
	for(int i=0; i<n; i++)	{
		int cnt[27];
		int c=0;
		memset(cnt,0,sizeof(cnt));
		for(int j=0; j<=i; j++)	{
			cnt[s[j]-'a']++;
		}
		for(int j=i+1; j<n; j++)	{
			if(cnt[s[j]-'a'])	{c++; cnt[s[j]-'a']=0;}
		}
		ans=max(ans,c);
	}
	cout << ans << endl;
}

int main()	
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; ; i++){
		if((a*i)%360==0){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

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

int main() {
	// your code goes here
    int N;
    cin>>N;
    vector <int> vect(N*2);
    for(int i = 0; i < N*2; i++)
    {
        cin>>vect[i];
    }
    sort(vect.begin(),vect.end());
    int res = 0;
    for(int i = 0; i < N*2; i +=2)
    {
        res = res + vect[i];
    }
    cout<<res;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pie 3.142857143
#define ll long long int
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define vi vector<int>
#define vlli vector<ll>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fv(i,a) for(auto i:a)
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define frv(i,c) for(auto i = c.begin(); i != c.end(); i++)

void solve()
{
	ll n;
	cin >> n;
	int dp[3] = {0};
	int c[3];
	fr (i, 0, n)
	{
		fr (j, 0, 3)
		cin >> c[j];
		int ndp[3] = {0};
		fr(i, 0, 3)
		{
			fr(j, 0, 3)
			{
				if (i != j)
				{
					ndp[j] = max(dp[i] + c[j], ndp[j]);
				}
			}
		}
		fr(i, 0, 3)
		dp[i] = ndp[i];

	}
	cout << max(dp[0], max(dp[1], dp[2])) << endl;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen ("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin>>t;
	t = 1;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int a, b, d, r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = 1.0 * a / b;

	printf("%d %d %f", d, r, f);

	return 0;
}

Measured memory_bytes: 636
import sys, os, bisect

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , k = f()
    a = f()

    ans = int(1e10)
    for i in range(n):
        if i+k-1<n:
            cur_ans = 0
            if a[i]* a[i+k-1]>=0:
                cur_ans = max(abs(a[i+k-1]),abs(a[i]))
            else:
                cur_ans = min(2*abs(a[i])+abs(a[i+k-1]), abs(a[i]) + 2*abs(a[i+k-1]))
            ans = min(ans, cur_ans)
    
    print(ans)

solve()


Measured memory_bytes: 14568
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// debug 도구

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto& x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

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

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main() {
    int n,i;
    cin>>n;
    int x[n];
    for (i=0;i<n;i++) cin >> x[i];
    for (;--i>0;) cout << x[i] << " ";
    cout << x[0] << endl;
    return 0;
}

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

using namespace std;

string s;
map < string , int > cnt;
int main()
{
    int n;  cin >> n;
    long long ans = 0;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> s;
        sort(s.begin(),s.end());

        ans += cnt[s];
        cnt[s]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#include<climits>
using namespace std;
int main()
{
    long long int n,m,i,k,l,p=0,j,sum,x=1;
    p = INT_MAX;
    int t = INT_MAX;
    cin>>n>>m>>k;
    int a[n],b[m],c[k],d[k],e[k];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<m; i++)
    {
        cin>>b[i];
    }
    for(i=0; i<k; i++)
    {
        cin>>c[i]>>d[i]>>e[i];
        l = a[c[i]-1]+b[d[i]-1]-e[i];
        if(p>l)
        {
            p = l;
        }
    }
    sort(a,a+n);
    sort(b,b+n);
    t = a[0]+b[0];
    if(p>t){
    cout<<t;
    }
    else
    {
        cout<<p;
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, ans=0;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a.at(i);
    sort(all(a));
    int now=1;
    REP(i, n-1){
        if(a.at(i) != a.at(i-1)){
            ans += now % 2;
            now=1;
        }
        else now++;
    }
    cout << ans+now%2;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[200000],y[200000];
signed main(){
	int a;
	cin>>a;
	f(i,a){
		cin>>x[i];
		y[i]=x[i];
	}
	sort(x,x+a);
	f(i,a){
		if(y[i]==x[a-1])cout<<x[a-2]<<endl;
		else cout<<x[a-1]<<endl;
	}
}


Measured memory_bytes: 4736
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	al = list(IN())
	#b , c = IN()
	#s = input()
	cc=[0]*a
	for v in al:
		cc[v-1]+=1
	for c in cc:
		print(c)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  
  if(k <a){
    cout << a-k << " " << b << endl;
  }else if(a + b > k){
    cout << 0 << " " << b-(k-a) << endl;
  }else{
    cout << 0 << " " << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


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

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

  ll ans = 0;
  for(int i=1;i<n+1;i++){
    for (int j=i;j<n+1;j++){
      for(int k=j;k<n+1;k++){
        int v = gcd(i, j);
        v = gcd(v, k);
        if (i == j && j == k) ans += v;
        else if (i != j && j != k && k != i) ans += v*6;
        else ans += v*3;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int here=0,n,sum=0;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    sum+=p[i];
    if((p[i]%10!=0) && (here==0 || here>p[i])){here=p[i];}
  }
  if(here==0){cout << 0 << endl;}
  else{
    if(sum%10==0){sum-=here;}
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100050];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,x;
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
a[x]++;
}
int ans=0;
for(int i=1;i<=100005;i++){
ans=max(ans,a[i-1]+a[i]+a[i+1]);
}
cout<<ans;
}

Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    x,y,z = LI()
    x -= z*2
    r = x // (z+y)
    x %= z+y
    if x >= y:
        r += 1
    return r


print(main())




Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll NCK_MAX = 510000;
ll extgcd(ll a, ll b, ll& x, ll& y) {
  if (b == 0) {
    x = 1, y = 0; return a;
  }
  ll q = a/b, g = extgcd(b, a - q*b, x, y);
  ll z = x - q * y;
  x = y;
  y = z;
  return g;
}
 
ll invmod (ll a, ll m) { // a^-1 mod m
  ll x, y;
  extgcd(a, m, x, y);
  x %= m;
  if (x < 0) x += m;
  return x;
}


ll COM(ll n,ll k,ll mod){// nが大きくてkが小さいとき
    ll ans=1;
    for(ll i=0;i<k;i++){
        ans=((ans*(n-i)%mod)*invmod(k-i,mod))%mod;
    }
    return ans;
}
int main(void){
    ll X,Y;
    cin>>X>>Y;
    bool ok=true;
    if((X+Y)%3!=0) ok=false;
    ll a=(X+Y)/3;
    ll x=X-a,y=Y-a;
    if(x<0||y<0) ok=false;
    if(ok){
        cout<<COM(x+y,x,mod)<<endl;
    }
    else cout<<0<<endl;
}

Measured memory_bytes: 256
import Control.Monad(forM_)

main = do
  ns <- lines <$> getContents
  let is = map (\n -> read n::Int) $ words $ head ns
  let h = head is
  let w = last is
  let ls = tail ns
  let res = reverse $ solve h w ls [(replicate (w + 2) '#')]
  forM_ res putStrLn

solve :: Int -> Int -> [String] -> [String] -> [String]
solve h w ls acc
  | ls == [] = replicate (w + 2) '#' : acc
  | otherwise = solve (subtract 1 h) w (tail ls) (l : acc)
  where
    he = head ls
    l = "#" ++ he ++ "#"

Measured memory_bytes: 1404
#include<iostream>
using namespace std;
string N;
int K;
long dp[111][2][4];
main()
{
	cin>>N>>K;
	dp[0][0][0]=1;
	for(int i=0;i<N.size();i++)
	{
		for(int j=0;j<2;j++)
		{
			int lim=j?9:N[i]-'0';
			for(int k=0;k<=K;k++)
			{
				for(int l=0;l<=lim;l++)
				{
					int nk=k+!!l;
					if(nk<=K)
					{
						dp[i+1][j||l<lim][nk]+=dp[i][j][k];
					}
				}
			}
		}
	}
	cout<<dp[N.size()][0][K]+dp[N.size()][1][K]<<endl;
}


Measured memory_bytes: 256
def check(p, n, w, k):
	temp = 0
	for i in range(n):
		if w[i] > p:
			return False
		if temp + w[i] > p:
			temp = 0
			k -= 1
			if k < 0:
				return False
		temp += w[i]
	if k == 0:
		return False
	else:
		return True

def main():
	n, k = map(int,input().split())
	w = []
	for _ in range(n):
		w += [int(input())]
	pmin = 0
	pmax = 10**10
	while True:
		if pmin >= pmax:
			print(pmin)
			break
		if check(int((pmin+pmax)/2),n,w,k):
			pmax = int((pmin+pmax)/2)
		else:
			pmin = int((pmin+pmax)/2)+1

main()


Measured memory_bytes: 9560
var
 a,b,c,i:longint;
 f:array[-100..100] of longint;
begin
 readln(a,b,c);
 inc(f[a]);inc(f[b]);inc(f[c]);
 for i:=-100 to 100 do
  if f[i]=1 then begin writeln(i);exit; end;
end.

Measured memory_bytes: 128
#include<stdio.h>

int func(int a, int b, int c){
    if(a < b+c && b < a+c && c < a+b){
        return 1;
    }
    return 0;
}

void swap(int* a, int* b){
    int buf = *a;
    *a = *b;
    *b = buf;
}

void sort(int* a, int n){
    if(n <= 1){
        return;
    }
    int l = 0, r = n-1;
    int p = *(a + (n/2));
    while(l <= r){
        while(*(a+l) > p){
            l++;
        }
        while(p > *(a+r)){
            r--;
        }
        if(r <= l){
            break;
        }
        swap(a+l, a+r);
        l++;
        r--;
    }
    sort(a, l);
    sort(a+r+1, n-r-1);
}

int main(){
    int n;
    scanf("%d", &n);
    int l[n];
    for(int i=0; i<n; i++){
        scanf("%d", &l[i]);
    }
    sort(l, n);
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(func(l[i], l[j], l[k]) == 1){
                    //printf("%d %d %d\n", l[i], l[j], l[k]);
                    ans++;
                }else{
                    break;
                }
            }
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")
#pragma GCC target("sse4.1")

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = ((int)(n) - 1); i >= 0; --i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

const int mod = 998244353;

void add (int &a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
}

void sub (int &a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
}

int mult (int a, int b)
{
    return (ll)a * b % mod;
}

string start;

bool read ()
{
    if (!(cin >> start))
        return false;

    return true;
}

int cnt_subsets (const string &s, map<string, int> &dp)
{
    if (s.empty())
        return 1;

    auto it = dp.find (s);
    if (it != dp.end())
        return it -> snd;

    int ans = mult(1 + s[0] - '0', cnt_subsets(s.substr(1), dp));
    for (int k = 2; k <= sz(s); k++)
    for (int block = 1; block * k <= sz(s); block++)
    {
        string what (block, '1');
        forn (i, block * k) if (s[i] == '0')
            what[i % block] = '0';
        add (ans, mult (cnt_subsets (what, dp), cnt_subsets(s.substr(block * k), dp)));
    }

    return dp[s] = ans;
}

int solve ()
{
    map<string, int> dp;
    auto res = cnt_subsets (start, dp);
    return res;
}

int32_t main()
{
#ifdef LOCAL
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
    {
        auto ans = solve();
        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const ll inf = 1e9 + 7;
const int MAXN = 2 * 1e5 + 10;

	
int main(){		
	int n; cin >> n;
	int W = 0, A = 0, T = 0, R = 0;
	for(int i = 0; i < n; ++i){
		string t; cin >> t;
		if(t == "AC"){++A;}
		else if(t == "WA"){++W;}
		else if(t == "TLE"){++T;}
		else{
			++R;
		}
	}
	cout << "AC x " << A << endl; 
	cout << "WA x " << W << endl; 
	cout << "TLE x " << T << endl; 
	cout << "RE x " << R << endl; 


	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll K;
    cin >> K;
    string S;
    cin >> S;

    ll N = S.size();

    if(N <= K){
        cout << S << endl;
        return 0;
    }

    REP(i,K){
        cout << S[i];
    }

    cout << "..." << endl;

    return 0;
}


Measured memory_bytes: 3620
n,k=map(int,input().split())
a=list(map(int,input().split()))
def f(x):
    global a,n,k
    if x==0:
        return 10**10
    ret=0
    for i in range(n):
        #print(-((-a[i])//x))
        ret+=(-((-a[i])//x)-1)
    return ret

l,r=0,10**10
while l+1<r:
    x=l+(r-l)//2
    if f(x)<=k:
        r=x
    else:
        l=x

print(r)
#print(f(r))

Measured memory_bytes: 93928
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	int n;
	while(scanf("%d", &n), n){
		Vp base;
		int m;
		scanf("%d", &m);
		rep(i,m){
			int x,y;
			scanf("%d%d", &x,&y);
			base.pb(P(x,y));
		}
		for(int i = 1; i < m; i++){
			base[i].fi -= base[0].fi;
			base[i].sec -= base[0].sec;
		}
		base[0].fi = 0;
		base[0].sec = 0;
		rep(u,n){
			Vp line;
			scanf("%d", &m);
			rep(i,m){
				int x, y;
				scanf("%d%d", &x, &y);
				line.pb(P(x,y));
			}
			if(m != base.size()) continue;
			for(int i = 1; i < m; i++){
				line[i].fi -= line[0].fi;
				line[i].sec -= line[0].sec;
			}
			line[0].fi = 0;
			line[0].sec = 0;
			rep(v,2){
				bool ok = true;
				rep(i,m){
					if(line[i].fi != base[i].fi || line[i].sec != base[i].sec){
						ok = false;
						break;
					}
				}
				if(ok){
					printf("%d\n",u+1);
					break;;
				}
				ok = true;
				rep(i,m){
					if(line[i].fi != -1*base[i].fi || line[i].sec != -1*base[i].sec){
						ok = false;
						break;
					}
				}
				if(ok){
					printf("%d\n",u+1);
					break;
				}
				ok = true;
				rep(i,m){
					if(line[i].fi != base[i].sec || line[i].sec != -1*base[i].fi){
						ok = false;
						break;
					}
				}
				if(ok){
					printf("%d\n",u+1);
					break;
				}
				ok = true;
				rep(i,m){
					if(line[i].fi != -1*base[i].sec || line[i].sec != base[i].fi){
						ok = false;
						break;
					}
				}
				if(ok){
					printf("%d\n",u+1);
					break;
				}
				if(v == 0){
					Vp tmp;
					for(int i = 0; i < m-1; i++){
						line[i].fi -= line[m-1].fi;
						line[i].sec -= line[m-1].sec;
					}
					line[m-1].fi = 0;
					line[m-1].sec = 0;
					tmp = line;
					rep(i,m){
						line[i] = tmp[m-i-1];
					}
				}
			}
		}
		printf("+++++\n");
	}
}

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


int main() {
  string s;
  cin >> s;
  bool check = true;
  string origin = s;
  reverse(s.begin(), s.end());
  string a = s.substr(0, (s.size() - 1) / 2);
  string b = a;
  reverse(b.begin(), b.end());
  if (origin == s && a == b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8
from collections import deque
input_line = input().strip()
stack1, stack2 = deque(), deque()
for index, i in enumerate(input_line):
    if i == "\\":
        stack1.append(index)
    elif i == "/" and len(stack1) != 0:
        a = stack1.pop()
        #池のマージ
        if len(stack2) != 0 and abs(stack2[-1][0] - a) == 1:
            stack2.append([a, index - a + stack2.pop()[1]])
        else:
            stack2.append([a, index - a])
        #さらにマージ
        while len(stack2) >= 2 and stack2[-1][0] < stack2[-2][0]:
            stack2.append([stack2[-1][0], stack2.pop()[1] + stack2.pop()[1]])
ans = [i[1] for i in stack2]
print(sum(ans))
ans.insert(0, len(ans))
print(*ans)

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

#define REP(i, n) for(int i=0;i<(int)n;++i)
#define FOR(i, c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;


typedef int Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight = 1) :
            src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
           e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool augment(const Graph &g, int u,
             vector<int> &matchTo, vector<bool> &visited) {
    if (u < 0) return true;
    FOR(e, g[u]) if (!visited[e->dst]) {
            visited[e->dst] = true;
            if (augment(g, matchTo[e->dst], matchTo, visited)) {
                matchTo[e->src] = e->dst;
                matchTo[e->dst] = e->src;
                return true;
            }
        }
    return false;
}

int bipartiteMatching(const Graph &g, int L, Edges &matching) {
    const int n = g.size();
    vector<int> matchTo(n, -1);
    int match = 0;
    REP(u, L) {
        vector<bool> visited(n);
        if (augment(g, u, matchTo, visited)) ++match;
    }
    REP(u, L) if (matchTo[u] >= 0) // make explicit matching
            matching.push_back(Edge(u, matchTo[u]));
    return match;
}


void solve(int N, vector<ll> a, vector<ll> b, vector<ll> c, vector<ll> d) {
    Graph g(2 * N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                g[i].push_back(Edge(i, N + j));
                g[N + j].push_back(Edge(N + j, i));

            }
        }
    }
    Edges ms;
    cout << bipartiteMatching(g, N, ms) << endl;

}

int main() {
    ll N;
    scanf("%lld", &N);
    vector<ll> d(N - 1 + 1);
    vector<ll> a(N - 1 + 1);
    vector<ll> b(N - 1 + 1);
    vector<ll> c(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
    }
    for (int i = 0; i <= N - 1; i++) {
        scanf("%lld", &c[i]);
        scanf("%lld", &d[i]);
    }
    solve(N, a, b, c, d);
    return 0;
}



Measured memory_bytes: 384
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n = int(input())
A = list(map(int, input().split()))

su = [0]*n
su[-1] = A[-1]
for i in reversed(range(n-1)):
    su[i] = (A[i]+su[i+1])%MOD

ans = 0
for i in range(n-1):
    ans = (ans + A[i]*su[i+1])%MOD

print(ans)


Measured memory_bytes: 94472
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n,a,b;cin>>n>>a>>b;
  if((b-a)%2==0){
    cout<<"Alice"<<endl;
  }
  else cout<<"Borys"<<endl;

}

Measured memory_bytes: 256