akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 100000

int A[MAX],num;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
int main(){
  int i,q;

  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,num-1);
  for(i=0;i<num;i++){
    if(i){
      printf(" ");
    }
    if(i==q){
      printf("[");
    }
    printf("%d",A[i]);
    if(i==q){
      printf("]");
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2108
import sys
input = sys.stdin.readline
N = int(input())
tree = [[] for i in range(N+1)]

for i in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

dist_fennec = [100001] * (N+1)
dist_snuke = [100001] * (N+1)
q = [1]
dist_fennec[1] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist_fennec[next] == 100001:
            dist_fennec[next] = dist_fennec[now] + 1
            q.append(next)

q = [N]
dist_snuke[N] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist_snuke[next] == 100001:
            dist_snuke[next] = dist_snuke[now] + 1
            q.append(next)

fennec, snuke = 0, 0
for i in range(1, N+1):
    if dist_snuke[i] >= dist_fennec[i]:
        fennec += 1
    else:
        snuke += 1

if fennec > snuke:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 28976
#include <stdio.h>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int V,E,R;
    scanf("%d %d %d",&V,&E,&R);
    int s[2005],t[2005],d[2005];
    rep(i,E){
        scanf("%d %d %d",&s[i],&t[i],&d[i]);
    }
    //Bellman-Ford
    int map[1005];
    rep(i,V){map[i]=1111111111;}
    map[R]=0;
    rep(i,V){
        bool end=true;
        rep(j,E){
            if(map[s[j]]!=1111111111&&map[t[j]]>map[s[j]]+d[j]){
                if(i>=V-1){
                    printf("NEGATIVE CYCLE\n");
                    return 0;
                }else{
                    map[t[j]]=map[s[j]]+d[j];
                    end=false;
                }
            }
        }
        if(end)break;
    }
    rep(i,V){
        if(map[i]!=1111111111)printf("%d\n",map[i]);
        else printf("INF\n");
    }
    return 0;
    
}



Measured memory_bytes: 2780
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> P;
struct pos {
  int row;
  int column;
};
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int main(void) {
  string S, T;
  cin >> S >> T;
  bool find = false;
  for (int i = (S.size() - 1); i >= T.size() - 1; i--) {
    int thres = T.size() - 1;
    bool check = true;
    for (int j = i - thres, k = 0; j <= i; j++, k++) {
      if (S[j] == '?') continue;
      if (S[j] == T[k]) continue;
      check = false;
      break;
    }

    if (!check) continue;
    for (int j = i - thres, k = 0; j <= i; j++, k++) {
      S[j] = T[k];
    }
    find = true;
    break;
  }

  if (!find) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '?') S[i] = 'a';
  }
  cout << S << endl;
  return 0;
}

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

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007; // 10^9+7
const ll INF = 100000000;

ll a[100010];

int main(void){
    int n;
    cin >> n;
    rep(i,n) cin >> a[i];

    int cnt2 = 0,cnt4 = 0;
    rep(i,n){
        if(a[i] % 4 == 0) cnt4++;
        else if(a[i] % 2 == 0) cnt2++;
    }

    //cout << cnt2 << endl;
    //cout << cnt4 << endl;

    if(cnt2 / 2 + cnt4 >= n/2) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 4328
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <cstdlib>
#include <cstddef>
#include <cinttypes>

#include <type_traits>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

namespace FastIn {
  static constexpr size_t BUF_SIZE=1<<17, INT_LEN=24, FLT_LEN=400;
  static char buf[BUF_SIZE|1]={}, *pos=buf, *endbuf=nullptr;
  FILE *fin;
 
  inline bool rebuffer() {
    // returns true <=> there is at least one unread character
    size_t rest=endbuf-pos;
    if (buf+rest > pos) {
      // buf[:pos] and buf[-pos:] are overlapping, which std::memcpy()
      // causes undefined behavior.
      return true;
    }
 
    std::memcpy(buf, pos, rest); 
    pos = buf;
    size_t len=std::fread(pos+rest, 1, BUF_SIZE-rest, fin);
    *(endbuf = buf + (rest+len)) = 0;
 
    return *pos;
  }
 
  template <class Int>
  inline bool scan(Int &in) {
    in = 0;
 
    // assume that no redundant whitespace appears
    if (pos + INT_LEN >= endbuf && !rebuffer()) {
      return false;
    }
 
    if (std::is_signed<Int>::value) {
      if (*pos == '-') {
        in = ~*++pos+'1';
        while (*++pos >= '0') {
          in = in*10 + ~*pos+'1';
        }
        ++pos;
        return true;
      }
    }
 
    // assume that numbers are separated by the character whose value is
    // less than '0' (e.g. whitespaces, newlines)
    do {
      in = in*10 + *pos-'0';
    } while (*++pos >= '0');
    ++pos;
    return true;
  }
 
  class Scanner {
    bool rebuffer() {
      return FastIn::rebuffer();
    }
 
  public:
    Scanner(FILE *fin=stdin) {
      FastIn::fin = fin;
      endbuf = pos + std::fread(buf, 1, BUF_SIZE, fin);
    }
 
    template <class T>
    inline bool scan(T &in) {
      return FastIn::scan(in);
    }
 
    template <class First, class... Rest>
    inline bool scan(First &in, Rest &...ins) {
      return scan(in) && scan(ins...);
    }
  };
}

FastIn::Scanner cin;

int main() {
  size_t N;
  cin.scan(N);

  std::vector<unsigned> a(N), b(N);
  for (size_t i=0; i<N; ++i)
    cin.scan(a[i]);

  for (size_t i=0; i<N; ++i)
    cin.scan(b[i]);

  unsigned res=0;
  for (unsigned i=(1<<28); i; i>>=1) {
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    size_t i1=0, i2=0, i3=0;
    unsigned cur=0;
    for (size_t j=N; j--;) {
      while (i1 < N && a[j]+b[i1] < 1*i) ++i1;
      while (i2 < N && a[j]+b[i2] < 2*i) ++i2;
      while (i3 < N && a[j]+b[i3] < 3*i) ++i3;
      cur += (i2-i1) + (N-i3);
    }
    if (cur & 1)
      res |= i;

    for (size_t j=0; j<N; ++j) {
      a[j] &= i-1;
      b[j] &= i-1;
    }
  }

  printf("%u\n", res);
}


Measured memory_bytes: 1920
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    cityDict = {}
    cityNameSet = set()
    for i in range(N):
        city = S[i]
        point = P[i]
        cityNameSet.add(city)
        if city not in cityDict:
            cityDict[city] = []
        cityDict[city].append((point,i))
    for city in sorted(list(cityNameSet)):
        arr = cityDict[city]
        arr.sort(reverse=True)
        for a in arr:
            print(a[1]+1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [str()] * (N)  # type: "List[str]"
    P = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int b[] = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = Integer.parseInt(in.next());
            }
            int a[][] = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = Integer.parseInt(in.next());
                }
            }
            int ans = 0;

            for (int i = 0; i < n; i++) {
                int ac = 0;
                for (int j = 0; j < m; j++) {
                    ac += a[i][j] * b[j];
                }
                if (ac + c > 0) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23636
n,l = map(int,input().split())
res = 0
if l > 0:
    for i in range(2,n+1):
        res += l+i-1
elif l+n-1<0:
    for i in range(1,n):
        res += l+i-1
else:
    for i in range(1,n+1):
        res += l+i-1
print(res) 

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<bitset>
#include<assert.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
template <class T>
int upmin(T &a, const T &b){return (b<a?a=b,1:0);}
template <class T>
int upmax(T &a, const T &b){return (b>a?a=b,1:0);}
namespace io
{
	const int SIZE=(1<<20)+1;
	char ibuf[SIZE],*iS,*iT;
	char obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1;
	int getc()
	{
		(iS==iT?iS=ibuf,iT=ibuf+fread(ibuf,1,SIZE,stdin):0);
		return iS==iT?EOF:*(iS++);
	}
	int f;
	char c;
	template <class T>
	void get(T &x)
	{
		f=1;
		for(c=getc();(c<'0'||c>'9')&&c!='-';c=getc());
		(c=='-'?f=-1,c=getc():0);
		x=0;
		for(;c>='0'&&c<='9';c=getc())
			x=x*10+c-'0';
		x*=f;
	}
	void flush()
	{
		fwrite(obuf,1,oS-obuf,stdout);
		oS=obuf;
	}
	void putc(char x)
	{
		*(oS++)=x;
		if(oS==oT)
			flush();
	}
	int a[55],t;
	template <class T>
	void put(T x)
	{
		if(!x)
			putc('0');
		x<0?putc('-'),x=-x:0;
		while(x)
		{
			a[++t]=x%10;
			x/=10;
		}
		while(t)
			putc(a[t--]+'0');
	}
	void space()
	{
		putc(' ');
	}
	void enter()
	{
		putc('\n');
	}
	struct flusher
	{
		~flusher()
		{
			flush();
		}
	}
	io_flusher;
}
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
int main()
{
	int n,x,s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		s=gcd(s,x);
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>


using namespace std;


template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}

template <class T>
void InputArray(std::size_t size, T &t)
{
	t.resize(size);
	for (auto &e : t) {
		cin >> e;
	}
}

template <class ...Args>
void InputArray(std::size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}

template <class ...Args>
void InputVerticalArray(std::size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}

template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}

template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}

template <class T>
void OutputArray(const T &t)
{
	for (const auto &e : t) {
		cout << e << ' ';
	}
	cout << endl;
}

template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}

template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}


#define inp(type, ...) \
	type __VA_ARGS__; \
	Input(__VA_ARGS__)

#define inpa(type, size, ...) \
	type __VA_ARGS__; \
	InputArray((size), __VA_ARGS__)

#define inpva(type, size, ...) \
	type __VA_ARGS__; \
	InputVerticalArray((size), __VA_ARGS__)

#define otp(...) \
	Output(__VA_ARGS__)

#define otpv(...) \
	OutputVertical(__VA_ARGS__)

#define otpa(...) \
	OutputArray(__VA_ARGS__)

#define otpva(...) \
	OutputVerticalArray(__VA_ARGS__)

#define rep(counter, range) \
	for (int (counter) = 0; (counter) < (range); (counter)++)

#define repi(range) \
	rep(i, range)

#define rrep(counter, range) \
	for (int (counter) = (range) - 1; (counter) >= 0; (counter)--)

#define rrepi(range) \
	rrep(i, range)

#define repc(element, container) \
	for (auto &(element) : (container))

#define repe(container) \
	repc(e, container)

#define all(container) \
	(container).begin(), (container).end()

#ifdef __CCR__
#	define dlog(x) clog << #x " = " << x << endl
#else
#	define dlog(x)
#endif



int main()
{
	inp(int, n);
	
	int maxi0;
	int maxe0 = 0;
	int maxe1 = 0;
	int a;
	repi(n) {
		cin >> a;
		if (maxe0 <= a) {
			maxe1 = maxe0;
			maxi0 = i;
			maxe0 = a;
		}
		else if (maxe1 < a) {
			maxe1 = a;
		}
	}
	
	repi(n) {
		otp(i == maxi0 ? maxe1 : maxe0);
	}
	
	return 0;
}


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

int main()
{
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];

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


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

int main(){
    vector<int> group;
    group = {-1,0,1,0,2,0,2,0,0,2,0,2,0};
    int x, y;
    cin >> x >> y;
    if (group[x] == group[y]) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
using namespace std;
 
int main(){
    char str[20001];
    int m,tmp,length;
    while(true){
        scanf("%s",str);
        if(str[0] == '-') break;
        length = 0;
        for(int k = 0; str[k] != '\0';k++) length++;
        scanf("%d",&m);
        int index = 0;
        for(int i = 0; i < m; i++){
            scanf("%d",&tmp);
            for(int j = 0; j < tmp; j++){
                str[index+length] = str[index];
                index++;
            }
        }
        for(int p = 0; p < length; p++){
            printf("%c",str[index+p]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 2532
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
int x;
vector<int>vec;
int main(){
	while(1){
		int n; cin>>n>>x; if(n+x==0) return 0;
		vec.clear();
		map<int,int>M;
		M[n] = 0;
		for(int i=0;i<x;i++){
			vec.pb(n%10); n/=10;
		}
		sort(vec.begin(),vec.end());
		for(int i=1;;i++){
			int mx =0 , mn = 0;
			for(int i=0;i<vec.size();i++) mx = mx*10+vec[i];
			for(int i=0;i<vec.size();i++) mn = mn*10+vec[vec.size()-1-i];
			int v = mn-mx; //cout << v << endl;
			if(M.find(v) != M.end()){
				cout << M[v] << " " << v << " " << i-M[v] << endl;
				break;
			}
			else {
				M[v] = i;
				vec.clear();
				rep(i,x) {vec.pb(v%10);v/=10;}
				sort(vec.begin(),vec.end());
			}
		}
		
	}
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int mx=10000;
int a[mx];
int tree[mx*4];
//void init(int node, int b, int e)
//{
//    if (b == e) {
//        tree[node] = a[b];
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    init(Left, b, mid);
//    init(Right, mid + 1, e);
//    tree[node] = __gcd(tree[Left],tree[Right]);
//}
//int query(int node, int b, int e, int i, int j)
//{
//    if (i > e || j < b)
//        return 0;
//    if (b >= i && e <= j)
//        return tree[node];
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    int p1 = query(Left, b, mid, i, j);
//    int p2 = query(Right, mid + 1, e, i, j);
//    return __gcd(p1,p2);
//}
//void update(int node, int b, int e, int i, int newvalue)
//{
//    if (i > e || i < b)
//        return;
//    if (b >= i && e <= i) {
//        tree[node] = newvalue;
//        return;
//    }
//    int Left = node * 2;
//    int Right = node * 2 + 1;
//    int mid = (b + e) / 2;
//    update(Left, b, mid, i, newvalue);
//    update(Right, mid + 1, e, i, newvalue);
//    tree[node] = __gcd(tree[Left] , tree[Right]);
//}
double maxvolume(double s)
{
    double length = s / 3;
    s -= length;
    double breadth = s / 2;
    double height = s - breadth;
    return length * breadth * height;
}
int main()
{
    double l;
    cin>>l;
    printf("%.12f\n",maxvolume(l));
}


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

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){
        cin >> v.at(i);
    }

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

    double a=v.at(0);

    for(int i=1;i<N;i++){
        a=(a+v.at(i))/2.0;
    }

    cout << a << endl;
}

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

int main(){
	vector<string> s;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string str;
		cin >> str;
		s.push_back(str);
	}
	int A = 0, Un = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == "A"){
			A++;
		}
		else{
			Un++;
			if (A >= Un){
				A--;
				Un--;
			}
		}
		
	}
	if (A == 0 && Un == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <stdio.h>
int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H)
    printf("Yes\n");
    else printf("No\n");
    return 0;
} 


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N;
    vec a(N);
    rep(i,N){
        char c;
        cin>>c;
        a[i] = (c == 'R');
    }
    ll rnum = accumulate(ALL(a), 0LL), res = 0;
    rep(i,rnum){
        res += 1 - a[i];
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

vector<P> inf[100005];
bool vis[100005];
int  x[100005];
bool judge(int vex)
{
   vis[vex] = true;
   x[vex] = 0;
   queue<int> que;
   que.push(vex);

   while (!que.empty()) {
      int ele = que.front();
      que.pop();

      for (int i = 0; i < (int)inf[ele].size(); i++) {
         int n = inf[ele][i].first;
         int dis = inf[ele][i].second;

         if (vis[n]) {
            if (x[n] - x[ele] != dis) {
               return false;
            }
         } else {
            vis[n] =  true;
            x[n] = x[ele] + dis;
            que.push(n);
          }
      }
   }

   return true;

}
int main()
{
   int i, j, k, N, M;

   cin >> N >> M;

   for (int o = 0; o < M; o++) {
      cin >> i >> j >> k;
      inf[i].push_back(make_pair(j, k));
      inf[j].push_back(make_pair(i, -k));
   }

   bool ans = true;

   for (i = 1; i <= N; i++) {
      if (!vis[i] && inf[i].size()) {
         if (!judge(i)) {
            ans = false;
            break;
         }
      }
   }
/*
   for (i = 1; i <= N; i++)
      cout << x[i] << ' ';
   cout << endl;
*/



   cout << (ans ? "Yes" : "No") << endl;

   return 0;
}


Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    long long n,i,j;
    cin>>n;
    for(i=1;i<=3500;i++){
        for(j=i;j<=3500;j++){
            if(4*i*j-n*i-n*j>0&&(n*i*j)%(4*i*j-n*i-n*j)==0){
            cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j);
            return 0;
            }
        }
    }
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	int m=max({a,b,c});
	int x=m+1;
	if((3*m-(a+b+c))%2==0)
		x=m;
	cout<<(3*x-(a+b+c))/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        int val;
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
            boolean yymm = false;
            boolean mmyy = false;
            int a = Integer.valueOf(s);

            // yymm
            if (a % 100 <= 12 && 0 < a %100){
                yymm = true;
            }
            if (a / 100 <= 12 && 0 < a / 100){
                mmyy = true;
            }


            if (yymm && mmyy) {
                System.out.println("AMBIGUOUS");
            } else if (yymm) {
                System.out.println("YYMM");
            } else if (mmyy) {
                System.out.println("MMYY");
            } else  {
                System.out.println("NA");
            }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &a : A) cin >> a;
    sort(A.begin(), A.end());
    int maxv = 0, maxi = 0;
    for (int i = 0; i < n-1; i++) {
        if (min(A[i], A[n-1]-A[i]) > maxv) {
            maxv = min(A[i], A[n-1]-A[i]);
            maxi = i;
        } 
    }
    printf("%d %d\n", A[n-1], A[maxi]);
    return 0;
}

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

int main(){
	int a[10],n,i,j;
	while(scanf("%d",&n)!=-1){
		if(n==0) break;
		for(i=0;n>1;n/=2,i++)a[i]=n%2;
		for(j=0;j<i;j++) if(a[j]==1) printf("%1.f ",pow(2,j));
		if(n==1)printf("%1.f\n",pow(2,j));
		else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 672
#include<iostream>
#include<bitset>
#include<vector>
#include<map>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n, k;
    vector<int> h;
    cin >> n >> k;

    for(int i = 0; i < n; i++){
        int s;
        cin >> s;
        h.push_back(s);
    }

    int cnt=0;

    for(int i = 0; i < n; i++){
        if(h[i] >= k) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3820
N = int(input())
ls = [list(map(int, input().split())) for _ in range(N)]
ls_sum = [ls[i][0] + ls[i][1] for i in range(N)]
ls_dif = [ls[i][0] - ls[i][1] for i in range(N)]
ls_sum.sort()
ls_dif.sort()

print(max([ls_sum[N-1] - ls_sum[0], ls_dif[N-1] - ls_dif[0]]))

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

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

	int n;
	cin >> n;
	int f = 0, l = 0, f1 = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int i = 0; i < SZ(s) - 1; ++i) {
			if (s[i] == 'A' && s[i+1] == 'B')
				ans++;
		}
		if (s[0] == 'B' && s[SZ(s)-1] != 'A')
			f++;
		if (s[0] != 'B' && s[SZ(s)-1] == 'A')
			l++;
		if (s[0] == 'B' && s[SZ(s)-1] == 'A')
			f1++;
	}
	if (f == 0 && l == 0 && f1 > 0)
		ans += f1-1;
	else if (f1 > 0 && (f == 0 || l == 0))
		ans += f1;
	else
		ans += min(f+f1, l+f1);
	cout << ans;
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
S = input()
if len(S)%2 == 0:
    tmp1 = S[:len(S)//2]
    tmp2 = S[len(S)//2:]
    tmp2 = tmp2[::-1]
    count = 0
    for i in range(len(tmp1)):
        if tmp1[i] != tmp2[i]:
            count += 1
    print(count)
else:
    tmp1 = S[:len(S)//2]
    tmp2 = S[len(S)//2+1:]
    tmp2 = tmp2[::-1]
    count = 0
    for i in range(len(tmp1)):
        if tmp1[i] != tmp2[i]:
            count += 1
    print(count)

Measured memory_bytes: 3064
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	int height=v[n-1];
	bool flag=true;
	for(int i=n-2;i>=0;i--)
	{
		if(v[i]<=height)
		{
			height=v[i];
		}
		else
		{
			if(v[i]-height==1)
			{
				v[i]--;
				height=v[i];
			}
			else
			{
				flag=false;
				break;
			}
		}
	}
	flag?cout<<"Yes":cout<<"No";
	return 0;
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

const double PI = acos(-1);

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

    if (N%10 == 7 || N/10%10 == 7 || N/100%10 == 7) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3540
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)

M = 0
for i in range(N):
  M += A[i] * F[i]

def nasu(n):
  ans = 0
  for i in range(N):
    ans += max(0, A[i] - (n // F[i]))
  if ans <= K:
    return True
  else:
    return False

def hersCode():
  ok = M
  ng = -1
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if nasu(mid):
      ok = mid
    else:
      ng = mid
  return ok

print(hersCode())




Measured memory_bytes: 119500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    int n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    priority_queue<int> give, recv;
    ll tmp = 0;
    int just = 0;
    if (accumulate(all(a),0LL) < accumulate(all(b),0LL)) {
        cout << -1 << endl;
        return 0;
    }
    rep(i,n) {
        if (a[i]>b[i]) give.push(a[i]-b[i]);
        if (a[i]<b[i]) recv.push(b[i]-a[i]);
        if (a[i]==b[i]) just++;
    }
    while(recv.size()) {
        ll r = recv.top(); recv.pop();
        if (tmp >= r) {
            tmp -= r;
        } else {
            while(tmp < r){
                tmp += give.top(); give.pop();
            }
            tmp -= r;
        }
    }
    cout << n-just-(int)give.size() << endl;
    return 0;
}


Measured memory_bytes: 2428
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int N = Integer.parseInt(stdin.next());
		int [][] A= new int[N][N];
		int ans=0;
		
		for(int i=0;i<N;++i) {
			for(int j=0;j<N;++j) {
				A[i][j] = -1;
			}
		}

		for(int i=0;i<N;i++) {
			int annum=Integer.parseInt(stdin.next());
			for(int j=0;j<annum;j++) {
				int x=Integer.parseInt(stdin.next());
				int y=Integer.parseInt(stdin.next());
				A[i][x-1]=y;
			}
		}
		for(int i=0;i<(1<<N);i++) {
			boolean ok=true;
			for(int j=0;j<N;j++) {
				if((i&(1<<j))==0) {
					continue;
				}
				for(int k=0;k<N;k++) {
					if(A[j][k]==-1) {
						continue;
					}
					if(A[j][k]!=(((i&(1<<k))==0)?0:1)) {
						ok=false;
					}
				}
				if(ok==false) {
					break;
				}
			}
			if(ok==false) {
				continue;
			}
			int max=0;
			for(int l=0;l<N;l++) {
				if((i&(1<<l))!=0) {
					max+=1;
				}
			}
			if(ans<max) {
				ans=max;
			}
		}
		out.println(ans);
		out.flush();
	}
}

Measured memory_bytes: 23380
#include <stdio.h>

int cnt = 0;
int p = 0;
char c;

int main(void){
    while(true){
       c = getchar();
       if(c == '\n') break;
       if(c == 'p') p++;
       cnt++; 
    }
    printf("%d\n", cnt/2 - p);
    return 0;
}


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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<i32,i32>
#define ti  triple<i32,i32,i32>
#define mk  make_pair
#define vi  vector<i32>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

bool isPrime(i64 x){
	
	for(i64 i=2;i*i<=x;i++)
		if(x%i==0)
			return false;
	return true;
}

vi V;
const i32 N=7e7+9;
bool prime[N]; 
void SieveOfEratosthenes() 
{
    for (int  p=2; p*p<=N; p++){ 
        if (prime[p] == false){ 
            for (int  i=p*p; i<=N; i += p) 
                prime[i] = true; 
        } 
    } 
    int u=0,mx=0;
    for (int p=2; p<=N; p++) 
      if (!prime[p]) {
          V.push_back(p);
    }
   
}
i64 a,k,w,c=0;
void solve(){
    cin>>a>>k;
    if(k>=a)
      cout<<a;
    else
       cout<<a-1;
}

int main(){
    fastInOut
    solve();
    return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A0016
Tresure hunt
*/
#include <stdio.h>
#include <math.h>
#include <float.h>

double x,y;
int len,arg;
double PAI=3.14159265;

main()
{
  x=0.0; y=0.0;
  int argsum = 90; 

  while(EOF != scanf("%d,%d",&len,&arg) && (len || arg))
    {
      x += cos(((double)argsum)*(PAI/180))*(double)len;
      y += sin(((double)argsum)*(PAI/180))*(double)len;

      //printf("%d:%d %d %d %d\n",(int)x,(int)y,argsum,len,arg);
      argsum -= arg;
    }
  printf("%d\n%d\n",(int)x,(int)y);
return(0);
}

Measured memory_bytes: 604
a = int(input())

while a > 10:
    a = a % 10

if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
    print("hon")
elif a == 0 or a == 1 or a == 6 or a == 8:
    print("pon" )
else:
    print("bon" )


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

const long long P = 1000000007;
int x[123456];
int main() {
	// your code goes here
	int n;
	cin >> n;
	long long ret = 1;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0, j = 0; i < n; i++) {
		while(j < n - 1 && x[j] > 2 * (j - i)) j++;
		ret = (ret * (j + 1 - i)) % P;
	}
	cout << ret << endl;
	return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

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

int main() {
  int x,a,b;
  cin >> x>>a>>b;
  if(b<=a){
    cout << "delicious" << endl;
  }
  else if(b<=a+x){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}
      
      

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep (i, n) {
    cin >> a[i];
  }

  multiset<int> st;
  rep (i, n) {
    auto itr = st.lower_bound(a[i]);
    if (itr == st.begin()) {
      st.insert(a[i]);
    }
    else {
      itr--;
      st.erase(itr);
      st.insert(a[i]);
    }
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 5376
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

template <class T>
bool updateMax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

template <class T>
bool updateMin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int sum[100010];

int main()
{
    int N, Q;
    string S;
    cin >> N >> Q >> S;

    REP(i, S.length() - 1)
    {
        sum[i + 1] = sum[i];
        if (S[i] == 'A' && S[i + 1] == 'C')
        {
            ++sum[i + 1];
        }
    }
/*
    REP(i, S.length())
    {
        cout << i << ":" << sum[i] << endl;
    }
    */

    int l, r;
    REP(i, Q)
    {
        cin >> l >> r;
        --l; --r;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

using minHeap = priority_queue< int, vector< int >, greater< int > >;

int dp[100005];
int n , a[101];

int fun(int k){

    if(a[1]>k) return 0;

    //cout<<k<<endl;

    if(dp[k] != -1) return dp[k];

    bool ret = false;

    for(int i=1; i<=n; i++){
        if(k>=a[i]) ret |= (fun(k-a[i])==false);
    }
    
    return dp[k] = ret;
}

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

    ///FastIO;
    int k;
    scn2(n,k);
    for(int i=1; i<=n; i++)scn(a[i]);
    Fill(dp,-1);
    if(fun(k))cout<<"First";
    else cout<<"Second";
    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


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

signed main(){
  int N;cin>>N;
  std::vector<int> a(N),b(N),c(N);
  for(int i=0;i<N;i++)cin>>a[i]>>b[i]>>c[i];
  std::vector<int> dpa(N),dpb(N),dpc(N);
  dpa[0]=a[0];dpb[0]=b[0];dpc[0]=c[0];
  for(int i=1;i<N;i++){
    dpa[i]=max(dpb[i-1],dpc[i-1])+a[i];
    dpb[i]=max(dpa[i-1],dpc[i-1])+b[i];
    dpc[i]=max(dpb[i-1],dpa[i-1])+c[i];
  }
  int ans=max(dpa[N-1],dpb[N-1]);
  ans=max(ans,dpc[N-1]);
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ls = [T-i*0.006 for i in H]
num = 999999
index = 0

for i, tmp in enumerate(ls, 1):
    tmp = abs(tmp-A)
    if num > tmp:
        num = tmp
        index = i

print(index)


Measured memory_bytes: 3060
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
int gcd (int a,int b){
	if(a%b==0) return b;
	if(b%a==0) return a;
	if (a>b) return gcd(b,a%b);
	return gcd(a,b%a);
}
int main(){
	int i,j,k,n,a,b;
	long long int ans=0;
	scanf ("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				a=gcd(i,j);
				b=gcd(a,k);
				ans+=b;
			}
		}
	}
	printf ("%lld\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;


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

    int a[n][3];
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    ll dp0[n], dp1[n], dp2[n];
    dp0[0] = a[0][0];
    dp1[0] = a[0][1];
    dp2[0] = a[0][2];

    for (int i = 1; i < n; i++) {
        dp0[i] = max(dp1[i-1],dp2[i-1])+a[i][0];
        dp1[i] = max(dp0[i-1],dp2[i-1])+a[i][1];
        dp2[i] = max(dp0[i-1],dp1[i-1])+a[i][2];
    }
    cout << max(dp0[n-1],max(dp1[n-1],dp2[n-1]));

    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 A, B;
  cin >> A >> B;
  cout << A*B << endl;
}


Measured memory_bytes: 3636
#include<algorithm>
#include<stdio.h>

#define MAX 500000

int n;
int A[MAX + 1];

void maxHeapfy(int A[], int root) {
    int left = root * 2;
    int right = root * 2 + 1;

    int max = root;
    if (left <= n && A[max] < A[left]) {
        max = left;
    }
    if (right <= n && A[max] < A[right]) {
        max = right;
    }

    if (max != root) {
        std::swap(A[root], A[max]);
        maxHeapfy(A, max);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &A[i]);
    }
    for (int i = n/2; i > 0; --i) maxHeapfy(A, i);
    for (int i = 1; i <= n; ++i) printf(" %d", A[i]);
    printf("\n");

    return 0;
}

Measured memory_bytes: 4516
def cal(i,j,k):
    a = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i 
    return a

N = int(input())
ans = [0] * (N + 1)
m = int(N ** 0.5)
for i in range(1,m):
    for j in range(1,m):
        for k in range(1,m):
            if cal(i,j,k) <= N:
                ans[cal(i,j,k)] += 1

for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 9344
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int a[200005];

int main() {
    int n,i;
    scanf("%d",&n);
    LL s = 0;
    for(i = 0;i < n; i++) {
        scanf("%d",&a[i]);
        s += a[i];
    }
    LL ss = 0;
    LL ans = 1LL * MAX * MAX;
    for(i = 0;i < n - 1; i++) {
        ss += a[i];
        s -= a[i];
        ans = min(ans,abs(ss - s));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  string s; cin >> s;
  if (s.substr(0, 4) == "YAKI") {
    Yes();
  } else {
    No();
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 888