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

struct node{
  struct node *parent;
  struct node *right;
  struct node *left;
  int key;
};

typedef struct node *Tree;

#define NILL NULL

Tree tree;Tree 

TreeSearch(Tree n,int k){
  if(n == NILL || k == n->key){
    return n;
  }
  if(k < n->key){
    return TreeSearch(n->left,k);
  }
  else{
    return TreeSearch(n->right,k);
  }
}

void TreeInsert(int k){
  Tree m = NILL;
  Tree l = tree;
  Tree n;

  n = malloc(sizeof(struct node));
  n->key = k;
  n->left = NILL;
  n->right = NILL;

  while(l != NILL){
    m = l;
    if(n->key < l->key){
      l = l->left;
    }
    else{
      l = l->right;
    }
  }
  n->parent = m;
  
  if(m == NILL){
    tree = n;
  }
  else if(n->key < m->key){
    m->left = n;
  }
  else{
    m->right = n;
  }
}

void TreePreorder(Tree n){
  if(n != NILL){
    printf(" %d",n->key); 
    TreePreorder(n->left);
    TreePreorder(n->right);
  }
}

void TreeInorder(Tree n){
  if(n != NILL){
    TreeInorder(n->left);
    printf(" %d",n->key);
    TreeInorder(n->right);
  }
}

int main(){
  int n,i,j;
  char command[10];
  scanf("%d",&n);

  for(i - 0;i < n;i++){
    scanf("%s",command);
    if(command[0] == 'i'){
      scanf("%d",&j);
      TreeInsert(j);
    }
    else if(command[0] == 'p'){
      TreeInorder(tree);
      printf("\n");
      TreePreorder(tree);
      printf("\n");
    }
    else if(command[0] == 'f'){
      scanf("%d", &j);
      Tree temp = TreeSearch(tree,j);
      if(temp != NILL)printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int h,w;
vector<vector<char>> str(100,vector<char>(100));

void f(vector<vector<char> >& str,int a,int b){
    int cnt=0;
    if(str[a+1][b+1]=='#') cnt++;
    if(str[a][b+1]=='#') cnt++;
    if(str[a-1][b+1]=='#') cnt++;
    if(str[a+1][b]=='#') cnt++;
    if(str[a-1][b]=='#') cnt++;
    if(str[a][b-1]=='#') cnt++;
    if(str[a-1][b-1]=='#') cnt++;
    if(str[a+1][b-1]=='#') cnt++;
    str[a][b]='0'+cnt;
}

int main(){
    cin>>h>>w;
    rep(i,h) rep(j,w) cin>>str[i+1][j+1];

    rep(i,h){
        rep(j,w){
            if(str[i+1][j+1]=='.') f(str,i+1,j+1);
        }
    }

    rep(i,h){
        rep(j,w) cout<<str[i+1][j+1];
        cout<<"\n";
    }
    return 0;
}

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

int main () {
  long long N;
  cin >> N;
  long long ans = 0;
  
  for (long long i = 1; i <= N; i++) {
    ans += ((1+N/i)*(N/i)/2)*i;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3644
function Main(input) {
    var N = parseInt(input[0], 10);
    var a = input.slice(1).map(e => parseInt(e, 10));

    var set = new Set(a);

    console.log(set.size);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 11468
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '1'){
            s[i] = '9';
        }else{
            s[i] = '1';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main{
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		
		int H1 = sc.nextInt();
		int M1 = sc.nextInt();
		int H2 = sc.nextInt();
		int M2 = sc.nextInt();
		int K = sc.nextInt();
		
		int start = H1 * 60 + M1;
		int end = H2 * 60 + M2;
		int temp = Math.min(start, end);
		end = Math.max(start, end);
		start = temp;
		
		System.out.println(end - start - K);
		
		sc.close();
	}
}

Measured memory_bytes: 35796
/*
 ALDS1_1_A
*/

#include <iostream>

using namespace std;

static const int MAX = 1000;

void outArray(int N, const int (&A)[MAX]) {
    for(int i = 0; i < N; i++) {
        cout << A[i];
        if(i < N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

int main() {
    int n, A[MAX];

    cin >> n;

    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }

    outArray(n, A);

    for(int i = 1; i < n; i++) {
        int v = A[i];
        int j = i-1;
        while( (j >= 0) && (A[j] > v) ) {
            A[j+1] = A[j];
            A[j] = v;
            j--;
        }
        outArray(n, A);
    }

}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 998244353;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

template<typename T>
struct SegmentTree {

	T id;
	function<T(T, T)> op;
	vector<T> dat;
	int size;

	SegmentTree(int n, T id, function<T(T, T)> op) : id(id), op(op) {
		size = 1;
		while (size < n) size <<= 1;
		dat.assign(size * 2 + 10, id);
	}

	void update(int k, T x) {
		k += size, dat[k] = x;
		while (k > 1) k >>= 1, dat[k] = op(dat[k << 1], dat[(k << 1) | 1]);
	}

	void merge(int k, T x) { update(k, op(x, dat[k + size])); }
	//[a, b)
	T query(int a, int b) {
		T tl = id, tr = id;
		for (int l = a + size, r = b + size; l < r; l >>= 1, r >>= 1) {
			if (l & 1) tl = op(tl, dat[l++]);
			if (r & 1) tr = op(tr, dat[--r]);
		}
		return (op(tl, tr));
	}
};


void Main() {
	int N; cin >> N;
	vector<Pl> dat(N); cin >> dat;
	SegmentTree<int> G(N, -INF, [](int a, int b) { return (max(a, b)); });

	sort(begin(dat), end(dat));
	for (int i = 0; i < N; i++) {
		auto &v = dat[i];
		int pos = lower_bound(begin(dat), end(dat), Pl(v.first + v.second, -LLINF)) - begin(dat);
		G.update(i, pos);
	}
	for (int i = N-1; i >= 0; i--) {
		int pos = G.query(i, i+1);
		int npos = G.query(i, pos);
		G.update(i, npos);
	}

	vint dp(N+1, 0);
	dp[0] = 1;
	for (int i = 0; i < N; i++) {
		(dp[i+1] += dp[i]) %= mod;
		(dp[G.query(i, i+1)] += dp[i]) %= mod;
	}
	cout << dp[N] << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}
const ll N=1e7+1;

ll arr[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(ll i=1;i<=N;i++){
        for(ll j=i;j<=N;j+=i){
            arr[j]++;
        }
    }
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=i*arr[i];
    }
    cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n ;
    cin >> n ;
    vector<tuple<ll,ll,ll>> vec(n) ;
    REP(i,n){
        ll x, y, h ;
        cin >> x >> y >> h ;
        vec[i] = MT(h,x,y) ;
    }
    sort(ALL(vec)) ;
    reverse(ALL(vec)) ;
    ll hh = get<0>(vec[0]) ;
    ll xx = get<1>(vec[0]) ;
    ll yy = get<2>(vec[0]) ;

    bool f ;

    for(ll i=0;i<=100;i++){
        for(ll j=0;j<=100;j++){
            f = true ;
            ll tmp = hh + abs(xx-i) + abs(yy-j) ;
            for(ll k=1;k<n;k++){
                ll hhh = get<0>(vec[k]) ;
                ll xxx = get<1>(vec[k]) ;
                ll yyy = get<2>(vec[k]) ;
                if(hhh != max((ll)0,tmp-abs(xxx-i)-abs(yyy-j))){
                    f = false ;
                }
            }
            if(f){
                cout << i << " " << j <<" " << tmp <<endl;
            }
        }
    }




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3668
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner scanner =  new Scanner(System.in);
        int x,y;
        while(true){
         x = scanner.nextInt();
         y = scanner.nextInt();
         if(x==0 && y==0){
             break;
         }
        if(x>y){
            System.out.printf("%d %d\n",y,x);
        }else{
            System.out.printf("%d %d\n",x,y);
        }
        }
    }

}



Measured memory_bytes: 41220
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    y = x;
    sort(y.begin(), y.end());
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        if(i < n/2) mp[y[i]] = y[n/2];
        else mp[y[i]] = y[n/2-1];
    }
    for(int i = 0; i < n; i++){
        cout << mp[x[i]] << '\n';
    }
    return 0;
}

Measured memory_bytes: 12928
fun main(args: Array<String>) {
  val inputs = readLine()
  if (inputs == null) return
  val (n, m, d) = inputs.split(" ").map { it.toInt() }
  val averageBeautifulnessPerPair = (n - d).toDouble() * (if (d == 0) 1 else 2 ) / n / n
  val averageBeautifulness = averageBeautifulnessPerPair * (m - 1)
  println(String.format("%.7f", averageBeautifulness))
}


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

bool solve(vector<tuple<int,int,int>>&a){
  bool ans=true;
  int x=0,y=0,t=0;
  for(int i=0;i<a.size();i++){
    if(abs(get<1>(a.at(i))-x)+abs(get<2>(a.at(i))-y)>get<0>(a.at(i))-t)
      ans=false;
    if(((get<0>(a.at(i))-t)-(abs(get<1>(a.at(i))-x)+abs(get<2>(a.at(i))-y)))%2!=0)
      ans=false;
    x=get<1>(a.at(i));
    y=get<2>(a.at(i));
    t=get<0>(a.at(i));
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  vector<tuple<int,int,int>>a(n);
  for(int i=0;i<n;i++)
    cin >> get<0>(a.at(i)) >> get<1>(a.at(i)) >> get<2>(a.at(i));
  cout << (solve(a)?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 4552
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int ar = a+w;
		int br = b+w;

		if(ar < b){
			System.out.println(b-ar);
		}else if (br < a) {
			System.out.println(a-br);
		}else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21204
#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>;
const int INF = 1001001001;

ll gcd(ll x, ll y){
  if(y == 0) return x;
  else return gcd(y, x%y);
}

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

  ll sum = 0;
  for(int a = 1; a < k+1; a++){
    for(int b = 1; b < k+1; b++){
      for(int c = 1; c < k+1; c++){
        sum += gcd(gcd(a,b), c);
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
#define int long long
int mas[300000];
int ps[300000];
int t[1000000];
void incr(int v, int tl, int tr, int pos) {
	if (tl == tr) {
		t[v] += 1;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm) {
		incr(v * 2, tl, tm, pos);
	}
	else {
		incr(v * 2 + 1, tm + 1, tr, pos);
	}
	t[v] = t[v * 2] + t[v * 2 + 1];
}
int get_sum(int v, int tl, int tr, int l, int r) {
	if (tl > r || l > tr) return 0;
	if (tl >= l && tr <= r) return t[v];
	int tm = (tl + tr) / 2;
	return get_sum(v * 2, tl, tm, l, r) + get_sum(v * 2 + 1, tm + 1, tr, l, r);
}
signed main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> mas[i];
	}
	for (int i = 1; i <= n; ++i) {
		mas[i] -= k;
	}
	vector <int> v;
	for (int i = 1; i <= n; ++i) {
		ps[i] = ps[i - 1] + mas[i];
		v.push_back(ps[i]);
	}
	v.push_back(0);
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	for (int i = 1; i <= n; ++i) {
		ps[i] = lower_bound(v.begin(), v.end(), ps[i]) - v.begin();
	}
	int ans = 0;
	incr(1, 0, 400000, lower_bound(v.begin(), v.end(), 0) - v.begin());
	for (int i = 1; i <= n; ++i) {
		ans += get_sum(1, 0, 400000, 0, ps[i]);
		incr(1, 0, 400000, ps[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 13296
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int memo[1026][1002];
const int INF = (1e6);

int cubo[12][1002];
int acumCubo[12][1002];
int getCubo(int x0, int y0, int x1, int y1) {
  if (x0 == 0 && y0 == 0) {
    return acumCubo[x1][y1];
  } else if (x0 == 0) {
    return acumCubo[x1][y1] - acumCubo[x1][y0 - 1];
  } else if (y0 == 0) {
    return acumCubo[x1][y1] - acumCubo[x0 - 1][y1];
  } else {
    return acumCubo[x1][y1] - acumCubo[x0 - 1][y1] - acumCubo[x1][y0 - 1] + acumCubo[x0 - 1][y0 - 1];
  }
}
int n, m;
int k;
int dp(int mask, int pos) {
  if (pos == m) return 0;
  if (memo[mask][pos] != -1) return memo[mask][pos];
  vector<int> cuts;
  cuts.pb(-1);
  fore(i, 0, n) if (mask & (1 << i)) cuts.pb(i);
  int &ans = memo[mask][pos] = INF;
  int maxi = -1;
  fore(i, pos, m) {
    bool valid = true;
    fore(_, 1, SZ(cuts)) {
      if (getCubo(cuts[_ - 1] + 1, pos, cuts[_], i) > k) valid = false;
    }
    if (!valid) break;
    maxi = i;
    //ans = min(ans, 1 + dp(mask, i + 1));
  }
  if (maxi != -1) ans = min(ans, 1 + dp(mask, maxi + 1));
  return ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m >> k;
  fore(i, 0, n) fore(j, 0, m) {
    char x;
    cin >> x;
    if (x == '1') cubo[i][j]++;
  }
  fore(i, 0, n) fore(j, 0, m) {
    if (i == 0 && j == 0) {
      acumCubo[i][j] = cubo[i][j];
    } else if (i == 0) {
      acumCubo[i][j] = cubo[i][j] + acumCubo[i][j - 1];
    } else if (j == 0) {
      acumCubo[i][j] = cubo[i][j] + acumCubo[i - 1][j];
    } else {
      acumCubo[i][j] = cubo[i][j] + acumCubo[i][j - 1] + acumCubo[i - 1][j] - acumCubo[i - 1][j - 1];
    }
  }
  int ans = INF;
  memset(memo, -1, sizeof memo);
  //cout << dp(13, 0) << endl;
  fore(mask, (1 << (n - 1)), 1 << n) {
    int currentCuts = __builtin_popcount(mask) - 1;
    //cout << mask << "->" << currentCuts << " " << dp(mask, 0) << endl;
    //break;
    ans = min(ans, currentCuts + dp(mask, 0) - 1);
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 long ans(vector<vector<char>>& grid,vector<vector<long>>& dp,int r,int c,int m,int n){
     if(r<0||c<0||r>=m||c>=n||grid[r][c]=='#'){
         return 0;
     }
     if(dp[r][c]!=-1){
         return dp[r][c];
     }
     if(r==m-1&&c==n-1){
         return 1;
     }
     long ans1 = ans(grid,dp,r+1,c,m,n);
     long ans2 = ans(grid,dp,r,c+1,m,n);
     dp[r][c] = (ans1 + ans2)%1000000007;
     return dp[r][c];
 }
int main() {
	int n,m;
	cin>>m>>n;
	vector<vector<char>> grid(m,vector<char>(n));
	for(int i=0;i<m;i++){
	    for(int j=0;j<n;j++){
	        cin>>grid[i][j];
	    }
	}
	vector<vector<long>> dp(m,vector<long>(n,-1));
    cout<<ans(grid,dp,0,0,m,n)<<'\n';
}

Measured memory_bytes: 9344
n = input()
k = int(input())

dp1 = [ [ i+1 for i in range(9) ] for i in range(201)]
dp2 = [ [ 0 for i in range(9) ] for i in range(201)]
dp3 = [ [ 0 for i in range(9) ] for i in range(201)]

for i in range(200):
    for j in range(9):
        if j == 0:
            dp1[i+1][j] = dp1[i][-1] + 1
        else:
            dp1[i+1][j] = dp1[i+1][j-1] + 1

for i in range(200):
    for j in range(9):
        if j == 0:
            dp2[i+1][j] = dp2[i][-1] + 9 * (i)
        else:
            dp2[i+1][j] = dp2[i+1][j-1] + 9 * (i+1)

for i in range(200):
    for j in range(9):
        if j == 0:
            dp2[i+1][j] = dp2[i][-1] + 9 * (i)
        else:
            dp2[i+1][j] = dp2[i+1][j-1] + 9 * (i+1)

for i in range(100):
    for j in range(9):
        if j == 0:
            dp3[i+1][j] = dp3[i][-1] + 81 * i*(i-1)//2
        else:
            dp3[i+1][j] = dp3[i+1][j-1] + 81 * (i+1) * i //2


def solve(s, x):
    if s == "0":
        return 0
    elif s[0] == "0":
        return solve(s[1:], x)

    if x == 1:

        return  dp1[len(s)-1][int(s[0]) - 1]
    elif x == 2:
        if len(s) < 2:
            return 0
        return  dp2[len(s)-1][int(s[0]) - 1] + solve(s[1:], 1)
    elif x == 3:
        if len(s) < 3:
            return 0
        return  dp3[len(s)-1][int(s[0]) - 1] + solve(s[1:], 2)

print(solve(n, k))


Measured memory_bytes: 39664
#include <iostream>

int main()
{
  	char b;
  	std::cin >> b;
  	switch (b)
    {
      case 'A': b = 'T'; break;
      case 'T': b = 'A'; break;
      case 'C': b = 'G'; break;
      case 'G': b = 'C'; break;
      default: __builtin_unreachable();
    }
  	std::cout << b;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		boolean plusA = (A % 10000 / 1000) * 10 + (A / 10000) >= (A % 100);
		boolean plusB = (B % 10000 / 1000) * 10 + (B / 10000) <= (B % 100);
		System.out.println((B / 100) - (A / 100) - 1 + (plusA ? 1 : 0) + (plusB ? 1 : 0));
	}
}


Measured memory_bytes: 23636
#include <iostream>
using namespace std;
int main () {
	int n, a[4][13]={0}, b;
	char x[4]={'S','H','C','D'}, y;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> y;
		for (int j=0; j<4; j++){
			if (y==x[j]) {
				cin >> b;
				a[j][b-1]=1;
			}
		}
	}
	for (int k=0;k<4;k++){
		for (int l=0;l<13;l++){
			if (a[k][l]==0) cout << x[k] << ' ' << l+1 << endl;
		}
	}
}


Measured memory_bytes: 3096
n = int(input())
l = []
for i in range(1,n+1):
    check = []
    if i%3 == 0:
        l.append(str(i))
    for j in str(i):
        if j == "3" and (not i%3 == 0):
            l.append(str(i))
            break
str = ' '.join(l)

print(" "+str)

        


Measured memory_bytes: 6004
import sys

readline = sys.stdin.readline
N, M = map(int, readline().split())
H = list(map(int, readline().split()))
good = [True] * N
for _ in range(M):
    a, b = map(int, readline().split())
    if H[a-1] > H[b-1]:
        good[b-1] = False
    elif H[a-1] < H[b-1]:
        good[a-1] = False
    else:
        good[a-1] = good[b-1] = False
print(sum(good))


Measured memory_bytes: 20192
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var k = int.Parse(Console.ReadLine());
            var sum = 0L;
            for (var a = 1; a <= k; a++)
            {
                for (var b = 1; b <= k; b++)
                {
                    var tmp = GCD(a, b);
                    for (var c = 1; c <= k; c++)
                    {
                        sum += GCD(tmp, c);
                    }
                }
            }
            Console.WriteLine(sum);
        }

        static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    }
}


Measured memory_bytes: 27520
#include <iostream> 
typedef long long ll;
using namespace std;

int main()
{
	string s;
	ll k;
	while(cin>>s>>k){
		int n=0,ans=1;
		for(int i=0;i<s.length();i++){
			int t=s[i]-'0';
			n=i+1;	
			if(t!=1){
				ans=t;
				break;
			}
		}
		if(k<n)
			cout<<1<<endl;
		else
			cout<<ans<<endl;
	}
	return 0;
}


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

AB_lis = [list(map(int, input().split())) for _ in range(N)]

AB_lis_sorted = sorted(AB_lis, key=lambda x: x[1])

count = 0
flag = 0
for a, b in AB_lis_sorted:
  count += a
  flag += 1
  if count > b:
    print("No")
    break
  if flag == N:
    print("Yes")
    break

Measured memory_bytes: 55264
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int size = Integer.parseInt(br.readLine());

		String[] input = br.readLine().split(" ");
		int[] A = new int[size];
		for (int i = 0; i < size; i++) {
			A[i] = Integer.parseInt(input[i]);
		}
		Arrays.sort(A);

		size = Integer.parseInt(br.readLine());
		input = br.readLine().split(" ");
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			if (isCreateNum(A, 0, 0, Integer.parseInt(input[i]))) {
				sb.append("yes").append("\n");
			} else {
				sb.append("no").append("\n");
			}
		}
		System.out.print(sb);
	}

	static boolean isCreateNum(int[] srcArray, int srcIndex, int sum, int num) {
		if (srcIndex > srcArray.length - 1) return false;
		if (srcArray[srcIndex] + sum == num) return true;
		if (srcArray[srcIndex] + sum > num) {
			return false;
		} else if (isCreateNum(srcArray, srcIndex + 1, sum, num)) {
			return true;
		} else if (isCreateNum(srcArray, srcIndex + 1, sum + srcArray[srcIndex], num)) {
			return true;
		}
		return false;
	}
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i];
    int m = 0;
    for(int i = n-1; i >= 0; i--){
        int sum = 0;
        for(int j = 2;j <= n/(i+1);++j){
            sum += b[j*(i+1)-1];
        }
        if(abs(a[i]-sum) % 2 == 0) b[i] = 0;
        else {
            b[i] = 1;
            m++;
        }
    }
    cout << m << endl;
    rep(i,n) if(b[i] == 1) cout << i+1 << endl;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    const ll MOD = 1e9 + 7;

    ll n, k;
    cin >> n >> k;

    vector<vector<ll>> comb(n + 1, vector<ll>(n + 1));
    for (int i = 0; i <= n; ++i) comb[i][0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= i; ++j)
            (comb[i][j] += comb[i - 1][j - 1] + comb[i - 1][j]) %= MOD;

    for (ll i = 1; i <= k; ++i)
        cout << (comb[k - 1][i - 1] * comb[n - k + 1][i]) % MOD << '\n';

    return 0;
}


Measured memory_bytes: 31616
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a,b) memset(a, b, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        ll ans=0;
        ll n,k;cin >> n >> k ;
//        if(n==1){
//            if(k==1) cout << 2 ;
//            else cout << 1 ;
//            return 0 ;
//        }
        ll chek;
        for(ll i=k;i<=n+1;++i){
            chek = (i*(n+1-i)+1)%mod;
            ans=(ans+chek)%mod;
        }
        cout << ans%mod<<endl;



return 0;
}



Measured memory_bytes: 3652
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    int n;cin>>n;
    int ans;
    for(int i=1000; i<n+1000; i+=1000){
        ans = i - n;
        if(ans>0) break;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3628
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> a(n);
		REP(i, n) cin >> a[i];
		bool f = true;
		REP(i, n) {
			if(a[i] != 0) {
				f = false;
			}
		}
		if(f) {
			cout << 0 << endl;
			continue;
		}
		auto mi = min_element(ALL(a));
		auto ma = max_element(ALL(a));
		vector<P> ans;
		if(abs(*ma) > abs(*mi)) {
			a[0] += *ma * 2;
			REP(_, 2) ans.emplace_back(ma - a.begin() + 1, 1);
			REP(i, n-1) {
				a[i+1] += a[i] * 2;
				ans.emplace_back(i+1, i+2);
				ans.emplace_back(i+1, i+2);
			}
		} else {
			a[n-1] += *mi * 2;
			REP(_, 2) ans.emplace_back(mi - a.begin() + 1, n);
			RREP(i, n-1) {
				a[i] += a[i+1] * 2;
				ans.emplace_back(i+2, i+1);
				ans.emplace_back(i+2, i+1);
			}
		}
		dpite(ALL(a));
		cout << SZ(ans) << endl;
		REP(i, SZ(ans)) {
			cout << ans[i].F << ' ' << ans[i].S << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <chrono>
#include <random>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define sz(x) x.size()
#define lowbit(x) x&(-x)
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define int long long
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;
const int N=1e6+10;

int a[N],sum[N],siz[N],ans[N],n;
vector<int>e[N];

void dfs1(int u,int fa) {
    siz[u]=1;
    for(auto v:e[u]) {
        if(v==fa) continue;
        dfs1(v,u);
        siz[u]+=siz[v];
    }
}

void dfs2(int u,int fa) {
    ans[a[u]]+=siz[u]*(n-siz[u]-sum[a[u]]+1);
    sum[a[u]]+=siz[u];
    int ss=sum[a[u]];
    int pre=0;
    for(auto v:e[u]) {
        if(v==fa) continue;
        sum[a[u]]=n-siz[v];
        dfs2(v,u);
        ans[a[u]]+=pre*siz[v];
        pre+=siz[v];
    }
    sum[a[u]]=ss;
}

signed main() {
    IOS;
#ifdef xiaofan
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
#endif

    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<n; i++) {
        int u,v;
        cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs1(1,1);
    dfs2(1,1);
    for(int i=1; i<=n; i++) cout<<ans[i]<<endl;



    return 0;
}

Measured memory_bytes: 55100
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void  solve(){
  int n,m,Q,p,q,l,r;
  cin>>n>>m>>Q;
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));
  rep(i,0,m){
    cin>>l>>r;
    dp[l][r]++;
  }
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i][j-1];
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i-1][j];
  rep(i,0,Q){
    cin>>p>>q;
    cout<<dp[q][q]+dp[p-1][p-1]-dp[p-1][q]-dp[q][p-1]<<endl;
  }
}
int main(){
    optimizeIO();
    solve();
}


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

using namespace std;

struct Op {
    int x,y,u,v;
    Op() {}
    Op(int _x,int _y,int _u,int _v):x(_x), y(_y),u(_u),v(_v){} 
};

int a[512][512];

void solve() {
    int n,m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    vector<Op> res;
    for (int i = 1; i <= n; i++) {
        if (i&1) {
            for (int j = 1; j < m; j++) {
                if (a[i][j] & 1) {
                    res.emplace_back(i,j,i,j+1);
                    a[i][j]--;
                    a[i][j+1]++;
                }
            }
            if (i != n && (a[i][m] & 1)) {
                res.emplace_back(i,m,i+1,m);
                a[i][m]--;
                a[i+1][m]++;
            }
        } else {
            for (int j = m; j >= 2; j--) {
                if (a[i][j] & 1) {
                    res.emplace_back(i,j,i,j-1);
                    a[i][j]--;
                    a[i][j-1]++;
                }
            }
            if (i != n && (a[i][1] & 1)) {
                res.emplace_back(i,1,i+1,1);
                a[i][1]--;
                a[i+1][1]++;
            }
        }
    }
    cout << res.size() << "\n";
    for (auto& p: res) {
        cout << p.x << ' ' << p.y << ' '<< p.u <<' '<<p.v<<"\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long n;
	cin>>n;
	long i,pre[n]={0},suf[n]={0},a1[n],a2[n],pree=0,suff=0,max=0,sum;
	for(i=0;i<n;i++)
		cin>>a1[i];
	for(i=0;i<n;i++)
		cin>>a2[i];
	for(i=0;i<n;i++)
	{
		pree+=a1[i];
		pre[i]=pree;
		}
	for(i=n-1;i>=0;i--)
	{
		suff+=a2[i];
		suf[i]=suff;
	}
	for(i=0;i<n;i++)
	{
		sum=pre[i]+suf[i];
		if(sum>max)
			max=sum;
		
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import factorial
from itertools import permutations
def main():
    n = int(input())
    town_coor = []
    for _ in range(n):
        town_coor.append(tuple(map(int, input().split())))

    towns = [i for i in range(n)]
    roads = permutations(towns, n)
    sum_roads = 0
    for road in roads:
        sum_road = 0
        for i1 in range(n-1):
            sum_road += ((town_coor[road[i1]][0] - town_coor[road[i1 +1]][0])**2 + (town_coor[road[i1]][1] - town_coor[road[i1 +1]][1])**2)**0.5
        sum_roads += sum_road
    print(sum_roads / factorial(n))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
from collections import defaultdict
str_s = input()
str_t = input()


def check_pattern(str):
    checkdict = defaultdict(int)
    pattern = list()
    for w in str:
        if w not in checkdict:
            checkdict[w] = len(checkdict) + 1

        pattern.append(checkdict[w])
    return pattern


if check_pattern(str_s) == check_pattern(str_t):
    print("Yes")
else:
    print("No")




Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
int main(){
int r,g,b,n;
  cin >> r >> g >> b;
  n = 100*r + 10 * g + b;
  if (n%4==0){
    cout <<"YES"<<endl;
  }
  else {
    cout <<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1010,M=200010;
int n,m;
int rx[N],ry[N];
vector<int> vec[N],id[N];
bool vis[N][N],bo[N][N],ans[M];
inline void dfs1(int x,int y)
{
    vis[y][x]=true;
    for(int k=0;k<vec[x].size();k++)
    {
        int to=vec[x][k];
        if(vis[y][to]) continue;
        dfs1(to,y);
    }
    return;
}
inline void dfs2(int x,int y)
{
    rx[x]=y;
    for(int k=0;k<vec[x].size();k++)
    {
        int to=vec[x][k];
        if(rx[to]) continue;
        dfs2(to,y);
    }
    return;
}
int main()
{
//    freopen("1.in","r",stdin);
    scanf("%d%d",&n,&m);
    for(int k=1;k<=m;k++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        vec[x].push_back(y);
        id[x].push_back(k);
    }
    for(int k=1;k<=n;k++)
        dfs1(k,k);
    for(int k=1;k<=n;k++)
    {
        memset(rx,0,sizeof rx);
        memset(ry,0,sizeof ry);
        rx[k]=1;
        for(int i=0;i<vec[k].size();i++)
        {
            int to=vec[k][i];
            if(rx[to]) continue;
            dfs2(to,id[k][i]);
        }
        for(int i=1;i<=n;i++)
            swap(rx[i],ry[i]);
        rx[k]=1;
        for(int i=vec[k].size()-1;i>=0;i--)
        {
            int to=vec[k][i];
            if(rx[to]) continue;
            dfs2(to,id[k][i]);
        }
        for(int i=0;i<vec[k].size();i++)
        {
            int to=vec[k][i];
            if(rx[to]^ry[to]) bo[k][to]=1;
        }
    }
    for(int k=1;k<=n;k++)
    {
        for(int i=0;i<vec[k].size();i++)
        {
            int to=vec[k][i];
//            cout<<k<<" "<<to<<" "<<vis[to][k]<<" "<<vis[k][to]<<" "<<bo[k][to]<<endl;
            if(vis[to][k]&&bo[k][to]==0) ans[id[k][i]]=1;
            if(vis[to][k]==0&&bo[k][to]) ans[id[k][i]]=1;
        }
    }
    for(int k=1;k<=m;k++)
    {
        if(ans[k]) printf("diff\n");
        else printf("same\n");
    }
    return 0;
}


Measured memory_bytes: 8956
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
int N;
bool can_buy = false;
cin >> N;
for(int i = 0; i < 25 ; i++){
    for(int j = 0; j < 15; j++){
        if(N == 4*i + 7*j)can_buy = true;
    }
    
}
if(can_buy)cout << "Yes" << endl;
else cout << "No" << endl;


}

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

using namespace std;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int rez = 0, t;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, rez += t >= k;
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0) puts("Positive");
    else if(b>=0) puts("Zero");
    else if((a&1)^(b&1)) puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<ll, ll>
ll ans = 0;
int main()
{
    ll m, d, c, tmp = 0, prv = 0;
    scanf("%lld", &m);
    for (ll i = 0; i < m; i++)
    {
        scanf("%lld %lld", &d, &c);
        for (; c > 9; c = (c / 10) + (c % 10))
            ans += (c / 10) * (d + 9);
        tmp = d;
        for (; c != 1; c--)
        {
            ans++;
            tmp += d;
            if (tmp > 9)
                ans++, tmp = (tmp % 10) + 1;
        }
        tmp += prv;
        ans++;
        if (tmp > 9)
            ans++, tmp = (tmp % 10) + 1;
        prv = tmp;
    }
    printf("%lld\n", ans - 1);
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
# import sys
# sys.setrecursionlimit(10 ** 5+1)
import numpy as np
# import IPython

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, M = ds_in()

child = {i+1: [] for i in range(N)}
parent = {i+1: [] for i in range(N)}
inflow = {i+1: 0 for i in range(N)}
for _ in range(N+M-1):
    a, b = ds_in()
    child[a].append(b)
    parent[b].append(a)
    inflow[b] += 1

candidates = []
for i, j in inflow.items():
    if j == 0:
        candidates.append(i)

sorted_edges = []
while len(sorted_edges) < N:
    par = candidates.pop()
    sorted_edges.append(par)
    for chi in child[par]:
        inflow[chi] -= 1
        if inflow[chi] == 0:
            candidates.append(chi)


sorted_index = np.zeros(N+1, dtype=int)
sorted_index[sorted_edges] = np.arange(N)

for i in range(1, N+1):
    if i == sorted_edges[0]:
        print(0)
    else:
        print(parent[i][np.argmax(sorted_index[parent[i]])])


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

int main() {
  int N,no_1=0,no_2=0;
  std::vector<int> vec(200000);
  cin >> N;

 for (int i = 0; i < N; i++) {
 cin >> vec.at(i);
}
  for (int j = 0; j < N; j++) {
  if(no_1 < vec.at(j)){
        no_2=no_1;
        no_1=vec.at(j);
    }else if(no_2 < vec.at(j)){
        no_2=vec.at(j);
    }
}
  for (int k = 0; k < N; k++) {
    if(vec.at(k)==no_1)
      cout << no_2 << endl;
    else
      cout << no_1 << endl;
}
}


Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int n,m;
vvi in;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int out;
void f(int x,int y,int c){
	if(c==10)return;
	rep(i,4){
		int nx=x,ny=y;
//		cout<<nx<<" "<<ny<<endl;
		while(1){
			nx+=dx[i];ny+=dy[i];
			if(nx<0||ny<0||nx>=n||ny>=m)break;
			if(in[x+dx[i]][y+dy[i]]==1)break;
			if(in[nx][ny]==3){
				out=min(out,c+1);
				return;
			}
			if(in[nx][ny]==1){
				in[nx][ny]=0;
				f(nx-dx[i],ny-dy[i],c+1);
				in[nx][ny]=1;
				break;
			}
		}
	}
}
int main(){
	while(cin>>m>>n,n+m){
		out=inf;
		in=vvi(n,vi(m));
		rep(i,n)rep(j,m)cin>>in[i][j];
		rep(i,n)rep(j,m)if(in[i][j]==2){
			f(i,j,0);
			if(out!=inf)cout<<out<<endl;
			else cout<<-1<<endl;
			goto end;
		}
		end:;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, s, t;
int u, v; ll a, b;

using Graph = vector<vector<pli>>;

void dijkstra(const Graph &g, int root, vector<ll> &dist) {
    rep(i, n+1) dist[i] = LLINF;
    dist[root] = 0;
    priority_queue<pli, vector<pli>, greater<pli>> q;
    q.emplace(0, root);

    while (!q.empty()) {
        auto top = q.top(); q.pop();
        int u = top.second;
        for (const auto &e: g[u]) {
            int v = e.second;
            ll cost = e.first;
            if (chmin(dist[v], dist[u] + cost)) {
                q.emplace(dist[v], v);
            }
        }
    }
}


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

    // g1: 円   g2: スヌーク
    Graph g1(n+1), g2(n+1);
    rep(i, m) {
        cin >> u >> v >> a >> b;
        g1[u].emplace_back(a, v);
        g1[v].emplace_back(a, u);
        g2[u].emplace_back(b, v);
        g2[v].emplace_back(b, u);
    }

    vector<ll> ds(n+1), dt(n+1);
    dijkstra(g1, s, ds);
    dijkstra(g2, t, dt);

    vector<ll> res(n, LLINF);
    res[n-1] = ds[n] + dt[n];
    for (int i = n-2; i >= 0; i--) {
        res[i] = min(ds[i+1] + dt[i+1], res[i+1]);
    }
    ll x = 1e15;
    rep(i, n) cout << x - res[i] << endl;
}


Measured memory_bytes: 19012
import java.util.*;

public class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a<b){
			System.out.println("a < b");
		}else if(a==b){
			System.out.println("a == b");
		}else{
			System.out.println("a > b");
		}
	}
}


Measured memory_bytes: 26244
def isUruu(t):
    if t%4==0:
        if t%100==0:
            if t%400==0:return True
            return False
        return True
    return False
n=0
while 1:
    n+=1
    a,b=map(int,raw_input().split())
    if a!=0 and b!=0 and n!=1:print
    if a==b==0:break
    cnt=0
    for i in xrange(a,b+1):
        if isUruu(i):
            print(i)
            cnt+=1
    if cnt==0:
        print('NA')

Measured memory_bytes: 6304