akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define ELM 100001 //問題によっては1000000001に変更

//限定
using namespace std;

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(n)
    vector<int> a(n);
    int ans=0;
    For(n, i){
        cin>>a.at(i);
        ans+=a[i]-1;
    }
    Pr(ans)
    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int flag = 1;
  int num = 0;
  if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R') num = 3;
  if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'S') num = 2;
  if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'R') num = 1;
  if (s.at(0) == 'R' && s.at(1) == 'S' && s.at(2) == 'S') num = 1;
  if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'R') num = 2;
  if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'S') num = 1;
  if (s.at(0) == 'S' && s.at(1) == 'S' && s.at(2) == 'R') num = 1;
  if (s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'R') num = 2;
  cout << num;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007


// 繰り返し二乗法
long long bipow(long long n, int m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

// fact_num[i] = i! % MOD
// fact_denpow[i] = (i**(MOD-2)) % MOD
// fact_den[i] = fact_denpow[i]! % MOD
// nCm = fact_num[n] * fact_den[m] * fact_den[n-m]
// で計算できる（MODを適切に取る）
// O(NlogN)
void set_table(int N, vector<long long> &fact_num, vector<long long> &fact_den){
    fact_num.resize(N+1, 0);
    fact_den.resize(N+1, 0);
    vector<long long> fact_denpow(N+1, 0);

    fact_num[0] = 1;
    for(int i=1; i<=N; i++) fact_num[i] = (fact_num[i-1] * i) % MOD;

    for(int i=0; i<=N; i++) fact_denpow[i] = bipow(i, MOD-2);
    fact_den[0] = 1;
    for(int i=1; i<=N; i++) fact_den[i] = (fact_den[i-1] * fact_denpow[i]) % MOD;
}

// mCn
long long comb(const vector<long long> &fact_num, const vector<long long> &fact_den, int m, int n){
    return ((fact_num[m] * fact_den[n]) % MOD * fact_den[m-n]) % MOD;
}

// 素因数分解O(√n)
map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main(){
    long long N, M;
    cin >> N >> M;

    vector<long long> fact_num, fact_den;
    set_table(N+40, fact_num, fact_den);

    map<int, int> primes = prime_factor(M);
    long long ans = 1;
    for(auto x : primes){
        ans *= comb(fact_num, fact_den, x.second+N-1, x.second);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0)
int s[1 << 20];
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int n;
    fi>>n;
    for (int i = 1;i <= n;++i)
        fi>>s[i];
    sort(s+1,s+1+n,greater < int > ());
    int cnt = 1;
    while (cnt + 1 <= n && s[cnt + 1] >= cnt + 1) ++cnt;
    if ((s[cnt] - cnt) & 1) return puts("First") * 0;
    int v = 0;
    for (int i = cnt + 1;i <= n;++i)
        v += s[i] >= cnt;
    if (v&1) return puts("First") * 0;
    puts("Second");
    return 0;
}

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

double a,b,x;

int main(){

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

    cin>>a>>b>>x;
    x/=a;
    if(x*2<=a*b){
        //cout<<sqrt(b*b+x*2/b*x*2/b)<<endl;
        cout<<fixed<<setprecision(10)<<asin(b/sqrt(b*b+x*2/b*x*2/b))*180/3.14159265358979<<endl;
    }else{
        x=a*b-x;
        cout<<fixed<<setprecision(10)<<asin(x*2/a/sqrt(a*a+x*2/a*x*2/a))*180/3.14159265358979<<endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
}

Measured memory_bytes: 256
#[macro_use]
extern crate lazy_static;

use std::collections::BTreeMap;
use std::sync::Mutex;

#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: u64
    }
    let mut sum = 0;
    for a in 1..=k {
        for b in 1..=k {
            for c in 1..=k {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    println!("{}", sum);
}

fn gcd(l: u64, r: u64) -> u64 {
    if r == 0 {
        l
    } else {
        gcd(r, l % r)
    }
}


Measured memory_bytes: 2160
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int a[n], tot = 0, mx = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i]; 
            mx = max(mx, a[i]);
            if (i) tot += max(0LL, mx - a[i]);
        }

        cout << tot << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll h1, m1, h2, m2, k, a, b;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    a = h1*60+m1;
    b = h2*60+m2;

    cout << b-a-k << endl;

    return 0;
}

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

int main(void) {
    int X;

    std::cin >> X;

    int p = 0;
    for (int i = 1; i <= X; i++) {
        p += i;

        if (p >= X) {
            std::cout << i << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

//  COMMAND TO USE WHEN RUNNING CODE: g++ day1.cpp -o day1 -std=c++11 -O2  | to run: ./(name of file)  //

int A, B, C;

int main() {
    cin >> A >> B >> C;
    if ( A + B >= C ) {
        cout << B + C << "\n";
    } else if ( A + B < C ) {
        int a;
        a = A + B + 1;
        cout << B + a << "\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>
#include <functional>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll a,b,k;
	cin >> a >> b >> k;
	ll n = 0;

	for (ll i = 100; i >= 1; i--)
	{
		if (a % i == 0 && b % i == 0) {
			n++;
			if (n == k) {
				cout << i << endl;
				exit(0);
			}
		}
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N;
int a[107];

void solve()
{
	ll res = LINF;
	int l=*min_element(a,a+N);
	int r=*max_element(a,a+N);
	for(int i=l;i<=r;++i){
		ll cur = 0;
		for(int j=0;j<N;++j) cur+=(i-a[j])*(i-a[j]);
		res=min(res,cur);
	}
	cout << res << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 256
//created by missever

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

int main() {
    int n,m,i,s = 1;
    scanf("%d%d",&n,&m);
    if(n < m) swap(n,m);
    if(n - m <= 1){
        for(i = 1;i <= n; i++) s = 1LL * s * i % MAX;
        for(i = 1;i <= m; i++) s = 1LL * s * i % MAX;
        if(n == m) s = 1LL * s * 2 % MAX;
    }
    else s = 0;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 1010
 
struct P{
    int p,l;
};
 
P p[MAX_N];
string s[MAX_N];
bool used[MAX_N];
int N;
 
void init(int N){
    for(int i = 0 ; i < N ; i++){
	p[i].p = i;
    }
}
 
bool find(int x,int target){
    if(p[x].p == target){
	return true;
    }
    if(p[x].p == x) return false;
    return find(p[x].p,target);
}
 
void make(int n,int parent,int root,int depth){
    set<int> children;
    if(used[n]){ return; }
    used[n] = true;
    p[n].p = parent; p[n].l = depth;
    for(int i = n+1 ; i < N ; i++){
	int len = s[i].size();
	if(depth+1 >= len) continue;
	if(s[i][depth] != '.') break;
	if(s[i][depth] == '.' && s[i][depth+1] != '.'){
	    children.insert(i);
	    make(i,n,root,depth+1);
	}
    }
}
 
int main(){
    int M;
    while(cin >> N >> M, N){
	map<string,int> mp;
	int cur = 0;
	init(N); cin.ignore();
	for(int i = 0 ; i < N ; i++){
	    getline(cin,s[i]);
	    for(int j = 0 ; j < (int)s[i].size() ; j++){
		if(s[i][j] != ' '){
		    mp[s[i].substr(j)] = cur++;
		    break;
		}
		s[i][j] = '.';
	    }
	    used[i] = false;
	}
	for(int i = 0 ; i < N ; i++){
	    if(used[i]) continue;
	    if(s[i][0] != '.'){
		make(i,i,i,0);
	    }
	}
	string ord,a,b,c;
	for(int i = 0 ; i < M ; i++){
	    getline(cin,ord);
	    stringstream ss(ord);
	    ss >> a;
	    ss >> ord; ss >> ord;
	    ss >> c;
	    ss >> ord;
	    ss >> b;
	    b.resize(b.size()-1);
	    bool ans = false;
	    if(c == "parent"){
		if(p[mp[b]].p == mp[a]){
		    ans = true;
		}
	    }else if(c == "child"){
		if(p[mp[a]].p == mp[b]){
		    ans = true;
		}
	    }else if(c == "ancestor"){
		if(p[mp[a]].l < p[mp[b]].l && find(mp[b],mp[a])){
		    ans = true;
		}
	    }else if(c == "descendant"){
		if(p[mp[a]].l > p[mp[b]].l && find(mp[a],mp[b])){
		    ans = true;
		}
	    }else{
		if(p[mp[a]].l == p[mp[b]].l && p[mp[a]].p == p[mp[b]].p){
		    ans = true;
		}
	    }
	    cout << (ans ? "True" : "False") << endl;
	}
	cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3404
inut_line = input().split(" ")

dataNum = int(inut_line[0])
distance = int(inut_line[1])
distance = distance*distance
cnter = 0
for cnt in range(dataNum):
      inut_line = [int(i) for i in input().split(" ")]
      d = inut_line[0]*inut_line[0] + inut_line[1]*inut_line[1]
      if(distance >= d):
          cnter = cnter + 1
print(cnter)

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int_fast64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;

inline int updiv(int a,int b){ return (a + b - 1) / b; }
 
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    int n, x, y;
    cin >> n >> x >> y;

    vector<vector<int> > G(n+1);

    reps(i, n-1){
        G[i].emplace_back(i+1);
        G[i+1].emplace_back(i);
    }
    G[x].emplace_back(y);
    G[y].emplace_back(x);

    vector<int> res(n);

    reps(i,n){
        queue<int> que;
        vector<int> dist(n+1, LINF);
        que.emplace(i);
        dist[i] = 0;
        while(!que.empty()){
            int now = que.front();
            que.pop();
            for(auto&& e : G[now]){
                if(chmin(dist[e], dist[now] + 1)){
                    que.emplace(e);
                }
            }
        }
        for(int j = i + 1; j <= n; ++j){
            res[dist[j]]++;
        }
    }

    for(int i = 1; i <= n-1; ++i){
        cout << res[i] << '\n';
    }

    return (0);
}

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

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    int A[n][m], B[m][l];
    long C[n][l];
    
    // A Initialize
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> A[i][j];
    
    //  B Initialize
    for (int i = 0; i < m; i++)
        for (int j = 0; j < l; j++)
            cin >> B[i][j];
    
    
    // C Initialize
    for (int i = 0; i < n; i++)
        for (int j = 0; j < l; j++)
        {
            C[i][j] = 0;
            
            // C Calculation(l = 3, m = 2)
            for (int k = 0; k < m; k++)
                C[i][j] += A[i][k] * B[k][j];   
        }
    
    
    // C out
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cout << C[i][j];
            if (j != l - 1) cout << ' ';
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(void){
    int n;
    int s[1000];
    while ( cin >> n && n != 0 ){
        double a = 0, m = 0;
        for ( int i = 0; i < n; i++ ){
            cin >> s[i];
            m += s[i];
        }
        m /= n;
        for ( int i = 0; i < n; i++ ){
            a += (s[i] - m) * (s[i] - m);
        }
        cout << fixed << setprecision(6) << sqrt( a / n ) << endl;
    }
}


Measured memory_bytes: 3248
class Heruistics:
    allpref = [] #allpref[day][contest]
    donelist = [0]*26
    resultlist = []
    contestlist = []

    def __init__(self,days):
        self.days = days
        self.clast = list(map(int,input().split()))
        for i in range(days):
            self.allpref.append(list(map(int,input().split())))

    def scoring(self,contlist):
        result = 0
        for i in range(self.days):
            cont = contlist[i]
            self.donelist[cont-1] = i+1
            zanen = sum([self.clast[j]*((i+1)-self.donelist[j]) for j in range(26)])

            result += self.allpref[i][cont-1] - zanen
            self.resultlist.append(result)

    def greedy(self):
        for i in range(self.days):
            max = -1**10
            result = 0
            contest = False
            for held in range(26):
                tempdonelist = self.donelist[:]
                tempdonelist[held] = i+1
                zanen = sum([self.clast[j]*((i+1)-tempdonelist[j]) for j in range(26)])
                result = self.allpref[i][held] - zanen
                if result >= max:
                    max = result;contest = held

            self.donelist[contest] = i+1
            self.contestlist.append(contest+1)


greed_heru = Heruistics(int(input()))
greed_heru.greedy()
#greed_heru.scoring(greed_heru.contestlist)
#for result in greed_heru.resultlist:
#    print(result)
for cont in greed_heru.contestlist:
    print(cont)


Measured memory_bytes: 9460
s1=[]
s2=[]
O=[]
while 1:
    A=input().split('"')
    if A==["."]:
        break
    i=0
    cnt=0
    B=input().split('"')
    l1=len(A)
    l2=len(B)
    if l1==l2:   
        while i<l1 and i<l2:
            if A[i]!=B[i]:
                cnt+=1
                if i%2==0:
                    cnt+=2
            i+=1
        if cnt==0:
            O.append("IDENTICAL")
        elif cnt==1:
            O.append("CLOSE")
        else:
            O.append("DIFFERENT")
    else:
        O.append("DIFFERENT")
for i in range(len(O)):
    print(O[i])


Measured memory_bytes: 5592
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
const int N = 3005;
int dp[N][N], a[N];
void solve(){
	int n;
	cin >> n;
	fr(i, 1, n){
		cin >> a[i];
		dp[i][i] = a[i];
	}
	fr(l, 2, n){
		fr(i, 1, n - l + 1){
			int j = i + l - 1;
			dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
		}
	}
	cout << dp[1][n];
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

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

int main()
{
  int N, count = 0;
  cin >> N;

  vector<int> d(N);
  for (int i = 0; i < N; i++)
  {
    int tmp;
    cin >> tmp;
    if (find(d.begin(), d.end(), tmp) == d.end())
    {
      d.at(i) = tmp;
      count++;
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Q = Integer.parseInt(sc.next());
        String S = sc.next();
        int[] l = new int[Q];
        int[] r = new int[Q];
        
        int dp[] = new int[N];
        String[] sp = S.split("");
        
        int count = 0;
        for(int i=1; i<N; i++) {
            if(sp[i-1].equals("A") && sp[i].equals("C")) {
                count++;
            }
            dp[i-1] = count;
        }
        dp[N-1] = count;
        int ans = 0;
        
        for(int i=0; i<Q; i++) {
            l[i] = Integer.parseInt(sc.next())-1;
            r[i] = Integer.parseInt(sc.next())-1;
            if(l[i] == 0) {
                ans = dp[r[i]-1];
            }else {
                ans = dp[r[i]-1] - dp[l[i]-1];
            }
            System.out.println(ans);
        }
    }
}

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

const int MAX_HW=35;

int w,h;
vector<vector<int>> mw(MAX_HW,vector<int>(MAX_HW)),mh(MAX_HW,vector<int>(MAX_HW)),d(MAX_HW,vector<int>(MAX_HW));
queue<pair<int,int>> que;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin >> w >> h,w){
		for (int i=0;i<2*h-1;++i){
			if (!(i&1)) for (int j=0;j<w-1;++j){
				cin >> mw[i/2][j];
			} else for (int j=0;j<w;++j){
				cin >> mh[(i-1)/2][j];
			}
		}
		for (int i=0;i<h;++i)
			for (int j=0;j<w;++j)
				d[i][j]=-1;
		d[0][0]=1;
		que.emplace(0,0);
		while(!que.empty()){
			auto p=que.front(); que.pop();
			int x=p.first,y=p.second;
			if (y<w-1&&!mw[x][y]&&d[x][y+1]==-1){
				d[x][y+1]=d[x][y]+1;
				que.emplace(x,y+1);
			}
			if (0<y&&!mw[x][y-1]&&d[x][y-1]==-1){
				d[x][y-1]=d[x][y]+1;
				que.emplace(x,y-1);
			}
			if (x<h-1&&!mh[x][y]&&d[x+1][y]==-1){
				d[x+1][y]=d[x][y]+1;
				que.emplace(x+1,y);
			}
			if (0<x&&!mh[x-1][y]&&d[x-1][y]==-1){
				d[x-1][y]=d[x][y]+1;
				que.emplace(x-1,y);
			}
		}
		cout << (d[h-1][w-1]!=-1?d[h-1][w-1]:0) << '\n';
	}
}


Measured memory_bytes: 3080
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            FastScanner fs = new FastScanner();

            int X = fs.nextInt();
            int A = fs.nextInt();
            int B = fs.nextInt();

            X -= A;

            System.out.println(X % B);
        }
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main(){
    int n, m; cin >> n >> m;
    int sum = 0;
    rep(i,m) {
        int a; cin >> a;
        sum += a;
    }
    if(sum > n) cout << -1 << endl;
    else cout << n - sum << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int sex[1010]; // male 0 female 1
typedef long long ll;
int read(){
	char c = getchar();
	int res = 0,flag = 0;
	while((c<'0'||c>'9')&&c!='-')
		c = getchar();
	if(c=='-'){
		flag = 1; c = getchar();
	}
	while(c>='0'&&c<='9'){
		res = res*10+c-'0';
		c = getchar();
	}
	if(flag) sex[res] = 1;
	return res;
}
int gcd(int a,int b){
	return !b?a:gcd(b,a%b); 
}
int gcd3(int a,int b,int c){
	return gcd(a,gcd(b,c));
}
int main(){
	int k;
	cin >> k;
	ll res = 0;
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++){
				res += gcd3(a,b,c); 
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
typedef pair<ll,ll> cp2;
typedef pair<ll,cp2> cp3;
#define fi first
#define se second
#define sec se.fi
#define thr se.se
const ll mod = 1000000007;
//              123456789
int N;
int p[5123];
int P[5123];
vector< int > z;

int ans = mod;

int main(){
	
	cin>>N;
	
	
	REP( i, N ){
		scanf("%d", p+i);
		P[i] = p[i];
	}
	
	
	REP( s, P[0]+1 ){
		REP( e, P[N-1]+1 ){
			p[0] = P[0] - s;
			p[N-1] = P[N-1] - e;
			int num = s+e;
			
			FOR( i, 1, N-1 ) p[i] = P[i];
			
			REP( i, N ){
				while( p[i] > 0 ){
					p[i]--;
					p[i+1]--;
					num += 2;
				}
			}
			ans = min( ans, num );
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<bool> snuke(n, true);
    set<int> s;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            snuke[a - 1] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
        if (snuke[i])
            ans++;
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n;
  cin >> n;
  VI x(n),y(n);
  REP(i,n)cin >> x[i] >> y[i];

  double sum=0.0; 
  REP(i,n)FOR(j,i+1,n){
    sum += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
  }

  printf("%0.6f\n",sum / (n*(n-1)/2) * (n-1));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ary[3];
    rep(i,3) cin >> ary[i];
    sort(ary, ary+3);
    int a = ary[0];
    int b = ary[1];
    int c = ary[2];
    if (a==b && b!=c)
    {
        cout << "Yes" << endl;
    }
    else if (a!=b && b==c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}




Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n = I()
    a = LI()
    s = sum([i%2 for i in a])
    if s in (0,n):
        print(0)
    else:
        print(n-2+(s%2))
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#G
def G():
    n = I()

    return

#H
def H():
    n = I()

    return

#I
def I_():
    n = I()

    return

#J
def J():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()



Measured memory_bytes: 30680
#include <bits/stdc++.h>
using namespace std;
const int BASE = 998244353;

int n, tree[200200];
pair<int, int> a[200200];

void add(int x)
{
  for (int i = x; i <= n; i += i & -i)
    tree[i]++;
}

int get(int x)
{
  int res = 0;
  for (int i = x; i; i -= i & -i)
    res += tree[i];
  return res;
}

void compress()
{
  map<int, int> x, y;
  for (int i = 0; i < n; i++)
  {
    x[a[i].first] = 0;
    y[a[i].second] = 0;
  }

  int id = 0;
  for (auto u : x)
    x[u.first] = ++id;
  id = 0;
  for (auto u : y)
    y[u.first] = ++id;

  for (int i = 0; i < n; i++)
    a[i] = {x[a[i].first], y[a[i].second]};
}

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

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second;
  compress();
  sort(a, a + n);

  int p2[200200] = {0};
  for (int i = 1; i <= n; i++)
    p2[i] = (p2[i - 1] * 2 + 1) % BASE;

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    int x = a[i].first, y = a[i].second;
    ans = (ans + p2[n]) % BASE;
    ans = (ans - p2[x - 1] + BASE) % BASE;
    ans = (ans - p2[n - x] + BASE) % BASE;
    ans = (ans - p2[y - 1] + BASE) % BASE;
    ans = (ans - p2[n - y] + BASE) % BASE;
    ans = (ans + p2[get(y - 1)]) % BASE;
    ans = (ans + p2[i - get(y)]) % BASE;
    add(y);
  }

  for (int i = 0; i < n; i++)
    a[i].first = n - a[i].first;
  sort(a, a + n);
  memset(tree, 0, sizeof tree);
  for (int i = 0; i < n; i++)
  {
    int y = a[i].second;
    ans = (ans + p2[get(y - 1)]) % BASE;
    ans = (ans + p2[i - get(y)]) % BASE;
    add(y);
  }

  cout << ans << endl;
}


Measured memory_bytes: 22144
import sys
w=""
a=[]
while (w!="0 0"):
    w=input()
    a.append(w)
a.pop()
for st in a:
    b=st.split()
    h=int(b[0])
    w=int(b[1])
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h-1 or j==0 or j==w-1:
                sys.stdout.write("#")
            else:
                sys.stdout.write(".")
        sys.stdout.write("\n")
    sys.stdout.write("\n")

Measured memory_bytes: 6316
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1000000000000
#define fr first
#define sc second
using vl =vector<ll>;
using vvl =vector<vl>;
const ll md = 998244353;
vl pr(2e3+1, true);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

ll log(ll b, ll e) {
	ll i, x = b;
	for(i = 0; x <= e; i++, x *= b) {}
	return i;
}

// ll dp[19][163][1460][2];
// string s;

// ll call(int idx, int sum, int sqr, int edge) {
// 	if(idx == n) {
// 		if(pr[sum] && pr[sqr]) return 1;
// 		else return 0;
// 	}
// 	ll &ans = dp[idx][sum][sqr][edge];
// 	if(ans != -1) return ans;
// 	ans = 0;
// 	for(int i = 0; i <= (tight ? s[i] - '0' : 9); ++i) {
// 		ans += call(idx + 1, sum + i, sqr + i*i, edge || i == s[i] - '0');
// 	}
// 	return ans;
// }

void sieve(ll n) {
    for(int i = 2; i*i <= n; i++) {
        if(pr[i]) {
            for(int j = i*i; j <= n; j += i) {
                pr[j] = false;
            }
        }
    }
}

ll dp[100001][2];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = dp[0][1] = 0;
    for(int i = 1; i <= n; ++i) {
    	int x = s[i-1] - '0';
    	dp[i][0] = dp[i-1][1] + (x==1);
    	dp[i][1] = dp[i-1][0] + (x==0);
    }
    cout << min(dp[n][0], dp[n][1]) << "\n";
    return 0;
}

Measured memory_bytes: 5288
#include<stdio.h>

#define true 1
#define false 0

int solve(int n, int A[], int i, int m);

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

	int A[n], i;
	for(i=0; i<n; i++) scanf("%d", &A[i]);

	int q;
	scanf("%d", &q);

	int m[q];
	for(i=0; i<q; i++)  scanf("%d", &m[i]);	
	
	for(i=0; i<q; i++) {
		if(solve(n, A, 0, m[i])) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

int solve(int n, int A[], int i, int m) {
	
	if (m == 0) return true;
	if (i >= n || m<0) return false;
	
	return solve(n, A, i + 1, m - A[i]) || solve(n, A, i + 1, m);
}


Measured memory_bytes: 2096
#include<iostream>
#include<map>
using namespace std;
int main(){
    map<string,int> votes;
    int t;
    cin>>t;
    int maxvote=0;
    while(t--){
        string v;
        cin>>v;
        votes[v]++;
        if(votes[v]>maxvote){
            maxvote=votes[v];
        }
    }
    for(map<string,int>::iterator it=votes.begin();it!=votes.end();it++){
        if(it->second==maxvote){
            cout<<it->first<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define N (200010)

int n;
int a[N];
int b[N]; /* a - 数值之和, b - 数值亦或和*/

int main()
{
    std::ios::sync_with_stdio(0);
    std::cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        std::cin >> x;
        a[i] = a[i - 1] + x, b[i] = b[i - 1] ^ x;
    }
    int l = 1;
    long long sum = 0;
    for (int i = 1; i <= n; i++)
    {
        while (a[i] - a[l - 1] != (b[i] ^ b[l - 1]))
            l++;
        sum += i - l + 1;
    }
    std::cout << sum << std::endl;
    return 0;
}

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

def solve():
    N = int(input())
    S = input()
    d = {chr(65+s):chr(65+(s+N)%26) for s in range(26)}
    table = str.maketrans(d)
    res = S.translate(table)
    return res

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

sum_ac = [0] * N
count = 0
for i in range(1, N):
    if S[i-1] == "A" and S[i] == "C":
        count += 1
    sum_ac[i] = count

for l,r in LR:
    print(sum_ac[r-1] - sum_ac[l-1])

Measured memory_bytes: 30688
#include <stdio.h> 
int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int findGCD(int arr[], int n) 
{ 
	int result = arr[0]; 
	for (int i = 1; i < n; i++) 
		result = gcd(arr[i], result); 

	return result; 
} 
int main() 
{ 
    int n,x,i;
    scanf("%d%d",&n,&x);
    int a[n],arr[n];
    for(i=0;i<n;i++)
    {
    scanf("%d",&a[i]);
    if(x>a[i])
    arr[i]=x-a[i];
    else
    arr[i]=a[i]-x;
    }
	printf("%d",findGCD(arr, n)); 
	return 0; 
} 


Measured memory_bytes: 896
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
#include <stdio.h>
string checkDigit(int n){
  int num = n;
  int cnt = 0;
  while(n){
    n /= 10;
    cnt++;
  }
  string s;
  string a = std::to_string(num);
  rep(i, 6 - cnt) s += "0";
  s += a.c_str();
  return s;
}
int main(){
  int n,m;
  cin >> n >> m;
  //vi p(m), y(m);
  vector<vector<pair<int,int>>> y(n);
  vector<string> v(m);
  rep(i, m){
    int p,x;
    cin >> p >> x;
    y[p - 1].push_back(make_pair(x, i));
  }
  rep(i, n) sort(y[i].begin(), y[i].end());
  rep(i, n){
    int cnt = 0;
    for(auto a : y[i]){
      cnt++;
      v[a.second] = checkDigit(i + 1) + checkDigit(cnt);
    }
  }
  rep(i, m) cout << v[i] << endl;
}

Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	int n,k; cin >> n >> k;
	vector<int> a(n);
	int M=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		M=max(a[i],M);
	}
	int m=a[0];
	for(int i=1;i<n;i++){
		m=GCD(m,a[i]);
	}
	for(int i=M;i>=0;i-=m){
		if(i==k){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 640
input = readlines()
n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

sum = list.sum()

min = nil
(1..n).each do |t|
  g1_sum = 0
  list.each_with_index do |l, i|
    g1_sum += l if (i + 1) <= t
  end
  diff = (g1_sum - (sum - g1_sum)).abs
  min = diff if min.nil? || min > diff
end

puts min

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

//再帰関数
//一ステップで何をしたら次につながるか
//何で終了するか

void dfs(vector<int> A) {
    //配列Aに対する得点計算
    if (A.size() == n+1) {
        //calc score
        int now = 0;
        rep(i,q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        } 
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        //再帰関数
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << "\n";
    return 0;
}



//行列入力(一括コメントアウトshift+alt+a)
/*     int main(){
        int n, m, q;
        cin >> n >> m >> q;
        int a[q][4];
        rep(i,q){
            for(int j=0; j<4; ++j){
                cin >> a[i][j];
            }
        }
        rep(i,q){
            for(int j=0; j<4; ++j){
                cout << a[i][j] << "\n";
            }
        } 
        return 0;
    } */

Measured memory_bytes: 3568
var a, b, c : integer;
    temp : integer;
begin
  readln(a, b, c);
  if a > b then begin a := a xor b; b := a xor b; a := a xor b end;
  if b > c then begin b := b xor c; c := b xor c; b := b xor c end;
  writeln(a + b + c * 10);
end.

Measured memory_bytes: 128
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int n; cin >> n;
  vector<int> p(n);
  for (int i=0; i<n; i++) cin >> p[i];
  
  int ans=0;
  
  for (int i=1; i<n-1; i++){
    if ((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])) ans++;
  }
  
  cout << ans;
 
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

/////////////         modの計算
constexpr ll mod = 1000000007;
constexpr ll M = mod * mod;

constexpr int K = 16;

constexpr ll v_e[] = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
constexpr ll v_o[] = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

int main() {
	int T; scanf("%d", &T);
	for (int _t = 0; _t < T; _t++) {
		ll N; scanf("%lld", &N);
		ll ans = 0, x = 1;

		if (N & 1) {// odd
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
				if (ans >= M) { ans -= M; }
				if (x >= mod) { x %= mod; }
			}
		}
		else {// even
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
				if (ans >= M) { ans -= M; }
				if (x >= mod) { x %= mod; }
			}
		}
		printf("%lld\n", ans % mod);
	}

	return 0;
}


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

int main()
{
    int a, b;
    cin >> a >>b;

    for(int i = 10*b; i<=10*b+9; i++){
        if((int) (i*0.08) == a){ cout << i << endl; return 0;}
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program{
    static void Merge(int[] A, int left, int mid, int right){
        var n1=mid-left;
        var n2=right-mid;
        var L=new int[n1+1];
        var R=new int[n2+1];
        for(var i=0; i<n1; i++){
            L[i]=A[left+i];
        }
        for(var i=0; i<n2; i++){
            R[i]=A[mid+i];
        }
        L[n1]=1000*1000*1000+1;
        R[n2]=1000*1000*1000+1;
        var l=0;
        var j=0;
        for(var k=left; k<right; k++){
            if(L[l]<=R[j]){
                A[k]=L[l];
                l++;
            } else{
                A[k]=R[j];
                j++;
            }
        }
    }

    static int BinarySearch(int[] A, int val, int left, int right){
        if(val>A[right-1]){
            return right;
        }
        while(left<=right){
            var mid=(left+right)/2;
            if(A[mid]<val){
                left=mid+1;
            } else{
                right=mid-1;
            }
        }
        return left;
    }

    static long MergeSort(int[] A, int left, int right){
        if(left+1<right){
            var mid=(left+right)/2;
            var a=MergeSort(A, left, mid);
            var b=MergeSort(A, mid, right);
            long c=0;
            for(var i=left; i<mid; i++){
                c+=BinarySearch(A, A[i], mid, right)-mid;
            }
            Merge(A, left, mid, right);
            return a+b+c;
        } else{
            return 0;
        }
    }

    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var S=new int[n];
        for(var i=0; i<n; i++){
            S[i]=int.Parse(s[i]);
        }

        var result=MergeSort(S, 0, n);

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 36920
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int n;
string s;

int main(){
	cin >> s;
  	n = s.size();
	if(s[n-1] == '1' or s[0] == '0'){
		puts("-1");
		return 0;
	}
	for(int i=0; i<n-1; i++){
		if(s[i] != s[n-2-i]){
			puts("-1");
			return 0;
		}
	}
	int root = 1;
	reverse(all(s));
	for(int i=2; i<=n; i++){
		printf("%d %d\n",root,i);
		if(s[i-1] == '1'){
			root = i;
		}
	}
	return 0;
}


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

int main() {
	int K;
	int N[5];
	cin >> N[0] >> N[1] >> N[2] >> N[3] >> N[4] >> K;
	for (int i = 1; i < 5; i++) {
	    for (int j = 0; j < i; j++) {
		    if (N[i] - N[j] > K) {
			    cout << ":(" << endl;
			    return 0;
		    }
	    }
	}

	cout << "Yay!" << endl;
}

Measured memory_bytes: 256