akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, (int)a.size()) {out<<a[i];if(i+1!=(int)a.size())out<<',';}
  out<<']';
  return out;
}

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

int w, h;
bool used[2010][2010];

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

  while(1) {
    cin >> w >> h;
    if(!h) break;
    int n;
    cin >> n;
    V<int> a(n), b(n), c(n), d(n);
    REP(i, n) {
      cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    V<int> x, y;
    REP(i, n) {
      x.PB(a[i]); x.PB(c[i]); 
      y.PB(b[i]); y.PB(d[i]);
    }
    x.PB(0); x.PB(w);
    y.PB(0); y.PB(h);

    sort(ALL(x)); sort(ALL(y));
    x.erase(unique(ALL(x)), x.end());
    y.erase(unique(ALL(y)), y.end());

    h = y.size(), w = x.size();
    VV<int> board(h, V<int>(w, 0));
    REP(i, n) {
      a[i] = lower_bound(ALL(x), a[i]) - x.begin();
      b[i] = lower_bound(ALL(y), b[i]) - y.begin();
      c[i] = lower_bound(ALL(x), c[i]) - x.begin();
      d[i] = lower_bound(ALL(y), d[i]) - y.begin();
      board[b[i]][a[i]]++;
      board[d[i]][c[i]]++;
      board[b[i]][c[i]]--;
      board[d[i]][a[i]]--;
    }

    REP(i, h) FOR(j, 1, w) board[i][j] += board[i][j-1];
    REP(i, w) FOR(j, 1, h) board[j][i] += board[j-1][i];

    // REP(i, h) cout << board[i] << endl;

    function<void(int,int)> dfs = [&](int x, int y) {
      used[y][x] = true;
      REP(i, 4) {
        int nx = x + dx[i], ny = y + dy[i];
        if(IN(0LL,w-1,nx) && IN(0LL,h-1,ny) && !used[ny][nx] && !board[ny][nx]) {
          dfs(nx, ny);
        }
      }
    };

    memset(used, false, sizeof(used));
    int ret = 0;
    REP(i, h-1) REP(j, w-1) {
      if(!used[i][j] && !board[i][j]) {
        ret++;
        dfs(j,i);
      }
    }

    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 15144
#include <iostream>
#include <vector>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int A = a+b;
    int B = a-b;
    int C = a*b;
    int D = a-b;
    int am,bm;
    if(A > B){
    am = A;
    }else am = B;
    if(C>D){
        bm = C;
    }else bm = D;
    if(am>bm){
        cout << am << endl;
    }else cout << bm << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    int n, z, w; cin >> n >> z >> w;
    int a[n];
    REP(i,n){
        cin >> a[i];
        if(n == 1){
            cout << abs(a[i]-w) << endl;
            return 0;
        }
    }
    cout << max(abs(a[n-1] - w), abs(a[n-2] - a[n-1])) << endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main (void){
    int n, c0 = 0, c1 = 0, c2 = 0, c3 = 0;
    char s[100005][5];

    scanf("%d", &n);
    for(int i = 1; i <= n; ++i){
        scanf("%s", &s[i][0]);
        switch (s[i][0])
        {
        case 'A':
            c0++;
            break;
        case 'W':
            c1++;
            break;
        case 'T':
            c2++;
            break;
        case 'R':
            c3++;
            break;
        default:
            break;
        }
    }

    printf("AC x %d\n", c0);
    printf("WA x %d\n", c1);
    printf("TLE x %d\n", c2);
    printf("RE x %d\n", c3);

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>

using namespace std;
//int moreGcd
int N = 0;
int K = 0;
vector<int > h;

//何がだめなのか全くわからん

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

    int t = 0;

     h.push_back(0);
    for(int i = 0; i < N; i++){
        cin >> t;
        h.push_back(t);
    }
    
    vector<int > cost(N + 1, 1145141919);

    //cout << cost.size() << endl;

    //初期化的な
    cost[0] = 0;
    cost[1] = 0;

    for(int i = 1; i <= N; i++){
        //cout << h[i] << endl;
        for(int j = 1; j <= K; j++){
            if(i - j >= 1){
                //cout << abs(h[i]-h[i-j]) << endl;
                
                cost[i] = min(cost[i], cost[i-j] + abs(h[i]-h[i-j]));
                //cout << cost[i] << " " ;

            }
        }
        
        //cout << "::" << cost[i] << endl;

    }

    cout << cost[N] << endl;

}

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

using std::cout;
using std::cin;
using std::vector;
using std::sort;

#define INF 999999999;


long long int T, N, K;
vector<long long int> X, dis;
long long int ans;

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

	cin >> T;
	for(int i = 0; i < T; i++){
		cin >> N >> K;
		for(int j = 0; j < N; j++){
			int inn;
			cin >> inn;
			X.push_back(inn);
			if(j > 0){
				ans += X[j] - X[j - 1];
				dis.push_back(X[j] - X[j - 1]);
			}
		}
		ans = X[X.size() - 1] - X[0];
		sort(dis.begin(), dis.end(), [](int a, int b){return a > b;});
		/*for(int i = 0; i < dis.size(); i++) cout << dis[i] << " ";
		cout << "\n";*/
		for(int j = 0; j < N - 1 && j < K - 1; j++){
			ans -= dis[j];
		}
		cout << ans << "\n";
		ans = 0;
		X.clear();
		dis.clear();
	}
	return 0;
}


Measured memory_bytes: 4748
ny_list = input().split(" ")
n = int(ny_list[0])
y = int(ny_list[1])/1000

for a in range(0,n+1):
    for b in range(0,n+1-a):
        if a*10+b*5+n-a-b == y:
            print(str(a)+" "+str(b)+" "+str(n-a-b))
            exit()
print("-1 -1 -1")


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

// ITP1_8_B:   Sum of Numbers
int main(){
  char str[1001];
  while (true) {
    cin >> str;
    if (str[0] == '0') {
      break; // 終わり
    }
    const int len = strlen(str);
    int total = 0;
    for (int i = 0; i < len; ++i) {
      total += int(str[i] - '0');
    }
    cout << total << endl;
  }

  return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false
 
using namespace std;
 
using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;
using Pd = pair<double,double>;
using T = tuple<double,double,int>;
 
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005, MAX_C = 30;
const ll lmod = 1e9+7;
 
vector<Pd> st[MAX_C];
priority_queue<double,vector<double>,greater<double>> s_que,t_que;
 
int main(){
	int N,C; cin >> N >> C ;
	rep(i,N){
		double s,t; int c;
		scanf("%lf%lf%d",&s,&t,&c);
		c--; st[c].pb(Pd(s,t));
	}
	rep(i,C) sort(ALL(st[i]));
	rep(i,C){
		if(st[i].size()==0) continue;
		rep(j,st[i].size()-1){
			double s1,t1,s2,t2;
			tie(s1,t1) = st[i][j];
			tie(s2,t2) = st[i][j+1];
			if(abs(s2-t1)<=0.5+EPS){
				st[i][j].first = st[i][j].second = 0;
				st[i][j+1].first = s1;
			}
		}
		rep(j,st[i].size()){
			if(st[i][j].first==0&&st[i][j].second==0) continue;
			double s,t; tie(s,t) = st[i][j];
			s_que.push(s-0.5); t_que.push(t);
		}
	}
	int ans,cnt;
	ans = -1;
	cnt = 0;
	while(!(s_que.empty())){
		double s,t;
		s = s_que.top();
		t = t_que.top();
		if(s<t){
			cnt++;
			ans = max(ans,cnt);
			s_que.pop();
		}else{
			cnt--;
			t_que.pop();
		}
	}
	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 500000;
int a[N];
int naive(){
    int res = 0;
    while(a[0] >= 2 || a[1] >= 2){
        if (a[0] > 2){
            a[0] -= 2;
            a[1]++;
        } else{
            a[0]++;
            a[1] -= 2;
        }
        res++;
    }
    return res;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("ou tput.txt", "w", stdout);
    int k;
    cin >> k;
    int k0 = k;
    while(k % 50) k++;
    int x = (49 + k / 50);
    for (int i = 1; i <= 50; i++) a[i] = x;
    while(k > k0){
        for (int i = 1; i <= 50; i++)
        if (a[i] >= 50){
            a[i] -= 51;
            for (int j = 1; j <= 50; j++)
                a[j]++;
            break;
        }
        k--;
    }
    cout << 50 << endl;
    for (int i = 1; i <= 50; i++)
        cout << a[i] << " ";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); for(int i=0; i<n; i++) cin >> a[i];
    vector<int> b(n);
    int now = 1;
    for(int i=0; i<n; i++) {
        if(a[i] == now) {
            now++;
        }
    }
    if(now==1) {
        cout << -1 << endl;
    } else
    cout << n - now + 1 << endl;
}


Measured memory_bytes: 1792
while line = gets
  h, w = line.chomp.split.map(&:to_i)
  break if h == 0 && w == 0

  h.times do |i|
    if i.even?
      w.times do |j|
        print "#" if j.even?
        print "." if j.odd?
      end
    else
      w.times do |j|
        print "." if j.even?
        print "#" if j.odd?
      end
    end
    puts
  end
  puts
end



Measured memory_bytes: 6868
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;
    r *= 100;
    r += g * 10 + b;
    if (r % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
n, y = list(map(int, input().split()))
ans = 0

for i in range(n+1):
    a1 = 10000 * i
    for j in range(n+1-i):
        a2 = 5000 * j
        k = n- (i+j)
        a3 = k*1000
        if a1 + a2 + a3  == y and i + j + k == n:
            print(i, j , k)
            ans += 1
            exit(0)
    if ans == 1:
        break
if ans == 0:
    print(-1, -1, -1)

Measured memory_bytes: 3064
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>

using namespace std;

const int Mod = 1000000007;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<long long> arr(n);
    vector<vector<int>> cnt(2, vector<int>(65, 0));
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        for (int bit = 0; bit < 60; ++bit) {
            ans = (ans + cnt[(arr[i] & (1LL << bit)) == 0][bit] * ((1LL << bit) % Mod)) % Mod;
            ++cnt[(arr[i] & (1LL << bit)) != 0][bit];
        }
    }


    cout << ans << '\n';


    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N;
  cin >> N;
  vector<PLL> xs(N*2);
  REP(i,N){
	cin >> xs[i].FF;
	xs[i].SS = -1;
  }
  REP(i,N){
	cin >> xs[N+i].FF;
	xs[N+i].SS = 1;
  }
  SORT(xs);

  LL num = 0, ans = 1;
  for(auto& p: xs){
	if(!num) num += p.SS;
	else{
	  if(p.SS * num < 0)
		(ans *= abs(num)) %= MOD;
	  num += p.SS;
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
int main(void){
	char S[12];
	int A,B,i;
	scanf("%d %d %s",&A,&B,S);
	for(i=0;S[i]!='\0';i++){
		if(i==A&&S[i]!='-'||i!=A&&S[i]=='-'){printf("No");return 0;}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
const int mod = (int)1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int h,w;
	cin>>h>>w;
	vector<vector<char>> a(h,vector<char>(w));
    vector<vector<ll>> dp(h,vector<ll>(w,0));
    
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	
	for(int i=0;i<w;){
		if(a[0][i]=='#'){
			dp[0][i] = 0;
			for(int j=i+1;j<w;j++)
				dp[0][j] = 0;
			i = w;	
		}
		else dp[0][i] = 1;
		i++;
	}
	
	for(int i=1;i<h;){
		if(a[i][0] == '#'){
			for(int j=i;j<h;j++)
				dp[j][0] = 0;
			i = h;	
		}
		else dp[i][0] = 1;
		i++;
	}
	
	//ctrl + /for(int i=0;i<h;i++){
		//ctrl + /for(int j=0;j<w;j++){
			//ctrl + /cout<<dp[i][j]<<" ";
		//ctrl + /}
		//ctrl + /cout<<"\n";
	//ctrl + /}
	
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(a[i][j]=='#')
				dp[i][j] = 0;
			else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
		}	
	}
    cout<<dp[h-1][w-1];
    return 0;
}









Measured memory_bytes: 9088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
      	int ans = a * b;
		//偶数か判定
       	if(ans % 2 == 0){
        	System.out.println("Even");
        } else {
        	System.out.println("Odd");
        }
	}
}

Measured memory_bytes: 21204
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int [][]a=new int [100][100];
        int []b=new int [100];
        int c=0;
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                int q=sc.nextInt();
                a[i][j]=q;
                
            }
        }
        
        for(int i=0;i<m;i++){
            int r=sc.nextInt();
            b[i]=r;
        }
        
       
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                c+=a[i][j]*b[j];
            }
            System.out.println(c);
            c=0;
        }
    }
}



Measured memory_bytes: 40776
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

int d, n;
vi t(200);
vi a(200), b(200), c(200);
vii dp(210, vi(210, 0));

signed main()
{
  cin >> d >> n;
  REP(i, d) t[i] = in();
  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  REP(i, d - 1) {
    REP(j, n) {
      if (a[j] <= t[i] && t[i] <= b[j]) {
        REP(k, n) {
          if (a[k] <= t[i + 1] && t[i + 1] <= b[k]) {
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abs(c[j] - c[k]));
          }
        }
      }
    }
  }
  int ans = -INF;
  REP(i, n) ans = max(ans, dp[d - 1][i]);
  print(ans);

  return 0;
}

Measured memory_bytes: 3320
#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int dup = 0;
  bool exist[100001] = {};
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (exist[a]) dup++;
    else exist[a] = 1;
  }
  cout << n - dup - dup % 2 << endl;
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();	
	while(v<'0'||v>'9'){
	v=getchar();
	}	
	while(v>='0'&&v<='9'){		
	t=(t<<3)+(t<<1)+(v^48);		
	v=getchar();	}
	return t;
}
int a,b,c,d;
int main(){
a=read();
if(a>9899){
	puts("1");
	return 0;
}
b=a/100;
if(b*105>=a)puts("1");
else puts("0");
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def solve(N: int):
    table = [[0]*10 for _ in range(10)]

    for i in range(1, N+1):
        first = int(str(i)[0])
        last = int(str(i)[-1])
        table[first][last] += 1

    count = 0
    for i in range(10):
        for j in range(10):
            count += table[i][j]*table[j][i]
    print(count)
    return


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
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40556
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
#define SEG_LEN (1 << 18)
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll>x(n),A(n - 1);
  rep(i,n)cin >> x[i];
  rep(i,n - 1)A[i] = x[i + 1] - x[i];
  ll ans = 0;
  rep(i,n - 1)ans += min(A[i] * a,b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

typedef struct list
{
  int node;
  int weight;
  struct list *next;
} list;

list *graph[MAX];
int colors[MAX] = {0};

void addEdge(int node1, int node2, int weight)
{
  list *new1 = (list *)malloc(sizeof(list *));
  new1->node = node2;
  new1->weight = weight;
  new1->next = graph[node1];
  graph[node1] = new1;

  list *new2 = (list *)malloc(sizeof(list *));
  new2->node = node1;
  new2->weight = weight;
  new2->next = graph[node2];
  graph[node2] = new2;
}

void paint(int node, int parent)
{
  list *child;
  for (child = graph[node]; child != NULL; child = child->next)
  {
    if (child->node == parent)
      continue;
    if (child->weight % 2)
      colors[child->node] = !colors[node];
    else
      colors[child->node] = colors[node];
    paint(child->node, node);
  }
  return;
}

int main(void)
{
  int n;
  scanf("%d", &n);

  rep(i, n + 1)
  {
    graph[i] = NULL;
  }

  int u, v, w;
  rep(i, n - 1)
  {
    scanf("%d %d %d", &u, &v, &w);
    addEdge(u, v, w);
  }

  addEdge(0, 1, 0);

  paint(0, -1);

  rep(i, n)
  {
    printf("%d\n", colors[i + 1]);
  }
  return 0;
}


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

int main() {
	string S, out = "None";
	cin >> S;
	for (int i = 1; i <= 26; i++) {
		bool check = true;
		char x = i + 96;
		for (int j = 0; j < S.size(); j++) {
			if (S[j] == x) check = false;
		}
		if (check) {
			out = x;
			break;
		}
	}
	cout << out << endl;
}


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

int H, W, K, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char g[805][805];
bool vis[805][805];
queue< pair< int, pair<int, int> > > Q;

int d(int x) {
	return x / K + (x % K != 0);
}

int main() {
	scanf("%d%d%d", &H, &W, &K);
	for (int i = 0; i < H; i++) scanf("%s", &g[i]);
	int sx, sy;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (g[i][j] == 'S') {
				sx = i;
				sy = j;
			}
		}
	}
	Q.push(make_pair(0, make_pair(sx, sy)));
	vis[sx][sy] = 1;
	int ans = 1000000000;
	while (!Q.empty()) {
		int dis = Q.front().first, x = Q.front().second.first, y = Q.front().second.second;
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int newx = x + dir[i][0], newy = y + dir[i][1];
			if (newx < 0 || newx >= H || newy < 0 || newy >= W) continue;
			int newdis = dis + 1;
			if (newdis > K) continue;
			if (g[newx][newy] == '#') continue;
			if (vis[newx][newy]) continue;
			else vis[newx][newy] = 1;
			Q.push(make_pair(newdis, make_pair(newx, newy)));
		}
	}
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (vis[i][j]) ans = min(ans, min(min(d(i), d(H - i - 1)), min(d(j), d(W - j - 1))));
	printf("%d\n", ans + 1);
		
}



Measured memory_bytes: 1536
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}


int main() {
   int N, D;
   cin >> N >> D;
   int X[N][D];

   for (int i = 0; i < N; i++) {
      for (int j = 0; j < D; j++) {
         cin >> X[i][j];
      }
   }

   int ans = 0;
   for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
         int tmp = 0;
         for (int k = 0; k < D; k++) {
            tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
         }
         int MAX = sqrt(tmp) + 1;
         for (int m = 0; m < MAX; m++) {
            if (m * m == tmp) ans++;
         }
      }
   }
   cout << ans << endl;
   return 0;
}


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

int main(){
 string s;
 getline(cin,s);
 for(int i=0; i<(int)s.size(); i++){
   if(s[i] >='a' && s[i] <= 'z') s[i] = s[i] -32;
   else if('A' <= s[i] && s[i] <= 'Z') s[i] = s[i] + 32;
   cout << s[i];
 }
 cout << endl;
}


Measured memory_bytes: 3160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int Maxn = 100000 + 100;
const int Mod = 1000000000 + 7;
int n,l,a[Maxn];
char s[Maxn],t[Maxn];
bool f = false;
bool cmp(char x,char y)
{
    return x < y;
}

bool cmp2(char x,char y)
{
    return x > y;
}
int main()
{
    cin>>s;
    getchar();
    cin>>t;
    l = strlen(s);
    sort(s,s+l,cmp);

    l = strlen(t);
    sort(t,t+l,cmp2);

    if(strcmp(s,t) < 0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<vector<ll>> a(n, vector<ll>(n));
  rep(i, n) rep(j, n) cin >> a[i][j];

  rep(k, n) rep(i, n) rep(j, n) if(chmin(a[i][j], a[i][k]+a[k][j])) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = i+1; j < n; ++j) {
      bool use = true;
      rep(k, n) {
        if(k == i || k == j) continue;
        if(a[i][j] == a[i][k]+a[k][j]) use = false;
      }
      if(use) ans += a[i][j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> H(N);
    int res = 0;
    int flag = 0;
    for (int i = 0; i < N; i++) cin >> H[i];
    
    for (int i = N - 1; i >= 0; i--) {
        flag = 0;
        for (int j = i - 1; j >= 0; j--) {
            if (H[i] < H[j]) flag = 1;
        }
        if (flag == 0) {
            res++;
        }
    }
    cout << res << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
const int mod=1e9+7;
int n;
LL x[100005],cheng[100005],inv[100005];
LL poww(LL x,LL nn)
{
	LL res=1;
	while(nn)
	{
		if(nn&1)res=res*x%mod;
		x=x*x%mod;
		nn>>=1;
	}
	return res;
}
LL sum[100005];
int main()
{
	scanf("%d",&n);cheng[0]=1;
	for(int i=1;i<=n;i++)
		cheng[i]=cheng[i-1]*i%mod;
	for(int i=1;i<=n;i++)
		sum[i]=(sum[i-1]+poww(i,mod-2))%mod;
	inv[n]=poww(cheng[n],mod-2);
	for(int i=n-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%mod;
	for(int i=1;i<=n;i++)
		scanf("%lld",&x[i]);
	for(int i=n;i;i--)
		x[i]=(x[i]-x[i-1]+mod)%mod;
	LL ans=0;
	//for(int i=1;i<n;i++)
	//	ans=(ans+x[i+1]*cheng[n-1]%mod)%mod;
	for(int i=1;i<n;i++)
		ans=(ans+x[i+1]*sum[i]%mod)%mod;
	cout<<ans*cheng[n-1]%mod<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main(void) {
    int x;
    cin>>x;
    for(int i=2;i<x;i++)
    {
        if(x%i==0)
        {x++;i=1;}
    }

    cout<<x;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
bool visit[3000][3000];
int offsetx = 1500;
int offsety = 1500;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<vector<int>> res(h, vector<int>(w));
    int idx = 0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            int color = idx + 1;
            --a[idx];
            if (a[idx] == 0) ++idx;

            if (i & 1)
            {
                res[i][w - j - 1] = color;
            }
            else
            {
                res[i][j] = color;
            }
            
        }
    }

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cout << res[i][j];
            if (j != w - 1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}


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

int debug=0;

int main()
{
    string s;
    cin >> s;
    string s1,s2,s3,s4;
    s1 = s.substr(2,1);
    s2 = s.substr(3,1);
    s3 = s.substr(4,1);
    s4 = s.substr(5.1);
    if(debug){
        cout << s1 << endl;
        cout << s2 << endl;
        cout << s3 << endl;
        cout << s4 << endl;
    }
    if( s1 == s2 && s3 == s4)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;    

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func isPrime(x int) bool {
	if x == 2 {
		return true
	} else if x%2 == 0 {
		return false
	}

	sqrtNum := math.Sqrt((float64)(x))
	for i := 3; i <= (int)(sqrtNum); i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	//sc.Split(bufio.ScanWords)
	n := nextInt()
	cnt := 0
	for i := 0; i < n; i++ {
		if isPrime(nextInt()) {
			cnt++
		}
	}
	fmt.Println(cnt)
}



Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
const int64_t ZERO=0LL;

int main() {
  int64_t A,B,C,D; cin>>A>>B>>C>>D;
  int64_t M=max(A*C,max(A*D,max(B*C,B*D)));
  if(A*B>0&&C*D>0) cout<<M;
  else cout<<max(M,ZERO);
}

Measured memory_bytes: 3624
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a;
    int b, c;
    scanf("%lld", &a);
    scanf("%d.%d", &b, &c);
    ll res = a * (b * 100 + c);
    cout << res / 100;
    return 0;
}


Measured memory_bytes: 3704
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int n;
    cin>>n;
    int r = 1;
    int n1 = log2(n);
    for(int i = 1; i<=n1;i++)
    {
        r = r*2;
    }
    cout<<r<<endl;






    return 0;
}


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

int main()
{
	string str;
	cin>>str;
	int len = str.length();
	int c{};
	for(int i=len-3;i>0;i-=2)
	{
		c = 0;
		for(int j = 0;j<(i+1)/2;j++)
			if(str[j] == str[(i+1)/2+j])
				c++;
		if(c == (i+1)/2)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 3508
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;
int main()
{
    int K,B,A,i;
    cin>>K;
    cin >> A >>B;
	srep(i,A,B+1){
		if(i%K==0){
			cout <<"OK"<< endl;
            return 0;
		}
	}
    cout <<"NG"<< endl;
    return 0;
}

Measured memory_bytes: 3676
L = list(map(int,input().split()))
L.sort()
a, b, c = L[0], L[1], L[2]
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    x = c // 2
    y = c - x
    print(abs(a * b * x - a * b * y))

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

struct sqe {
	int n,w[5],h[5];
 };
 
 struct block {
	 int n,f[100],x[100],y[100],w[100],h[100];
 };
  
 sqe sq[101];
 block bl[15];
 
 int t,b[15],x,y,n,m[10][10],m2[10][10],m3[10][10],m4[15],an[10][10];
 
 void makebl(int s,int x1,int y1) {
	 int i,j,k,w2,h2;
	 bl[s].n=0;
	 for (i=0;i<100;i++) bl[s].f[i]=0;
	 for (i=0;i<sq[b[s]].n;i++) {
		 for (j=y1-sq[b[s]].h[i]+1;j<=y1;j++) {
			 if (j<0 || j+sq[b[s]].h[i]>y) continue;
			 for (k=x1-sq[b[s]].w[i]+1;k<=x1;k++) {
				 if (k<0 || k+sq[b[s]].w[i]>x) continue;
				 for (h2=j;h2<=j+sq[b[s]].h[i]-1;h2++)
				     for (w2=k;w2<=k+sq[b[s]].w[i]-1;w2++) if (m[h2][w2]!=0 && m[h2][w2]!=s+1) {h2=w2=99;} 
				     if (h2<99) { bl[s].x[bl[s].n]=k; bl[s].y[bl[s].n]=j;
				                  bl[s].w[bl[s].n]=sq[b[s]].w[i]; bl[s].h[bl[s].n]=sq[b[s]].h[i]; bl[s].n++;}
						  }
					  }
				  }
    }
    
void setflg() {
	int i,j,k,x1,y1;
	for (i=0;i<n;i++) {
		m4[i]=0;
		for (j=0;j<bl[i].n;j++) {
             for (y1=bl[i].y[j];y1<=bl[i].y[j]+bl[i].h[j]-1;y1++) { 
                  for(x1=bl[i].x[j];x1<=bl[i].x[j]+bl[i].w[j]-1;x1++) m2[y1][x1]=m2[y1][x1] | (1 << i);
			  }
	      }
	   }
	 for (y1=0;y1<y;y1++) for (x1=0;x1<x;x1++) for (i=0;i<n;i++) if (m2[y1][x1]==(1 << i)) m4[i]++;
	  for (i=0;i<n;i++) {
		 for (j=0;j<bl[i].n;j++) {
			  k=0;
			  for (y1=bl[i].y[j];y1<=bl[i].y[j]+bl[i].h[j]-1;y1++)
				for(x1=bl[i].x[j];x1<=bl[i].x[j]+bl[i].w[j]-1;x1++) if (m2[y1][x1]==(1 << i)) k++;
				if (k!=m4[i]) bl[i].f[j]=1;
			}
		}
	}  	     

int ans(int n1) {
	int i,j,x1,y1;
	if (n1==n) { t++;
		if (t==1) { for (i=0;i<y;i++) for (j=0;j<x;j++) an[i][j]=m3[i][j];} else return 1;
		return 0;}  
	for (i=0;i<bl[n1].n;i++) {
		if (bl[n1].f[i]==1) continue;
		
		 for (y1=bl[n1].y[i];y1<=bl[n1].y[i]+bl[n1].h[i]-1;y1++) 
		 	  for (x1=bl[n1].x[i];x1<=bl[n1].x[i]+bl[n1].w[i]-1;x1++) if (m3[y1][x1]!=0) x1=y1=99;
		 	  
		 	  if (x1<99) {
				 for (y1=bl[n1].y[i];y1<=bl[n1].y[i]+bl[n1].h[i]-1;y1++) 
		 	     for (x1=bl[n1].x[i];x1<=bl[n1].x[i]+bl[n1].w[i]-1;x1++) m3[y1][x1]=n1+1;
		 	     if (ans(n1+1)==1) return 1;
		 	     for (y1=bl[n1].y[i];y1<=bl[n1].y[i]+bl[n1].h[i]-1;y1++) 
		 	     for (x1=bl[n1].x[i];x1<=bl[n1].x[i]+bl[n1].w[i]-1;x1++) m3[y1][x1]=0;
			 }
			 
		 }
		 return 0;
	 }
	 
 int main() {
	 int i,j,g,k;
	 for (i=0;i<101;i++) sq[i].n=0;
	 for (i=1;i<11;i++) for (j=1;j<11;j++) { sq[i*j].w[sq[i*j].n]=j; sq[i*j].h[sq[i*j].n]=i; sq[i*j].n++;}
	 while(cin >> x >> y >> n && n>0) {
		 t=0;
		 for (i=0;i<n;i++) { cin >> g >> k; b[g-1]=k; t+=k; }
		 for (i=0;i<y;i++) for (j=0;j<x;j++) cin >> m[i][j];
		 for (i=0;i<y;i++) for (j=0;j<x;j++) { if (m[i][j]!=0) makebl(m[i][j]-1,j,i); m2[i][j]=m3[i][j]=0; }
		 if (t!=i*j) { cout << "NA" << endl; continue;}
		 t=0;
		 setflg();
		 ans(0);
		 if (t!=1) cout << "NA" << endl;
		 else { 		 
		 for (i=0;i<y;i++) {
			 for (j=0;j<x;j++) { cout << an[i][j]; if (j<x-1) cout << ' ';} 
			 cout << endl;
		      }
		  }
		}
			 
	 return 0;
 }

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

vector<vector<int>> G;

void dfs(int v, int p, vector<ll>& val){
    if(p != -1) val[v] += val[p];
    for(int i = 0; i < G[v].size(); i++){
        if(G[v][i] == p) continue;
        dfs(G[v][i], v, val);
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    G.resize(n);
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> val(n);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >> p >> x;
        p--;
        val[p] += x;
    }
    dfs(0, -1, val);
    for(auto v: val) cout << v << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 28264
#include<bits/stdc++.h>
using namespace std;
long long n,a[105],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])if(max(a[i],max(a[j],a[k]))<a[i]+a[j]+a[k]-max(a[i],max(a[j],a[k]))){
					ans++;
				}
			} 
		}
	} 
	cout<<ans;
	return 0;
}  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int a[510][510];
int ans[250000+10][4];

signed main(void) {
    int H, W; cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            int tmp; cin >> tmp;
            a[i][j] = tmp % 2;
        }
    }
    int cnt=0;
    for (int h=0; h<H; h++) {
        for (int w=0; w<W-1; w++) {
            if (a[h][w] == 1 && a[h][w+1] == 0) {
                ans[cnt][0] = h+1;
                ans[cnt][1] = w+1;
                ans[cnt][2] = h+1;
                ans[cnt][3] = w+2;
                cnt++;
                a[h][w] = 0;
                a[h][w+1] = 1;
            } else if (a[h][w] == 1 && a[h][w+1] == 1) {
                ans[cnt][0] = h+1;
                ans[cnt][1] = w+1;
                ans[cnt][2] = h+1;
                ans[cnt][3] = w+2;
                cnt++;
                a[h][w] = 0;
                a[h][w+1] = 0;
            }
        }
    }

    for (int w=0; w<W; w++) {
        for (int h=0; h<H-1; h++) {
            if (a[h][w] == 1 && a[h+1][w] == 0) {
                ans[cnt][0] = h+1;
                ans[cnt][1] = w+1;
                ans[cnt][2] = h+2;
                ans[cnt][3] = w+1;
                cnt++;
                a[h][w] = 0;
                a[h+1][w] = 1;
            } else if (a[h][w] == 1 && a[h+1][w] == 1) {
                ans[cnt][0] = h+1;
                ans[cnt][1] = w+1;
                ans[cnt][2] = h+2;
                ans[cnt][3] = w+1;
                cnt++;
                a[h][w] = 0;
                a[h+1][w] = 0;
            }
        }
    }

    cout << cnt << endl;
    rep(i, cnt) {
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    }


    return 0;
}

Measured memory_bytes: 9856
#include <cstdio>
using namespace std;
const long long mod=1000000007,NR=1919810;
long long n,k,ans,a[NR];
long long power(long long x,long long y)
{
	if(y==0)
	{
		return 1;
	}
	long long tmp=power(x,y>>1),ans=(tmp*tmp)%mod;
	if(y&1)
	{
		ans=(ans*x)%mod;
	}
	return ans;
}
long long c(long long n,long long k)
{
	return (a[n]*power((a[k]*a[n-k])%mod,mod-2))%mod; 
}
int main()
{
	scanf("%lld%lld",&n,&k);
	a[0]=1;
	for(long long i=1;i<2*n;i++)
	{
		a[i]=a[i-1]*i;
		a[i]%=mod; 
	}
	ans=c(2*n-1,n);
	for(long long i=1;i<n-k;i++)
	{
		ans=(ans-c(n,i)*c(n-1,i-1))%mod;
	}
	printf("%lld",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<string>
using namespace std;
void sort(int n[4],int a[6]);
int main(){
	int n[4]={1,2,6,5};
	int s[4]={1,5,6,2};
	int e[4]={1,4,6,3};
	int w[4]={1,3,6,4};
	int r[4]={2,3,5,4};
	int l[4]={2,4,5,3};
	int in;
	int sum;
	string st;
	while(cin>>in,in!=0){
		int a[6]={1,2,3,4,5,6};
		sum=1;
		for(int i=0;i<in;i++){
			cin>>st;
			if(st[0]=='N')sort(n,a);
			else if(st[0]=='N')sort(n,a);	
			else if(st[0]=='S')sort(s,a);	
			else if(st[0]=='E')sort(e,a);	
			else if(st[0]=='W')sort(w,a);	
			else if(st[0]=='R')sort(r,a);		
			else if(st[0]=='L')sort(l,a);	
			//for(int i=0;i<6;i++)cout<<a[i]<<" ";
			//cout<<endl;
			sum+=a[0];
		}
		cout<<sum<<endl;
	}
}



void sort(int n[4],int a[6]){
	int t;
	t=a[n[0]-1];
	for(int i=0;i<3;i++)
		a[n[i]-1]=a[n[i+1]-1];
	a[n[3]-1]=t;
}

Measured memory_bytes: 1200