akhauriyash/Code-Regression huggingface dataset:
// ref. https://img.atcoder.jp/dwacon5th-prelims/editorial.pdf

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll n;
string s;

ll solve(ll k) {
  ll d_cnt = 0, m_cnt = 0;
  ll now = 0; // current contribution
  ll ans = 0;
  rep(i, n) {
    // At first, decrease from i-k
    if (i >= k) {
      char target = s[i-k];
      if (target == 'D') {
        --d_cnt;
        now -= m_cnt; // decrease contribution by this D
      } else if (target == 'M') {
        --m_cnt;
      } else {
        // Do nothing
      }
    }

    // Next, add contribution from i
    if (s[i] == 'D') {
      ++d_cnt;
    } else if (s[i] == 'M') {
      ++m_cnt;
      now += d_cnt; // increase contribution by this M
      // cout << "d_cnt:" << d_cnt << endl;
    } else if (s[i] == 'C') {
      // cout << "now:" << now << endl;
      ans += now;
    }
  }
  return ans;
}

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  cin >> n;
  cin >> s;
  ll q;
  cin >> q;
  rep(iter, q) {
    ll k;
    cin >> k;
    ll ans = solve(k);
    cout << ans << endl;
  }
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string S;
	cin >> S;
	if(S[S.size()-1] == 's') S+="es";
	else S+="s";
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  string s;
  cin >> s;
  ll gn=0;
  ll pn=0;
  ll ans=0;
  for(ll i=0;i<s.size();i++) {
    if(s[i]=='p') {
      if(pn<gn) {
        pn++;
      }
      else {
        gn++;
        ans--;
      }
    }
    else {
      if(pn<gn) {
        pn++;
        ans++;
      }
      else {
        gn++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define cs(ans); cout<<setprecision(20)<<fixed<<ans<<endl;
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
const ll mod=1e9+7;
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int X[]={2,1,-1,-2,-2,-1,1,2}; 
int Y[]={1,2,2,1,-1,-2,-2,-1}; 
struct comp{
	bool operator()(const pair<int,int>&a,const pair<int,int>&b) const {
		if(a.first>b.first) return true;
		if(a.first<b.first) return false; 
		if(a.second<b.second) return true;
		return false;
	}
};	
void solve(){
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=(r/d)-(l/d);
	if(l%d==0) ans++;
	cout<<ans<<endl;
	
		
	
	
	
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    set<string>st;
    for(int i=0; i<n; i++)
    {
        cin>>s;
        st.insert(s);
    }
    cout <<st.size()<<endl;
}


Measured memory_bytes: 19196
import sys

for i in sys.stdin:
    n,x = map(int,i.split())
    s = 0
    if n==0 and x==0:
      break
    if x <= 3*n-3 and x >= 6:
      for i in range(1,min(n-1,x//3)):
        s += len(range(max(i+1,x-i-n),min(n,(x-i+1)//2)))
    print(s)

Measured memory_bytes: 7680
INF = 1 << 30
loop {
	n, m = gets.split.map(&:to_i)
	break if n == 0 && m == 0
	a = []
	b = []
	if n != 0
		a += gets.split.map(&:to_i)
	end
	if m != 0
		b += gets.split.map(&:to_i)
	end
	a += [INF]
	b += [INF]
	c = []
	na = nb = 0
	tmp = 0
	loop {
		if a[na] <= b[nb]
			break if a[na] == INF
			c += [a[na] - tmp]
			tmp = a[na]
			na += 1
		else
			c += [b[nb] - tmp]
			tmp = b[nb]
			nb += 1
		end
	}
	p c.max
}

Measured memory_bytes: 115888
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
#include <queue>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;

const int INF = 1001001001;
vector<int> to[100005];
int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, INF); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> pre(N, -1);
    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int u : to[v]) {
            if (dist[u] != INF) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[u] = dist[v] + 1;
            pre[u] = v;
            que.push(u);
        }
    }
    

    cout << "Yes" << endl;
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    for (int v = 0; v < N; ++v) {
        if (v == 0)continue;
        int ans = pre[v];
        ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 10684
#include <stdio.h>

int	main(void)
{
  	int	K;
  	int X;
 	int	num;
  
  	num = scanf("%d %d", &K, &X);
  	if (num != 2)
      	return (0);
  
  	if (500 * K >= X)
      	printf("Yes");
  	else
      	printf("No");
  	return (0);
}

Measured memory_bytes: 128
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Measured memory_bytes: 18784
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int n;
  cin >> n;
  vector <int> a;
  vector <int> b;
  REP(i,n){

    int c;
    cin >> c;
    a.pb(c);
    b.pb(c);
    
  }
  sort(b.begin(),b.end());
  int f,t;
  f = b.size()/2 - 1;
  t = f+1;

  REP(i,n){
    if(a[i] <= b[f]){
      cout << b[t] << endl;
    }
    else if(a[i] >= b[t]){
      cout << b[f] << endl;
    }
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    deque<int> deq;
    bool f = true;
    for(int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        if(f)
        {
            deq.push_back(a);
            f = 0;
        }
        else
        {
            deq.push_front(a);
            f = 1;
        }
    }
    if(f)
    {
        for(int i = 0; i < n; i++)
            cout << deq[i] << ' ';
    }
    else
    {
        for(int i = n - 1; i >= 0; i--)
            cout << deq[i] << ' ';
    }
    return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
struct node
{
    int sum;
    int x;
    char ch[107];
}a[107];
bool cmp(node s1,node s2)
{
    if(strcmp(s1.ch,s2.ch)<0)
        return 1;
    else if(strcmp(s1.ch,s2.ch)==0&&s1.x>s2.x)
        return 1;
    else
        return 0;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s%d",a[i].ch,&a[i].x);
        a[i].sum=i;
    }
    sort(a+1,a+1+n,cmp);
    for(int i=1;i<=n;i++)
        printf("%d\n",a[i].sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
    int x=max(A,C);
    int y=min(B,D);
    if(y-x>0){
    	cout<<y-x<<endl;
	}
  else {
  	cout<<0<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    int dp[n][3];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
          if(j==0)
          dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
          else if(j==1)
          dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
          else
          dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][0]);
        }
    }
int k =max(dp[n-1][0],dp[n-1][1]);
k=max(k,dp[n-1][2]);
cout<<k<<endl;
}


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


int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;

    int tmp;
    tmp=Y;
    Y=X;
    X=Z;
    Z=tmp;

    cout << X  << " " <<  Y   << " " <<  Z  << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		sc.close();
		if (n == 0) {
			System.out.println(0);
			return;
		}

		long bn = Long.MAX_VALUE;
		while (true) {
			bn = n;
			n = m(n, k);
			if (bn >= n) {
				n = Math.min(k - n, n);
				System.out.println(n);
				break;
			}
		}

	}

	public static long m(long n, long k) {
		return n - ((long) (n / k)) * k;
	}
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  string si, s;
  cin >> si;

  s = si;

  string s2 = s;
  reverse(s.begin(), s.end());

  if (s != s2) {
    cout << "No" << endl;
    return 0;
  }

  i32 n = si.length();
  s = si.substr(0, (n - 1) / 2);
  s2 = s;
  reverse(s2.begin(), s2.end());

  if (s != s2) {
    cout << "No" << endl;
    return 0;
  }

  s = si.substr((n + 3) / 2 - 1, n);
  s2 = s;
  reverse(s2.begin(), s2.end());
  if (s != s2) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int n,m=0,kotae=0;
  cin>>n;
  string i[10000];
  int j[10000];
  for (int h=0;h<n;h++){
    cin>>i[h];
    cin>>j[h];
  }
  cin>>i[n];
  while (m<n){
    if(i[m]==i[n]){
      break;
    }
    m++;
  }
  for(int a=m+1;a<n;a++){
    kotae+=j[a];
  }
  cout<<kotae;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;

const int CN = 5e3+3;

int read(){
    int s = 0,ne = 1; char c = getchar();
    while(c < '0' || c > '9') ne = c == '-' ? -1 : 1, c = getchar();
    while(c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - '0', c = getchar();
    return s * ne;
}

int qp(int a,int b,int R) {int r = 1; while(b) {if(b & 1) r = 1ll * r * a % R; a = 1ll * a * a % R; b >>= 1;} return r;}

int n, P;

int C[CN][CN], S[CN][CN];

int main()
{
    // freopen("_in.in", "r", stdin);
    n = read(), P = read();

    C[0][0] = C[1][0] = C[1][1] = 1;
    for(int i = 2;i <= n + 10;i++){
        C[i][0] = 1;
        for(int j = 1;j <= i;j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % P;
    }
    S[0][0] = S[1][1] = 1;
    for(int i = 2;i <= n + 10;i++) 
        for(int j = 1;j <= i;j++) 
            S[i][j] = (1ll * j * S[i - 1][j] % P + S[i - 1][j - 1]) % P;

    int ans = 0;
    for(int i = 0;i <= n;i++){
        int prd = 1ll * C[n][i] * qp(2, qp(2, n - i, P - 1), P) % P, si = 0;
        for(int k = 0;k <= i;k++) si = (si + 1ll * S[i + 1][k + 1] * qp(qp(2, n - i, P), k, P) % P) % P;
        prd = 1ll * prd * si % P;
        prd = i & 1 ? P - prd : prd, ans = (ans + prd) % P;
    }

    printf("%d", ans);
}

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

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << W * H / 2 << endl;
  if (2 * x == W && 2 * y == H)
    cout << 1;
  else cout << 0;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;
#include<atcoder/all>
using namespace atcoder;


#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

using mint = modint998244353;

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


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

	vll a(M), b(M);
	rep(i, M)cin >> a[i] >> b[i];

	scc_graph g(N);

	rep(i, M)g.add_edge(a[i], b[i]);

	vector<vector<int>> c=g.scc();

	ll K= c.size();
	cout << K << endl;
	rep(i, K) {
		ll s=  c[i].size();
		cout << s;
		rep(j, s)cout << " " << c[i][j];
		cout << endl;
	}

}


Measured memory_bytes: 47936
using namespace std;
#include<bits/stdc++.h>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define st first
#define nd second
#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)
#define FORD(i,a,b) for(int i=(a),b_=(b);i>=b_;--i)
#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())))
 
const int N = 2e5 + 1;
const int MOD = 1e9 + 7; 
const int INF = 1e9 + 10; 

 
int main() {
    #define TASK "TASK"	
	// freopen(TASK".inp","r",stdin);
	// freopen(TASK".out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; 
	cin >> n; 
	vector <int> h(n + 1); 
	vector <int> dp(n + 1, INF);
	for (int i = 1; i <= n; ++i) cin >> h[i]; 
	dp[1] = 0;  
	for (int i = 2; i <= n; ++i) {
		if (i >= 3) {
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i])); 
			dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])); 
		}
		else {
			dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1])); 
		}
	}
	cout << dp[n]; 
     
  	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1e9

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;

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

  for(int i = 1;i <= N;i++){
    count = 0;
    if(i % 2 == 1){
      for(int t = 1;t <= i;t++){
        if(i % t == 0)count++;
      }
      if(count == 8)supercount++;
    }
  }
  cout<<supercount;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-02 21:21:40
*/

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int n;
vector<vector<int>> temp;
vector<vector<int>> comb;

void set_comb(int k) {
    vector<int> x;
    for (int i = 0; i < temp.size(); i++) {
        x = temp[i];
        x.push_back(k);
        if (x.size() == n) {
            comb.push_back(x);
        } else {
            temp.push_back(x);
        }
    }
}

int main()
{
    int m, q;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    temp.push_back({});
    for (int k = 1; k <= m; k++) {
        set_comb(k);
    }

    int ans = 0;
    for (int i = 0; i < comb.size(); i++) {
        int sum = 0;
        for (int j = 0; j < q; j++) {
            int x = comb[i][b[j]-1] - comb[i][a[j]-1];
            if (x == c[j]) {
                sum += d[j];
            }
        }

        if (sum > ans) {
            ans = sum;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 16016
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b {
		fmt.Println("Draw")
	} else if a == 1 {
		fmt.Println("Alice")
	} else if b == 1 {
		fmt.Println("Bob")
	} else if a > b {
		fmt.Println("Alice")
	} else if b > a {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,strf,strm,strl;
    cin>>s;
    
    
    strf=s.substr(0,5);
    strm=s.substr(6,7);
    strl=s.substr(14,5);
    
    cout<<strf<<" "<<strm<<" "<<strl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    if (s.back() == 's') {
        cout << s+ "es" << '\n';
    }
    else {
        cout << s + "s" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();
        if (A1 + A2 + A3 >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}

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

int main() {
	int n;
	cin >> n;
	string cur;
	double y;
	double num=0;
	for(int i=0; i<n; i++) {
		cin >> y;
		cin >> cur;
		if (cur == "JPY"){
			num += y;
		}
		else {
			num += y*380000.0;
		}
	}
	cout << num << endl;
}


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

int main(){
  int n ;
  cin >> n ;
  if(n==1){
    cout << 1 << endl ;
    return 0 ;
  }
  vector<long int> l(n+1) ;
  l.at(0) = 2 ;
  l.at(1) = 1 ;
  for(int i=2; i<n+1; i++)
    l.at(i) = l.at(i-1) + l.at(i-2) ;
  cout << l.at(n) << endl ;
}

Measured memory_bytes: 256
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

A, B, N = list(map(int, sys.stdin.buffer.readline().split()))

if N < 10:
    ans = 0
    for x in range(N + 1):
        y = A * x // B - A * (x // B)
        ans = max(ans, y)
    print(ans)
    exit()
if A == 1 or B == 1:
    print(0)
    exit()

x = min(N, B - 1)
ans = A * x // B
print(ans)

# ans = 0
# for x in range(N + 1):
#     y = A * x // B - A * (x // B)
#     y2 = (A * (x % B) - (A * x % B)) / B
#     # print(x, y, y2)
#
#     z = x % B
#     print(z * A, (z * A) % B, (z * A - (z * A) % B) / B)
# print(ans)


Measured memory_bytes: 61876
import java.util.Scanner;

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

		String ans = "Yes";
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if ((i % 2 == 0 && c == 'L')
					|| (i % 2 != 0 && c == 'R')) {
				ans = "No";
				break;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, W, w[100009], v[100009], sum;

int main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>W;
    for(int i=1;i<=n;i++) {
        cin>>w[i]>>v[i];
        sum += v[i];
    }
    vector<ll> dp(sum + 1, inf);
    dp[0] = 0;
    for(int i=1;i<=n;i++) {
        vector<ll> newdp = dp;
        for(ll j=v[i];j<=sum;j++) {
            newdp[j] = min(newdp[j], dp[j - v[i]] + w[i]);
            //cout<<i<<" "<<j<<" "<<newdp[j]<<endl;
        }
        dp = newdp;
    }
    ll ans;
    for(int i=0;i<=sum;i++)
        if(dp[i] <= W)
            ans = i;
    cout<<ans;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define everyyear 0.01
using namespace std;
long long n;
int main(){
	cin>>n;
	double x=0;
	long long y=100;int i=0;
	while(x+y<n){
		i++;
		long long z=(long long)((x+y)/100.0+x+y);
		//x=(double)((x+y)/100.0+x+y)-z;
		y=z;
		//cout<<x<<" "<<y<<endl;
	}
	cout<<i;
}



Measured memory_bytes: 3636
/*
  AOJ 0152
  Title:bowling
  @kankichi573
*/
#include <stdio.h>
#include <stdlib.h>
int m;
struct seiseki_st
{
  int gakuseki_no;
  int tokuten;
} seiseki[40];

int compare(const void *a, const void *b)
{
  if(((struct seiseki_st *)b)->tokuten > ((struct seiseki_st *)a)->tokuten)
    return(1);
  else if(((struct seiseki_st *)b)->tokuten == ((struct seiseki_st *)a)->tokuten)
    if(((struct seiseki_st *)b)->gakuseki_no < ((struct seiseki_st *)a)->gakuseki_no)
      return(1);
  return(-1);
  
}
void display_result()
{
  int i;
  for(i=0;i<m;i++)
    printf("%d %d\n",seiseki[i].gakuseki_no,seiseki[i].tokuten);
} 
void clear()
{
  int i;

  for(i=0;i<40;i++)
    seiseki[i].gakuseki_no=seiseki[i].tokuten=0;
}
main()
{
  int i,current,next,next2,pin,prev,toume,score,frame,strike_f;

  while(scanf("%d",&m) && m)
    {
      clear();
      for(i=0;i<m;i++)
	{
	  scanf("%d",&seiseki[i].gakuseki_no);
	  current=next=next2=1;
	  frame=1;
	  score=0;
	  toume=1;
	  while(frame<=10)
	    {
	      scanf("%d",&pin);
	      score += current*pin;
#ifdef DEBUG
	      printf("fr=%d %d score=%d\n",frame,toume,score);
#endif
	      if(frame<10)
		{
		  strike_f=0;
		  if(pin==10 && toume==1)
		    {
		      next++;
		      next2++;
		      strike_f=-1;
		      //printf("**");
		    }
		  else if(pin+prev==10 && toume==2)
		    {
		      //printf("*@");
		      next++;
		    }
		  if(toume==2||strike_f)
		    {
		      toume=1;
		      frame++;
		    }
		  else
		    toume=2;

		}
	      else // 10th frame
		{
		  if(toume==3||(toume==2 && pin+prev<10))
		    goto END;
		  toume++;
		}
	      prev=pin;
	      current=next;
	      next=next2;
	      next2=1;
	    }
	END:
	  //printf("score=%d\n",score);
	  seiseki[i].tokuten=score;
	}
      qsort(seiseki,m,sizeof(struct seiseki_st),compare);
      display_result();
    }
  return(0);
}

Measured memory_bytes: 604
#include<algorithm>
#include<iostream>
#include<math.h>

using namespace std;

int main(){
	int n, l;
	cin >> n >> l;
	int sum = 0;
	int i;
	int saisyoj = 0;
	int saisyo = 1000000;
	for (int j = 1; j < n + 1; j++) {
		sum = 0;
		for ( i = 1; i < n + 1; i++) {
			if (i != j) sum += l + i - 1;
		}
		if (saisyo > abs(l + j - 1)) {
			saisyo = abs(abs(l + j - 1));
			saisyoj = sum;
		}
	}
	cout << saisyoj << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
char buf[114514];
string S;
map<string, int> cnt[19];

int main() {
  scanf("%d", &N);
  scanf("%s", buf);
  S = buf;
  int lim = 1 << N;
  rep(st, lim) {
    string ao, aka;
    int popcnt = 0;
    rep(i, N) {
      if (st >> i & 1) {
        popcnt++;
        ao += S[i];
      } else {
        aka += S[i];
      }
    }
    reverse(all(ao));
    cnt[popcnt][aka + ao]++;
  }

  LL ans = 0;
  rep(st, lim) {
    string ao, aka;
    int popcnt = 0;
    rep(i, N) {
      if (st >> i & 1) {
        ao += S[N+i];
        popcnt++;
      } else {
        aka += S[N+i];
      }
    }
    reverse(all(ao));
    ans += cnt[N-popcnt][ao + aka];
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 68224
#include<bits/stdc++.h>
#define endl "\n"
#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cout<<#x<<" : {"<<x<<"}"<<endl;
#endif
using namespace std;
typedef long long int lli;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin>>n>>k;
	vector<int> v;
	int x;
	for(int i=0; i<n; ++i){
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for(int i=0; i<k; ++i)
		sum += v[i];
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
    string s="POSSIBLE\n";
    int n,m,a,b,i;
    cin>>n>>m;
    bool f[n]={};
    for(i=0;i<m;i++){
        cin>>a>>b;
        if(a==1||a==n){
            if(f[b]){cout<<s;return 0;}
            f[b]=true;
        }
        if(b==1||b==n){
            if(f[a]){cout<<s;return 0;}
            f[a]=true;
        }
    }
    cout<<"IM"+s;
    return 0;
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 310, Mod = 1e9 + 7;

int dp[N][N][N];
inline void Add(int &a, int b) {
	if ((a += b) >= Mod) a -= Mod;
}

int n, m;
typedef pair<int, int> PII;
#define fir first
#define sec second
#define mp make_pair
vector<PII> V[N];

int main () {

	File();

	n = read(); m = read();

	For (i, 1, m) { int l = read(), r = read(), x = read(); V[r].push_back(mp(l, x)); }

	dp[0][0][0] = 1;
	int ans = 0;
	For (i, 0, n) For (j, 0, i) For(k, 0, i) {
		if (!dp[i][j][k]) continue ;
		for (PII lim : V[i]) {
			int l = lim.fir, x = lim.sec, times = 1;
			if (l <= j) ++ times;
			if (l <= k) ++ times;
			if (times != x) { dp[i][j][k] = 0; break; }
		}
		if (!dp[i][j][k]) continue ;
		if (i == n) { Add(ans, dp[i][j][k]); }
		Add(dp[i + 1][i][k], dp[i][j][k]);
		Add(dp[i + 1][i][j], dp[i][j][k]);
		Add(dp[i + 1][j][k], dp[i][j][k]);
	}
	printf ("%d\n", ans);

    return 0;
}


Measured memory_bytes: 113024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define MAXN 14
using namespace std;
char str[MAXN+3][20+5];
int dp[MAXN+3][MAXN+3][(1 << MAXN)+3], cps[MAXN+3][MAXN+3], len[MAXN+5];
bool included[MAXN+5];
bool judge(int h, int t, int num) {
	for (int i = 0; i < num; i++) {
		if (str[h][len[h]+i-num] != str[t][i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int n, min_len, nows;
	while (scanf("%d", &n) == 1) {
		if (n == 0) break;
		memset(dp, 0x3f, sizeof(dp));
		//cout << "%%%" << endl;
		memset(cps, 0, sizeof(cps));
		memset(included, false, sizeof(included));
		for (int i = 0; i < n; i++) {
			scanf("%s", str[i]);
			len[i] = strlen(str[i]);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j) continue;
				min_len = min(len[i], len[j]);
				for (int k = min_len; k > 0; k--) {
					if (judge(i, j, k)) {
						cps[i][j] = k;
						break;
					}
				}
				if (strstr(str[i], str[j]) != NULL) {
					included[j] = true;
				}
			}
			dp[i][i][1 << i] = len[i];
		}
		//cout << "&&&" << endl;
		int maxs = (1 << n);
		int finaln = maxs-1;
		for (int s = 0; s < maxs; s++) {
			for (int i = 0; i < n; i++) {
				if (included[i] || (!(1&(s >> i)))) continue;
				for (int j = 0; j < n; j++) {
					if (included[j] || (!(1&(s >> j)))) continue;
					for (int k = 0; k < n; k++) {
						if (included[k] || (1&(s >> k))) continue;
						nows = (1 << k);
						dp[k][i][s|nows] = min(dp[k][i][s|nows], dp[j][i][s]+len[k]-cps[k][j]);
						dp[j][k][s|nows] = min(dp[j][k][s|nows], len[k]-cps[i][k]+dp[k][j][s]);
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			if (included[i]) {
				finaln ^= (1 << i);
			}
		}
		int ans = 0x7fffffff;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans = min(ans, dp[i][j][finaln]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 19712
#include<bits/stdc++.h>
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i, a, b) for(int i=(int)(a); i>=(int)(b); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return 1;}return 0;}

using namespace std;
string s[2222];
int dp[2222][2222];
vector<int> h[2222];
vector<int> w[2222];

int main(void)
{
    int H, W;
    cin >> H >> W;
    REP(i, 0, H){
        cin >> s[i];
    }
    REP(i, 0, H){
        int c=0;
        REP(k, 0, W){
            if(s[i][k]=='#'){
                if(c==0){
                    h[i].push_back(0);
                }else{
                    h[i].push_back(c);
                    h[i].push_back(0);
                }
                c=0;
            }else{
                c++;
            }
        }
        if(c != 0){
            h[i].push_back(c);
        }
    }
    REP(k, 0, W){
        int c=0;
        REP(i, 0, H){
            if(s[i][k]=='#'){
                if(c==0){
                    w[k].push_back(0);
                }else{
                    w[k].push_back(c);
                    w[k].push_back(0);
                }
                c=0;
            }else{
                c++;
            }
        }
        if(c != 0){
            w[k].push_back(c);
        }
    }

    REP(i, 0, H){
        int ind=0;
        for(auto itr=h[i].begin(); itr!=h[i].end(); itr++){
            int k_max;
            if((*itr)==0){
                k_max = 1;
            }else{
                k_max = (*itr);
            }
            for(int k=0; k < k_max; k++){
                dp[i][ind] += (*itr);
                ind++;
            }
        }
    }
    REP(k, 0, W){
        int ind=0;
        for(auto itr=w[k].begin(); itr!=w[k].end(); itr++){
            int i_max;
            if((*itr)==0){
                i_max = 1;
            }else{
                i_max = (*itr);
            }
            for(int i=0; i < i_max; i++){
                dp[ind][k] += (*itr);
                ind++;
            }
        }
    }
    int ans = 0;
    REP(i, 0, H){
        REP(k, 0, W){
            chmax(ans, dp[i][k]);
        }
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 54912
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[100000];
int g[100000]= {0};
int main()
{
    int n,m,i,s=0;
    cin>>n>>m;
    scanf("%s",a);
    int d,b;
    for( i=1; i<n; i++)
    {
        if(a[i]=='C'&&a[i-1]=='A')
            s++;
        g[i+1]=s;
    }
    while(m--)
    {
        cin>>b>>d;
        cout<<g[d]-g[b]<<endl;
    }

return 0;
}


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

int main(){
	int n;
	cin >> n;
	int cnt = 0;
	for(int i=n;i>=1;i--) {
		if(to_string(i).size() % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
 
int main()
{

	int n,flag=0;
    cin >> n;
    int a[n],b[n],ans[n];
    
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n){
        ans[i]=b[n-1-i];  
    }
    int l=0,r=n-1;
    rep(i,n){
        if(a[i]==ans[i]){
            if(a[i]!=ans[l] && a[l]!=ans[i]){
                swap(ans[i],ans[l]);
                l++;
            }
            else if(a[i]!=ans[r] && a[r]!=ans[i]){
                swap(ans[i],ans[r]);
                r--;
            }
            else
                flag=1;
               
            
        }
    }
    if(flag==1) cout << "No" << endl;
    else
    {
    cout << "Yes" << endl;
    rep(i,n) cout << ans[i] << " ";
    cout << "" << endl;
	}
}

Measured memory_bytes: 5940
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) printf(" %d", i);
        else {
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            } while (x);
        }
    }
    printf("\n");
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define MP make_pair
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define fst first
#define snd second

int get_dir(int x1, int y1, int x2, int y2) {
  if (x1 == x2) {
    return y2 > y1 ? 0 : 2;
  } else {
    return x2 > x1 ? 1 : 3;
  }
}

Vi make_line(int t, int *X, int *Y) {
  Vi ret;
  int x0 = X[0], y0 = Y[0], px = X[1], py = Y[1];
  ret.push_back(abs(x0-px)+abs(y0-py));
  int pd = get_dir(x0, y0, px, py);
  FOR(i, 2, t) {
    int x = X[i], y = Y[i];
    int d = get_dir(px, py, x, y);
    ret.push_back((d+1)%4 == pd ? 1 : -1);
    ret.push_back(abs(x-px)+abs(y-py));
    px = x, py = y, pd = d;
  }
  return ret;
}  

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

  while (1) {
    int N;
    cin >> N;
    if (N == 0) break;

    int t, x[16], y[16];
    cin >> t;
    REP(i, t) cin >> x[i] >> y[i];
    Vi target = make_line(t, x, y);
    int T = target.size();
    REP(n, N) {
      int m, mx[16], my[16];
      cin >> m;
      REP(i, m) cin >> mx[i] >> my[i];
      Vi line = make_line(m, mx, my);
      if (T != (int)line.size()) continue;
      bool flag = true;
      REP(i, T) {
	if (target[i] != line[i]) {
	  flag = false;
	}
	if (i%2) line[i] = -line[i];
      }
      if (flag) {
	cout << n+1 << endl;
	continue;
      }

      flag = true;
      REP(i, T) {
	if (target[i] != line[T-i-1]) {
	  flag = false;
	  break;
	}
      }
      if (flag) {
	cout << n+1 << endl;
	continue;
      }      
    }
    cout << "+++++" << endl;
  }  

  return 0;
}

Measured memory_bytes: 1216
import collections

n = int(input())
s = [input() for i in range(n)]
if n == 1:
    print("".join(sorted(s[0])))
else:
    c = []
    for i in s:
        c.append(collections.Counter(i))
    a = c[0]
    for i in range(1, n):
        a &= c[i]
    ans = []
    a = a.most_common()
    
    for i in a:
        for j in range(i[1]):
            ans.append(i[0])
    print("".join(sorted(ans)))

Measured memory_bytes: 3316
var
  s:string;
  i,l,sc,sf:longint; 
   //l表示字符串长度; sc,sf分别表示第一个C的坐标和最后一个F的坐标.
 begin
  read(s);
  l:=length(s);sc:=maxlongint; //sc一定要赋值为maxlongint！
  for i:=1 to l do if s[i]='F'then sf:=i; //寻找最后一个F
  for i:=l downto 1 do if s[i]='C'then sc:=i;//寻找第一个C
  if sc<sf then writeln('Yes')
           else writeln('No');  //注意输出格式
 end.

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

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int x; cin >> x;
	int g = gcd(x, 360);
	cout << 360 / g;
	return 0;
}

/*

*/

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vector<int> G[MAX_N];
bool used[MAX_N];
int d[MAX_N];
vector<pi> ans;

int loop(int v, int p, int dep) {
	// debug(v, p);
	used[v] = true;
	d[v] = dep;
	int cnt = 0;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(n == p) continue;
		if(!used[n]) {
			cnt += loop(n, v, dep + 1);
		}
		else {
			// debug(v, n);
			if(d[v] > d[n]) {
				ans.pb(pi(v, n));
				cnt++;
			}
		}
	}
	if(p == -1) return 0;
	else {
		if(cnt % 2) {
			ans.pb(pi(v, p));
			return 0;
		}
		else {
			ans.pb(pi(p, v));
			return 1;
		}
	}
}

void solve() {
	cin >> N >> M;
	if(M % 2) {
		cout << "-1\n";
		return;
	}
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	loop(0, -1, 0);
	rep(i, 0, M) {
		cout << ans[i].fst + 1 << " " << ans[i].sec + 1 << "\n";
	}
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 27380
#include <stdio.h>
int main()
{
    int a, b, i, j;
    while (1)
    {
        scanf("%d%d", &a, &b);
        if (a == 0 && b == 0)
        {
            break;
        }

        for (i = 1; i <= a; i++)
        {
            for (j = 1; j <= b; j++)
            {
                if (i > 1 && i < a && j < b && j > 1)
                    printf(".");
                else
                    printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2100
import itertools
n=int(input())
dict={'M':0,'A':0,'R':0,'C':0,'H':0}
tmp=['M','A','R','C','H']
for i in range(n):
  name=input()
  if name[0] in tmp:
    dict[name[0]]+=1
num=list(dict.values())
c=list(itertools.combinations(num,3))
ans=0
for i in c:
  ans+=i[0]*i[1]*i[2]
print(ans)

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

int main(int argc, char const *argv[])
{
	int a[5],ans=0,mi=10;
	for (int i = 0; i < 5; ++i)
	{
		cin>>a[i];
		if (a[i]%10>0)
		{
			ans+=a[i]/10*10+10;
			mi=min(mi,a[i]%10);
		}
		else
		{
			ans+=a[i];
		}
	}
	if (mi==10)
	{
		cout<<ans<<endl;
	}
	else
	{
		cout<<ans-10+mi<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const int INF = 1e9;
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}
ll cnk(ll n, int k)
{
    ll res = 1;
    if(k==0)
    return 0;
    for(int i = 0 ; (i) < (k) ; ++i) res = (res * (n - i)) / (i + 1);
    return res;
}
void solve()
{
int n;
long long ans=0; cin>>n;
int a[n];
map<int,long long>mp;
map<int,long long>::iterator it;
for(int i=0;i<n;i++)
{
cin>>a[i];
mp[a[i]]++;
}
for(it=mp.begin();it!=mp.end();it++)
{
int x=it->second;
ans+=x*(long long)(x-1)/2;
//cout<<x<<"\n";
}
for(it=mp.begin();it!=mp.end();it++)
{
int x=it->second;
it->second=ans-(x*(long long)(x-1)/2)+((x-1)*(long long)(x-2)/2);
}
for(int i=0;i<n;i++)
cout<<mp[a[i]]<<"\n";
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	// cin >> t;
	while(t--){
	solve();
	}
	return 0;
}

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

const int mod = 1000000007;

ll modpow(ll a, ll n, ll mod){
  ll res = 1;
  while(n>0){
    if(n%2 == 1) res = res * a % mod;;
    a = a * a % mod;
    n /= 2;
  }
  return res;
}

ll comb(int n, int a){
  ll x = 1, y = 1;
  rep(i,a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll Y = modpow(y,mod-2,mod);
  ll res = x * Y % mod;
  return res;
}

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

  ll ans;
  ans = modpow(2,n,mod);
  ans -= 1;
  ans -= comb(n,a);
  if(ans<0) ans += mod;
  ans -= comb(n,b);
  if(ans<0) ans += mod;

  cout << ans % mod << endl;

  return 0;
}

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

using namespace std;


int main(){
    
    long int A, B, C, D;
   
    cin >> A >> B >> C >> D;
    
    long int ac = (A-1)/C;
    long int ad = (A-1)/D;
    
    long int bc = B/C;
    long int bd = B/D;
    
    
    
    long int CD = C*D;
    
    
    
    long int temp = 0;
    long int m;
    long int n;
    
    if (D > C) {
        m = D;
        n = C;
        
    }else{
        m = C;
        n = D;
    }
    
    while(m % n != 0){
        
        temp = n;
        n = m % n;
        m = temp;
        
        
    }
    
    /*
    for (long int i = 1; i <= bc; i++) {
      
        if (C*i % D == 0) {
            CD = C*i;
            break;
        }
    }
    
    */
    
    long int aa = C * D / n;
    
   long int acd = (A-1)/aa;
    
    long int bcd = B/aa;
    
    
    cout << B-A-((bc+bd-bcd)-(ac+ad-acd))+1 << endl;
    
    return 0;
    
}


Measured memory_bytes: 256