akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#define fr first
#define sc second
using namespace std;

int n,p,dp[1001];
typedef pair<int,int> iP;
vector <iP> v;

void rec(int idx,int sum){
  if(sum > 1000) return;
  if(idx == n){ dp[sum]++; return; }
  for(int i=0;i<=v[idx].sc;i++){
    rec(idx+1,sum + (v[idx].fr * i));
  }
}

int main(){
  int m;
  while(cin >> n,n){
    v.resize(0);  memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
      int t,m; cin >> t >> m; v.push_back(iP(t,m));
    }
    cin >> m;
    rec(0,0);
    for(int i=0;i<m;i++){
      cin >> p;
      cout << dp[p] << endl;
    }
  }
}

Measured memory_bytes: 1196
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define ull unsigned long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
using namespace std;

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

	ull N;
	cin >> N;
	ull cnt4 = 0;
	ull cnt2 = 0;
	ull cnt1 = 0;
	REP(i, N) {
		int a;
		cin >> a;
		if(a % 4 == 0) cnt4++;
		else if(a % 2 == 0) cnt2++;
		else cnt1++;
	}

	if(N <= (cnt4 & 1) + cnt4 * 2) {
		cout << "Yes" << endl;
		return 0;
	}

	if(N <= cnt4 * 2 + cnt2) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    int a[6], i, temp, len, j;
    char c[101];
    for(i=0;i<6;i++)
        scanf("%d", &a[i]);
    scanf("%s", c);
    len = strlen(c);

    for(i=0;i<len;i++){
        if(c[i] == 'S'){
            temp = a[4];
            a[4] = a[5];
            a[5] = a[1];
            a[1] = a[0];
            a[0] = temp;
        }else if(c[i] == 'E'){
            temp = a[3];
            a[3] = a[5];
            a[5] = a[2];
            a[2] = a[0];
            a[0] = temp;
        }else if(c[i] == 'W'){
            temp = a[2];
            a[2] = a[5];
            a[5] = a[3];
            a[3] = a[0];
            a[0] = temp;
        }else if(c[i] == 'N'){
            temp = a[1];
            a[1] = a[5];
            a[5] = a[4];
            a[4] = a[0];
            a[0] = temp;
        }
    }
    printf("%d\n", a[0]);
return 0;
}



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

int main() {
  int A,B,C,X,i,j,k,count=0;
  
  cin >> A >> B >> C >> X;
  
  for(i=0;i<=A;i++) {
    for(j=0;j<=B;j++) {
      for(k=0;k<=C;k++) {
        if(X == 500*i+100*j+50*k) count++;
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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

int main() {
  // 科目の数Nを受け取る
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int count(0);
  for(int na = 0; na <= A; na++)
  {
    const int resA = X - 500 * na; 
    for(int nb = 0; nb <= B; nb++)
    {
      const int res = resA - 100 * nb;
      if( res % 50 == 0 && res / 50 <= C)
      {
         count++;
      }
      if( res < 100 )
      {
        break; 
      }        
    }
    if( resA < 500 )
    {
      break; 
    }
  }
  cout << count << endl;  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	static int a[]=new int[10];
	static int ans;
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		while(n-->0)
		{
			ans=0;
			for(int i=0;i<10;i++)
				a[i]=in.nextInt();
			solve(0,0,0);
			if(ans==1)
				System.out.println("YES");
			else 
				System.out.println("NO");
		}
	}
	public static void solve(int l,int r,int i)
	{
		if(i==10)
		{
			ans=1;
			return;
		}
		if(l<a[i])
			solve(a[i],r,i+1);
		else if(r<a[i])
			solve(l,a[i],i+1);
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int[] num = new int[3];
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 4 == 0) num[2]++;
            else if (A[i] % 2 == 0) num[1]++;
            else num[0]++;
        }

        int pre = 2;
        for (int i = 0; i < N; i++)
        {
            bool ok = false;
            for (int j = 2 - pre; j <= 2; j++)
            {
                if(num[j] > 0)
                {
                    num[j]--;
                    pre = j;
                    ok = true;
                    break;
                }
            }
            if (!ok)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 20448
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define int ll int 
#define ll long long
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define test int tc;for(cin>>tc;tc>0;tc--)
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int n,k;
	cin>>n>>k;
	vi A(n);
	in(n)
	{
		cin>>A[i];
	}
	in(n)
		A[i]--;
	// for(auto it : A)
	// 	cout<<it<<' ';
	// cout<<endl;
	vi B(n,0);
	int cntcycle=0,stindex=-1;
	int i=0;
	bool flag=1;
	int temp=k,ans=-1;
	int len=0;
	while(1)
	{
		if(B[i]==0)
		{
			B[i]++;
			i=A[i];
			len++;
			k--;
			if(k==0)
			{
				ans=i;
				break;
			}
		}
		else if(B[i]==1)
		{
			if(flag)
			{
				flag=0;
				stindex=i;
			}
			B[i]++;
			i=A[i];
			cntcycle++;
			k--;
			if(k==0)
			{
				ans=i;
				break;
			}
		}
		else if(B[i]==2)
		{
			break;
		}
		// for(auto it : B)
		// 	cout<<it<<' ';
		// cout<<endl;
	}
	if(ans!=-1)
	{
		cout<<ans+1<<endl;
		return 0;
	}
	int mx=len-cntcycle;
	//cout<<mx<<endl;
	temp-=(mx);
	temp%=cntcycle;
	i=stindex;
	while(temp>0)
	{
		i=A[i];
		temp--;
	}
	cout<<i+1<<endl;
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "h" "h.cpp" -fsanitize=address
// -fsanitize=undefined -D_GLIBCXX_DEBUG -g

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n;
        k=n%1000;
        if(k!=0)
        cout<<1000-k;
        else
        cout<<"0";
        
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const ll INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;


int main(){
    int N;
    cin >> N;
    vector<int> T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];
    ll t_ans = 1, a_ans = 1;
    rep(i, N){
        ll x = (t_ans + T[i] - 1)/ T[i];
        ll y = (a_ans + A[i] - 1) / A[i];
        ll tmp = max(x, y);
        t_ans = tmp * T[i];
        a_ans = tmp * A[i];
        // cout << t_ans << ' ' << a_ans << endl;
    }
    cout << t_ans + a_ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int fa[110000];
typedef struct
{
    int w,wer,hao;
}qq;
typedef struct
{
    int p1,p2,p3;
}pp;
bool cmp1(qq r,qq t)
{
    return r.wer<t.wer;
}
bool cmp2(qq r,qq t)
{
    return r.w<t.w;
}
bool cmp3(pp r,pp t)
{
    return r.p1<t.p1;
}
int getfa(int a)
{
    if(fa[a]!=a)
    {
        return fa[a]=getfa(fa[a]);
    }
    else
    {
        return a;
    }
}
qq a[110000];
pp b[440000];
int main()
{
    int n;
     scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        fa[i]=i;
    }
 for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].wer,&a[i].w);
        a[i].hao=i;
    }
    sort(a,a+n,cmp1);
    int k=0;
    for(int i=1;i<n;i++)
    {
       b[k].p1=a[i].wer-a[i-1].wer;
       b[k].p2=a[i].hao;
       b[k].p3=a[i-1].hao;
       k++;
    }
    sort(a,a+n,cmp2);
    for(int i=1;i<n;i++)
    {
        b[k].p1=a[i].w-a[i-1].w;
        b[k].p2=a[i].hao;
        b[k].p3=a[i-1].hao;
        k++;
    }
    sort(b,b+2*n-2,cmp3);
    long long int s=0;
    for(int i=0;i<2*n-2;i++)
    {
        if(getfa(b[i].p2)!=getfa(b[i].p3))
        {
            s+=b[i].p1;
            fa[getfa(b[i].p3)]=getfa(b[i].p2);
        }
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 7040
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int sum = 0; 
    for (int i = 0; i <= a; i++){
        for (int k = 0; k <= b; k++){
            for (int p = 0; p <= c; p++){
                if (500 * i + 100 * k + 50 * p == x){
                    sum++;
                }
            }
        }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
	int N;
    cin >> N;
  	if(N%2==1){
    	cout << N*2 << endl;
    }else cout << N << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int m; scan(m);
  print(48 - m);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,P,Q,R,x[100];
	scanf("%d%d%d",&P,&Q,&R);
	//A-B=P B-C=Q A-C=R
	
		x[1]=P+R; x[4]=R+Q; 
		x[2]=P+Q;
		x[3]=Q+R; x[5]=Q+P;
		x[6]=R+P;
	 	
	int	min=x[1];
		for(i=1;i<7;i++){
		if(min>x[i]){
			min=x[i];
			}
		}
	printf("%d\n",min);
	
	return 0;
}

		
			

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

int main(){
  int cards = 0;
  cin >> cards;
  
  vector<int> points(cards);  
  for(int i = 0; i < points.size(); i++){
    cin >> points.at(i);
  }
  
  sort(points.begin(),points.end());
  reverse(points.begin(),points.end());
  
  int alice = 0;
  int bob = 0;
  for(int i = 0; i < points.size(); i++){
    if(i % 2 == 0){
      alice += points.at(i);
    }
    else{
      bob += points.at(i);
    }
  }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
Program main
  implicit none
  integer :: K , A,B, i

  read (*,*) K
  read(*,*) A,B
  do i = A,B
     if (mod(i,K) == 0 ) then
        write(*,'(a)') 'OK'
        stop
     end if
  end do
  write(*,'(a)') 'NG'

  stop
end program main


Measured memory_bytes: 2924
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

void dfs() {

}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), m = inl();
        vector<ll> k(m);
        vector<set<ll>> s(m);
        vector<ll> p(m);
        rep(i, m) {
            k[i] = inl();
            rep(j, k[i]) s[i].insert((inl() - 1));
        }
        rep(i, m) p[i] = inl();

        ll ans = 0;
        rep(i, 1 << n) {

            ll tmp = 0;
            rep(d, m) { // 電球

                int c_on = 0;
                rep(j, n) { // オンになっているスイッチ
                    if (i & (1 << j)) {
                        auto f = s[d].find(j);
                        if (f != s[d].end()) c_on++;
                    }
                }
                if (c_on % 2 == p[d]) tmp++;
            }
            if (tmp == m) ans++;
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int poww[100];

int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  rep(i,h){
    rep(j,w)cin >> a[i][j];
  }
  poww[0]=1;
  rep(i,h)poww[i+1]=w*poww[i];
  vector<int> v;
  rep(i,poww[h]){
    v.clear();
    int temp=i;
    int sum=0;
    while(temp>0){
      sum+=temp%w;
      v.push_back(temp%w);
      temp/=w;
    }
    if(sum==w-1){
      bool ok=true;
      int tempw=0;
      int cnt=0;
      rep(j,h){
        for(int k=0;k<w;k++){
          if(a[j][k]=='#')cnt++;
          if(tempw<=k && k<=tempw+v[j] && a[j][k]=='.')ok=false;
        }
        tempw+=v[j];
      }
      if(ok && cnt==h+w-1){
        cout << "Possible" << endl;
        return 0;
      }
    }
  }
  cout << "Impossible" << endl;
return 0;}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007ULL
#define EPS 1e-8

typedef unsigned long long ULL;

ULL p3[100010];

inline ULL func(int u, int ofs){
	return ((u ? p3[u - 1] * u : 0ULL) + ofs * p3[u]) % MOD;
}

void mainmain(){
	p3[0] = 1;
	for(int i = 1; i < 100010; ++i){ p3[i] = p3[i - 1] * 3 % MOD; }
	string s;
	cin >> s;
	int lt = 0;
	int rt = count(ALL(s), '?');
	int a = 0;
	int c = count(ALL(s), 'C');
	ULL ans = 0;
	for(char x : s){
		if(x == '?'){ --rt; }
		if(x == 'C'){ --c; }
		if(x == '?' || x == 'B'){
			ULL t = func(lt, a);
			ULL u = func(rt, c);
			ans = (ans + t * u) % MOD;
		}
		if(x == '?'){ ++lt; }
		if(x == 'A'){ ++a; }
	}
	cout << ans << endl;
}



}
int main() try{
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ve<char> c(9);
  rep(i, 9){
    ci(c.at(i));
  }
  st a = "";
  a += c.at(0);
  a += c.at(4);
  a += c.at(8);
  co(a);
}


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

int main() {
  // ここにプログラムを追記
  int s123, s1, s2, s3;
  
  cin >> s123;
  s1 = s123/100;
  s2 = (s123-s1*100)/10;
  s3 = s123%10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=60;
int n,m,x,y,eg,u[MAXN],v[MAXN],hd[MAXN],ver[2*MAXN],nx[2*MAXN],f[MAXN];
bitset <51> q[21],t[1<<20];
ll ans;
ll qpow (ll a,ll b) {
    ll res=1;
    while (b) {
        if (b&1) {res*=a;}
        a*=a,b>>=1;
    }
    return res;
}
void add_edge (int x,int y) {
    ver[++eg]=y;
    nx[eg]=hd[x];
    hd[x]=eg;
    return;
}
void dfs (int x,int fa) {
    f[x]=fa;
    for (int i=hd[x];i;i=nx[i]) {
        if (ver[i]==fa) {continue;}
        dfs(ver[i],x);
    }
    return;
}
void mk (int x,int y,int p) {
    for (int i=x;i!=1;i=f[i]) {q[p].set(i,1);}
    int cur=y;
    for (;cur!=1&&!q[p][cur];cur=f[cur]) {q[p].set(cur,1);}
    for (;cur!=1;cur=f[cur]) {q[p].set(cur,0);}
    return;
}
int main () {
    eg=1;
    scanf("%d",&n);
    for (int i=1;i<=n-1;i++) {
        scanf("%d%d",&x,&y);
        add_edge(x,y),add_edge(y,x);
    }
    dfs(1,0);
    scanf("%d",&m);
    for (int i=1;i<=m;i++) {
        scanf("%d%d",&u[i],&v[i]);
        mk(u[i],v[i],i);
    }
    for (int i=0;i<(1<<m);i++) {
        int cnt=0,cur=0;
        for (int j=0;j<m;j++) {
            if (i&(1<<j)) {cnt++,cur=j+1;}
        }
        if (cnt) {t[i]=t[i^(1<<(cur-1))]|q[cur];}
        if (cnt&1) {
            ans-=qpow(2,n-1-t[i].count());
        } else {
            ans+=qpow(2,n-1-t[i].count());
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

ans = 0
for i in range(1, N + 1):
    ans += i * (N + 1 - i)

for i in range(N - 1):
    u, v = map(int, input().split())
    u, v = min(u, v), max(u, v)
    ans -= (N - v + 1) * u

print(ans)


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

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

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 (a>b) { a=b; return 1; } return 0; }

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

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

using namespace std;

const int INF=1e9;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin>>S;
    int N = S.size();
    vi sum(N+1);
    rep(i,N){
        if (S[i]=='0') sum[i+1]=sum[i]+1;
        else sum[i+1]=sum[i]-1;
    }
    vi maxi(N+1,-INF);
    RFOR(i,N-1,0){
        maxi[i] = max(maxi[i+1],sum[i+1]);
    }

    auto getDiff = [&](int x){
        int res=0;
        int c=0;
        rep(i,N){
            if (S[i]=='?' && maxi[i]+c+2<=x) c+=2;
            chmin(res,sum[i+1]+c);
        }
        return x-res;
    };
    int minMax = max(0,maxi[0]);
    int ans=min(getDiff(minMax), getDiff(minMax+1));
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 12184
from collections import Counter
  
P = 2019
S = input()
N = len(S)

ans = 0
S = S[::-1]
a, temp = [int(S[0]) % P], 1
for i in range(1, N):
    temp *= 10
    temp %= P
    val = (a[i-1] + (int(S[i]) % P * temp) % P) % P
    a.append(val)    
    
c = Counter(a)
if 0 in c:
    ans += c[0]
    ans += c[0] * (c[0] - 1) // 2
    del c[0]
for x in c.keys():
    ans += c[x] * (c[x]-1) // 2 
print(ans)

Measured memory_bytes: 16560
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++) {
        string S = to_string(i);
        string SS = S;
        reverse(SS.begin(), SS.end());
        if (S == SS) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
	0127:Pocket Pager Input
*/
#include	<iostream>
#include	<string>

using namespace std;

const char WORDS[] = "abcdefghijklmnopqrstuvwxyz.?! ";

int main(void) {
	char WORDSET[6][5];
	int w = 0;
	
	for(int i = 0; i < 6; i++) {
		for(int j = 0; j < 5; j++) {
			WORDSET[i][j] = WORDS[w];
			w++;
		}
	}
	
	while(1) {
		string str;
		string ans;
		bool fl = true;
		
		cin >> str;
		
		if( cin.eof() ) { break; }
			else if( (int)str.size() % 2 != 0 ) { cout << "NA" << endl; continue; }
		string::iterator it = str.begin();
		while( it != str.end() ) {
			int a, b;
			
			a = *it - '0' - 1;
			it++;
			b = *it - '0' - 1;
			it++;
			
			if(0 <= a && a < 6 && 0 <= b && b < 5) {
				ans += WORDSET[a][b];
			} else {
				fl = false;
				break;
			}
		}
		if(fl) {
			cout << ans << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for(int i=0;i<N;i++) cin >> p[i];
    sort(p.begin(),p.end());
    int ans = 0;
    for (int i=0;i<K;i++) {
        ans += p[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3660
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b){
		x=a;
	}
	else{
		x=b;
	}
	if(c<d){
		y=c;
	}
	else{
		y=d;
	}
	printf("%d\n",x+y);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int N = sc.nextInt();
    int count = 0;

    for (int i = 0; i < A+1; i++) {
      if (N - i * 500 < 0) {
        break;
      }

      for (int j = 0; j < B+1; j++) {
        if (N - i * 500 - j * 100 < 0) {
          break;
        }

        for (int k = 0; k < C+1; k++) {
          if (N - i * 500 - j * 100 - k * 50 < 0) {
            break;
          } else if (N - i * 500 - j * 100 - k * 50 == 0) {
            count += 1;
          }
        }
      }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 21844
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[100010],b[100010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i]>>b[i];
    }
    ll now = 0;
    ll result = 0;
    for (int i = n-1; i >= 0; i--) {
        // std::cout << a[i]<<" "<<b[i]<<" "<<now <<" "<<b[i] - (a[i]+now) % b[i]<< std::endl;
        if(b[i] - (a[i]+now) % b[i] != b[i]){
            result += b[i] - (a[i]+now) % b[i];
        now += b[i] - (a[i]+now) % b[i];
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 1916
use std::io;
use std::io::*;
use std::str::FromStr;
use std::fmt;
 
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    /*
    assert_eq!(abc(), "Yes");
    assert_eq!(abc(101), "No");
    assert_eq!(abc(999999999), "Yes");
    */
    let n: i32 = read();
    let mut A_min: i32 = (0..n).map(|_| read::<u32>().trailing_zeros()).min().unwrap() as i32;
    
    println!("{}", A_min);
}

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

const double eps = 1e-10;

int dcmp(double x) {
        if(fabs(x) < eps) return 0;
        return x < 0 ? -1 : 1;
}

bool same(double a, double b) {return dcmp(a - b) == 0;}
#define Vector P
struct P {
        double x, y;
        P(double x = 0, double y = 0): x(x), y(y) {}
        P operator + (P b) {return P(x + b.x, y + b.y);}
        P operator - (P b) {return P(x - b.x, y - b.y);}
        P operator * (double b) {return P(x * b, y * b);}
        P operator / (double b) {return P(x / b, y / b);}
        double operator * (P b) {return x * b.x + y * b.y;} // Dot
        double operator ^ (P b) {return x * b.y - y * b.x;} // Cross
        double abs() {return hypot(x, y);}
        P unit() {return *this / abs();}
        P spin(double o) {
                double c = cos(o), s = sin(o);
                return P(c * x - s * y, s * x + c * y);
        }
};

struct Line {
        //ax + by + c = 0
        double a, b, c, theta;
        P pa, pb;
        Line(): a(0), b(0), c(0), theta(0), pa(), pb() {}
        Line(P pa, P pb): a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), theta(atan2(-a, b)), pa(pa), pb(pb) {}        P projection(P p) {return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());}                P reflection(P p) {return p + (projection(p) - p) * 2;}
        double get_ratio(P p) {return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs());}
        P dis(P p) {return ((pb - pa) ^ (p - pa)) / (pb - pa).abs();} // directed distance
};

struct Circle {
        P c;
        double r;
        Circle(P c, double r = 0): c(c), r(r) {}
};
bool onsegment(P p, P a, P b) {
        return dcmp((a - p) ^ (b - p)) == 0 && dcmp((a - p) * (b - p)) <= 0;
}
bool segment_intersection(P p1, P p2, P p3, P p4) { // end points are not allowed
        return dcmp((p2 - p1) ^ (p3 - p1)) * dcmp((p2 - p1) ^ (p4 - p1)) < 0
                && dcmp((p4 - p3) ^ (p1 - p3)) * dcmp((p4 - p3) ^ (p2 - p3)) < 0;

}
bool parallel(Line l1, Line l2) {return same(l1.a * l2.b, l1.b * l2.a);}
P line_intersection(Line l1, Line l2) {
        return P(-l1.b * l2.c + l1.c * l2.b, l1.a * l2.c - l1.c * l2.a) / (-l1.a * l2.b + l1.b * l2.a);     }
double Area(vector<P> &p) {
        double res = 0;
        for(int i = 1; i < (int)p.size() - 1; i++)
                res += (p[i] - p[0]) ^ (p[i + 1] - p[0]);
        return res * 0.5;
}
int main() {
        ios_base::sync_with_stdio(false); cin.tie(0);
        int n; cin >> n;
        vector<P> vec;
        for(int i = 0; i < n; i++) {
                P p; cin >> p.x >> p.y;
                vec.push_back(p);
        }
        cout << fixed << setprecision(1) << Area(vec) << '\n';
        return 0;
}


Measured memory_bytes: 3308
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        R: usize, C: usize, K: usize,
        yxv: [(usize, usize, i64); K],
    }

    let mut items = vec![vec![0; C+1]; R+1];
    for (y, x, v) in yxv {
        items[y][x] = v;
    }

    let mut dp = vec![vec![0; 5]; C+1];
    for y in 1..R+1 {
        for x in 1..C+1 {
            let mut from_above = 0;
            for i in 0..=3 {
                from_above = max(from_above, dp[x][i]);
            }
            dp[x][0] = max(dp[x][0], from_above);
            dp[x][1] = max(dp[x][1], from_above + items[y][x]);
            for k in 0..=3 {
                let from_left = dp[x-1][k];
                dp[x][k] = max(dp[x][k], from_left);
                dp[x][k+1] = max(dp[x][k+1], from_left + items[y][x]);
            }
        }
    }
    let mut ans = 0;
    for i in 0..=3 {
        ans = max(ans, dp[C][i]);
    }
    println!("{}", ans);

}


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

void addEdge(vector < vector <long long> > &g, long long x, long long y){
    g[x].push_back(y);
    g[y].push_back(x);
}

void dfs(vector < vector <long long> > &g, long long x, vector <bool> &visited, vector <long long> &c, long long s){
    visited[x] = 1;
    c[x] += s;
    for(auto i : g[x]){
        if(visited[i] == 0){
            dfs(g, i, visited, c, c[x]);
        }
    }
}


int main()
{
    long long n, e, q;
    cin >> n >> q;
    e = n-1;
    vector < vector <long long> > g;
    g.resize(n+1);
    vector <long long> c; c.resize(n+1);
    vector <bool> visited; visited.resize(n+1);
    while(e--){
        long long x, y;
        cin >> x >> y;
        addEdge(g, x, y);
    }
    long long x, y;
    while(q--){
        cin >> x >> y;
        c[x] += y;
    }
    dfs(g, 1, visited, c, 0);

    for(long long i = 1; i <= n; i++)
        cout << c[i] << " ";
    cout << "\n";
}

Measured memory_bytes: 30592
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long w = Long.parseLong(sc.next());
        long h = Long.parseLong(sc.next());
        long x = Long.parseLong(sc.next());
        long y = Long.parseLong(sc.next());
        double ans = (double)(w*h)/2;
        int hukusu = 0;
        if((double)x == (double)w/2.0 && (double)y == (double)h/2.0) {
            hukusu = 1;
        }
        System.out.println(ans+" "+hukusu);
    }
}

Measured memory_bytes: 21844
if __name__ == '__main__':

    s = list(input())
    s.reverse()
    n = len(s)
    now = 0
    mods = [0] * 2019
    mods[0] += 1
    for i in range(n):
        now += pow(10, i, 2019) * int(s[i])
        now %= 2019
        mods[now] += 1
    ans = 0
    for i in mods:
        ans += (i * (i - 1)) // 2
    print(ans)


Measured memory_bytes: 10528
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll k, a, b;
	cin >> k >> a >> b;
	ll sum = 0;
	sum += a + (k-a+1)/2 * (b-a) + (k-a+1)%2;
	sum = max(sum, k+1);
	cout << sum << endl;
	return 0;
}

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


Measured memory_bytes: 3100
#coding:utf-8
from Queue import PriorityQueue
H,W=map(int,raw_input().split())
c=[]
for i in range(10):
    c.append(map(int,raw_input().split()))

A=[]
for i in range(H):
    A.append(map(int,raw_input().split()))
cost=[-1]*10
cost[1]=0
pq=PriorityQueue()
for i in range(0,10): 
    if i!=1:pq.put((c[i][1],i))
while not pq.empty():
    co,po=pq.get()
    if cost[po]!=-1:continue
    cost[po]=co
    for i in range(0,10):
        if cost[i]==-1:
            pq.put((c[i][po]+co, i))

ans=0
for L in A:
    for l in L:
        if l!=-1:ans+=cost[l]
print(ans)
    

Measured memory_bytes: 33512
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,p = I()
A = [2 if i%2==0 else 1 for i in I()]
a = set(A)



if p == 0:
    if len(a)==1 and 2 in a:
        print(2**n)
    else:
        print(2**(n-1))
else:
    if len(a)==1 and 2 in a:
        print(0)
    else:
        print(2**(n-1))

Measured memory_bytes: 10492
#include <iostream>

using namespace std;

int main()
{
    char b;
    cin >> b;
    switch (b){
        case 'A':
            cout << 'T';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
        case 'T':
            cout << 'A';
            break;
    }
    return 0;
}


Measured memory_bytes: 3564
#include<stdio.h>
#define SENTINEL 1000000001
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int count=0;

int main(){
  int n;
  int left;
  int right;
  int mid;
  int i;
  int S[500000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  left = 0;
  mid = i/2;
  right = i;

  mergeSort(S,left,right);

  for(i=0;i<n;i++){
    if(i != n-1) printf("%d ",S[i]);
    else printf("%d\n",S[i]);
  }
  printf("%d\n",count);
  return 0;
}

void merge(int *S,int left,int mid,int right){
  int n1;
  int n2;
  int i;
  int j;
  int k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1];
  int R[n2];
  
    for(i=0;i<n1;i++){
    L[i] = S[left + i];
  }
  for(i=0;i<n2;i++){
    R[i] = S[mid + i];
    }

  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  i = 0;j = 0;
 
    for(k=left;k<right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i += 1;
    }
    else{
      S[k] = R[j];
      j += 1;
    }
    count++;
  }
}

void mergeSort(int *S,int left,int right){
  int mid;

  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}


Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back	
#define mp make_pair
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(x) cout << x << endl
const int INF = 1e9;
const LL INF64 = 1e18;

const int NMAX = 1e5 + 5;

int main(){
	LL a, b;
	cin >> a >> b;
	LL ans = a;
	if(b < a) ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define lim 100000ll
#define siz 1000005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX lim
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

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

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll a[n+1], b[n+1];
    rep(i, n+1){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    b[n] = 0;
    ll c = 0, prev = 0;
    rep(i, n+1){
        if(b[i] + prev < a[i]){
            c += (b[i] + prev);
            prev = 0;
        }
        else{
            c += a[i];
            if(a[i] <= prev){
                prev = b[i];
            }
            else{
                ll left = a[i] - prev;
                b[i] -= left;
                prev = b[i];
            }
        }
    }
    cout << c << endl;
    return 0;
} 

Measured memory_bytes: 1792
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
    int l,m,i,c=0;
    string s;
   cin>>l;
    cin>>s;
      m=l/2;
    if(l%2!=0){
        cout<<"No";
        return 0;
    }
        else{
            for(i=0;i<m;i++){
                if(s[i]==s[i+m]){
                c++;
                }
            }
            if(c==m)
                cout<<"Yes";
            else
                cout<<"No";
        }




}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010


int main()
{
  double a,b,x;
  cin>>a>>b>>x;
  
  double theta;
  double mid = (a*a*b)/2;
  
  if (0<=x && x<=mid)
  {
    theta = atan(a*b*b/(2*x));
    theta *= 180/PI;
  }
  else if (mid < x)
  {
    //cout<<"===="<<endl;
    theta = atan((2*(a*a*b-x))/(a*a*a));
    theta *= 180/PI;
  }
  
  cout<<fixed<<setprecision(15)<<theta<<endl;
}

Measured memory_bytes: 512