akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main() {
    vector<int> v(3);
    bool ans = false;
    for (int i=0; i<3; ++i) {
        cin >> v.at(i);
    }

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

    if (v.at(0) + v.at(1) == v.at(2)) ans = true;
    
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();
		
		// 計算
		long result = 0;
		long x = min(b-1, n);
		result = a*x/b - a*(x/b);
		
		// 出力
		System.out.println(result);
	}
}



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

class C {
    static StreamWriter Out = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    static void Main(string[] args) {
        int N;
        Input(out N);
        int[] A;
        Input(out A);
        SortedSet<int> set = new SortedSet<int>();
        for(int i = 0; i < N; i++) {
            set.Add(A[i]);
        }
        if(set.Count == N) {
            Print("YES");
        } else {
            Print("NO");
        }
        Out.Flush();
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void Input<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
    static void Print<T>(T s) => Out.WriteLine(s);
    static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
    static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}

Measured memory_bytes: 39624
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int MOD = 1000000000 + 7;

class Combination {
   private:
    long long maxn;
    long long mod;
    vector<long long> fact, rev_fact;

   public:
    // コンストラクタ。maxn: 組み合わせのnの最大値。m: mod
    Combination(long long maxn, long long mod) : maxn(maxn), mod(mod) {
        setFact(maxn);
    }

    // 1からnの階乗とその逆元を前計算
    void setFact(long long n) {
        fact.resize(n + 1);
        rev_fact.resize(n + 1);
        fact[0] = 1;
        for (long long i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
            fact[i] %= mod;
        }
        rev_fact[n] = modpow(fact[n], mod - 2, mod);
        for (long long i = n - 1; i >= 0; i--) {
            rev_fact[i] = rev_fact[i + 1] * (i + 1);
            rev_fact[i] %= mod;
        }
    }

    constexpr long long modpow(long long a, long long n, long long m) {
        long long rtn = 1;
        while (n > 0) {
            if (n & 1) rtn = rtn * a % m;
            a = a * a % m;
            n >>= 1;
        }
        return rtn;
    }

    // n種類のものからk個選ぶ場合の数
    long long c(long long n, long long k) {
        if (!(0 <= n && n <= maxn) || !(0 <= k && k <= maxn)) return -1;
        return (((fact[n] * rev_fact[k]) % mod) * rev_fact[n - k]) % mod;
    }

    // n種類のものから重複を許してk個選ぶ場合の数
    // n+k-1<=maxn とすること
    long long h(long long n, long long k) { return c(n + k - 1, k); }

    // n種類のものからk個選んで並び替える場合の数
    long long p(long long n, long long k) {
        if (!(0 <= n && n <= maxn) || !(0 <= k && k <= maxn)) return -1;
        return fact[n] * rev_fact[n - k] % mod;
    }
};

constexpr int modpow(int a, int n) {
    int rtn = 1;
    while (n > 0) {
        if (n & 1) rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

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

    int n;
    cin >> n;

    Combination combi(2 * n, MOD);

    int ans = 0;

    // 0または9がi個あるとき
    for (int i = 2; i <= n; i++) {
        int now = 1;

        // 0または9にする要素をi個選ぶ
        (now *= combi.c(n, i)) %= MOD;
        // 選んだ中からどれを0にするか選ぶ
        // Σk=1..n-1 nCk = 2^n-2
        // https://mathtrain.jp/nikoubekijo
        (now *= (modpow(2, i) - 2)) %= MOD;
        // 選ばなかった要素の値
        (now *= modpow(8, n - i)) %= MOD;

        ans += now % MOD;
        ans %= MOD;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 34296
#include<iostream>
#include<cstring>
using namespace std;
int s[55];
int main()
{
    int m,n;
    while(cin>>m>>n)
    {
        memset(s,0,sizeof(s));
        for(int i=0; i<n; i++)
        {
            int a,b;
            cin>>a>>b;
            s[a]++;
            s[b]++;
        }
        for(int i=1;i<=m;i++)
        {
            cout<<s[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

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

		String s = br.readLine();
		String[] array = s.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		if ((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)
				&& (b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)) {
			System.out.println("Yes");
		} else if ((a == 4 || a == 6 || a == 9 || a == 11) && (b == 4 || b == 6 || b == 9 || b == 11)) {
			System.out.println("Yes");
		} else if ((a == 2) && (b == 2)) {
			System.out.println("Yes");
		} else
			System.out.println("No");
		{

		}
	}
}

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

#define int ll 
typedef long long        ll;
 
#define fastio        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
 
const int N = 2e5+7; 
bool p[N];

void solve() {
	int x, n;	cin >> x >> n;
	for (int i = 0; i < n; i++) {
		int h;	cin >> h;
		p[h] = 1;
	}

	int d = INT_MAX, ans = 0;
	for (int k = -151; k <= 151; k++) {
		int cd = INT_MAX;
		if (k < 0) {
			cd = abs(k - x);
		} else {
			if (!p[k]) cd = abs(k - x);
		}
		if (cd < d) {
			d = cd;
			ans = k;
		}
	}
	cout << ans << endl;
}

signed main() {
 
    fastio;
    int t = 1;	
    // cin > > t;
    while (t--) {
    	solve();
    }

    return 0;
}

Measured memory_bytes: 3648
import heapq

def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * -1, input().split()))
    heapq.heapify(A)

    for _ in range(M):
        n_v = heapq.heappop(A)
        heapq.heappush(A, (-1) * (-n_v // 2))

    print(-sum(A))
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N;
	long[] A;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		A = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
	}

	void calc() {
		long sum = 0;
		long prevMax = A[0];
		for (int i = 1; i < N; ++i) {
			if (prevMax <= A[i]) {
				// なにもしない
			} else {
				sum += prevMax - A[i];
			}
			prevMax = Math.max(prevMax, A[i]);
		}
		System.out.println(sum);
	}

	void showResult() {
	}
}

Measured memory_bytes: 58848
import sys
sys.setrecursionlimit(10**7)
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
ans=0
s,seq=[],[]
def dfs(s):
    if len(s)==n:
        seq.append(s)
        return
    for i in range(1,m+1):
        if s:
            if s[-1]<=i:
                dfs(s+[i])
        else:
            dfs(s+[i])
dfs(s)
#print(seq)
for s in seq:
    cand=0
    for a,b,c,d in abcd:
        a-=1
        b-=1
        if s[b]-s[a]==c:
            cand+=d
    ans=max(ans,cand)
print(ans)

Measured memory_bytes: 22908
#include <iostream> // cout, endl, cin
#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
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n, m;
	cin >> n >> m;
	priority_queue<ll, vector<ll>, greater<ll>> a;
	rep(i, n) {
		ll x;
		cin >> x;
		a.push(x);
	}
	vector<P> bc(m);
	rep(i, m) {
		ll x, y;
		cin >> x >> y;
		bc.at(i) = make_pair(y, x);
	}
	sort(all(bc));
	reverse(all(bc));
	rep(i, m) {
		rep(j, bc.at(i).second) {
			if (a.top() < bc.at(i).first) {
				a.pop();
				a.push(bc.at(i).first);
			}
			else break;
		}
	}
	ll s = 0;
	rep(i, n) {
		s += a.top();
		a.pop();
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 2804
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

//ll mod = 1000000007;
ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}



int main() {
	string s;
	cin >> s;
	int n = s[s.size() - 1] - '0';
	string ans;
	if (n == 3) {
		ans = "bon";
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		ans = "pon";
	}
	else {
		ans = "hon";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
'use strict'

function main(input) {
  input = input.split('\n');
  const NK = input[0].split(' ').map(n => parseInt(n, 10));
  const N = NK[0],
        K = NK[1];
  const A = input[1].split(' ').map(n => parseInt(n, 10));
  const countBucket = [...Array(N+1)].fill(0);

  for (const num of A) {
    countBucket[num] += 1;
  }
  console.log(countBucket.sort((a, b) => b - a).slice(K).reduce((a, b) => a + b));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

class Baseball {
private:
	int out;
	int runner;
	int score;

public:
	//constructor
	Baseball() {
		out = 0; 
		runner = 0;
		score = 0;
	}

	//getter
	int getOut() { return out; }
	int getRunner() { return runner; }
	int getScore() { return score; }
	//input OUT
	void execOut() { ++out; }
	//input HIT
	void execHit() {
		if(runner == 3)++score;
		else ++runner;
	}
	//input HOMERUN
	void execHomerun() {
		score += runner + 1;
		runner = 0;
	}

};

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

	std::vector< Baseball > baseball;
	baseball.resize(dataSetNum);

	for(int i = 0; i < dataSetNum; ++i){

		while(baseball[i].getOut() != 3){
			//input
			std::string tmp;
			std::cin >> tmp;

			if(tmp == "OUT")baseball[i].execOut();
			else if(tmp == "HIT")baseball[i].execHit();
			else if(tmp == "HOMERUN")baseball[i].execHomerun();
		}

	}
	//output
	std::for_each(baseball.begin(), baseball.end(),
    [](Baseball x) { std::cout << x.getScore() << std::endl; } );

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,answer=0;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;++i){cin>>vec.at(i);}
  sort(vec.begin(),vec.end());
  for(int i=1;i<N-1;++i){
    for(int j=i+1;j<N;++j){
      for(int k=0;k<i;++k){
        if(vec.at(k)>vec.at(j)-vec.at(i)){++answer;}
      }
    }
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())
lcm = (c*d)//fractions.gcd(c,d)
print(((b-((b//c)+(b//d)-(b//lcm)))-((a-1)-(((a-1)//c)+((a-1)//d)-((a-1)//lcm)))))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

vector<int>G[100010];
vector<int>dp(100010,0);
int r(){int x;cin>>x;return x;}
int dfs(int v){
    if(dp[v])return dp[v];
    int mx=0;
    for(auto it:G[v])mx=max(mx,dfs(it)+1);
    dp[v]=mx;
    return mx;
}

void solve() 
{
    int n,m,ans=0;cin>>n>>m;
    REP(i,m)G[r()-1].pb(r()-1);
    REP(i,n)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 10624
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int get(string s)
{
	if (s == "A")
	{
		return 0;
	}
	else if (s == "B")
	{
		return 1;
	}
	else if (s == "AB")
	{
		return 2;
	}
	else
	{
		return 3;
	}
}

int main()
{
	vector<int> a(4);

	string s;
	for (; cin >> s;)
	{
		stringstream ss;
		ss << s;

		int no;
		ss >> no;

		ss.ignore();

		string x;
		ss >> x;
		a.at(get(x))++;;

	}

	for (int i = 0; i < 4; i++)
	{
		cout << a.at(i) << endl;
	}
}


Measured memory_bytes: 3132
#include <cstdio>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int sum = 0;
    if(n > 0) sum += (n - 1) * n / 2;
    if(m > 0) sum += (m - 1) * m / 2;
    printf("%d\n", sum);
    return 0;
}


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


int a_val(int t);
int b_val(int t, int K);

 
int main()
{
    int N, K;
    cin >> N >> K;
    
    int t = 1;
    vector<int> ans(N+1);
    ans.at(0)=1;
    
    for(int i = 0; i < N; i++)
    {
        if(a_val(ans.at(i)) < b_val(ans.at(i),K))
        {
            ans.at(i+1)=a_val(ans.at(i));
        }
        else
        {
            ans.at(i+1)=b_val(ans.at(i),K);
        }
    }
    cout << ans.at(N) << endl;
}

//操作A
int a_val(int t)
{
    int retval = t*2;
    return retval;
}



//操作B
int b_val(int t, int K)
{
    int retval = t+K;
    return retval;
}



Measured memory_bytes: 256
#include <stdio.h>
int main () {
	char hue[11];
	scanf ("%s", &hue);
	for (int i = 0; i < 10; i++) {
		if (hue[3] >= '0' && hue[3] <= '9') {
			hue[3] = '8';
		}
	}
	printf ("%s", hue);
	return 0;
}

Measured memory_bytes: 1692
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        if('a' <= a && a <= 'z') System.out.println("a");
        if('A' <= a && a <= 'Z') System.out.println("A");
        
    }
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

const ll MOD = 1e9+7;
int N;
int a[111111];
map<int, int> mp;

ll f(ll x) {
   ll ret = 2;
   while (x > 0) {
      // ret *= 2;
      ret = ((ret%MOD) * (2%MOD)) % MOD;
      debug(ret)
      x /= 10;
   }
   return ret;
}

ll t(ll a, ll b) {
   ll ans = 1;
   while (b > 0) {
      if (b&1) {
         // ans *= a;
         ans = ((ans%MOD) * (a%MOD)) % MOD;
      }
      // a *= a;
      a = ((a%MOD) * (a%MOD)) % MOD;
      b /= 2;
   }
   return ans;
}

int main() {
   cin >> N;
   rep (i, N) {
      cin >> a[i];
      mp[a[i]]++;
   }

   if (N&1) {
      int n = 0;
      for (auto x : mp) {
         if (x.first == 0) {
            if (x.second != 1) {
               cout << 0 << endl;
               return 0;
            }
            n += 2;
            continue;
         }
         if (x.first == n && x.second == 2) {

         } else {
            cout << 0 << endl;
            return 0;
         }
         n += 2;
      }
   } else {
      int n = 1;
      for (auto x : mp) {
         if (x.first == n && x.second == 2) {

         } else {
            cout << 0 << endl;
            return 0;
         }
         n += 2;
      }
   }

   // cout << (1 << (N/2)) << endl;
   cout << t(2, N/2) % MOD << endl;

   return 0;
}

Measured memory_bytes: 3584
def factorial(n):
    res = 1
    while n > 0:
        res = (res*n)%mod
        n -= 1
    return res

n, m = map(int, input().split())
mod = 10**9 + 7
if abs(n-m) >= 2:
    print(0)
    exit()
ans = (factorial(min(n,m))%mod)**2 * max(n,m) if n != m else 2*(factorial(min(n,m))%mod)**2
print(ans%mod)

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

long long a, b, c, d, sol;

int main()
{
    ios::sync_with_stdio(false);
    cin >> a >> b >> c >> d;

    sol = a * c;

    sol = max(sol, a * d);
    sol = max(sol, b * c);
    sol = max(sol, b * d);

    cout << sol;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <iterator>

using namespace std;

int main()
{
	int n, m; cin>> n >> m;
  	
	vector<int> v(n, -1);
  
	int index, num;
	bool possible = true;
  
  	
	for(int i = 0; i < m; ++i)
	{
		cin >> index >> num; --index;
        if(n > 1 and index == 0 and num == 0)
        {
            possible = false; break;
        }
		if(v[index] == -1)
			v[index] = num;
		else if (v[index] != num)
		{
			possible = false; break;
		}
	}
	
	if(possible)
	{
		 if(v[0] == -1) v[0] = 1;
      	if(m==0 and n==1)
          v[0] = 0;
          for(int i = 1; i < n; ++i)
		 {
			if(v[i] == -1) v[i] = 0;
		 }
		 
		 copy(v.begin(), v.end(), ostream_iterator<int>(cout, ""));
        
	}
    else	
	cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)

const ll maxn=1e5+5, inf=0x3f3f3f3f3f3f3f3f;
ll n,m,a,b;
vector<ll> ady[maxn];

ll vis[maxn], memo[maxn];
ll dfs(ll x) {
    if(vis[x]) return memo[x];
    vis[x]=1;
    for(ll v: ady[x]) memo[x]=max(memo[x], 1+dfs(v));
    return memo[x];
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin>>n>>m;
    rep(i,0,m) {
        cin>>a>>b;
        ady[a].push_back(b);
    }
    ll ans=0;
    rep(i,1,n+1) ans=max(ans, dfs(i));
    cout<<ans<<"\n";
}

Measured memory_bytes: 8704
import copy

s = input().rstrip()
t = input().rstrip()
ns, nt = len(s), len(t)

start = -1
for i in range(ns - nt, -1, -1):
    for j in range(nt):
        if s[i+j] != t[j] and s[i+j] != '?':
            break
    else:
        start = i
        break

if start >= 0:
    s_ans = s[:start] + t + s[start+len(t):]
    print(s_ans.replace('?', 'a'))
else:
    print('UNRESTORABLE')


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();

    int cntA = 0;
    int cntB = 0;
    int cntC = 0;
    REP(i, n) {
        if (s[i] == 'a') cntA++;
        if (s[i] == 'b') cntB++;
        if (s[i] == 'c') cntC++;
    }

    if (n == 1) cout << "YES" << '\n';
    else if (n == 2) {
        if (s[0] != s[1]) cout << "YES" << '\n';
        else cout << "NO" << '\n';
    } else if (cntA == 0 || cntB == 0 || cntC == 0) cout << "NO" << '\n';
    else if (abs(cntA - cntB) <= 1 && abs(cntA - cntC) <= 1 && abs(cntB - cntC) <= 1)
        cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 512
SA = list(input())
SB = list(input())
SC = list(input())

x = "a"

while True:
  if x == "a":
    if len(SA) ==0:
      print("A")
      exit()

    x = SA[0]
    SA.remove(x)
  
  elif x == "b":
    if len(SB) ==0:
      print("B")
      exit()

    x = SB[0]
    SB.remove(x)

  else:
    if len(SC) == 0:
      print("C")
      exit()
    
    x = SC[0]
    SC.remove(x)

Measured memory_bytes: 3064
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val MOD = 1e9.toInt + 7

  val H, W = in.next().toInt
  val a = new Array[String](H+1)
  for (i <- 1 to H)
    a(i) = "#" + in.next()

  //
  val dp = Array.ofDim[Long](H+1, W+1)
  dp(1)(1) = 1
  for (y <- 1 to H; x <- 1 to W if x != 1 || y != 1) {
    if(a(y)(x) == '#')
      dp(y)(x) = 0
    else {
      dp(y)(x) = dp(y-1)(x) + dp(y)(x-1)
      dp(y)(x) %= MOD
    }
  }

  println(dp(H)(W))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



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

#define endl '\n'

using namespace std;
using ll = long long int;

int main(){

    ll d, t, s;
    cin >> d >> t >> s;

    if (s * t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3672
import sys
from itertools import islice

def kruskal(v_count: int, edges: list) -> int:
    tree = [-1]*v_count

    def get_root(x):
        if tree[x] < 0:
            return x
        tree[x] = get_root(tree[x])
        return tree[x]

    def unite(a):
        x, y = get_root(a[1]), get_root(a[2])
        if x != y:
            big, small = (x, y) if tree[x] < tree[y] else (y, x)
            tree[big] += tree[small]
            tree[small] = big
        return x != y

    cost = 0
    for w, _s, _t in islice(filter(unite, sorted(edges)), v_count-1):
        cost += w
    return cost

V, E = map(int, input().split())
edges = [(w, s, t) for s, t, w in (map(int, l.split()) for l in sys.stdin)]
print(kruskal(V, edges))


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

int main(){
  int a[10];

  for(int i=0;i<10;i++){
    cin >> a[i];
  }
  sort(a,a+10,greater<int>());
  cout << a[0]+a[1]+a[2] << " ";

  for(int i=0;i<10;i++){
    cin >> a[i];
  }
  sort(a,a+10,greater<int>());
  cout << a[0]+a[1]+a[2] << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

Int a[100001][30];
Int d[100001];

int main() {
    string s, t;
    cin >> s >> t;
    Int n = s.size();
    Int m = t.size();
    map<char, Int> mp1;
    for (Int i = 0; i < n; i++) {
        mp1[s[i]]++;
    }
    for (Int i = 0; i < m; i++) {
        if (mp1[t[i]] == 0) {
            dump(-1);
            return 0;
        }
    }
    for (Int k = 0; k < 2; k++) {
        for (Int i = n - 1; i >= 0; i--) {
            for (Int j = 0; j < 26; j++) {
                a[i][j] = d[j];
            }
            d[s[i] - 'a'] = i;
        }
    }
    Int res = 0;
    Int index = 0;
    while (s[index] != t[0]) index++;
    res = index + 1;
    for (Int i = 0; i < m - 1; i++) {
        Int next  =a[index][t[i + 1] - 'a'];
        if (index < next) {
            res += next - index;
        }
        else {
            res += (n - index - 1) + (next + 1);
        }
        index = next;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007ll

int main(){
	string S;
	cin >> S;
	int l=S.size();
	long long dp[l+1][4];
	for(int i=0;i<l+1;i++)for(int j=0;j<4;j++)dp[i][j]=0ll;
	dp[0][0]=1;
	for(int i=0;i<l;i++){
		for(int j=0;j<4;j++){
			dp[i+1][j]=dp[i][j];
			if(S[i]=='?'){
				dp[i+1][j]*=3;
				if(dp[i+1][j]>=MOD)dp[i+1][j]%=MOD;
			}
			if(j>0 && (S[i]=='A'+j-1 || S[i]=='?')){
				dp[i+1][j]+=dp[i][j-1];
				if(dp[i+1][j]>=MOD)dp[i+1][j]-=MOD;
			}
		}
	}
	cout << dp[l][3] << endl;
	return 0;
}

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

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/g*b;
}

main() {
  ll n;cin>>n;
  ll ans;cin>>ans;
  for(ll i=1;i<n;i++){
    ll t;cin>>t;
    ans=lcm(ans,t);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
n = k = 0
cards = []
mini_ans = {}


def dfs(s: list) -> None:
    global n, k, cards, mini_ans
    if len(s) == k:
        string = ""
        for i in s:
            string += cards[i]
        mini_ans.add(string)
        return

    for i in range(n):
        if i not in s:
            dfs(s + [i])


def main() -> None:
    ans = []

    global n, k, cards, mini_ans
    while True:
        n, k = [int(input()) for _ in range(2)]
        if n + k == 0:
            break
        cards = [input() for _ in range(n)]
        mini_ans = set()

        dfs([])
        ans += [len(mini_ans)]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()



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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.length()){
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define fori( tt,aa)      for(int i= tt; i<aa; i++)
#define forj( yy,bb)      for(int j=yy; j<bb; j++)
#define fork( uu,cc)      for(int k=uu; k<cc; k++)
#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define EPS 1e-7
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define sc scanf
#define print printf
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string String;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

ll numOfDigits(ll n);
bool compare(int &a, int &b){
    return a>b;
}

ll pow (ll a, ll b);

dd BN (vector<pii> &v, ll n, ll m);



dd sum(dd mid){
    return ((dd)mid/2)*(mid+1);
}
int  N, M, NUM, mn = IMAX;
#define MAX 1000000
bool visited[15][102];
bool arr[15][102];

bool valid(int r, int c){//if not out of the bounds
    if(r>=N || r<0) return 0;
    if(c>=M || c<0) return 0;
    return 1;
}
void countReachable(int r, int c, int cnt, int i){
    //if out of bounds || visited before
    if(!valid(r, c) || visited[r][c])
        return;

    visited[r][c] = 1; //mark as visited

    if(i==NUM) {mn = min(mn, cnt); return;}
    //try 4 moves
    countReachable(r,c+1, cnt+1, i+arr[r][c]);//right

    countReachable(r,c-1, cnt+1, i+arr[r][c]);//left

    countReachable(r+1,c, cnt+1, i+arr[r][c]);//up
    visited[r][c] = 0;
    countReachable(r-1,c, cnt+1, i+arr[r][c]);//down
    visited[r][c] = 0;

}

int main()
{
    JULEE_DO_THE_THING;
    //freopen("test cases\\.txt", "r", stdin) ;
    int n, k; cin>>n>>k;
    ll arr[n];
    fori(0, n) cin>>arr[i];
    sort(arr, arr+n);
    ll sum = 0;
    for(int i=n-1; i>=0; i--){
        if(k){
            k--;
            continue;
        }
        sum+=arr[i];
    }
    cout<<sum;
    return 0;
}


dd BN (vector<pii> &v, ll n, ll m){
dd low = 0;
dd up = 1e21;
dd ans = 0;
while(low<=up){
    dd mid = trunc((low+ up)/2);
    dd fx = 0;
    fori(0, n){
        fx += max(0.0, mid-v[i].F)*v[i].S;
    }
    if(fx<=m) {
        ans = mid;
        low = mid+1;
    }else up = mid-1;
}
return ans;
}

ll pow (ll a, ll b){
    ll pow = 1;
    fori(0,b)
        pow *=a;
    return pow;
}
ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n)+1);
}


Measured memory_bytes: 1792
<?php
$str = trim(fgets(STDIN));
for($i = 0; $i < strlen($str); $i++){
    if(preg_match("/[a-z]/",$str[$i])){
        echo strtoupper($str[$i]);
    } elseif(preg_match("/[A-Z]/",$str[$i])){
        echo strtolower($str[$i]);
    } else{
        echo $str[$i];
    }
}
echo "\n";

Measured memory_bytes: 15580
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

n,m = map(int,input().split())

if m%n==0:
    print(m//n)
else:
    arr = sorted(divisor(m))
    # print(arr)
    for i in arr:
        if i >= n:           
            print(m//i)
            exit()

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

int N;
int A[100010],B[100010];
vector<int> a,b;
vector<int> cmp;
vector<int> G[100010];
bool F[100010] = {0};
bool visit[100010] = {0};
int ans = 0;

void DFS(int v)
{
    if(visit[v])return;
    visit[v] = true;
    for(int i = 0; i < G[v].size(); i++)DFS(G[v][i]);
    return;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);
    for(int i = 0; i < N; i++)scanf("%d",B + i);
    int xa = A[0],xb =B[0];
    for(int i = 0; i < N; i++)
    {
        a.push_back(A[i]);
        b.push_back(B[i]);
        cmp.push_back(A[i]);
        cmp.push_back(B[i]);
        if(i != 0)
        {
            xa ^= A[i];
            xb ^= B[i];
        }
    }
    A[N] = xa;
    B[N] = xb;
    a.push_back(xa);
    b.push_back(xb);
    cmp.push_back(xa);
    cmp.push_back(xb);
    sort(cmp.begin(),cmp.end());
    cmp.erase(unique(cmp.begin(),cmp.end()),cmp.end());
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int i = 0; i < N + 1; i++)
    {
        if(a[i] != b[i])
        {
            printf("-1\n");
            return 0;
        }
    }
    for(int i = 0; i <= N; i++)
    {
        A[i] = lower_bound(cmp.begin(),cmp.end(),A[i]) - cmp.begin() + 1;
        B[i] = lower_bound(cmp.begin(),cmp.end(),B[i]) - cmp.begin() + 1;
    }
    for(int i = 0; i <= N; i++)
    {
        if(A[i] != B[i])
        {
            if(i != N)ans++;
            G[A[i]].push_back(B[i]);
            G[B[i]].push_back(A[i]);
            F[A[i]] = F[B[i]] = true;
        }
    }
    for(int i = 0; i <= N; i++)
    {
        if(!visit[i] && F[i])
        {
            DFS(i);
            ans++;
        }
    }
    printf("%d\n",ans - (F[A[N]]));
    return 0;
}


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

int main(){
    int a,b,c,x,y,ans=0,her;
    cin >> a >> b >> c >> x >> y;
    if(x>y) her = a;
    else her = b;
    if(2*c >= a+b){
        ans=a*x+b*y;
        cout << ans << '\n';
        return 0;
    }
    ans = 2 * c * min(x,y);
    ans+= (max(x,y)-min(x,y)) * min(2*c,her);
    cout << ans << '\n';
}


Measured memory_bytes: 3576
n, k = map(int, input().split())
c = 0
AB = []
ABC = []
for _ in range(n):
    a, b = map(int, input().split())
    AB.append((a,b))

AB = sorted(AB, key=lambda x:x[0])

for i in range(n):
    c += AB[i][1]
    ABC.append((AB[i][0], AB[i][1], c))

for i in range(n):
    if k <= ABC[i][2]:
        ind = i
        break

print(ABC[ind][0])

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N; cin >> N;
    ll a = N/15;
    ll b = N/3;
    ll c = N/5;
    cout << N*(N+1)/2 + 15*a*(a+1)/2 - 3*b*(b+1)/2 - 5*c*(c+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 3648
def main():
    n, p = map(int, input().split())
    s = input()

    TF = 2, 5
    if p in TF:
        answer = 0
        for i, char in enumerate(s):
            if int(char) % p == 0:
                answer += i + 1
        print(answer)
        return

    # u = [int(s[i:]) for i in range(n)]
    remainders = []
    t = 0
    for i, char in enumerate(s[::-1]):
        t += pow(10, i, p) * int(char)
        remainders.append(t % p)
    remainders = remainders[::-1]
    remainders.append(0)
    # The numbers to consider are int(s[i:j]) (0 <= i < j <= n)
    # u[i] := int(s[i:]) (u[n] = 0 for convenience)
    # int(s[i:j]) and u[i] - u[j] are congruent (unless p == 2 or 5)
    d = {}
    for remainder in remainders:
        if remainder not in d:
            d[remainder] = 1
        else:
            d[remainder] += 1
    answer = 0
    for count in d.values():
        if count > 1:
            answer += count * (count - 1) // 2
    print(answer)

main()


Measured memory_bytes: 12928
#include<iostream>
using namespace std;
long M=1e9+7,i,ans,N,K;
long power(long a,long b){return b?power(a*a%M,b/2)*(b%2?a:1)%M:1;}
long F[4<<17],I[4<<17];
long C(long n,long k){return F[n]*I[n-k]%M*I[k]%M;}
int main(){
	F[0]=1;
	for(i=1;i<4<<17;i++)F[i]=F[i-1]*i%M;
	I[(4<<17)-1]=power(F[(4<<17)-1],M-2);
	for(i=(4<<17)-1;i--;)I[i]=I[i+1]*(i+1)%M;
	cin>>N>>K;
	for(i=0;i<N&&i<=K;i++)ans+=C(N,i)*C(N-1,i)%M;
	cout<<ans%M<<endl;
}


Measured memory_bytes: 8448
#include <iostream>

using namespace std;

int main()
{
    // INPUT
    string s, t;
    cin >> s >> t;
    
    // PROSES
    int ans = 0;
    for(int i = 0; i<s.length(); i++)
        if(s[i]!=t[i])
            ans++;
    
    // OUTPUT
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3884
/***********************************************
#
#      Filename: e.cpp
#
#        Author: Comsyl - ylsong15@fudan.edu.cn
#   Description: ---
#        Create: 2017-05-10 21:25:55
***********************************************/
#include <bits/stdc++.h>
using namespace std;

int ceil(int x, int y) {
    if (x % y == 0) return x / y;
    else return x / y + 1;
}

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> bar(H);
    for (int i = 0; i < H; ++ i) {
        cin >> bar[i];
    }
    int sx, sy;
    for (int i = 0; i < H; ++ i) {
        for (int j = 0; j < W; ++ j) {
            if (bar[i][j] == 'S') {
                sx = i;
                sy = j;
            }
        }
    }

    queue<int> qx;
    queue<int> qy;
    auto vis = vector<vector<int>>(H, vector<int>(W, -1));
    int dir[4][2] = {{-1,0}, {0,1}, {1,0}, {0,-1}};
    vis[sx][sy] = 0;
    qx.push(sx); qy.push(sy);
    while (!qx.empty()) {
        int x = qx.front();
        int y = qy.front();
        qx.pop();
        qy.pop();
        int step = vis[x][y] + 1;
        if (step > K) continue;
        for (int i = 0; i < 4; ++ i) {
            int nx = x + dir[i][0];
            int ny = y + dir[i][1];
            if (nx>=0 && nx<H && ny>=0 && ny<W && vis[nx][ny] == -1 && bar[nx][ny]=='.') {
                vis[nx][ny] = step;
                qx.push(nx);
                qy.push(ny);
            }
        }
    }

    int ans = 1000000;
    for (int x = 0; x < H; ++ x) {
        for (int y = 0; y < W; ++ y) {
            if (vis[x][y] == -1) continue;
            ans = min(ans, ceil(x, K));
            ans = min(ans, ceil(H-1-x, K));
            ans = min(ans, ceil(y, K));
            ans = min(ans, ceil(W-1-y, K));
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


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

int main(){
	int N, ans = 0, a = 0;
	cin >> N;
	int p[N];
	for(int i=0; i<N; i++){
		cin >> p[i];
		if(p[i] == i+1){
			a++;
		}else{
			ans += (a+1)/2;
			a = 0;
		}
	}
	ans += (a+1)/2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    int x;
    int i=0;
    
    cin>>a>>b>>c;
    for(x=a;x<=b;x++){
        if(c%x==0)i++;
    }
    cout<<i<<endl;
    return 0;
}



Measured memory_bytes: 3100
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.equals("Sunny"))
			out.println("Cloudy");
		else if (s.equals("Cloudy"))
			out.println("Rainy");
		else
			out.println("Sunny");
		
	}
}

Measured memory_bytes: 20564
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())

cnt1 = 0
flag = False
for i in range(N):
    num = A[i]
    if num == 0:
        flag = True
    if num < 0:
        cnt1 += 1
        A[i] = -num

if flag or cnt1 % 2 == 0:
    print sum(A)
else:
    print sum(A) - min(A) * 2


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

typedef long long ll;
const ll MOD = 1000000007;

int main(){
	ll n;
	cin >> n;
	
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	
	static ll dp[1000010][4] = {};
	dp[1][1] = 1;
	for(int i = 1 ; i < n ; i ++){
		dp[i+1][0] = dp[i][3];
		dp[i+1][1] = dp[i][0];
		dp[i+1][2] = dp[i][1]+dp[i][2];
		if(dp[i+1][2] >= MOD)dp[i+1][2] -= MOD;
		dp[i+1][3] = dp[i][3]+dp[i+1][2];
		if(dp[i+1][3] >= MOD)dp[i+1][3] -= MOD;
	}
	
	/*for(int i = 1 ; i <= n ; i ++){
		cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << endl;
	}*/
	
	ll x = (n-1)*n; x %= MOD;
	ll ret = x+1;
	for(int i = 1 ; i <= n-2 ; i ++){
		ret += x*(dp[i][0]+dp[i][1]+dp[i][2]);
		ret %= MOD;
	}
	ret += (n-1)*(dp[n-1][0]+dp[n-1][1]+dp[n-1][2]);
	//ret += dp[n][0]+dp[n][1]+dp[n][2];
	cout << ret%MOD << endl;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define INF 0x7ffffffffff
using namespace std;
const int N = 2005;
long long dp[N][N] = {};
pair<long long, int> arr[N];
int n;
inline bool cmp(const pair<long long , int> &a, const pair<long long , int> &b) {
    return a.first > b.first;
}
long long DP(int l, int r) {
    if (l < 0 || r > n + 1) return -INF;
    if (~dp[l][r]) return dp[l][r];
    long long t = l + n - r + 1;
    long long val = arr[t].first, idx = arr[t].second;
    return dp[l][r] = max(DP(l - 1, r) + val * abs(idx - l), DP(l, r + 1) + val * abs(idx - r));
}
int main() {
    cin >> n;
    fill(dp[0], dp[0] + N * N, -1);
    dp[0][n + 1] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i].first;
        arr[i].second = i;
    }
    sort(arr + 1, arr + 1 + n, cmp);
    long long ans = 0;
    for (int i = 1; i < n; i++)
        ans = max(ans, DP(i, i + 1));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 35152
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var str = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var list = new List<int>();
            var count = 0;
            var flag = true;

            for (var x = 0; x < N; x++)
                list.Add(str[x]);
            
            while(flag == true)
            {
                for(var x=0; x<N; x++)
                {
                    if (list[x] % 2 != 0)
                    {
                        flag = false;
                        break;
                    }
                    else
                    {
                        list[x] = list[x] / 2;
                        count++;
                    }
                }
            }
            Console.WriteLine(count / N);
        }
    }
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}

using t4 = tuple<int,int,int,int>;

vi v;
int n, m;
vector<t4> q;
int mx = 0;

int check(){
    int scr = 0;
    for(auto &tt : q){
        int a = get<0>(tt);
        int b = get<1>(tt);
        int c = get<2>(tt);
        int d = get<3>(tt);
        if(v[b] - v[a] == c) scr += d;
    }
    return scr;
}

void go(int i, int x){
    if(i == n){
        mx = max(mx, check());
        return;
    }
    for(int x0 = x; x0 <= m;x0++){
        v[i] = x0;
        go(i+1, x0);
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int nq;
    cin >> n >> m >> nq;
    v = vi(n);
    q = vector<t4>(nq);
    for(int i=0;i<nq;i++){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        q[i] = {a-1,b-1, c, d};
    }
    mx = 0;
    go(0, 1);
    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int h,w;
    int n;
    cin>>h>>w>>n;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    vector<vector<int>> b(h,vector<int>(w,-1));
    int x=0,y=0,cnt=0,now=0,now_cnt=0;
    while(cnt<h*w){
        b[y][x]=now+1;
        now_cnt ++;
        cnt ++;
        if(y%2==1){x --;}
        else{x ++;}

        if(x==w){
            x=w-1;
            y ++;
        }
        if(x==-1){
            x=0;
            y ++;
        }

        if(now_cnt==a[now]){
            now_cnt=0;
            now ++;
        }
    }
    rep(i,h){
        rep(j,w-1){
            cout<<b[i][j]<<" ";
        }
        cout<<b[i][w-1]<<endl;
    }
}
//./problem.exe

Measured memory_bytes: 384
s=list(input())
n=len(s)
from collections import defaultdict
d=defaultdict(int)
t=['g' if i%2==0 else 'p' for i in range(n)]
pnt=0
for i in range(n):
    if s[i]==t[i]:
        continue
    elif s[i]=='g':
        pnt+=1
    else:
        pnt-=1
print(pnt)

Measured memory_bytes: 84172