akhauriyash/Code-Regression huggingface dataset:
/*Infor {{{
 ******************************************************
 * > File Name: b.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018年06月23日 星期六 20时05分58秒
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  int N;
  cini(N);
  int t = N;
  int ans = 0;
  while (t) {
    ans += t % 10;
    t /= 10;
  }
  if (N % ans) cous("No"), LIN;
  else cous("Yes"), LIN;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    H = 0
    ans = 0
    for a in A:
        if H > a:
            ans += H - a
        else:
            H = a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92480
import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())

INF = 10 ** 9
dp = [INF] * (2 ** N)
dp[0] = 0
for i in range(M):
  a,b = map(int,readline().split())
  C = list(map(int,readline().split()))
  key = 0
  for c in C:
    key += (1 << (c - 1))
  for j in range(len(dp) - 1, -1, -1):
    if dp[j] == INF:
      continue
    dp[j | key] = min(dp[j | key], dp[j] + a)

if dp[-1] == INF:
  print(-1)
else:
  print(dp[-1])


Measured memory_bytes: 9172
import sys
import numpy as np
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W,K=map(int,readline().split())
C=np.array(list(map(str,read().rstrip().decode().split())))
ans=0
for paint_H in itertools.product([0,1], repeat=H):
  for paint_W in itertools.product([0,1], repeat=W):
    cnt=0
    for i in range(H):
      for j in range(W):
        if paint_H[i]==0 and paint_W[j]==0 and C[i][j]=="#":
          cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Measured memory_bytes: 27076
k = int(input())
ans = [
    1,
    9,
    30,
    76,
    141,
    267,
    400,
    624,
    885,
    1249,
    1590,
    2208,
    2689,
    3411,
    4248,
    5248,
    6081,
    7485,
    8530,
    10248,
    11889,
    13687,
    15228,
    17988,
    20053,
    22569,
    25242,
    28588,
    31053,
    35463,
    38284,
    42540,
    46581,
    50893,
    55362,
    61824,
    65857,
    71247,
    76884,
    84388,
    89349,
    97881,
    103342,
    111528,
    120141,
    128047,
    134580,
    146316,
    154177,
    164817,
    174438,
    185836,
    194157,
    207927,
    218812,
    233268,
    245277,
    257857,
    268182,
    288216,
    299257,
    313635,
    330204,
    347836,
    362973,
    383709,
    397042,
    416448,
    434025,
    456967,
    471948,
    499740,
    515581,
    536073,
    559758,
    583960,
    604833,
    633651,
    652216,
    683712,
    709065,
    734233,
    754734,
    793188,
    818917,
    846603,
    874512,
    909496,
    933081,
    977145,
    1006126,
    1041504,
    1073385,
    1106467,
    1138536,
    1187112,
    1215145,
    1255101,
    1295142,
    1342852,
    1373253,
    1422195,
    1453816,
    1502376,
    1553361,
    1595437,
    1629570,
    1691292,
    1726717,
    1782111,
    1827492,
    1887772,
    1925853,
    1986837,
    2033674,
    2089776,
    2145333,
    2197483,
    2246640,
    2332104,
    2379085,
    2434833,
    2490534,
    2554600,
    2609625,
    2693919,
    2742052,
    2813988,
    2875245,
    2952085,
    3003306,
    3096024,
    3157249,
    3224511,
    3306240,
    3388576,
    3444609,
    3533637,
    3591322,
    3693924,
    3767085,
    3842623,
    3912324,
    4027884,
    4102093,
    4181949,
    4270422,
    4361548,
    4427853,
    4548003,
    4616104,
    4718640,
    4812789,
    4918561,
    5003286,
    5131848,
    5205481,
    5299011,
    5392008,
    5521384,
    5610705,
    5739009,
    5818390,
    5930196,
    6052893,
    6156139,
    6239472,
    6402720,
    6493681,
    6623853,
    6741078,
    6864016,
    6953457,
    7094451,
    7215016,
    7359936,
    7475145,
    7593865,
    7689630,
    7886244,
    7984165,
    8130747,
    8253888,
    8403448,
    8523897,
    8684853,
    8802826,
    8949612,
    9105537,
    9267595,
    9376656,
    9574704,
    9686065,
    9827097,
    9997134,
    10174780,
    10290813,
    10493367,
    10611772,
    10813692
]
print(ans[k-1])


Measured memory_bytes: 9372
package main

import(
    "fmt"
)



func main() {
    var n int
    fmt.Scan(&n)
    ans := n/3
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main() {
    int n, i;
    long sum=0;
    cin >> n;
    for(i=1; i<=n; i++){
        if(i % 15 == 0){
            continue;
        } else if (i % 3 == 0){
            continue;
        } else if (i % 5 == 0){
            continue;
        }else{
            sum += i;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int main(void)
{
	ll x,y,res=0;
	scanf("%lld%lld",&x,&y);
	while(y>=x) x<<=1,res++;
	printf("%lld\n",res);
	return 0;
}
    
    


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vi a(n);
	Foz(i, n) cin >> a[i];
	int ans = 0;
	Foz(i, n) ans = __gcd(ans, a[i]);
	cout << ans << '\n';
}



Measured memory_bytes: 640
import sys

X,N=[int(i) for i in input().split(" ")]
if N==0:
    print(X)
    sys.exit(0)
p=[int(i) for i in input().split(" ")]

i=0
while True:
    if (X-i in p)==False:
        print(X-i)
        sys.exit(0)
    elif (X+i in p)==False:
        print(X+i)
        sys.exit(0)
    else:
        i+=1


Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  //int X; cin >> X;
  int t; cin >> t;
  int output;
  for(int X=1;X<=179;X++){
    double px=0,py=0;
    int ans = 0;
    double deg = X;
    do{
      px += cos(deg*2*acos(-1)/360);
      py += sin(deg*2*acos(-1)/360);
      deg += X;
      ans++;
    }while(abs(px)>0.00001 || abs(py)>0.00001);
    int ans2=0;
    int now=0;
    rep(i,1000){
      now += X;
      ans2++;
      if(now%360==0) break;
    }
    if(ans^ans2) cout << "!";
    if(X==t) output = ans;
  }
  cout << output << endl;
  return 0;
}


Measured memory_bytes: 3872
import java.util.*;


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

        N = sc.nextInt();
        W = sc.nextInt();
        int [] v = new int [N+1];
        int w [] = new int [N+1];

        for(int i=1;i<=N;i++)
        {
            w[i] = sc.nextInt();
            v[i]=sc.nextInt();
        }

        long  [][] dp = new long [N+1][W+1];

        for(int i=0;i<N;i++) dp[i][0]=0;
        for(int i=0;i<W;i++) dp[0][i]=0;



        for(int i=1;i<=N;i++)
        {
            for(int j=1;j<=W;j++)
            {
                if(w[i]>j) dp[i][j] = dp[i-1][j];
                else{
                    dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
            //    System.out.println(dp[i][j]);
                }
            }
        }
        System.out.println(dp[N][W]);
        
    }


}


Measured memory_bytes: 125252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    int num = 111;
    int x = 0;
    for (int i = 1; i <= 9; i++) {
        x = num * i;
        if (x - n >= 0) {
            break;
        }
    }
    cout << x << endl;
    return 0;
}

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

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

	sort(a, a+N);

	int ans = 0;
	int turn = 1;
	for (int i=N-1; i>-1; i--){
		if (turn == 1) {
			ans += a[i];
		} else {
			ans -= a[i];
		}
		turn *= -1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ');
            var a = int.Parse(arr[0]);
            var b = int.Parse(arr[1]);
            var c = int.Parse(arr[2]);
            var k = int.Parse(arr[3]);
            var result = 0;
            if(k < a)
            {
                result += k;
            }else if(k <= a + b)
            {
                result += a;
            }
            else
            {
                result += a - (k - a - b);
            }
            Console.WriteLine(result);
        }
    }
}


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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.assign(n+1,0);
    hash2.assign(n+1,0);
    mpow1.assign(n+1,1);
    mpow2.assign(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)>>1;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}


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

int cities,roads,a,b,group;
vector<int> adj[100100];
bool visited[100100];

void dfs(int c){
	if(!visited[c]){
		visited[c] = true;
		for(int i = 0;i < adj[c].size();i++){
			int d = adj[c][i];
			dfs(d);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>cities>>roads;
	for(int i = 1;i <= roads;i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 1;i <= cities;i++){
		if(!visited[i]) group++;
		dfs(i);
	}
	cout<<group - 1<<endl;
}


Measured memory_bytes: 9708
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

void dfs(int x,vector<vector<int>> &v,vector<int> &g, int &num){
  int x_size = v[x].size();
  if(x > 0){
    rep(i,x_size){
      if(g[v[x][i]] == 0){
        g[v[x][i]] = num;
        dfs(v[x][i],v,g,num);
      }
    }
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M),group(N+10,0);
  rep(i,M)cin >> A[i] >> B[i];
  vector<vector<int>> G(N+10);
  rep(i,M){
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }
  int num = 1;
  for(int i = 1;i <= N;i++){
    if(group[i] == 0){
      group[i] = num;
      dfs(i,G,group,num);
      num++;
    }
  }
  vector<int> cnt(N+10,0);
  for(int i = 1;i <= N;i++){
    cnt[group[i]]++;
  }
  int ans = -1;
  for(int i = 1;i <= N;i++){
    if(ans < cnt[i])ans = cnt[i];
  }
  cout << ans << endl;
/*
  for(int i = 1;i <= N;i++){
    cout << group[i] << " ";
  }
  cout << endl;
  for(int i = 1;i <= N;i++){
    cout << G[i].size() << " ";
  }
  cout << endl;
*/
  return 0;
}


Measured memory_bytes: 29900
#include <iostream>
#include <vector>

using namespace std;

typedef unsigned long long ull;

ull gcd(ull x, ull y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

vector<pair<ull, int>> factorize(ull n)
{
    vector<pair<ull, int>> res;
    for (ull i = 2; i * i <= n; ++i)
    {
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main()
{
    ull a, b;
    cin >> a >> b;
    ull g = gcd(a, b);
    vector<pair<ull, int>>f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int D; cin >> D;
    cout << "Christmas";
    REP(i, 25-D) cout << " Eve";
    cout << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def main():
	a, b, c = input().split(" ")
	
	A = list(a)
	B = list(b)
	C = list(c)
	
	print("{}{}{}".format(A[0], B[0], C[0]))

if __name__ == "__main__":
	main()


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


int main() {
  int a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v<=w) {
    cout<<"NO";
    return 0;
  }
  int d=v-w;
  int dist=abs(b-a);
  if(dist*1.0/d>t) {
    cout<<"NO";
  }else {
    cout<<"YES";
  }
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll L, R, d;
  cin >> L >> R >> d;

  ll cnt = 0;

  rep2(n, L, R + 1){
    if(n % d == 0) cnt++;
  }

  cout << cnt << "\n";
  
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    int last = 1;
    while (last * 2 <= n) {
        last *= 2;
    }
    cout << last << endl;
}


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

int main() {
  int n;
  cin >> n; //4
  long long d; //5
  cin >> d;
  
  int wievielmal = 0;
  for (int i = 0; i<n; i++) {
    // X, Y einlesen (das wird wiederholt!)
    long long x;
    long long y;
    cin >> x;
    cin >> y;
    if (x*x + y*y <= d*d) {
      wievielmal++;
    }
  }
  cout << wievielmal << endl;
	return 0;
}


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

int main()
{
	int n, c;
	string s1;
	
	cin >> s1 >> n;
	
	c = 0;
	
	while (n--){
		string s2;
		cin >> s2;
		
		for (int i = 0; i < s2.size(); i++){
			s2 += s2[0];
			s2.erase(s2.begin() + 0);
			if (s2.find(s1) != -1){
				c++;
				break;
			}
		}
	}
	
	cout << c << endl;
	return (0);
}

Measured memory_bytes: 1224
N, Q = map(int, input().split())
S = input()
X = [list(map(int, input().split())) for _ in range(Q)]
L = [0] * N
n = 0
for i in range(N - 1):
    if S[i:i + 2] == "AC":
        n += 1
    L[i] = n
L[-1] = n
R = [0] * N
n = 0
for i in range(1, N):
    if S[i - 1:i + 1] == "AC":
        n += 1
    R[i] = n
R[-1] = n
for l, r in X:
    if l == 1:
        print(R[r - 1])
    else:
        print(R[r - 1] - L[l - 2])


Measured memory_bytes: 33004
import java.util.ArrayList;
import java.util.Scanner;

  class Main  {
     public static void main(String[]args){
         Scanner scan = new Scanner(System.in);
         int n = scan.nextInt();
         int d = scan.nextInt();
         int x = scan.nextInt();
         int arr[] = new int[n];
         
         for(int i = 0 ; i < n ; i++ ){
            arr[i] = scan.nextInt();
         }
         int day = 0 ; 
         int count = 0 ; 
         for(int i = 0 ; i < n ; i++){ 
             for(int j = 0 ; j*arr[i]+1<=d ; j++){
                 day = j*arr[i]+1;
                 //System.out.print  (j*arr[i]+1 +" ");
                 count++;
                  
             }
             day = 0 ;
             //
             //System.out.println();
         }
         System.out.println(count+x);
     }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a,b;
    if(n==1) cout<<"Hello World"<<endl;
    else if(n==2){
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)
#define N 2005
#define M 10005
#define ll long long
using namespace std;
int n, m, len, tp, tot, a[N], q[M], f[M<<1];
char s[N][M], s1[M<<1], ch[M];
bool fl[N][M], ok[M], vis[M];
struct node {
	int x, y; node() {}//x,y表示，将ch中的长为x的串和a[i]拼起来
	node(int a, int b) { x = a, y = b; }
} b[M];
inline void exkmp(char s[], int n) {
	int k = 1; memset(f, 0, sizeof f); f[1] = n;
	rep(i, 2, n) {
		f[i] = max(0, min(k+f[k]-i, f[i-k+1]));
		while(i+f[i] <= n && s[f[i]+i] == s[f[i]+1]) f[i]++;
		if(k == 1 || f[i]+i > f[k]+k) k = i;
	}
}
inline int cmp(const node &u, const node &v) {//比较函数，-1/0/1表示</=/>，等于相当于存在真包含关系
	if(!u.y && !v.y) return 0;
	if(!u.y) return -cmp(v, u);
	if(!v.y) {
		if(v.x < u.x) return 0;
		int t = f[u.x+u.y+1];
		if(u.x+t >= v.x) return 0;
		return s1[t+1] < s1[u.x+u.y+t+1] ? -1 : 1;
	}
	if(u.x == v.x) return 0;
	if(u.x > v.x) return -cmp(v, u);
	int t = f[u.x+u.y+1];
	if(u.x+t <= v.x) return s1[t+1] < s1[u.x+u.y+t+1] ? -1 : 1;
	t = f[v.x-u.x+1];
	if(v.x+t >= u.x) return 0;
	return s1[v.x-u.x+t+1] < s1[t+1] ? -1 : 1;
}
bool operator < (const node &x, const node &y) { return cmp(x, y) < 0; }
bool operator == (const node &x, const node &y) { return !cmp(x, y); }
int main() {
	scanf("%d%d", &n, &m);//a[i]是第i个串的长度
	rep(i, 1, n) { scanf("%s", s[i]+1); a[i] = strlen(s[i]+1); }
	fl[n+1][0] = 1;//fl[i][j]表示i到n的串中是否能拼出长度为j的串
	per(i, n, 1) rep(j, 0, m) {
		fl[i][j] = fl[i+1][j];//不选第i个串
		if(j >= a[i]) fl[i][j] |= fl[i+1][j-a[i]];//选第i个串
	}
	//ch保存目前为止【不考虑长度的字典序最小】且【最长】的串，并且之后是能拼出长度m的串的
	//ok[i]=1表示这是一个断点，len保存长度
	len = 0; ok[0] = 1;
	rep(i, 1, n) {
		if(!len) {
			if(fl[i+1][m-a[i]]) rep(j, 1, a[i]) ch[++len] = s[i][j];
			ok[len] = 1; continue;
		}
		//将当前串s[i]和目前最优串ch拼起来，exkmp预处理出任意一个后缀与该串的lcp，用f保存
		tot = 0;
		rep(j, 1, a[i]) s1[++tot] = s[i][j];//s1保存拼接后的串
		rep(j, 1, len) s1[++tot] = ch[j];
		exkmp(s1, tot);
		memset(vis, 0, sizeof vis);
		rep(j, 0, m) if(fl[i+1][m-j]) {//枚举前i个串能拼成的合法长度
			if(ok[j]) { vis[j] = 1; b[j] = node(j, 0); }
			if(j >= a[i] && ok[j-a[i]]) {
				if(vis[j]) b[j] = min(b[j], node(j-a[i], a[i]));
				else { vis[j] = 1; b[j] = node(j-a[i], a[i]); }
			}
		}
		q[1] = 0; tp = 1;
		rep(j, 1, m) if(vis[j]) {
			while(tp > 1 && b[j] < b[q[tp]]) tp--;
			if(b[j] == b[q[tp]]) q[++tp] = j;
		}//这里的'=='表示是一个真包含关系，都要保存下来，记录断点
		len = q[tp];
		if(b[len].y) rep(j, 1, a[i]) ch[b[len].x+j] = s[i][j];
		ch[len+1] = 0;
		memset(ok, 0, sizeof ok);
		while(tp) ok[q[tp--]] = 1;
	}//由于每次操作都保证了之后的串能拼出长度为m的，所以最后的答案长一定为m
	printf("%s\n", ch+1);
	return 0;
}

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

using namespace std;
vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000'000'007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//

int main()
{

	ll n;
	cin >> n;
	vector<string> s(n);
	ll sb = 0;
	ll fa = 0;
	ll ab = 0;
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> s[i];
		for (int j = 0; j < s[i].size() - 1; ++j)
		{
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')
			{
				++ans;
			}
		}
		if (s[i].back() == 'A' && s[i].front() == 'B')
		{
			++ab;
		} else if (s[i].back() == 'A')
		{
			++fa;
		} else if (s[i].front() == 'B')
		{
			++sb;
		}
	}
	if (ab != 0)
	{
		ans += ab - 1;
		if (sb != 0)
		{
			ans += 1;
			sb -= 1;
		}

		if (fa != 0)
		{
			ans += 1;
			fa -= 1;
		}

		ans += min(sb, fa);
	} else {
		ans += min(sb, fa);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b == c+d) cout << "Balanced" << endl;
	else if(a+b > c+d) cout << "Left" << endl;
	else cout << "Right" << endl;
	return 0;
}

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

int main(){
  int a,b,cnt=0;
  cin>>a>>b;
  for(int i=a; i<=b; i++){
    if(i%10 != 0 && i/10000==i%10 && i/1000%10==i/10%10) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

class Dict {
private:
  set<string> set_;

public:
  Dict() :
    set_(set<string>())
  {}

  void insert(const string& val) {
    set_.insert(val);
  }

  bool find(const string& val) const {
    auto result = set_.find(val);
    return result == set_.end() ? false : true;
  }
};

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

  Dict dict{};
  for(int i = 0; i < n; i++) {
    string command, value;
    cin >> command >> value;

    if(command == "insert") {
      dict.insert(value);
    } else if(command == "find") {
      if(dict.find(value)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
}



Measured memory_bytes: 32148
N=int(input())
M=list(map(int,input().strip().split(' ')))
H=list(map(int,input().strip().split(' ')))
count=0
for i in range(len(H)):
    temp=min(M[i],H[i])
    H[i]-=temp
    M[i]-=temp
    count+=temp
    temp2=min(M[i+1],H[i])
    H[i]-=temp2
    M[i+1]-=temp2
    count+=temp2
print(count)

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

int main(){
	ios::sync_with_stdio(0);
	
	int n;
	cin>>n;
	vector<vector<int>> arr;
	arr.resize(n);
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		arr[i].push_back(a);
		arr[i].push_back(b);
	}
	int correct=0;
	for(int i=0;i<n;i++){
		if(arr[i][0]==arr[i][1])
			correct++;
		else correct=0;
		if(correct==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
#define all(vec) vec.begin(), vec.end()
namespace mp = boost::multiprecision;
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};

int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

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

bool prime(int a) {
	if (a == 1)
		return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0)
			return false;
	}
	return true;
}

class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(int x, int y) {
		if (same(x, y))
			return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}

	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(int x, int y) {
		return Find(x) == Find(y);
	}

	int get_Size(int a) {
		return s[a];
	}
};

set<int> prime_num_factor(int n) {
	if (n < 2)
		return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0)
				break;
		}
	}
	return prime;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
signed main() {
	int n,h[100000];
	bool b1=true,b2=false;
	cin>>n;
	rep(i,n){
		cin>>h[i];
		if(i!=0){
			if (b2 && h[i] == h[i - 1] - 1 || h[i] < h[i - 1] - 1) {
				b1=false;
			}
			else if(h[i]==h[i-1]-1){
				b2=true;
			}
			if(h[i]>h[i-1]){
				b2=false;
			}
		}
	}
	if(b1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int a[15];
int x[15][15];
int y[15][15];
int ve(int bit,int n)
{
	int b[15];
	fill(b,b+15,0);
	for(int i=0;i<n;i++)
	{
		if(bit&(1<<i))
			b[i]=1;
		else
			b[i]=-1;
	}
	for(int i=0;i<n;i++)
	{
		if(b[i]<0)
			continue;
		for(int j=0;j<a[i];j++)
		{
			if(y[i][j]==1 && b[x[i][j]]>0)
				b[x[i][j]]++;
			else if(y[i][j]==0 && b[x[i][j]]<0)
				b[x[i][j]]--;
			else
				return 0;
		}
	}
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(b[i]>=0)
			ret++;
	}
	return ret;
}
int main()
{
	int n;
	int ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		for(int j=0;j<a[i];j++)
		{
			cin>>x[i][j]>>y[i][j];
			x[i][j]--;
		}
	}
	for(int bit=0;bit<(1<<n);bit++)
	{
		ans=max(ans,ve(bit,n));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#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<ll, ll>;

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;
  ll ans = INF;
  rep(i, s.size() - t.size() + 1) {
    ll cnt = 0;
    rep(j, t.size()) if (s[i + j] != t[j]) cnt++;
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int dir[4] = {};
    for (char c : S)
    {
        if (c == 'N') dir[0]++;
        if (c == 'S') dir[1]++;
        if (c == 'W') dir[2]++;
        if (c == 'E') dir[3]++;
    }

    bool okNS = false;
    bool okWE = false;
    if ((dir[0] > 0 && dir[1] > 0) || (dir[0] == 0 && dir[1] == 0))
    {
        okNS = true;
    }
    if ((dir[2] > 0 && dir[3] > 0) || (dir[2] == 0 && dir[3] == 0))
    {
        okWE = true;
    }

    if (okNS & okWE)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        sc.close();
        if(x >= y / 2){
            System.out.println(y / 2);
        }else{
            y -= x * 2;
            System.out.println(x + y / 4);
        }
    }
}

Measured memory_bytes: 35736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <string.h>
#include <cmath>


const int MAXN = 10000;
const int MAXQ = 500;
int n, q;
int seqa[MAXN], seqb[MAXQ];

void init() {
	
}

void input() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", seqa + i);
	}
	scanf("%d", &q);
	for(int i = 0; i < q; i++){
		scanf("%d", seqb + i);
	}
}

void output() {
	int cnt = 0;
	for(int i = 0; i < q; i++) {
		for(int j = 0; j < n; j++) {
			if(seqa[j] == seqb[i]) {
				cnt++;
				break;
			}
		}
	}
	//
	printf("%d\n", cnt);
}

int main() {
	input();
	output();
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,t,a,td[100010],ad[100010];
vector<ll>ch[100010];
void dep1(ll now,ll cnt){
	if(now!=t&&ch[now].size()==1){
		return;
	}
	for(ll i=0;i<ch[now].size();i++){
		ll next=ch[now][i];
		if(td[next]!=-1){
			continue;
		}
		td[next]=cnt+1;
		dep1(next,cnt+1);
	}
}
void dep2(ll now,ll cnt){
	if(now!=a&&ch[now].size()==1){
		return;
	}
	for(ll i=0;i<ch[now].size();i++){
		ll next=ch[now][i];
		if(ad[next]!=-1){
			continue;
		}
		ad[next]=cnt+1;
		dep2(next,cnt+1);
	}
}
int main() {
	cin>>n>>t>>a;
	t--;a--;
	for(ll i=0;i<n-1;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	for(ll i=0;i<n;i++){
		td[i]=ad[i]=-1;
	}
	td[t]=ad[a]=0;
	dep1(t,0);
	dep2(a,0);
	ll ans=0;
	for(ll i=0;i<n;i++){
//		cout << td[i]<< " "<<ad[i]<<endl;
		if(td[i]<ad[i]){
			ans=max(ad[i],ans);
		}
	}
	if(ans-1<=0){
		cout << 0;
	}
	else{
		cout <<ans-1;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 11264
#include<iostream>
using namespace std;
int n, a, b, c, d, i;
long long minim, maxim;
int main(){
    cin>> n >> a >> b >> c >> d;
    if(a > b){
        swap(a, b);
    }
    n--;
    for(i = 0; i <= n / 2; i++){
        minim = max(0LL, c * 1LL * (n - i) - d * 1LL * i);
        maxim = (n - i) * 1LL * d - i * 1LL * c;
        if(b - a >= minim && b - a <= maxim){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;

	string s;
	unordered_map<string, int> cnt;
	for(int i = 0; i < n; i++) {
		cin >> s;
		cnt[s]++;
	}

	int maxval = -1;
	std::vector<string> res;
	for(auto &x: cnt) {
		auto key = x.first;
		auto value = x.second;
		if(value > maxval) {
			maxval = value;
			res.clear();
			res.emplace_back(key);
		} else if(value == maxval) res.emplace_back(key);
	}

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

	for(int i = 0; i < res.size(); i++) cout << res[i] << endl;
	
	return 0;
}


Measured memory_bytes: 26692
import sys
n = int(input())
A=[int(e)for e in sys.stdin]
cnt = 0
G = [int((3**i-1)/2)for i in range(14,0,-1)]
G = [v for v in G if v <= n]
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
for g in G:
    insertionSort(A, n, g)
print(len(G))
print(*G)
print(cnt)
print(*A,sep='\n')


Measured memory_bytes: 53308
#include <stdio.h>

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


Measured memory_bytes: 128
n, m = map(int, raw_input().split())
a = []
for i in xrange(n):
	row = map(int, raw_input().split())
	a.append(row)

order = []
for i in xrange(n):
	for j in xrange(m):
		if i % 2 == 0:
			order.append((i, j))
		else:
			order.append((i, m - j - 1))

ans = []
for i in xrange(1, len(order)):
	x1, y1 = order[i - 1]
	x2, y2 = order[i]
	if a[x1][y1] % 2 != 0:
		ans.append(" ".join(map(str, (x1 + 1, y1 + 1, x2 + 1, y2 + 1))))
		a[x2][y2] += 1

print len(ans)
for row in ans:
	print row


Measured memory_bytes: 37160
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		
		for(int i = A; i <= B; i++){
			String s = String.valueOf(i);
			boolean tf = true;
			//System.out.println(s + ":");
			for(int j = 0; j < s.length()/2; j++){
				//System.out.print(s.charAt(j));
				if(s.charAt(j) != s.charAt(s.length()-1-j)){
					tf = false;
					break;
				}
			}
			//System.out.println();
			if(tf) ans++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 27732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
 
 
int main() {
  ll n;
  cin >> n;
  
  ll nsquaresum=0;
  ll nsum=0;
  for(ll i=0; i<n; i++){
    ll a;
    cin >> a;
    nsum += a;
    nsquaresum += a*a;
    nsum %= mod;
    nsquaresum %= mod;
  }
  
  ll result=(nsum*nsum-nsquaresum);
  result = (result+mod)%mod;
  result *= (mod+1)/2;
  result %= mod;
  
  cout << result << endl;
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
ll x,res;

int main()
{
	cin>>x;
	res=x/11*2;x%=11;
	if(x&&x<=6) res++;
	else if(x) res+=2;
	cout<<res;
 	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

B=[0 for i in range(N+1)]
for i in range(M):
  B[int(input())]=1
#print(N,M)
#print(B)

C=[0 for i in range(N+1)]
C[0]=1

for i in range(1,N+1):
  if B[i]==1:
    C[i]=0
  else:
    if i==1:
      C[i]=C[0]
    else:
      C[i]=(C[i-1]+C[i-2])%(10**9+7)
print(C[N])

Measured memory_bytes: 7832
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#define lli long long int
#define loop(i,x,n) for(int i=x;i<n;i++)
#define loopr(i,x,n) for(int i=n-1;i>=x;i--)
#define st set<lli>
#define v vector<lli>
#define um unordered_map<lli,lli>
#define vpl vector<pair<lli,lli>>
#define llu long long unsigned
#define ms muliset<int,greater<int>>
#define ums unordered_map<string,lli>
#define pb push_back
#define time ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test lli t; cin>>t; while(t--)
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
v adj[100001];
lli vist[100001];

void dfs(lli node)
{
    vist[node]=1;
    for(lli child : adj[node]) if(!vist[child]) dfs(child);
}

int main()
{
    time
    lli n,m;
    cin>>n>>m;
    loop(i,0,m)
    {
        lli x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    lli c=-1;
    loop(i,1,n+1)
    {
        if(!vist[i])
        {
            dfs(i);
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 11112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      char x,y;
      cin >> x >> y ;
      int X,Y;
      rep(i,6){
       if(x=='A'+i) X=10+i;
        if(y=='A'+i) Y=10+i;
      }
      rep(i,10){
       if(x=='0'+i) X=i;
        if(y=='0'+i) Y=i;
      }
      if(X>Y) cout << '>' << endl;
      if(X==Y) cout << '=' << endl;
      if(X<Y) cout << '<' << endl;
      return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int a[maxn];
const int INF=1e9;
void chkmin(int &x,int y){
	x=x<y?x:y;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int x,y,ans=INF;
	for(int i=1;i<=n-k+1;i++){
		if(a[i+k-1]<=0) chkmin(ans,-a[i]);
		else if(a[i]>=0) chkmin(ans,a[i+k-1]);
		else{
			chkmin(ans,-a[i]*2+a[i+k-1]);
			chkmin(ans,-a[i]+a[i+k-1]*2);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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


int main(){
    
    int N,M;
    cin >> N >> M;
    int a[M]={};
    int b[M]={};
    int c[N]={};
    
    for(int i = 0;i<M;i++){
        cin >> a[i] >> b[i];
        c[a[i]-1]++;
        c[b[i]-1]++;
    }   
    for(int i = 0;i<N;i++){
        cout << c[i]<<endl;

    }


}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int l, m, n, i, a[4][13] = {};
    char ch;
    cin >> n;
    for (i = 0; i < n; i++){
        cin >> ch >> m;
        switch (ch){
            case 'S': l = 0; break;
            case 'H': l = 1; break;
            case 'C': l = 2; break;
            case 'D': l = 3; break;
        }
        a[l][m-1] = 1;
    }
    for (i = 0; i < 13; i++){
        if (a[0][i] == 0){
            cout << "S" << " " << i+1 << endl;
        }
    }
    for (i = 0; i < 13; i++){
        if (a[1][i] == 0){
            cout << "H" << " " << i+1 << endl;
        }
    }
    for (i = 0; i < 13; i++){
        if (a[2][i] == 0){
            cout << "C" << " " << i+1 << endl;
        }
    }
    for (i = 0; i < 13; i++){
        if (a[3][i] == 0){
            cout << "D" << " " << i+1 << endl;
        }
    }
    return 0;
}


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

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

using namespace std;

ll dp[101][100001];
// dp[i][j]:i個までの品物を使って、重さjで実現可能な最大価値

int main(){
  int n, w;
   vector<ll>ws(n),vs(n);

  //n = 4;w=5;
  //vector<int> ws({2,1,3,2});
  //vector<int> vs({3,2,4,2});


   cin>>n>>w;
   rep(i,n)cin>>ws[i]>>vs[i];
//   rep(i,n)cin>>vs[i];

  for(int i=0; i<n; i++){
    rep(j,w+1){

      if(j-ws[i]>=0){
        dp[i+1][j] = max( dp[i][j], dp[i][j-ws[i]]+vs[i]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  cout<<dp[n][w]<<endl;

  return 0;

  rep(i,n+1){
    rep(j,w+1)cout<<dp[i][j]<<' ';
    cout<<endl;
  }

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
return 0;}

Measured memory_bytes: 256
main = do
  s <-  getLine
  putStrLn .show $ solve s

solve s = solve' $ take (length s - 2) s

solve':: String -> Int
solve' s
  | ff == bb = l
  | otherwise = solve' $ take (l - 2) s
  where
    l = length s
    ff = take (div l 2) s
    bb = drop (div l 2) s

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

//NODE?????????
class Node{
	public:
 Node* prev;
 Node* next;
 int data;
 Node(){prev=0;next=0;data=0;}
};

//List?????????
class List{
	private:
 Node head;
	public:
 List(){head.prev=&head;head.next=&head;}
 int insert(int x);
 int del(int x);
 int deleteFirst();
 int deleteLast();
 void print();
};

//insert????????????
int List::insert(int x){
 Node* p= new Node();

 if(p==0)
	return -1;

 Node* q=&head;
 Node* r=head.next;

 p->prev=q;
 p->next=r;
 p->data=x;

 q->next=p;
 r->prev=p;

 return 0;
}

//del
int List::del(int x){
 Node* p;
 for (p=head.next;p!=&head;p=p->next){
	if(p->data==x)
		break;
 }
 if(p==&head)
	return -2;

 Node* q=p->prev;
 Node* r=p->next;

 q->next=r;
 r->prev=q;

 delete p;

 return 0;
}

//deleteFirst
int List::deleteFirst(){
 Node*p=head.next;

 if(p==&head)
	return -2;

 Node*q=p->prev;
 Node*r=p->next;

 q->next=r;
 r->prev=q;

 delete p;

return 0;
}

//deleteLast
int List::deleteLast(){
 Node* p=head.prev;

 if(p==&head)
	return -2;

 Node* q=p->prev;
 Node* r=p->next;

 q->next=r;
 r->prev=q;

 delete p;

return 0;
}

//print
void List::print(){
 for(Node* p=head.next;p!=&head;p=p->next){
	cout<<p->data;
	if(p->next!=&head){
		cout<<' ';
	}else{
		cout<<endl;
	}
 }
}

//main
int main(){
 List L;

 int n;
 cin>>n;

 for(int i=0;i<n;i++){
	char com[20];
	cin>>com;

	if(com[0]=='i'){
		int x;
		cin>>x;
		L.insert(x);
	}
	else if(com[6]=='F'){
		L.deleteFirst();
	}
	else if(com[6]=='L'){
		L.deleteLast();
	}
	else {
		int x;
		cin>>x;
		L.del(x);
	}
 }
 L.print();
 return 0;
}

Measured memory_bytes: 34236
#include <bits/stdc++.h>
using namespace std;
int main(){
  int w, a, b; cin >> w >> a >> b;
  if(a <= b && b <= a + w) cout << 0 << endl;
  else if(b <= a && a <= b + w) cout << 0 << endl;
  else cout << min(abs(b - a - w), abs(a - b - w)) << endl;
  return 0;
}


Measured memory_bytes: 256