akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        Console.WriteLine(ReadInt(n).Where((x, i) => x % 2 == 1 && i % 2 == 0).Count());
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 28268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buffer[] = new String[3];
        int array[] = new int[3];
        String ans;
 
        while(true){
 
 
            try {
                buffer = br.readLine().split("\\s+");
                for(int i = 0; i < buffer.length; i++){
                    array[i] = Integer.parseInt(buffer[i]);
                }
                if(array[0] == -1 && array[1] == -1 && array[2] == -1)break;
 
                if(array[0] == -1 || array[1] == -1){
                    ans = "F";
                }else if(array[0]+array[1] >= 80){
                    ans = "A";
                }else if(array[0]+array[1] >= 65){
                    ans = "B";
                }else if(array[0]+array[1] >= 50){
                    ans = "C";
                }else if(array[0]+array[1] >= 30){
                    if(array[2] >= 50){
                        ans = "C";
                    }else{
                        ans = "D";
                    }
                }else{
                    ans = "F";
                }
 
                System.out.printf("%s\n", ans);
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 24640
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;

void solve()
{
	int n,m;
	cin>>n>>m;
	int a[n+1];
	f(i,1,n) cin>>a[i];
	vector<int> v[n+1];
	f(i,1,m){
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int ans=n;
	f(i,1,n){
		for(auto X:v[i]){
			if(a[X]>=a[i])
			{
				// cout<<i<<endl;
				ans--;
				break;
			}
		}
	}
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 10280
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
string s;
long long K;
int main(){
  cin >> s;
  cin >> K;
  long long k = K;
  int l = s.length();
  for(int i = 0; i < l; i++){
    long long p = (long long)( 26 - (s[i] - 'a') ) % 26;
    if( p <= k ){
      s[i] = 'a';
      k -= p;
    }
  }
  long long t = s[l-1] - 'a' + k;
  s[l-1] = 'a' + (char)( t % 26 );
  cout << s << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x; cin>>n>>m>>x;
    vi a(m);
    rep(i,m) cin>>a[i];
    int a1 = lower_bound(all(a),x)-a.begin();
    int a2 = a.end()-upper_bound(all(a),x);
    cout<<min(a1,a2)<<endl;
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pll> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;

    sort(ALL(v));
    ll ans = 0;
    ll cnt = 0;
    rep(i, n)
    {
        if (cnt >= m)
            break;

        if (v[i].second + cnt <= m)
        {
            cnt += v[i].second;
            ans += v[i].first * v[i].second;
        }
        else
        {
            ans += v[i].first * (m - cnt);
            break;
        }
    }

    OP(ans);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
        using namespace std;
        #define endl              "\n"
        #define int               long long
        #define rep(i,a,b)        for(long long i=a;i<b;i++)
        #define repp(i,a,b)        for(long long i=a;i<=b;i++)
        #define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
         
         
        void solve()
        {
            
            string s;
            cin >> s;


cout<<s[0];
cout<<s[1];
cout<<s[2];

            cout<<endl;
           
        }
         
        signed main() {
            IOS;
        
            //sieve();
            int t = 1;
            //cin >> t;
            while (t--) solve();
            return 0;
        }

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <queue>

struct N {
    N(int i, int c) : i(i), c(c) {}
    int i;
    int c;
};

using vi = std::vector<int>;
using vvi = std::vector<vi>;

using qN = std::queue<N>;

int main() {
    int n; std::cin >> n;
    vvi g(n + 1);
    for (int i = 0; i < n - 1; i++) {
        int a, b; std::cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi marked(n + 1);
    vi c(2);
    qN q;
    q.emplace(1, 0);
    q.emplace(n, 1);

    while (!q.empty()) {
        auto e = q.front();
        q.pop();
        if (marked[e.i]) continue;
        marked[e.i] = 1;
        c[e.c]++;
        for (auto a : g[e.i]) {
            if (!marked[a]) q.emplace(a, e.c);
        }
    }

    std::cout << (c[0] > c[1] ? "Fennec" : "Snuke") << std::endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> graph(n+1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<int> dict(n+1, -1);
  queue<int> que;
  dict[1] = 0;
  que.push(1);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv : graph[v]){
      if(dict[nv] != -1) continue;
      dict[nv] = dict[v] + 1;
      que.push(nv);
    }
  }
  cout << "Yes" << endl;
  for(int i=2; i<=n; i++){
    for(int v : graph[i]){
      if(dict[i] - dict[v] == 1){
        cout << v << endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 10196
def query(x):
    cnt=0
    while(x>0):
        x=x%bin(x).count('1')
        cnt+=1
    return cnt

N=int(input())
X=input()[::-1]
c=X.count('1')

sump,summ=0,0
for i in range(N):
    if X[i]=='1':
        sump=(sump+pow(2,i,c+1))%(c+1)
        if c>1:
            summ=(summ+pow(2,i,c-1))%(c-1)
ans=[]
for i in range(N):
    if X[i]=='0':
        x=(sump+pow(2,i,c+1))%(c+1)
        ans.append(query(x)+1)
    else:
        if c==1:
            ans.append(0)
        else:
            x=(summ-pow(2,i,c-1)+c-1)%(c-1)
            ans.append(query(x)+1)
print(*ans[::-1],sep='\n')

Measured memory_bytes: 95828
N=int(input())
l=[1,3,6,10,15,21,28,36,45]
a=0
for i in range(2,1000001):
    t=0
    while N%i==0:
        t+=1
        N//=i
    if t:
        for i in range(9):
            if t<l[i]:
                a+=i
                break
if N>1000000:
    a+=1
print(a)

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {

    private static final String YES = "Yes";
    private static final String NO = "No";

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;

        return areBothOdd(A, B) ? YES : NO;
    }

    private static boolean areBothOdd(int A, int B) {
        return isOdd(A) && isOdd(B);
    }

    private static boolean isOdd(int n) {
        return n % 2 != 0;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        return new TestCase(A, B);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;

        public TestCase(int A, int B) {
            this.A = A;
            this.B = B;
        }
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE
/*
  考察:
  Cをソートすることで大きい順に操作することができる。
  i番目の要素を見ているときに、それ以降はビットが揃っていることが保証される。
  S[i] != T[i]かつそれ以下のビットが違う数 * 通り数 * C[i]の和が答えになる
 */


Int pow2(Int n){
  static Int mem[200010], used[200010];
  if(n == 0) return 1;
  if(used[n]++) return mem[n];
  return mem[n] = 2 * pow2(n - 1) % mod;
}

Int numbit(Int n){
  static Int mem[200010], used[200010];
  if(n == 0) return 0;
  if(used[n]++) return mem[n];
  Int a = pow2(n - 1) + numbit(n - 1);
  Int b = 0 + numbit(n - 1);
  return mem[n] = (a + b) % mod;
}

Int numbit2(Int n){
  Int res = 0;
  for(Int i=0;i<(1<<n);i++) if(i&1) res += __builtin_popcount(i);
  return res * pow2(n);
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> C(N);
  cin>>C;
  sort(C.begin(), C.end(), greater<Int>());

  Int ans = 0;
  for(Int i=0;i<N;i++){
    Int a = (pow2(i) + numbit(i)) * pow2(i+1)  % mod;
    Int b = pow2(N - i - 1) * pow2(N - i - 1) % mod;
    Int num = (a * b % mod) * C[i];
    ans = (ans + num) % mod;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	int N;
	cin >> N;
	bool ok = 0;
	rep(i,10)rep(j,10){
		if(i*j==N)ok =1;
	}
	if(ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

typedef unsigned long long ulli;

const ulli B = 1000000007ULL;


ulli getHash(const string &s) {
  int n = s.size();
  ulli res = 0;
  for(int i = 0; i < n; ++i) {
    res = res * B + s[i];
  }
  return res;
}

int main() {
  for(int n, d; cin >> n && n; ) {
    cin >> d;
    vector<string> ss(n);
    for(int i = 0; i < n; ++i) {
      cin >> ss[i];
    }

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

    vector<set<ulli> > nextHash(n);
    for(int k = 0; k < n; ++k) {
      string s = ss[k];
      // Deleting
      for(int i = 0; i < s.size(); ++i) {
        char tmp = s[i];
        s.erase(i, 1);
        nextHash[k].insert(getHash(s));
        s.insert(i, string(1, tmp));
      }
      // Inserting
      for(int i = 0; i <= s.size(); ++i) {
        for(char c = 'a'; c <= 'z'; ++c) {
          s.insert(i, string(1, c));
          nextHash[k].insert(getHash(s));
          s.erase(i, 1);
        }
      }
      // Replacing
      for(int i = 0; i < s.size(); ++i) {
        char tmp = s[i];
        for(char c = 'a'; c <= 'z'; ++c) {
          s[i] = c;
          nextHash[k].insert(getHash(s));
        }
        s[i] = tmp;
      }
      // Swapping
      for(int i = 0; i + 1 < s.size(); ++i) {
        int j = i + 1;
        swap(s[i], s[j]);
        nextHash[k].insert(getHash(s));
        swap(s[i], s[j]);
      }
    }

    map<ulli, int> A;
    map<ulli, set<int> > B;
    for(int i = 0; i < n; ++i) {
      A[getHash(ss[i])] = i;
      if(d <= 1) continue;
      for(set<ulli>::iterator it = nextHash[i].begin();
          it != nextHash[i].end(); ++it) {
        B[*it].insert(i);
      }
    }

    set<pair<int, int> > ans;
    for(int i = 0; i < n; ++i) {
      for(set<ulli>::iterator it = nextHash[i].begin();
          it != nextHash[i].end(); ++it) {
        if(A.count(*it)) {
          pair<int, int> p(i, A[*it]);
          if(p.first > p.second) swap(p.first, p.second);
          ans.insert(p);
        }
      }
      for(set<ulli>::iterator it = nextHash[i].begin();
          it != nextHash[i].end(); ++it) {
        if(B.count(*it)) {
          for(set<int>::iterator it2 = B[*it].begin();
              it2 != B[*it].end(); ++it2) {
            pair<int, int> p(i, *it2);
            if(p.first > p.second) swap(p.first, p.second);
            ans.insert(p);
          }
        }
      }
    }

    int res = 0;
    for(set<pair<int, int> >::iterator it = ans.begin();
        it != ans.end(); ++it) {
      if(it->first == it->second) continue;
      ++res;
      cout << ss[it->first] << "," << ss[it->second] << endl;
    }
    cout << res << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    ll n, m, a, sum = 0;
    cin >> n >> m;
    while (m--) {
        cin >> a;
        sum += a;
    }
    if (sum > n) cout << -1 << "\n";
    else cout << n - sum << "\n";
}


Measured memory_bytes: 3644
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import sys
from itertools import combinations, permutations, product, combinations_with_replacement, accumulate
from heapq import heapify, heappop, heappush, heappushpop
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from math import sqrt, log, floor, ceil, factorial, cos, sin, pi#, gcd
from fractions import gcd
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
INF = float('inf')
LINF = 2**63-1
NIL = -LINF
MOD = 10**9+7
MGN = 4
def II(): return int(input())
def IF(): return float(input())
def IS(): return input().replace('\n', '')
def ILCI(n: int): return [II() for _ in range(n)]
def ILCF(n: int): return [IF() for _ in range(n)]
def ILI(): return list(map(int, input().split()))
def ILLI(n: int): return [[int(j) for j in input().split()] for i in range(n)]
def ILF(): return list(map(float, input().split()))
def ILLF(n: int): return [[float(j) for j in input().split()] for i in range(n)]
def LTOS(lst: list, sep: str = ' '): return sep.join(map(str, lst))
def DEC(lst: list): return list(map(lambda x: x-1, lst))
def INC(lst: list): return list(map(lambda x: x+1, lst))


def nck_mod(N: int, K: int, MOD: int = 10**9+7) -> int:
    """ 非負整数 N, K を受け取り、
    N 個の物から K 個を選ぶ組み合わせの数を返す """
    assert N is not None and K is not None, "N, K は None でない"
    assert N >= 0 and K >= 0

    x, y = 1, 1
    for i in range(K):
        x = x * (N - i) % MOD
        y = y * (i + 1) % MOD

    return x * pow(y, MOD-2, MOD) % MOD


def main():
    N,A,B = ILI()

    all = pow(2, N, MOD)
    ans = (all - nck_mod(N, A, MOD) - nck_mod(N, B, MOD) - 1) % MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5168
#include<iostream>
#include<queue>
#include<string>

using namespace std;

int main() {
  priority_queue <int> q;
  string method;
  int x;

  while(true) {
    cin >> method;
    if(method == "insert") {
      cin >> x;
      q.push(x);
    }
    else if(method == "extract") {
      cout << q.top() << endl;
      q.pop();
    }
    else break;
  }

  return 0;
}

Measured memory_bytes: 7024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

struct WeightedUnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;

    WeightedUnionFind(int n) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        rep(i, n) {
            par[i] = i;
            rank[i] = 0;
            diff_weight[i] = 0;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        int r = root(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }

    int weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, int w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int n, m; cin >> n >> m;
    WeightedUnionFind wuf(n);

    rep(i, m) {
        int l, r, d; cin >> l >> r >> d;
        l--; r--;
        if (wuf.same(l, r)) {
            int diff = wuf.diff(l, r);
            if (diff != d) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            wuf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    IN n;
    if(n%10 == 0)P(10);
    else{
	int ans = 0;
	while(n > 0){
	    ans += n%10;
	    n /= 10;
	}
	P(ans);
    }
    return  0;
}


Measured memory_bytes: 256
class Check():
    def __init__(self, N, number_of_truck,baggage):
        self.N = N
        self.number_of_truck = number_of_truck
        self.baggage = baggage

    def check(self, mid):
        baggage_num = 0
        for j in range(self.number_of_truck):
            baggage_sum = 0
            while(baggage_sum + self.baggage[baggage_num] <= mid):
                baggage_sum += self.baggage[baggage_num]
                baggage_num += 1
                if baggage_num == self.N:
                    return baggage_num
        return baggage_num

    def binary_search(self):
        left = 0
        right = 1000000000
        while(left + 1 < right):
            mid = int((left + right) / 2)
            ok = self.check(mid)
            if ok == self.N:
                right = mid
            else :
                left = mid
        return right

def main():
    N,number_of_truck = [int(i) for i in input().split()]
    baggage = list()
    for i in range(N):
        i = int(input())
        baggage.append(i)
    ok = Check(N,number_of_truck,baggage)
    print(ok.binary_search())

if __name__ == "__main__":
    main()


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

using namespace std;

#define ll long long
const int mxN=1e5+5;

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

	ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n,x,t;
    cin>>n>>x>>t;
    int ans=0;
    while(n>0){
    	n-=x;
    	ans+=t;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int a[2], b[2];
    cin >> a[0] >> b[0] >> a[1] >> b[1];

    for (int i = 0; ; i ^= 1) {
        a[i ^ 1] -= b[i];
        if (a[i ^ 1] <= 0) {
            if (i == 0) {
                cout << "Yes\n";
            }
            else {
                cout << "No\n";
            }
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = [0] + list(map(int, input().split()))

def prim(n):
    result = []
    for x in range(1, int(n ** 0.5) + 1):
        if n % x == 0:
            result.append(x)
            pair = n // x
            if pair != x:
                result.append(n // x)
    return result

ans = [0] * (n + 1)
ball = [0] * (n + 1)
for i in reversed(range(1, n + 1)):
    value = ans[i] ^ a[i]
    ball[i] = value
    for x in prim(i):
        ans[x] ^= value
print(sum(ball))
for i, v in enumerate(ball[1:], 1):
    if v:
        print(i, end=" ")
print()


Measured memory_bytes: 68584
#include<stdio.h>
int main(){
  int n,a,i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int u[10]={0};
    for(i=0;i<n;i++){
      scanf("%d",&a);
      u[a]++;
    }
    for(i=0;i<10;i++){
      if(u[i]==0)printf("-");
      else{
	for(j=0;j<u[i];j++){
	  printf("*");
	}
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 572
require 'prime'

primes = []
Prime.each( 10000 ) { |i|
	primes.push( i )
}

n = gets.to_i
nums = []
n.times {
	nums.push( gets.to_i )
}
cnt = n
nums.each { |val|
	primes.each { |i|
		break if val == i
		
		if 0 == val%i
			cnt-=1
			break;
		end
	}
}

puts( cnt )

Measured memory_bytes: 9148
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length();
		int cnt = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.substring(i, i + 1).equals("o")) {
				cnt++;
			}
		}
		if(cnt + 15 - len >= 8) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

int main(){
	int n, A[100];
	cin >> n;
	for(int i = 0; i < n; i++) cin >> A[i];
	for(int i = n-1; i >= 0; i--){
		if( i != n-1 ) cout << " ";
	        cout << A[i];
	}
cout <<endl;
	return 0;
}


Measured memory_bytes: 3040
n = int(input())
s = [input() for _ in range(n)]

dic={}
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=1
    else:
        dic[s[i]]+=1

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

ans.sort()
for answers in ans:
    print(answers)


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

bool izryt(pair<pair<int, int>, string> a, pair<pair<int, int>, string> b) {
  if (a.fs.fs * b.fs.sc == b.fs.fs * a.fs.sc) return a.sc < b.sc;
  return a.fs.fs * b.fs.sc > b.fs.fs * a.fs.sc;
}
signed main() {
  int n;

  while (cin >> n, n) {
    vector<pair<pair<int, int>, string>> v;

    rep(i, n) {
      string l;
      cin >> l;

      int p = in();
      int u = 0, t = 0;

      rep(i, 3) u += in();
      rep(i, 2) t += in();

      int f = in();
      int s = in();
      int m = in();

      v.pb(mp(mp((f * m * s - p), (u + t * m)), l));
    }
    sort(all(v), izryt);

    rep(i, n) {
      cout << v[i].sc << endl;
    }
    cout << "#" << endl;
  }
}

Measured memory_bytes: 3208
n = int(input())
a = list(map(int,input().split()))

f = 0

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            f = 1

if f:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, K; cin >> N >> K;
    if (K == 0) {
        cout << N*N << endl;
        return 0;
    }

    ll res = 0;
    for (ll b = 1; b <= N; b++) {
        res += max(0L, b-K) * (N/b);
        res += max(0L, N % b - K + 1);
    }
    cout << res << endl;
}


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

int main(){	
	int h, w;
	cin >> h >> w;
	while(h != 0){
		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}



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

int main(){
 
   while (1){
    int x,y;
    cin>>x>>y;
    if(x==0&&y==0) break;
    
    if(x>y) swap(x,y);
    cout<<x<<" "<<y<<endl;
   }

    return 0;
}


Measured memory_bytes: 3084
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int64_t read_int() {
    int64_t ret = 0, sgn = 1;
    int ch = getchar_unlocked();
    while (isspace(ch)) { ch = getchar_unlocked(); }
    if (ch == '-') { sgn = -1; ch = getchar_unlocked(); }
    for (; isdigit(ch); ch = getchar_unlocked())
        ret = (ret * 10) + (ch - '0');
    ungetc(ch, stdin);
    return sgn * ret;
}

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

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

constexpr char LF = '\n';

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

vector<int> make_identity_permutation(int n) {
    vector<int> ret(n);
    iota(ret.begin(), ret.end(), 0);
    return ret;
}

vector<int> concat_permutations(const vector<int>& first, const vector<int>& second) {
    assert(first.size() == second.size());
    vector<int> ret(first.size());
    for (int i = 0; i < (int)ret.size(); ++i) {
        ret[i] = second[first[i]];
    }
    return ret;
}

template<class T, class Product>
auto monoid_pow(T base, int64_t exponent, T identity, Product product) {
    T ans = move(identity);
    while (exponent > 0) {
        if (exponent & 1) {
            ans = product(ans, base);
        }
        base = product(base, base);
        exponent >>= 1;
    }
    return ans;
}

int main() {
    auto N = read_int();
    auto K = read_int();
    vector<int> A(N);
    REP(i, N) A[i] = read_int()-1;

    auto PK = monoid_pow(A, K,
        make_identity_permutation(N),
        [](const auto& p1, const auto& p2){ return concat_permutations(p1, p2); }
    );
    cout << PK[0]+1 << LF;
}


Measured memory_bytes: 6080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int N,mae,ato,count=0;
  vector<vector<int>> M(10,vector<int>(10,0));
  cin>>N;
  rep(i,N)
  {
    mae=ato=i+1;
    ato%=10;
    while(mae/10>0) mae/=10;
    M.at(mae).at(ato)++;
  }
  rep(i,9)
  {
    rep(j,9)
    {
      count+=M.at(i+1).at(j+1)*M.at(j+1).at(i+1);
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        StringBuilder sb1 = new StringBuilder();
        StringBuilder sb2 = new StringBuilder();
        StringBuilder sb3 = new StringBuilder();
        StringBuilder sb4 = new StringBuilder();
        sb3.Append('L');
        sb4.Append('R');
        for(int i = n[1]; i < n[3]; i++)
        {
            sb1.Append('U');
            sb2.Append('D');
            sb3.Append('U');
            sb4.Append('D');
        }
        sb3.Append('U');
        sb4.Append('D');
        for(int i = n[0]; i < n[2]; i++)
        {
            sb1.Append('R');
            sb2.Append('L');
            sb3.Append('R');
            sb4.Append('L');
        }
        sb3.Append('R');
        sb4.Append('L');
        sb3.Append('D');
        sb4.Append('U');

        sb1.Append(sb2.ToString());
        sb1.Append(sb3.ToString());
        sb1.Append(sb4.ToString());
        WriteLine(sb1.ToString());
    }
}



Measured memory_bytes: 18960
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	int H, W; cin >> H >> W;
	H+=2; W+=2;
	VS ans(H);
	REP(i, H)REP(j, W)ans[i].push_back('#');
	REP(i, H - 2) {
		REP(j, W - 2)cin >> ans[i + 1][j + 1];
	}
	REP(i, H) {
		REP(j, W)cout << ans[i][j];
		cout << endl;
	}
	return 0;
}



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

int main(void){
    vector<int> a(5);
    for(int i=0;i<5;i++) cin >> a[i];
    for(int i=0;i<5;i++){
        if(a[i]==0){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int r = scanner.nextInt();
        int d = scanner.nextInt();
        int count = 0;

        for (int i = l; i <= r; i++) {
            if (i % d == 0) {
                count = count + 1;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair
#define Debug(...) fprintf(stdout, __VA_ARGS__)

using namespace std;

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

const int MAXN = 5e5 + 7;
const int MOD = 998244353;
const int sig[] = {1, -1};

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int fac[MAXN], ifac[MAXN], inv[MAXN];
int muln[MAXN], mulm[MAXN];

inline void Add(int &x, int y) { x += y; if(x >= MOD) x -= MOD; if(x < 0) x += MOD; }

inline int C(int n, int m) {
	if(n < m) return 0;
	return (LL) fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int n, m, ans;

inline int f(int x) { return (LL) C(n, x) * C(m, x) % MOD * fac[x] % MOD * muln[m - x] % MOD * mulm[n - x] % MOD; }

inline void init() {
	fac[0] = ifac[0] = inv[1] = 1;
	for(int i = 1; i < MAXN; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
	for(int i = 2; i < MAXN; ++i) inv[i] = (LL) (MOD / i) * (MOD - inv[MOD % i]) % MOD;
	for(int i = 1; i < MAXN; ++i) ifac[i] = (LL) ifac[i - 1] * inv[i] % MOD;

	n = read<int>(); m = read<int>();
	muln[0] = mulm[0] = 1;
	muln[1] = n + 1; mulm[1] = m + 1;
	for(int i = 2; i < MAXN; ++i) muln[i] = (LL) muln[i - 1] * muln[1] % MOD;
	for(int i = 2; i < MAXN; ++i) mulm[i] = (LL) mulm[i - 1] * mulm[1] % MOD;
}

inline void solve() {
	int tp = min(n, m);
	for(int i = 0; i <= tp; ++i) {
		Add(ans, f(i) * sig[i & 1]);
	}
	printf("%d\n", ans);
}

int main() {

	init();
	solve();

	return 0;
}




Measured memory_bytes: 9984
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
ll l1[500005],l2[500005];
ll dp[200][200];
char s[5000][5000];
char t[5000];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}



ll nume(ll a){
	if(a >= 1){
		b = x[a];
		return b;
	}else{
		return 1;
	}
}
int main(){
	cin >> h >> w >> k;
	dp[0][1] = 1;
	x[0] = 1;
	x[1] = 2;
	for(i=2;i<=15;i++){
		x[i] = x[i-1] + x[i-2];
		x[i] %= mod;
	}
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			dp[i][j] += ((dp[i-1][j] * nume(j-2))%mod) * nume(w-j-1)%mod;
			dp[i][j] %= mod;
			if(j != 1)dp[i][j] += (dp[i-1][j-1] * nume(j-3))%mod * nume(w-j-1) %mod;
			dp[i][j] %= mod;		
			if(j!=w)dp[i][j] += (dp[i-1][j+1] * nume(w-j-2))%mod * (nume(j-2))%mod;
			dp[i][j] %= mod;			
		}
	}
	/*for(j=1;j<=h;j++){
		for(i=1;i<=w;i++)pe(dp[j][i]);
		el;
	}
	el;*/
	p(dp[h][k]);

	//p(ans);
    return 0;
}

Measured memory_bytes: 32896
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);

        while(scanner.hasNext()) {
            BigInteger inputNum = BigInteger.valueOf(Long.parseLong(scanner.next()));
            System.out.println(inputNum.pow(3));
        }
    }
}

Measured memory_bytes: 26196
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <climits>
#include <map>
using namespace std;
const int SIZEN = 100010;
typedef long long LL;
int N,H,W;
int a[SIZEN],b[SIZEN];
struct Node{
	int a,b;
	Node(int x,int y){a = x;b = y;}
	bool operator < (const Node &x)const{
		if(a == x.a)return b < x.b;
		return a < x.a;
	}
};
map<Node,bool> m;
LL ans[20] = {0};
int cha[10][10] = {
{0,0,0,1,1,1,2,2,2},
{0,0,0,1,1,1,2,2,2},
{0,0,0,1,1,1,2,2,2},
{-1,-1,-1,0,0,0,1,1,1},
{-1,-1,-1,0,0,0,1,1,1},
{-1,-1,-1,0,0,0,1,1,1},
{-2,-2,-2,-1,-1,-1,0,0,0},
{-2,-2,-2,-1,-1,-1,0,0,0},
{-2,-2,-2,-1,-1,-1,0,0,0}
};
int chb[10][10] = {
{0,1,2,0,1,2,0,1,2},
{-1,0,1,-1,0,1,-1,0,1},
{-2,-1,0,-2,-1,0,-2,-1,0},
{0,1,2,0,1,2,0,1,2},
{-1,0,1,-1,0,1,-1,0,1},
{-2,-1,0,-2,-1,0,-2,-1,0},
{0,1,2,0,1,2,0,1,2},
{-1,0,1,-1,0,1,-1,0,1},
{-2,-1,0,-2,-1,0,-2,-1,0}
};

void Solve(int o){
	int x = a[o],y = b[o];
	for(int i = 0;i <= 8;i++){
		int sum = 0;
		for(int j = 0;j <= 8;j++){
			int xx = x + cha[i][j],yy = y + chb[i][j];
			if(xx <= 0 || xx > H || yy <= 0 || yy > W){sum = 10;break;}
			if(m[Node(xx,yy)])sum++;
		}
		ans[sum]++; 
	}
} 
int main(){
    scanf("%d%d%d",&H,&W,&N);
    for(int i = 1;i <= N;i++){
		scanf("%d%d",&a[i],&b[i]);
		m[Node(a[i],b[i])] = true;
	}
	for(int i = 1;i <= N;i++)Solve(i);
	for(int i = 1;i <= 9;i++)ans[i] /= i;
	ans[0] = (1LL * H-2) * (1LL * W - 2);
	for(int i = 1;i <= 9;i++)ans[0] -= ans[i];
	for(int i = 0;i <= 9;i++)printf("%lld\n",ans[i]);
	return 0;
}
/*
2
1 1
100 0
100 100
1 1
100 100
100 100
*/

Measured memory_bytes: 157312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int main()
{
  int n;
  cin >> n;
  vector<ll> alist(n), blist(n), clist(n);
  for (int i = 0; i < n; i++) {
    cin >> alist[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> blist[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> clist[i];
  }
  sort(alist.begin(), alist.end());
  sort(blist.begin(), blist.end());
  sort(clist.begin(), clist.end());

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll a = lower_bound(alist.begin(), alist.end(), blist[i]) - alist.begin();
    ll c = clist.end() - upper_bound(clist.begin(), clist.end(), blist[i]);
    sum += a * c;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <limits.h>
#include <cmath>

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

    std::vector<int> V(N), C(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> V[i];
    }

    for (int  i = 0; i < N; i++)
    {
        std::cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int s = V[i] - C[i];
        if (s > 0)ans += s;
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256