akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mod = 998244353;

ll powmod(ll a, ll b) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res = int(res * 1ll * a % mod), --b;
        } else {
            a = int(a * 1ll * a % mod), b >>= 1;
        }
    }
    return res;
}

ll reverse(ll a) {
    return powmod(a, mod - 2);
}

int main() {
    int n;
    cin >> n;
    vector<ll> two(n + 1);
    vector<ll> three(n + 1);
    vector<ll> fact(n + 1);
    vector<ll> finv(n + 1);
    two[0] = three[0] = fact[0] = 1;
    for (int i = 1; i <= n; ++i) {
        three[i] = (3ll * three[i - 1]) % mod;
        two[i] = (2ll * two[i - 1]) % mod;
        fact[i] = (1ll * i * fact[i - 1]) % mod;
    }
    finv[n] = reverse(fact[n]);
    for (int i = n - 1; i >= 0; --i) {
        finv[i] = ((i + 1) * finv[i + 1]) % mod;
    }
    auto C = [fact, finv](int n, int k) {
      return (((fact[n] * finv[k]) % mod) * finv[n - k]) % mod;
    };
    ll ans = three[n];
    for (int i = n / 2 + 1; i <= n; ++i) {
        ans = (mod + ans - 2 * C(n, i) * two[n - i]) % mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 468992
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		String s = next();
		String t = next();
		System.out.println(t + s);
	}
	
	private static long pow(final long a) {
        long result = 1;
        for (long i = 0; i < a; i++) {
        	result *= 2;
        	result %= mod;
        } 
        return result;
    }
	static int mod = 1000000007;


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()

i = 0
sevens = 0
while True:
    sevens += 7 * pow(10, i, K)
    sevens %= K
    i += 1
    if sevens == 0:
        break
print(i)


Measured memory_bytes: 63472
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int main(void){
    int i,j;
    int N,K,Q;
    scanf("%d",&N);
    scanf("%d",&K);
    scanf("%d",&Q);

    int A[Q];
    int Score[N];
    int crr[N];
    REP(i,Q){
        scanf("%d",&A[i]);
    }
    REP(i,N){
        Score[i]=K;
        crr[i]=0;
    }
    
    REP(i,Q){
        crr[A[i]-1]=crr[A[i]-1]+1;
    }

    REP(i,N){
        if(Score[i]-Q+crr[i]>0) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const int INF=0x3f3f3f3f;
const int N=1e6+7;
const int mod=1e9+7;
int maxn,minn;
int T,n,m,q;

int main(){
	int a,b;
	cin >> n;
	int flag = 0;
	maxn= 0;
	for(int i = 1; i <= n; i ++ ){
		cin >> a >> b;
		if(a == b){
			flag ++ ;
			maxn = max(flag,maxn);
		}
		else{
			flag = 0;
		}
	}
	if(maxn >= 3){
		puts("Yes");
	}
	else{
		puts("No");
	}



	return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,x,y,z;
  cin>>A>>B;
  if(A%2==0){
    x= A*25/2;
    y= (A+1)*25/2;
  }
  else{
    x= A*25/2+1;
    y= (A+1)*25/2-1;
  }
  z=10*B;
  if(x<=z&&z<=y){
    cout<< z <<endl;
  }
  else if(z<=x&&x<=z+9){
    cout<< x <<endl;
  }
  else{
    cout<< -1 <<endl;
  }
}
  

  

  

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[4][100010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=3;i++)
	{
		for(int j=0;j<n;j++)
			scanf("%d",&a[i][j]);
	}
    sort(a[1],a[1]+n);
	sort(a[2],a[2]+n);
	sort(a[3],a[3]+n);                                                
	long long sum=0;
	long long x=0,y=0;
	for(int i=0;i<n;i++)
	{
		x=lower_bound(a[1],a[1]+n,a[2][i])-a[1];
		y=upper_bound(a[3],a[3]+n,a[2][i])-a[3];
		if(y<n&&a[3][y]==a[2][i])
		y++;
		
		sum+=(x*(n-y)); 
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main()
{
    int x,a;
    a = 1;
    while(1){;
        scanf("%d",&x);
        if(x==0){break;
        }else{
        printf("Case %d: %d\n",a,x);
        a++;
        }
    }
    return 0; 
}

Measured memory_bytes: 600
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

if A[0][0] in B and A[0][1] in B and A[0][2] in B:
  print('Yes')
elif A[1][0] in B and A[1][1] in B and A[1][2] in B:
  print('Yes')
elif A[2][0] in B and A[2][1] in B and A[2][2] in B:
  print('Yes')
elif A[0][0] in B and A[1][0] in B and A[2][0] in B:
  print('Yes')
elif A[0][1] in B and A[1][1] in B and A[2][1] in B:
  print('Yes')
elif A[0][2] in B and A[1][2] in B and A[2][2] in B:
  print('Yes')
elif A[0][0] in B and A[1][1] in B and A[2][2] in B:
  print('Yes')
elif A[2][0] in B and A[1][1] in B and A[0][2] in B:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
template<class T>void gi(T &x){
	int f;char c;
	for(f=1,c=getchar();c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(x=0;c<='9'&&c>='0';c=getchar())x=x*10+(c&15);x*=f;
}
const int N=205;
int n,a[N];
int main(){
  cin>>n;
  int t=40000,ans=0;
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=1;i<=n;i++){
	  if(a[i]==a[i+1])a[i+1]=t--,ans++;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
from itertools import combinations as comb

n=int(input())
lst=list(map(int,input().split()))

numlst=[]
for i in range(1,n+1):
    for x in comb(lst,i):
        y=sum(x)
        if not y in numlst:
            numlst.append(y)

q=int(input())
lst2=list(map(int,input().split()))
for x in lst2:
    if x in numlst : print("yes")
    else : print("no")


Measured memory_bytes: 5704
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x3=x2-(y2-y1);
    int y3=y2+(x2-x1);
    int x4=x1+x3-x2;
    int y4=y1+y3-y2;

    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    
    ll n;cin>>n;
    vvll path(n);
    REP(i,n-1) {
        ll aa, bb;cin>>aa>>bb;
        aa--; bb--;
        path[aa].push_back(bb);
        path[bb].push_back(aa);
    }

    vll vis(n,0);
    vis[0]=1; vis[n-1]=1;
    queue<ll> que1, que2;
    que1.push(0); que2.push(n-1);
    ll c1=0, c2=0;


    while(que1.size() || que2.size()){      
        ll siz1=que1.size();
        REP(i,siz1){
            ll p = que1.front();
            que1.pop();
            vis[p]=1;
            c1++;
            for(auto pp: path[p]){
                if (vis[pp]==0) {que1.push(pp); vis[pp]=1;}
            }
        }

        ll siz2=que2.size();
        REP(i,siz2){
            ll p = que2.front();
            que2.pop();
            vis[p]=2;
            c2++;
            for(auto pp: path[p]){
                if (vis[pp]==0) {que2.push(pp); vis[pp]=2;}
            }
        }

    }
    if(c2>=c1) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
    return 0;
}


Measured memory_bytes: 9968
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int n;
    cin>>n;
    int tmp = n;
    int wa=0;
    while(tmp){
        wa += tmp%10;
        tmp = tmp/10;
    }
    if(n%wa==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >>B;
  if((A >= 2 && A <= 13) && (B >= 2 && B <= 13)) {
    if (A > B) {
      cout << "Alice" << endl;
    }
    else if (A < B) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" << endl;
    }
  }
  else {
    if (A == 1 && B != 1) {
      cout << "Alice" << endl;
    }
    else if (B == 1 && A != 1) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int ai[200005];
int bi[200005];
int main()
{
    int a;
    scanf("%d",&a);
    long long sum = 0;
    for(int i=0;i<a;i++)
    {
        scanf("%d",&ai[i]);
        while(ai[i]%2==0)
        {
            ai[i]/=2;
            sum++;
        }
    }
    printf("%d\n",sum);

    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  map<string,int> NS;
  REP(i,N) {
    string n;cin>>n;
    NS[n]++;
  }
  int M;cin>>M;
  map<string,int> MS;
  REP(i,M) {
    string m;cin>>m;
    MS[m]++;
  }

  int ans = 0;
  for (auto item:NS) {
    ans = max(ans, item.second-MS[item.first]);
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N, A;
int main() {
	cin >> N >> A;
	cout << N * N - A << endl;
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n,ans=0;
    cin>>n;

    rep(i,n){
        int a;cin>>a;
        ans+=a-1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000;

int aa[N + 1], ii[N + 1];

int main() {
	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a, a--;
		aa[i] = (aa[i - 1] + a) % k;
		ii[i] = i;
	}
	n++;
	sort(ii, ii + n, [] (int i, int j) { return aa[i] < aa[j] || aa[i] == aa[j] && i < j; });
	long long ans = 0;
	for (int i = 0, j = 0; i < n; i++) {
		while (j < n && aa[ii[j]] == aa[ii[i]] && ii[j] - ii[i] < k)
			j++;
		ans += j - i - 1;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++) cin>>A[i];

  ll pre=A[0]-1;
  for(int i=1;i<N;i++){
    if(pre==A[i]) continue;
    else if(pre>A[i]){
      cout<<"No"<<endl;
      return 0;
    }else pre=A[i]-1;
  }

  cout<<"Yes"<<endl;

  return 0;
}


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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  ll K = il();

  ll tmp = 0;
  REP(i, 1, 10000000){
    tmp *= 10;
    tmp += 7;
    tmp %= K;
    if (tmp == 0){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;



}

Measured memory_bytes: 3660
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
const long long INF = 1LL << 60;

using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int a[N][M];
  vector<int> c(N);

  rep(i, N){
    cin >> c[i];
    rep(j, M){
      cin >> a[i][j];
    }
  }

  // 購入できる場合
  ll answer = INF, tmp;
  bool flag = true;
  // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<N); ++bit)
    {
        // bit の表す集合を求める
        vector<int> S;
        vector<ll> ans(M);
        flag = true;
        tmp = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        // bit の表す集合の出力
        for (int i = 0; i < (int)S.size(); ++i) {
          rep(j, M){
            ans[j] += a[S[i]][j];
          }
          tmp += c[S[i]];
        }
        
        rep(j, M){
          if(ans[j] < X){
            flag = false;
            break;
          }
        }
        if(flag){
          answer = min(answer, tmp);
        }
    }

    if(answer == INF) {
      print(-1);
      return 0;
    }
  

  print(answer);

}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in1 = sc.nextLine();
		int n = Integer.parseInt(in1);
		String in2 = sc.nextLine();
		int k = Integer.parseInt(in2);
		String in3 = sc.nextLine();
		int x = Integer.parseInt(in3);
		String in4 = sc.nextLine();
		int y = Integer.parseInt(in4);
		int shukuhaku = 0;
		int wk = 0;
		if (  n >= k) {
			for (int i = 0; i < k; i++) {
				shukuhaku += x;	
				wk = i;
			} 

			for (int j = wk+1; j < n; j++) {
				shukuhaku += y;
			
			}
		} else {
			for (int i = 0; i < n; i++) {
				shukuhaku += x;	
				wk = i;
			} 
			
		}
		
		System.out.println(shukuhaku);
		
	}
}

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

int main(){
    constexpr long MOD = 1000000007;
    long N;
    cin >> N;
    long dp{N};
    vector<long> sum(4, (N - 1) * N % MOD);
    sum[0] = 0;
    for(long i = 3; i != N + 3; ++i)sum[i & 3] = (sum[(i ^ (i << 1) ^ 3) & 3] - 1 + (dp += sum[(i ^ (i << 1) ^ 1) & 3])) % MOD;
    cout << dp % MOD << endl;
    return 0;
}

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

using namespace std;

#define int long long
constexpr int MOD = 1'000'000'007;

signed main(){
	int N, T;
	int ans = 1;
	vector<int> D;
	
	cin>>N>>T;
	
	D.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>D[i];
	}
	
	sort(D.begin(), D.end());
	
	for(int i = 0, j = 0; i < N; i++){
		for(; j < i; j++){
			if(D[i] - D[j] <= T) {
				break;
			}
		}
		ans *= (MOD + i + 1 - j) % MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();
        int[] a = in.ii(N);

        int l = 1;
        for(int i = 0; i < N; i++) {
            a[i] >>= 1;
            int t = l / gcd(l, a[i]);
            if (M / a[i] < t) {
                l = 0;
                break;
            }
            l = t * a[i];
        }
        for (int i = 0; i < N; i++) {
            if (l / a[i] % 2 == 0) {
                l = 0;
                break;
            }
        }

        int ans = l == 0 ? 0 : (M - l) / l / 2 + 1;
        out.println(ans);
    }

    static int gcd(int a, int b) {
        int r;
        while ((r = a % b) != 0) {
            a = b;
            b = r;
        }
        return b;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 35968
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

char S[MAX_N];

int main()
{
    unordered_set<int> P[3];
    int N;
    read(N, S);
    REP(i, N) {
        int k = int(S[i] - '0');
        REP(ii, P[1]) {
            P[2].insert(*ii * 10 + k);
        }
        REP(ii, P[0]) {
            P[1].insert(*ii * 10 + k);
        }
        P[0].insert(k);
    }
    print(SZ(P[2]));
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
constexpr ll INF = 1ll << 61;
vector<vector<ll>> dp;
vector<int> a, b;
int n;

ll dfs(ll s, ll l, int c) {
  // s:状態。立っているビットは未使用であることを示す
  // l:最後のカードの値
  // c:使ったカードの枚数(dpに影響なし)
  if (s == 0) {
    dp[s][l] = 0;
  }
  if (dp[s][l] != -1) {
    return dp[s][l];
  }
  dp[s][l] = INF;
  for (int i = 0; i < n; i++) {
    // 次のカード
    if ((s >> i) & 1) {
      // 未使用
      int next = ((i + c) % 2 == 0) ? a[i] : b[i];
      if (next < l)
        continue;
      int d = 0;
      for (int j = 0; j < i; j++) {
        // nextのカードよりも前にあって、まだ使っていないカードの枚数を数える
        // つまりnextを前に持っていくのに必要なコスト
        if (s >> j & 1) {
          d++;
        }
      }
      dp[s][l] = min(dp[s][l], d + dfs(s & ~(1 << i), next, c + 1));
    }
  }
  return dp[s][l];
}

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  dp.assign(1 << n, vector<ll>(51, -1));
  ll ans = INF;
  for (int i = 1; i < 51; i++) {
    // 仮想的に最初に何かしらの値があると考える
    ans = min(ans, dfs((1 << n) - 1, i, 0));
  }
  // ans = min(ans, dfs((1 << n) - 1, 1, 0));
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 113024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define S_MAX   100

int compare(const char *t, const char *h)
{
    int i;

    for(i=0;i<S_MAX;i++) {
        if(t[i] == '\0' && h[i] == '\0') break;

        if(t[i] > h[i]) return 1;
        else if(t[i] < h[i]) return -1;
    }

    return 0;
}

int main(void)
{
    int i;
    int n;
    int t_p = 0, h_p = 0;
    char str[S_MAX*2+5];
    char *t, *h;
    char tmp[] = " \n";

    scanf("%d%*c", &n);

    for(i=0;i<n;i++) {
        int r;
        fgets(str, S_MAX*2+5, stdin);
        t = strtok(str, tmp);
        h = strtok(NULL, tmp);

        r = compare(t, h);

        if(r == 1)          t_p += 3;
        else if(r == -1)    h_p += 3;
        else {              t_p++;  h_p++;  }
    }

    printf("%d %d\n", t_p, h_p);

    return 0;
}

Measured memory_bytes: 604
use std::io;

pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
    fn read_to_string(&mut self) -> io::Result<String>;
}

impl ExRead for io::StdinLock<'_> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }

    fn read_to_string(&mut self) -> io::Result<String> {
        self.read_line().map(|s| s.trim().to_string())
    }
}

pub trait SplitAndParse<T: std::str::FromStr> {
    type Result;
    fn split_and_parse(&self) -> Self::Result;
}

impl<T: std::str::FromStr> SplitAndParse<T> for String {
    type Result = Result<Vec<T>, <T as std::str::FromStr>::Err>;
    fn split_and_parse(&self) -> Self::Result {
        self.split_whitespace()
            .map(|e| e.parse())
            .fold(Ok(Vec::new()),
                |acc, e| acc.and_then(|mut v| e.map(|parsed| {v.push(parsed); v})))
    }
}

fn main() {
    const MOD: usize = 1_000_000_000 + 7;
    let (n, k): (usize, usize);

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        let mut input = lkin.read_line().unwrap().split_and_parse().unwrap().into_iter();
        n = input.next().unwrap();
        k = input.next().unwrap();
    }

    println!("{}", (k..=n+1).fold(0, |ans, c| (ans + (c * (2*n-c+1) / 2 - c * (c-1) / 2 + 1)) % MOD));
}


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

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

  while(m--){
    long first,year,charge,tmp,t,max=-1;
    int n,r;
    long double per;

    cin>>first>>year>>n;

    while(n--){
      cin>>r>>per>>charge;
      tmp=first;
      t=0;
      for(int i=0;i<year;i++){
	if(r){
	  tmp+=(long)(tmp*per);
	  tmp-=charge;
	}else{
	  t+=tmp*per;
	  tmp-=charge;
	}
      }

      if(!r) tmp+=t;

      if(max==-1||max<tmp)max=tmp;
    }

    cout<<max<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    map<string,int> mp;
    ll n,ans=0;
    cin >> n;
    vs ss(n);
    rep(i,n){
        cin >> s;
        sort(all(s));
        ss[i]=s;
    }
    sort(all(ss));
    rep(i,n){
        ans+=mp[ss[i]];
        mp[ss[i]]++;
    }
    cout << ans << endl;
    return 0;
}

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

unsigned int xor128(){
	static unsigned int x=123456789,y=362436069,z=521288629,w=88675123; 
	unsigned int t=(x^(x<<11));
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}

template<class Key,class Val>
class Treap{
	struct Node{
		unsigned int priority;
		Key key;
		Val value;
		Node *left,*right;
		Node(const Key& k,const Val& v)
			:priority(xor128()),key(k),value(v),left(0),right(0){}
		
		Node *rotate_right(){
			Node *s=left;
			left=s->right;
			s->right=this;
			return s;
		}
		Node *rotate_left(){
			Node *s=right;
			right=s->left;
			s->left=this;
			return s;
		}
		~Node(){
			if(this){
				if(left)delete left;
				if(right)delete right;
			}
		}
		Node *insert(const Key& k,const Val& v){
			return insert(new Node(k,v));
		}
		Node *insert(Node *t){
			if(this==NULL)return t;
			if(t==NULL)return this;
			Node *s=this;
			if(t->key < key){
				left = left->insert(t);
				if(priority < left->priority)s=rotate_right();
			}else{
				right = right->insert(t);
				if(priority < right->priority)s=rotate_left();
			}
			return s;
		}
		Node *find(const Key& k){
			return this==NULL?NULL:k==key?
				this:k<key?left->find(k):right->find(k);
		}
		Node *erase(const Key& k){
			if(this==NULL)return NULL;
			if(k==key){
				if(left && (!right || left->priority > right->priority)){
					Node *s=rotate_right();
					right=right->erase(k);
					return s;
				}else if(right && (!left || left->priority < right->priority)){
					Node *s=rotate_left();
					left=left->erase(k);
					return s;
				}
				delete this;
				return NULL;
			}
			else if(k<key)left = left->erase(k);
			else right = right->erase(k);
			return this;
		}
		int getHeight(){
			if(this==NULL)return 0;
			return 1+max(left->getHeight(),right->getHeight());
		}
	} *root;
public:
	Treap():root(0){}
	~Treap(){if(root)delete root;}
	void insert(const Key& k,const Val& v){
		root=root->insert(k,v);
	}
	void insert(Treap<Key,Val> t){
		root=root->insert(t->root);
	}
	Val* find(const Key& k){
		Node *p=root->find(k);
		if(p)return &p->value;
		return NULL;
	}
	void erase(const Key& k){
		root=root->erase(k);
	}
};


struct A{};

int main(){
	int q;
	cin>>q;
	while(q--){
		int n;
		//set<int> s;
		Treap<int,A> s;
		cin>>n;
		int ans=0;
		while(10<=n){
			if(s.find(n)){
				ans=-1;
				break;
			}
			s.insert(n,A());
			int next=0;
			int b=10;
			while(b<=n){
				int t=(n%b)*(n/b);
				next=max(next,t);
				b*=10;
			}
			n=next;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    map<string,ll> mp;
    rep(i,N){
        string S;
        cin >> S;
        mp[S]++;
    }
    string tmp[] = {"AC","WA","TLE","RE"};
    for(auto &s: tmp){
        cout << s << " x " << mp[s] << endl;
    }
}


Measured memory_bytes: 3684
N = input()

if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9":
    print("hon")
elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 61608
local function f(n)
    if n % 2 == 0 then
        return n / 2
    else
        return 3 * n + 1
    end
end
local prev = io.read("n")
local appeared = {}
appeared[prev] = true
for m=2,1000000 do
    local a = f(prev)
    if appeared[a] then
        print(m)
        return
    else
        appeared[a] = true
        prev = a
    end
end

Measured memory_bytes: 760
N,D = list(map(int,input().split()))
XY = []
for i in range(N):
    XY.append(list(map(int,input().split())))
count = 0
distance_square = D * D
for i in range(N):
    distance_xy = XY[i][0] * XY[i][0] + XY[i][1] * XY[i][1]
    if distance_xy <= distance_square:
        count += 1
print(count)

Measured memory_bytes: 45372
#include <cstdio>
#include <cstring>
using namespace std;

int W,H,f[20][20];
int rotx[]={1,0};
int roty[]={0,1};

int cdx[4][4]={
	{-1,-1,0,0},
	{0,0,1,1},
	{-1,-1,0,0},
	{0,0,1,1}
};

int cdy[4][4]={
	{-1,0,-1,0},
	{0,-1,-1,0},
	{0,1,0,1},
	{0,1,0,1}
};

bool check(int x, int y)
{
	for(int j=0; j<4; j++)
	{
		int cnt=0;
		bool ck[400]={0};
		for(int i=0; i<4; i++)
		{
			int tx=x+cdx[j][i], ty=y+cdy[j][i];
			if(tx<0||ty<0||tx>=W||ty>=H) continue;
			if(f[tx][ty]==0) continue;
			if(!ck[f[tx][ty]]) cnt++;
			ck[f[tx][ty]]=1;
		}
		
		if(cnt>3) return false;
	}
	
	return true;
}

int dfs(int x, int y, int ccnt)
{
	if((ccnt-1)*2==W*H) return 1;
	int ret=0;
	bool g=false;
	for(int i=y; i<H; i++)
	{
		for(int j=(i==y?x:0); j<W; j++)
		{
			if(f[j][i]) continue;
			
			g=true;
			for(int k=0; k<2; k++)
			{
				int tx=j+rotx[k], ty=i+roty[k];
				if(tx<0||ty<0||tx>=W||ty>=H) continue;
				if(f[tx][ty]) continue;

				f[j][i]=ccnt;
				f[tx][ty]=ccnt;
				if(check(j,i)) ret+=dfs(j,i,ccnt+1);
				f[j][i]=0;
				f[tx][ty]=0;
				
			}
			
			if(g) break;
		}
		if(g) break;
	}
	
	return ret;
}

int main()
{
	while(scanf("%d%d", &H,&W), (H||W))
	{
		memset(f,0,sizeof(f));
		printf("%d\n", dfs(0,0,1));
	}
}

Measured memory_bytes: 764
inpl = lambda: list(map(int,input().split()))
MOD = 2019
L, R = inpl()
if R-L >= MOD-1:
    print(0)
else:
    Lm = L % MOD
    Rm = R % MOD
    if Lm == 0 or Rm < Lm:
        print(0)
    else:
        ans = MOD - 1
        for i in range(Lm, Rm+1):
            for j in range(i+1, Rm+1):
                m = i*j % MOD
                if m < ans:
                    ans = m
        print(ans)

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

typedef long long ll;

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)s; i < (int)(e); ++i)

#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

typedef double D;
typedef complex<D> P;
namespace std{
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}

struct L : public vector<P> {
  L(const P&a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; D r;
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1; //ccw
  if(cross(b, c) < 0) return -1; //cw
  if(dot(b, c) < 0)   return +2; //c-a-b on line
  if(norm(b) < norm(c)) return -2; //a-b-c on line
  return 0;
}

P projection(const L& l, const P& p) {
  D t = dot(p - l[0], l[0] - l[1]) / norm(l[0]- l[1]);
  return l[0] + t * (l[0] - l[1]);
}
P refrection(const L& l, const P& p) {
  return p + 2.0 * (projection(l, p) - p);
}
int main() {
  int n;
  cin >> n;
  while(n--) {
    vector<P> ps(4);
    rep(i, 4) {
      D x, y;
      cin >> x >> y;
      ps[i] = {x, y};
    }
    int ans;
    if(abs(cross(ps[1]-ps[0], ps[3]-ps[2])) < EPS) ans = 2;
    else if(abs(dot(ps[1]-ps[0], ps[3]-ps[2])) < EPS) ans = 1;
    else ans = 0;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;

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

		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = a*b;
		int d = 2*(a+b);
		System.out.println( c + " " + d );

	}
}

Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int Ans=0;
  long long X;
  cin>>X;
  long long Tmp=100;
  while(Tmp<X)
  {
    Ans++;
    Tmp=Tmp+Tmp/100;
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
d,n=map(int,input().split())
if d==0:
	if n<100:
		print(n)

	else:
		print(101)    

elif d==1:
	if n<100:
		print(n*100)
        
	else:
		print(10100)

elif d==2:
	if n<100:
		print(n*10000)
        
	else:
		print(n*10000+10000)
        

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

using namespace std;
typedef long long int ll;

vector<vector<int>>G;
vector<int>v;
vector<int>p;
vector<bool>f;

void dfs(int i,int sum)
{
    f[i] = true;
    sum += v[i];
    p[i] += sum;
    for(auto x: G[i])
    {
        if(f[x]) continue;
        dfs(x,sum);
    }
}

int main()
{
    int n,q;
    cin >> n >> q;
    G.resize(n);
    v.assign(n,0);
    for(int i = 0; i < n-1; i++)
    {
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i = 0; i < q; i++) 
    {
        int a,b;
        cin >> a >> b;
        a--;
        v[a] += b;
    }
    p.assign(n,0);
    f.assign(n,false);
    dfs(0,p[0]);
    for(int i = 0; i < n; i++) cout << p[i] << " ";
}

Measured memory_bytes: 25168
h, n = map(int, input().split())
a, b= [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

max_v = 10100
x = float("inf")

dp = [x] * max_v

dp[0] = 0
for i in range(1,max_v):
    for j in range(n):
        dp[i] = min(dp[i], dp[i - a[j]] + b[j])

ans = x
for i in range(max_v):
    if i >= h:
        ans = min(ans, dp[i])

print(ans)

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

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

    vector<vector<int>> grid(3*k, vector<int>(3*k));
    for(int i=0; i<n; i++){
        int x, y;
        char c;
        cin >> x >> y >> c;

        if(c == 'W') y += k;
        x %= 2*k;
        y %= 2*k;

        // RU corner of black squares containing (x,y)
        grid[x][y]     += 1;
        grid[x+k][y]   -= 1;
        grid[x][y+k]   -= 1;
        grid[x+k][y+k] += 1;
    }

    // cumulative sum
    for(int i=0; i<3*k; i++){
        for(int j=0; j<3*k-1; j++){
            grid[i][j+1] += grid[i][j];
        }
    }
    for(int j=0; j<3*k; j++){
        for(int i=0; i<3*k-1; i++){    
            grid[i+1][j] += grid[i][j];
        }
    }

    vector<vector<int>> grid_resize(2*k, vector<int>(2*k));
    for(int i=0; i<3*k; i++){
        for(int j=0; j<3*k; j++){
            grid_resize[i%(2*k)][j%(2*k)] += grid[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<2*k; i++){
        for(int j=0; j<2*k; j++){
            ans = max(ans, grid_resize[i][j] + grid_resize[(i+k)%(2*k)][(j+k)%(2*k)]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51200
# 2020/02/16
# AtCoder Beginner Contest 155 - A

# Input
a, b, c = map(int,input().split())

# Calc
if a == b:
    if a != c:
        ans = "Yes"
    else:
        ans = "No"
else:
    if a == c or b == c:
        ans = "Yes"
    else:
        ans = "No"

# Output
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<array>
using namespace std;

int hand_tr(char c){
  if(c == 'r'){
    return 0;
  }else if(c == 's'){
    return 1;
  }else{
    return 2;
  }
}

int main(){
  int N, K;
  cin >> N >> K;

  int R, S, P;
  cin >> R >> S >> P;
  array<int, 3> scores = {R, S, P};

  string T;
  cin >> T;

  int ans = 0;
  vector<int> hand_his(N);
  for(int i = 0; i < N; i++){
    int now_hand = hand_tr(T[i]);
    if((i - K < 0) || (hand_his[i - K] != (now_hand + 2) % 3)){
      ans += scores[(now_hand + 2) % 3];
      hand_his[i] = (now_hand + 2) % 3;
    }else{
      hand_his[i] = -100;
    } 
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long dp[3030][3030] = { 0 };
int a[3030];
int main() {
	int n;
	int s;
	cin >> n >> s;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= s; j++) {
			if (a[i] + j <= s) {
				dp[i][a[i] + j] = dp[i][a[i] + j] + dp[i - 1][j] % 998244353;
			}
			dp[i][j] = (dp[i][j] + dp[i - 1][j] * 2) % 998244353;
		}
	}
	cout << dp[n][s] << endl;
	return 0;
}


Measured memory_bytes: 74632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

    cout << (M * 1900 + (N-M) * 100) * pow(2, M) << endl;
}

Measured memory_bytes: 4096
#include<iostream>
using namespace std;
long long X,K,D,X_;
int main(){
    cin>>X>>K>>D;
    X=abs(X);
    if((double)X/D>K)cout<<X-(K*D)<<endl;
    else {
        if((X/D)%2==K%2)cout<<X%D<<endl;
        else cout<<D-X%D<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
N,M = map(int, input().split())
l_ans = 1
r_ans = N
for i in range(M):
    L,R = map(int, input().split())
    if L > l_ans:
        l_ans = L
    if R < r_ans:
        r_ans = R
ans = max(r_ans - l_ans + 1,0)
print(ans)


Measured memory_bytes: 3060
Q = 10**9 + 7
def zen(A,k):
    jiku = 0
    for i in range(k):
        jiku += i*A[i] - (k-1-i)*A[i]
    return jiku%Q
n, m = map( int, input().split())
X = list(map( int, input().split()))
Y = list(map( int, input().split()))
ans = zen(X,n)*zen(Y,m)
ans %= Q
print(ans)

Measured memory_bytes: 18576
N,K=map(int,input().split())
a=[list(map(int,input().split()))for i in range(2*K)]
sunuke=[]
for i in range(2*K):
    if i%2==1:
        d=sum(a[i-1])
        for n in range(d):
            sunuke.append(a[i][n])
sunuke=set(sunuke)
print(N-len(sunuke))

Measured memory_bytes: 9204
n = gets.chomp.to_i
ans = 0
amari = false
n.times do
    a = gets.chomp.to_i
    ans += (a + (amari ? 1 : 0)) / 2
    if amari && a > 0 then
        amari = ((a-1) & 1) == 1
    else
        amari = (a & 1) == 1
    end
end
puts ans

Measured memory_bytes: 14360
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: &Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn f(n: i32) -> i32 {
    let mut sum = 0;
    let mut nn = n;
    while nn > 0 {
        sum += nn % 10;
        nn = nn / 10;
    }
    sum
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let A = read::<i32>();
    let B = read::<i32>();

    let mut sum = 0;
    for i in 1..N+1 {
        let l = f(i);
        if A <= l && l <= B {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352