akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define ll long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, m, s;
vector <pair <int, pii> > dsk[mn];
int C[mn], D[mn];
ll ans[mn];
const int MAX_TOTAL_COST = 5005;
bool passed[55][MAX_TOTAL_COST * 3];
// main solution goes here:
void execute(int test_number)
{
    cin>>n>>m>>s;
    int a, b, c, d;
    for (int i=1; i<=m; i++) {
        cin>>a>>b>>c>>d;
        dsk[a].push_back({b, {c, d}});
        dsk[b].push_back({a, {c, d}});
    }
    for (int i=1; i<=n; i++) {
        cin>>C[i]>>D[i];
        C[i] = min(C[i], MAX_TOTAL_COST);
    }
    s= min(s, MAX_TOTAL_COST);

    priority_queue<pair <ll, pii> > PQ; // {time, {id, wealth}}
    PQ.push({0, {1, s}});
    for (int i=2; i<=n; i++) ans[i] = inf;

    while (!PQ.empty()) {
        ll f = -PQ.top().XX;
        int u = PQ.top().YY.XX;
        int c = PQ.top().YY.YY;
        PQ.pop();

        if (passed[u][c]) continue;
        passed[u][c] = 1; 
        ans[u] = min(ans[u], f);

        if (c<=MAX_TOTAL_COST - 5) {
            PQ.push({-f - D[u], {u, c + C[u]}});
        }

        for (pair <int, pii> p: dsk[u]) if (c >= p.YY.XX) {
            PQ.push({-f - p.YY.YY, {p.XX, c - p.YY.XX}});
            // cerr<<p.XX<<"\n";
        }
    }

    for (int i=2; i<=n; i++) cout<<ans[i]<<"\n";
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

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

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

    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (d[i] == d[j]) d[j] = 0;
            else break;
        }
    }

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

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())

dpa, dpb, dpc = 0, 0, 0

for i in range(n):
    a, b, c = map(int, input().split())
    dpa, dpb, dpc = max(dpb, dpc) + a, max(dpa, dpc) + b, max(dpa, dpb) + c

print(max(dpa, dpb, dpc))


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

vector<int> v;
map<int,int> m;
int i,x,n,ans=0;

int main(){
	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>x;
		if(m[x]==0) v.push_back(x);
		m[x]++;
	}
	
	for(i=0;i<v.size();i++)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
		
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


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




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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b ;
  cin >> a >> b ;
  
  for(int i=1; i<10000; i++){
    int aa, bb ;
    aa = i*0.08 ;
    bb = i*0.10 ;
    if(aa==a && bb==b){
      cout << i <<endl ;
      return 0 ;
    }
  }
  
  cout << -1 <<endl ;
  
  
  
  return 0 ;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	class Trie {
		int[][] next;
		int states;

		public Trie() {
			next = new int[2][(int) 2e5];
			states = 1;
			for (int[] i : next) {
				Arrays.fill(i, -1);
			}
		}

		void add(String s) {
			int cur = 0;
			for (char c : s.toCharArray()) {
				c -= '0';
				if (next[c][cur] == -1) {
					next[c][cur] = states++;
				}
				cur = next[c][cur];
			}
		}

		long get(long len) {
			return get(0, len);
		}

		long get(int cur, long len) {
			if (len < 0) {
				return 0;
			}
			if (cur == -1) {
				len++;
				return 1L << (Long.numberOfTrailingZeros(len));
			}

			return get(next[0][cur], len - 1) ^ get(next[1][cur], len - 1);
		}
	}

	void solve() {
		Map<Integer, Integer> count = new HashMap<>();
		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			count.put(x, count.getOrDefault(x, 0) + 1);
		}
		int ans = 0;
		for (int i : count.keySet()) {
			int j = count.get(i);
			if (j >= i) {
				j -= i;
			}
			ans += j;
		}
		out.println(ans);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

#define all(s) s.begin(), s.end()
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define bit(x, y) ((x >> y) & 1)

int main() {
    ios::sync_with_stdio(false); cin.tie(0); 
    cout.tie(0);
    int x;
    cin >> x;
    cout << 1 -x;
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<vector<int>>A(N,vector<int>(2));
  vector<vector<int>>C(M,vector<int>(2));
  for(int i=0;i<N;i++){
  int a,b;
    cin>>a>>b;
    A.at(i).at(0)=a;
    A.at(i).at(1)=b;
    }for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    C.at(i).at(0)=a;
    C.at(i).at(1)=b;
  
  }for(int i=0;i<N;i++){
  int Min=abs(A[i][0]-C[0][0])+abs(A[i][1]-C[0][1]);
    int k=0;
    for(int j=0;j<M;j++){
     if(abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])<Min){
     Min=abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1]); k=j;
     }
  }  cout<<k+1<<endl;
  
  }
  
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

const int MOD = 1e9 + 7;
typedef vector<vector<int>> Matrix;

Matrix mult(const Matrix& a, const Matrix& b) {
	int n = a.size();
	Matrix r(n, vector<int>(n));
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				int x = ((long long)a[i][k] * b[k][j]) % MOD;
				r[i][j] += x;
				if (r[i][j] > MOD) r[i][j] -= MOD;
			}
		}
	}
	
	return r;
}

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

	int n;
	long long k;
	cin >> n >> k;
	Matrix adj(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) cin >> adj[i][j];
	}
	
	Matrix m(n, vector<int>(n));
	for (int i = 0; i < n; i++) m[i][i] = 1;
	
	while (k > 0) {
		if (k % 2) m = mult(m, adj);
		adj = mult(adj, adj);
		k /= 2;
	}
	
	long long answer = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			answer += m[i][j];
			if (answer > MOD) answer -= MOD;
		}
	}
	cout << answer << endl;
}


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

s = list(input())

tmp_str =""
output=""
start_pos = end_pos = -1


for i in range(len(s)):
    if s[i] == 'A':
        start_pos = i
        break

for i in range(len(s)-1,0,-1):
    if s[i] == 'Z':
        end_pos = i
        break

if end_pos>=0 and start_pos>=0:
    length = end_pos - start_pos + 1
else:
    length = 0

print(length)

Measured memory_bytes: 10616
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	char c;
	cin >> c;
	if(c=='A'){
		cout << 'T' << endl;
	}else if(c=='T'){
		cout << 'A' << endl;
	}else if(c=='G'){
		cout << 'C' << endl;
	}else if(c=='C'){
		cout << 'G' << endl;
	}

	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9

int main(){
    char a,b;
    cin >> a >> b;
    string s = string();
    if( a <= b ) {
        for(int i = 0; i < (b - '0') ; i++){
            s += a;
        }
    }
    if( b < a ) {
        for(int i = 0; i < (a - '0') ; i++){
            s += b;
        }
    }
    cout << s << endl;
    return 0;
}

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

#if 0
????????????30????????????sort???greater??????????????§'>>'??§?????????'> >'??§????????¨??????????????????????????????????????????
??????N,??????M???????????????N??????pair????????£??\???N??????????´??????????????????????(NlogN)???N????????????????????§????¨???§O(NlogN)??¨??????
#endif

int main(){
  int N,M;
  pair<int,int> PD[10010];
  while(cin >> N >> M && N){
    int d,p;
    for (int i=0; i<N; ++i){
      cin >> d >> p;
      PD[i]=make_pair(p,d);
    }
    sort(PD,PD+N,greater<pair<int,int>>());
    int ans=0;
    for (int i=0;i<N;++i){
      if (M>PD[i].second) M-=PD[i].second;
      else {
	ans+=(PD[i].second-M)*PD[i].first;
	M=0;
      }
    }
    cout << ans << endl;
  }  
}
  

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=1e5+7;
int n,w;
int W[N],v[N],f[N];
signed main(){
	n=read(),w=read();
	for(int i=1;i<=n;i++) W[i]=read(),v[i]=read();
	for(int i=1;i<=n;i++){
		for(int j=w;j>=W[i];j--){
			f[j]=max(f[j],f[j-W[i]]+v[i]);
		}
	}
	cout<<f[w]<<endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

type Point struct {
	X float64
	Y float64
}

func split(s, e Point) (Point, Point, Point) {
	rad60 := math.Pi / 3.0

	p1 := Point{(s.X * 2.0 + e.X) / 3.0, (s.Y * 2.0 + e.Y) / 3.0}
	p3 := Point{(s.X + e.X * 2.0) / 3.0, (s.Y + e.Y * 2.0) / 3.0}
	
	x, y := p3.X - p1.X, p3.Y - p1.Y
	rx := math.Cos(rad60) * x - math.Sin(rad60) * y
	ry := math.Sin(rad60) * x + math.Cos(rad60) * y

	p2 := Point{p1.X + rx, p1.Y + ry}

	return p1, p2, p3
}

func main() {
	points := []Point{Point{0.0, 0.0}, Point{100.0, 0.0}}

	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		lineCount := len(points) - 1
		newPoints := make([]Point, len(points) + lineCount * 3)
		p := 0
		for j := 0; j < lineCount; j++ {
			newPoints[p] = points[j]
			newPoints[p+1], newPoints[p+2], newPoints[p+3] = split(points[j], points[j+1])
			p += 4
		}
		newPoints[p] = points[len(points) - 1]
		points = newPoints
	}

	for i := 0; i < len(points); i++ {
		fmt.Printf("%.8f %.8f\n", points[i].X, points[i].Y)
	}
}



Measured memory_bytes: 1288
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
       String s = "xabacacaacaca";
      
      if(s.charAt(x)==s.charAt(y)){
        System.out.print("Yes");
      }else{
         System.out.print("No");
      }
 
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int x;
int d[200010];

int main(void)
{
	scanf("%d", &x);
	
	d[0] = 1;
	
	for(int i = 0 ; i <= 100010 ; i++)
	{
		if(d[i] == 1)
		{
			d[i + 100] = 1;
			d[i + 101] = 1;
			d[i + 102] = 1;
			d[i + 103] = 1;
			d[i + 104] = 1;
			d[i + 105] = 1;
		}
	}
	
	printf("%d", d[x]);
	return 0;
}

Measured memory_bytes: 512
classes = ["light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"]
border = [48,51,54,57,60,64,69,75,81,91]

while True:
    try:
        w = float(input())
        for i in range(len(border)):
            if w <= border[i]:
                print(classes[i])
                break
        else: print(classes[-1])
    except EOFError: break

Measured memory_bytes: 7336
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n, m, x;
  vector<int> a;
  cin >> n >> m >> x;
  for(int i=0;i<m;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  int cnt=0;
  for(int i=0;i<m;i++){
    if(a[i]>x){
      break;
    }
    else{
      cnt++;
    }
  }
  cout << min(cnt, m-cnt) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

signed main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    unordered_map<int, int> cnt;
    int n;
    sf(n);
    rep(i, 1, n) {
        if (i * i > n) break;
        rep(j, 1, n) {
            if (i * i + j * j > n) break;
            rep(k, 1, n) {
                ll t = i * i + j * j + k * k + i * j + j * k + i * k;
                if (t > n) break;
                cnt[t]++;
            }
        }
    }
    rep(i, 1, n) {
        out(cnt[i]);
    }
    return 0;
}

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

int main(){
	int N,H,W;
	cin>>N>>H>>W;
	vector<int>A(N);
	vector<int>B(N);
	int ans=0;
	rep(i,N){
		cin>>A.at(i)>>B.at(i);
		if(A.at(i)>=H&&B.at(i)>=W){
			ans++;
		}
	}
	cout<<ans<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] nums = new int[4];
        int[][] ops = {{1,1,1},{1,1,-1},{1,-1,1},{-1,1,1},{1,-1,-1},{-1,1,-1},{-1,-1,1},{-1,-1,-1}};
        char[][] opss = {{'+','+','+'},{'+','+','-'},{'+','-','+'},{'-','+','+'},{'+','-','-'},{'-','+','-'},{'-','-','+'},{'-','-','-'}};
        for (int i = 0 ; i < 4 ; i++) {
            nums[i] = Character.getNumericValue(s.charAt(i));
        }
        for (int i = 0 ; i < 8 ; i++) {
            if (nums[0] + nums[1] * ops[i][0] + nums[2] * ops[i][1] + nums[3] * ops[i][2] == 7) {
                System.out.println(nums[0]+String.valueOf(opss[i][0])+nums[1]+String.valueOf(opss[i][1])+nums[2]+String.valueOf(opss[i][2])+nums[3]+"=7");
                System.exit(0);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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 V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

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

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct UnionFind{
    int par[10000000],size[10000000];
    UnionFind(int N){
        for(int i=0;i<N;i++){
            par[i]=i;
            size[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        int y=find(par[x]);
        par[x]=y;
        return y;
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(size[x]>=size[y])swap(x,y);
        par[x]=y,size[y]+=size[x];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};
signed main(){
  int N,M;
  cin>>N>>M;
  UnionFind U(N);
  while(M--){
    int X,Y,Z;
    cin>>X>>Y>>Z;
    U.unite(X-1,Y-1);
  }
  int ans=0;
  for(int i=0;i<N;i++)
    if(U.par[i]==i)ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 5152
#include <stdio.h>

int main(){

    int a = 0;
    int b = 0;
    int ans = 0;

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

    if (a > b){
        ans = a - 1;
    }
    else{
        ans = a;
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3


def solv(n, p):
    sp = sorted(p)
    count = 0
    for i in range(n):
        if p[i] != sp[i]:
            count += 1
    if count == 0 or count == 2:
        return 'YES'
    return 'NO'


if __name__ == '__main__':

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

    ans = solv(n, p)

    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main ()

{
  char c,m;
  cin >> c;
  
  while (c == 'z' || isupper(c))
  {
    cout << "Please enter a letter before z and small\n";
  }
  m=c+1;
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

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

int main(){
	int n;cin>>n;
	VI l(2*n);
	rep(i,2*n)cin>>l.at(i);
	sort(l.rbegin(),l.rend());
	int ans=0;
	for(int i=0;i<2*n;i+=2){
		ans+=min(l.at(i),l.at(i+1));
	}
	cout<<ans<<endl;
	return 0;
}


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


def main():
    r, g, b, n = map(int, input().split())
    comb = list()
    ans = 0

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            comb.append(r * i + g * j)

    for c in comb:
        if (n - c) >= 0 and (n - c) % b == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 170604
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  char a,b;
  cin>>a>>b;

  cout << ( a==b ? 'H' : 'D' ) <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,M,L=map(int,input().split())

A=[[10**12 for i in range(N+1)]for j in range(N+1)]
B=[[10**12 for i in range(N+1)]for j in range(N+1)]
for i in range(M):
    a,b,c=map(int,input().split())
    if c<=L:
        A[a][b]=c
        A[b][a]=c
        B[a][b]=1
        B[b][a]=1
for i in range(N+1):
    A[i][i]=0
    B[i][i]=0   
#print(A)

for c in range(1,N+1):
    for a in range(1,N+1):
        for b in range(1,N+1):
            A[a][b]=min(A[a][b],A[a][c]+A[c][b])
            if A[a][b]<=L:
                B[a][b]=1
#print(A)
for c in range(1,N+1):
    for a in range(1,N+1):
        for b in range(1,N+1):
            B[a][b]=min(B[a][b],B[a][c]+B[c][b])

#print(B)
Q=int(input())
for i in range(Q):
    s,t=map(int,input().split())
    if B[s][t]==10**12:
        print(-1)
    else:
        print(B[s][t]-1)


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

int H, W;
int c[10][10];
int ans = 0;

void warshall_floyd() {
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
}

signed main(){
  cin >> H >> W;
  rep(i,10)rep(j,10)cin >> c[i][j];
  warshall_floyd();
  rep(i,H)rep(j,W){int a;cin >> a;if(a==-1)continue;ans+=c[a][1];}
  cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

int main() {
  uint64_t N, res = 1;
  cin >> N;
  string S;
  cin >> S;
  char c = S[0];
  for (uint32_t i = 1; i < N; ++i) {
    if (S[i] != c) {
      res++;
      c = S[i];
    }
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 512
from collections import defaultdict

n = int(input())

s_dict = defaultdict(int)
for _ in range(n):
    s = input()
    s_dict[s] += 1

count_max = max(s_dict.values())
s_list = sorted([s for s, count in s_dict.items() if count == count_max])
print("\n".join(s_list))

Measured memory_bytes: 36040
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<ctime>
#define PI acos(-1.0)
typedef long long ll;

using namespace std;

int n,a[110],sum=0;
void fun()
{
	int b,j;
	bool flag=true;
	for(int i=0;flag;i++)
	{
		flag=false;
		for(int j=n-1;j>=1;j--)
		{
			if(a[j]<a[j-1])
			{
				swap(a[j],a[j-1]);
				flag=true;
				sum++;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i>0) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
	printf("%d\n",sum);
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	fun();
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, A, B;
    cin >> N;
    if(N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <functional>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
const int MOD = 1000000007;
const int INF = 100100100;
const double EPS = 0.000000001;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int const MAX = 55555;
  int N;
  cin >> N;

  bool is_prime[MAX+2];
  REP(i, MAX+1) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  is_prime[2] = true;
  if(N % 2){
    cout << 2 << " ";
    N--;
  }

  FOR(i, 2, MAX+1) {
    if(N == 0) break;
    if(is_prime[i]) {
      if((i != 2) && ((i % 5) == 1)) {
        cout << i << " ";
        N--;
      }
      for(int j = 2*i; j <= MAX; j += i) is_prime[j] = false;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,k,d,e;
	cin>>n>>k;
	d=n%k;
	if(d==0)
	{
	cout<<"0\n";
}
else if(d!=0){

		e=abs(d-k);
		if(e<n)
		cout<<e<<endl;
		else
		cout<<n<<endl;
}
	return 0;
}

Measured memory_bytes: 256
n, d = gets.split.map(&:to_i)
xs = n.times.map do
  gets.split.map(&:to_i)
end

result = xs.combination(2).to_a.map do |x1, x2|
  x1.zip(x2).map { |p1, p2| (p1-p2)**2 }.reduce(:+)
end.select do |d|
  (Math.sqrt(d).to_i) ** 2 == d
end.count

puts result

Measured memory_bytes: 1788
n=gets.to_i
w=[]
yj=false
n.times {|i| w[i]=gets}
(n-1).times do |i|
unless w[i][w[i].length-2]==w[i+1][0]
yj=true
end
end
(n-1).times do |i|
for j in i+1..n-1
if w[i]==w[j] 
yj=true
end
end
end
if yj==true 
puts "No"
else
puts "Yes"
end

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

const double pi=3.14159265359;

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  if(x<a*b*a/2){
    double y=(a*b*b)/(2*x);
    cout << fixed << setprecision(10);
    cout << atan(y)*(double)180/pi << endl;
  }
  else{
    double y=2*(a*a*b-x)/(a*a*a);
    cout << fixed << setprecision(10);
    cout << atan(y)*(double)180/pi << endl;
  }
}

Measured memory_bytes: 4048
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin >>a>>b>>c){
    bool f[11] = {false};
    int ans = 0;
    f[a] = f[b] = f[c] = true;
    for(int i=1; i<11; i++) if(!f[i] && i+a+b <= 20) ans++;
    if(ans<4) cout <<"NO"<<endl;
    else cout <<"YES"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

// 二分累乗法
template <typename T>
T modpow(T a, T n, T mod) {
    T ret = 1;

    if (mod == 1) {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a;
            }
            a = a * a;
            n >>= 1;
        }
    } else {
        while (n > 0) {
            if (n & 1) {
                ret = ret * a % mod;
            }
            a = a * a % mod;
            n >>= 1;
        }
    }

    return ret;
}

vector<Int> factorials, invs;
bool is_ncr_table = false;
// modが素数の場合のみ
void calc_ncr_table(Int n, Int mod) {
    is_ncr_table = true;

    // 1! ~ n! の計算
    Int f = 1;
    factorials.push_back(f);
    for (Int i = 1; i <= n; i++) {
        f *= i;
        f %= mod;
        factorials.push_back(f);
    }

    // n!^-1 の計算
    Int inv = modpow(factorials[n], mod - 2, mod);
    // (n-1)!^-1 ~ 1!^-1 の計算
    invs.assign(n, 1);
    invs[n] = inv;
    for (Int i = n; i >= 1; i--) {
        inv *= i;
        inv %= mod;
        invs[i - 1] = inv;
    }
}

// 一度だけnCrを計算するとき用の関数
Int factorial(Int n, Int mod = 1) {
    Int ret = 1;
    if (mod == 1) {
        for (Int i = 1; i <= n; i++) {
            ret *= i;
        }

        return ret;
    } else {
        for (Int i = 1; i <= n; i++) {
            ret *= i;
            ret %= mod;
        }

        return ret;
    }
}

Int ncr(Int n, Int r, Int mod) {
    if (n < r) {
        return (Int)0;
    } else {
        if (is_ncr_table) {
            // modが素数の場合のみ
            return (factorials[n] * invs[r] % mod) * invs[n - r] % mod;
        } else {
            Int x = 1;
            for (Int i = n - r + 1; i <= n; i++) {
                x *= i;
                x %= mod;
            }
            return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
        }
    }
}

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

    calc_ncr_table(1000005LL, MOD);

    Int x, y;
    cin >> x >> y;

    Int n, m;
    n = (2 * y - x) / 3;
    m = (2 * x - y) / 3;

    Int ans;
    if ((x + y) % 3 != 0 || (n < 0 || m < 0)) {
        ans = 0;
    } else {
        ans = ncr(n + m, n, MOD);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16232
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;

public class Main {

    public static void main(String[] args){
        new Main().solve();
    }
    int n,m,R;
    int[]r;
    int[]a;
    int[]b;
    long[]c;
    long[][]path;
    void solve() {
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        R=sc.nextInt();
        r=new int[R];
        for(int i=0;i<R;i++) {
        	r[i]=sc.nextInt()-1;
        }
        a=new int[m];
        b=new int[m];
        c=new long[m];
        path=new long[n][n];
        for(int i=0;i<n;i++) {
        	for(int j=0;j<n;j++) {
        		if(i==j)path[i][j]=0;
        		else path[i][j]=Long.MAX_VALUE/2;
        	}
        }
        for(int i=0;i<m;i++) {
        	a[i]=sc.nextInt()-1;
        	b[i]=sc.nextInt()-1;
        	c[i]=sc.nextLong();
        	path[a[i]][b[i]]=c[i];
        	path[b[i]][a[i]]=c[i];
        }

        for(int k=0;k<n;k++) {
        	for(int i=0;i<n;i++) {
        		for(int j=0;j<n;j++) {
        			path[i][j]=Math.min(path[i][j], path[i][k]+path[k][j]);
        		}
        	}
        }
        
        visited=new boolean[R];
        long min_cost=Long.MAX_VALUE/2;
        
        for(int i=0;i<R;i++) {
        	count=0;
        	Arrays.fill(visited, false);
        	visited[i]=true;
        	cost=0;
        	min=Long.MAX_VALUE/2;
        	dfs(i);
        	min_cost=Math.min(min_cost, min);
        }
        System.out.println(min_cost);
    }
    
    boolean[] visited;
    long cost=0;
    long min=Long.MAX_VALUE/2;
    int count=0;
    
    void dfs(int n) {
    	if(count==R-1)min=Math.min(cost, min);
    	long p=0;
    	for(int i=0;i<R;i++) {
    		if(!visited[i]) {
    			p=path[r[n]][r[i]];
    			visited[i]=true;
    			cost+=p;
    			count++;
    			dfs(i);
    			
    			visited[i]=false;
    			cost-=p;
    			count--;
    		}
    	}
    }
}


Measured memory_bytes: 46932
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans, X, Y;

int main(void) {
    scanf("%lld %lld", &X, &Y);
    for (ll i = X; i <= Y; i *= 2) ans++;
   

  
    printf("%lld\n", ans);

	  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int[] A = new int[N + 1];
		Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
		int[] B = new int[N];
		Arrays.setAll(B, $ -> Integer.parseInt(sc.get()));

		long count = 0;
		long remainder = 0;
		for (int i = 0; i < N; i++) {
			long prev = Math.min(A[i], remainder);
			long current = Math.min(A[i] - prev, B[i]);
			remainder = B[i] - current;
			count += prev + current;
		}

		System.out.println(count + Math.min(remainder, A[N]));
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 47756
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MOD 1000000007
#define MAX 100100
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,a[MAX];
struct Matrix
{
	int s[3][3];
	void clear(){memset(s,0,sizeof(s));}
	void init(){clear();for(int i=0;i<3;++i)s[i][i]=1;}
	int*operator[](int x){return s[x];}
}P[31],A,B,G;
Matrix operator*(Matrix a,Matrix b)
{
	Matrix c;c.clear();
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<3;++k)
				add(c[i][j],1ll*a[i][k]*b[k][j]%MOD);
	return c;
}
Matrix fpow(int b)
{
	Matrix s;s.init();
	for(int i=0;b;b>>=1,++i)
		if(b&1)s=s*P[i];
	return s;
}
int f[MAX][3];
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)a[i]=read()+1;
	/*
	f[0][0]=1;
	for(int i=1,pos=1;i<=n;++i)
	{
		if(i!=a[pos])
			for(int j=0;j<3;++j)
				add(f[i][j],((j==1)?2:1)*f[i-1][2]%MOD);
		for(int j=0;j<3;++j)
		{
			add(f[i][j],f[i-1][j]);
			if(j<2)add(f[i][j+1],(2-j)*f[i-1][j]%MOD);
			if(j<1)add(f[i][j+2],f[i-1][j]);
		}
		if(i==a[pos])++pos;
	}
	printf("%d\n",f[n][2]);
	*/
	A[0][0]=1;A[0][1]=2;A[0][2]=1;
	A[1][0]=0;A[1][1]=1;A[1][2]=1;
	A[2][0]=1;A[2][1]=2;A[2][2]=2;
	B=A;
	B[2][0]=0;B[2][1]=0;B[2][2]=1;
	P[0]=A;for(int i=1;i<=30;++i)P[i]=P[i-1]*P[i-1];
	G[0][0]=1;
	for(int i=1;i<=m;++i)G=G*fpow(a[i]-a[i-1]-1)*B;
	G=G*fpow(n-a[m]);
	printf("%d\n",G[0][2]);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

bool solve() {
  string s; cin >> s;
  const ll n = s.size();
  if (s.back() != '0') return false;
  rep(i, n-1) {
    if (s[i] != s[n-2-i]) return false;
  }
  if (s[0] != '1') return false;
  ll last = 0;
  rep(i, n-1) {
    cout << last+1 << " " << i+2 << endl;
    if (s[i] == '1') {
      last = i+1;
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  if (!solve()) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1616
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, l;
    std::cin >> n >> l;
    int ret = std::numeric_limits<int>::max(), sum = 0;
    for (int i = 0; i < n; i++) {
        sum += l + i;
        if (abs(ret) > abs(l + i)) ret = l + i;
    }
    std::cout << sum - ret << std::endl;

    return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)

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

constexpr int mod = 1000000007;

inline int add(int a, int b) {
	const int res = a + b;
	return res >= mod ? res - mod : res;
}

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

	int n, l;
	cin >> n >> l;

	vector<int> x(n), a(n);
	for(auto &e : x) cin >> e;
	for(auto &e : a) {
		cin >> e;
		if(e == 0) e = l + 1;
	}

	vector<int> dp(l + 1, 0);
	dp[l] = 1;

	for(int i = n - 1; i >= 0; --i) {
		vector<int> next_dp(l + 1, 0);

		int sum = 0;
		for(int j = l; j >= x[i]; --j) {
			if((j - x[i]) % a[i] == 0) {
				next_dp[j] = sum;
			}
			sum = add(sum, dp[j]);
		}
		dp = move(next_dp);
	}

	cout << accumulate(begin(dp), end(dp), 0, add) << endl;


	return EXIT_SUCCESS;
}

Measured memory_bytes: 1280
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


li func(li x){
	return x*x;
}

int main(){
	li lim=600;
	li x;
	while(cin>>x){
		li sum=0;
		for(li i=x; i<lim; i+=x){
			sum+=func(i);
		}
		cout<<sum*x<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

int main() {
	int n, num;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i ++) {
		scanf("%d", &num);
		if(num % 2) cnt ++;
	}
	if(cnt & 1) puts("NO");
	else puts("YES");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <deque>
#include <queue>
#include <cassert>
#include <stack>
#include <iomanip>
#include <utility>
#include <math.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) {
        cout << s;
        return 0;
    }
    for (int i = 0; i < k; i++) {
        cout << s[i];
    }
    cout << "...";
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int h, w, n;

int main(){
    cin >> h >> w >> n;
    h = max(h, w);
    cout << (n - 1) / h + 1 << '\n';
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
H, W = map(int,input().split())
S = []
for _ in range(H):
  S.append(input())

# check palindrome

def main():
  num1 = (H*W) % 2 
  num2 = (W % 2)*H//2 + (H % 2)*W//2
  num4 = ((H*W) - num1 - num2*2)//4
  #print(num1,num2,num4)
  d = {}
  for i in range(H):
    for j in range(W):
      ch = S[i][j]
      if ch in d:
        d[ch] += 1
      else:
        d[ch] = 1

  check1 = sum([val % 2 for key,val in d.items()])
  #print(check1)
  if check1 != num1:
    return False
  
  check4 = 0
  for key,val in d.items():
    if val >= 4:
      deduct = min(num4-check4,val//4)
      d[key] = val - deduct*4
      check4 += deduct
      
      if check4 == num4:
        break
    
  #print(check4)
  if check4 != num4:
    return False
  
  check2 = sum([val//2 for key,val in d.items()])
  #print(check2)
  if check2 != num2:
    return False
      
  return True
      
  
ans = main()
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9272
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
    int l;
    int length = 2;
    int input[length];
    for(int i = 0;i < length && cin>>l;i++){
        input[i] = l;
    }
    string out;
    if(input[0] < input[1]) out = "a < b";
    else if(input[0] > input[1]) out = "a > b";
    else out = "a == b";
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define sc(m) scanf("%d",&m);
#define scl(m) scanf("%lld",&m);
#define scd(m) scanf("%lf",&m);
#define pf(res) scanf("%d",res);
#define pfl(res) scanf("%lld",res);
#define pfd(res) scanf("%lf",res);
using namespace std;


int main()
{
    int n,res,a,b;
    sc(n);
    scanf("%d",&a);
    scanf("%d",&b);
    int c=0,sum=1;
    for(int i=1;i<=1000;i++)
    {
        sum=n*i;
        if(sum>b){c=1;;break;}
        else if(sum>=a && sum<=b)
        {
            c=0;
            break;
        }
    }
    if(c==0)
        cout<<"OK";
    else cout<<"NG";


}



Measured memory_bytes: 3764