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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    ll sum = 0;
    map<char,char> kachi;
    map<char,ll> score;
    kachi['r'] = 'p';
    kachi['s'] = 'r';
    kachi['p'] = 's';
    kachi['*'] = '*';
    score['r'] = R;
    score['s'] = S;
    score['p'] = P;
    REP(i,0,K) T += '*';

    string U;
    REP(i,0,K) {
        sum += score[kachi[T[i]]];
        U += kachi[T[i]];
    }
    REP(i,K,N) {
        if(kachi[T[i]] != U[i-K]) {
            sum += score[kachi[T[i]]];
            U += kachi[T[i]];
        }
        else if(T[i] == kachi[T[i+K]]) U += kachi[kachi[T[i]]];
        else U += T[i];
    }
    PR(sum);

    return 0;
}

/*
2275 2106 615
rspssprspsppprpsrpspr
prsrrsprsrssspsrpsrsp
r7 s9 p5


*/

Measured memory_bytes: 3980
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

N, M, K = inpl()
A = [0]
B = [0]
A += inpl()
B += inpl()
for i in range(N):
    A[i+1] += A[i]
for i in range(M):
    B[i+1] += B[i]

ans = 0
j = M
for i in range(N+1):
    if A[i] > K:
        break
    while B[j] > K - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 42636
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		String s = reader.ns();
		String t = reader.ns();
		if (t.startsWith(s) && s.length() == t.length() - 1) {
			out.println("Yes");
		} else {
			out.println("No");
		}
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32792
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
char s[500005];
int main()
{
    scanf(" %s",s);
    int cnt=0,ans=0,flag;
    for(int i=0;s[i];i++)
    {
        if(s[i]=='T')
            cnt--;
        if(s[i]=='S')
            cnt++;
        if(cnt<0&&s[i]=='T')
        {
            ans++;
            cnt=0;
        }
    }
    printf("%d\n",ans*2);
    return 0;
}


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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N / 2; i++) {
        if (S[i] != S[i + N / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

int main(void) {
    ll a, b;
    cin >> a >> b;
    cout << b*2-a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int x;
	scanf("%d",&x);
	x=abs(x);
	int t=0;
	while(t*(t+1)/2<x){
		t++;
	}
	printf("%d\n",t);
	return 0;
}
	

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int k,c=0;
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i%2==0&&j%2!=0) c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3524
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> s = new HashSet<>();
        for(int i=0; i<n; i++) {
            s.add(sc.next());
        }
        System.out.println(s.size());
    }
}

Measured memory_bytes: 71132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
const ll INF = 1LL<<60;

int main(void) {
    ll k, q;
    cin >> k >> q;
    vector<ll> d0(k);
    REP(i, k) cin >> d0[i];

    REP(i, q) {
        ll n, x, mo;
        cin >> n >> x >> mo;
        x %= mo;

        ll sum = 0;
        vector<ll> d(d0);
        REP(j, k) d[j] %= mo, sum += d[j];

        ll ret = 0;
        REP(j, k) if(d[j] == 0) ret += (n-1)/k + (j < (n-1)%k);
        
        ll last = (n-1)/k*sum + x;
        REP(j, (n-1)%k) last += d[j];
        ret += last/mo - x/mo;
        
        cout << n-1 - ret << "\n";
    }

    return 0;
}

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

int main() {
  int H, W; cin >> H >> W;
  char a[H][W];
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) cin >> a[i][j];
  }

  for(int i = 0; i < H; i++) {
    if(i==0){
      for(int k = 0; k < W+2; k++) {
        cout << "#";
      }
      cout << endl;
    }for(int j = 0; j < W; j++){
      if(j==0) cout << "#";
      cout << a[i][j] ;
    }
    cout << "#" << endl;
    if(i==H-1){
      for(int k = 0; k < W+2; k++) {
        cout << "#";
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int128 LL;
//typedef __int64 LL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<long double, long double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII > VP;
typedef vector<double> VD;
typedef vector<LL> VL;
typedef long double ld;

void solve(int ks) {
	int n;
	VP V;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		V.push_back({ x + y, x });
	}
	sort(ALL(V));
	reverse(ALL(V));
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			ans -= V[i].first - V[i].second;
		}
		else {
			ans += V[i].second;
		}
	}
	printf("%lld\n", ans);
}

int main()
{
#ifdef LOCAL
	double start_time = clock();
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	if (0) {
		int T;
		scanf("%d", &T);
		for (int ks = 1; ks <= T; ks++) solve(ks);
	}
	else {
		solve(0);
	}

#ifdef LOCAL
	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
#endif

	return 0;
}


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

int main(void){
  long N;
  map <string, int> d;
  string buf;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> buf;
  	d[buf] = 0;
  }
  cout << d.size() << endl;
}


Measured memory_bytes: 19036
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int h,w,c;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int p[8][8];
bool ck[8][8];
bool valid(int x, int y){
  return x>=0&&x<w&&y>=0&&y<h;
}
void check(int x, int y, int c){
  if(ck[y][x]) return;
  if(p[y][x]==c) ck[y][x] = true;
  else return;
  REP(r,4){
    int nx = x+dx[r];
    int ny = y+dy[r];
    if(valid(nx,ny)){
      check(nx,ny,c);
    }
  }
}
void printp(){
  REP(y,h){
    REP(x,w)printf("%d ",p[y][x]);
    putchar('\n');
  }
}
int dfs(int t){
  int ret = 0;
  if(t==5){
    memset(ck,0,sizeof(ck));
    check(0,0,c);
    REP(y,h)REP(x,w)if(ck[y][x])ret++;
  }else{
    int tmp[8][8];
    memcpy(tmp,p,sizeof(p));
    REP(nc,6){
      memset(ck,0,sizeof(ck));
      check(0,0,p[0][0]);
      REP(y,h)REP(x,w)if(ck[y][x])p[y][x] = nc;
      ret = max(ret,dfs(t+1));
      memcpy(p,tmp,sizeof(tmp));
    }
  }
  return ret;
}
int main(){
  while(cin>>h>>w>>c,h){
    c--;
    REP(y,h)REP(x,w)cin>>p[y][x],p[y][x]--;
    cout<<dfs(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
import java.util.*;
import java.lang.*;
public class Main{

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

		int N = sc.nextInt();
		int[] count = new int[N+1];
		for( int i=2; i<=N; i++ ){
			int a = sc.nextInt();
			count[a]++;
		}
		for( int i=1; i<=N; i++ ){
			System.out.println(count[i]);
		}
	}
}

Measured memory_bytes: 61460
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cout<<"# "<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=500005,mod=998244353;
int fac[N],rev[N],pw1[N],pw2[N];
int n,m,ans;

int power(int x,int p){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%mod)
		if(p&1)res=(ll)res*x%mod;
	return res;
}

int C(int n,int m){
	return (ll)fac[n]*rev[m]%mod*rev[n-m]%mod;
}

void init(int lim){
	fac[0]=pw1[0]=pw2[0]=1;
	rep(i,1,lim){
		fac[i]=(ll)fac[i-1]*i%mod;
		pw1[i]=(ll)pw1[i-1]*(n+1)%mod;
		pw2[i]=(ll)pw2[i-1]*(m+1)%mod;
	}
	rev[lim]=power(fac[lim],mod-2);
	per(i,lim,1)rev[i-1]=(ll)rev[i]*i%mod;
}

int main(){
	read(n),read(m);
	init(max(n,m));
	rep(i,0,min(n,m)){
		int now=(ll)C(n,i)*C(m,i)%mod;
		now=(ll)now*fac[i]%mod;
		now=(ll)now*pw1[m-i]%mod;
		now=(ll)now*pw2[n-i]%mod;
		if(i&1)ans=(ans+mod-now)%mod;
		else ans=(ans+now)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

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(){

    ll k,n;
    cin >> k >> n;
    vector<ll> a(n);
    vector<ll> d(n,0);
    rep(i,n){
        cin >> a[i];
    }

    for(int i = 0; i < n-1; i++){
        d[i] = a[i+1] -a[i];
    }
    d[n-1] = k - a[n-1] + a[0];

    sort(d.begin(), d.end(), greater<ll>());
    ll ans = k - d[0];
    cout << ans << endl;

    return 0;
}  

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



int main(){
    double a,b,x;cin>>a>>b>>x;
    cout<<fixed;
    double ang=atan((2*a*a*b-2*x)/a/a/a)*180.0/M_PI;
    if(ang>=atan(b/a)*180.0/M_PI){
        ang=atan(a*b*b/(2*x))*180.0/M_PI;
    }
    cout<<ang<<endl;
}






Measured memory_bytes: 512
#define DEBUG 0

/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 3/23/2019, 9:57:56 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
vector<int> b;
bool ok = true;
vector<int> V;

void flush()
{
  if (ok)
  {
    reverse(V.begin(), V.end());
    for (auto x : V)
    {
      cout << x + 1 << endl;
    }
  }
  else
  {
    cout << -1 << endl;
  }
}

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    b.push_back(a - 1);
  }
  while (!b.empty())
  {
    ok = false;
    for (auto i = (int)b.size() - 1; i >= 0; i--)
    {
      if (b[i] == i)
      {
        auto it = b.begin();
        it = it + i;
        b.erase(it);
        V.push_back(i);
        ok = true;
        break;
      }
    }
    if (!ok)
    {
      flush();
      return 0;
    }
  }
  flush();
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<ll> sum(n + 1);
  rep(i, n) {
    int a;
    cin >> a;
    sum[i + 1] = sum[i] + a;
  }

  ll ans = abs((sum[n] - sum[1]) - sum[1]);
  REP(i, 1, n) ans = min(ans, abs((sum[n] - sum[i]) - sum[i]));

  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans  = 0;
  for (int i=1;i<=n;i+=2){
    int num = 0;
    for (int j=1;j<=i;j+=2){
      if (i % j == 0) num ++;
    }
    if (num == 8) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>

#define MAX 100000

int partition(int A[], int p, int r){
	int x = A[r];
	int nu = 0;
	int i = p - 1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i = i + 1;
			nu = A[i];
			A[i] = A[j];
			A[j] = nu;
		}
	}
	nu = A[i + 1];
	A[i + 1] = A[r];
	A[r] = nu;
	return i + 1;
}

int main(){
	int n,k = 0;
	int val[MAX];
	
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&val[i]);
	}
	int index = partition(val, 0, n-1);
	
	printf(index==0?"[":"");
	printf("%d",val[0]);
	printf(index==0?"]":"");
	for(int i = 1;i < n; i++){
		printf(" ");
		printf(index==i?"[":"");
		printf("%d",val[i]);
		printf(index==i?"]":"");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2144
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A<=9&&B<=9) System.out.println(A*B);
        else System.out.println(-1);
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(xx) (xx).begin(),(xx).end()
#define print(a); for(auto xx:a)cout<<xx<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll t;cin>>t;
    map<string,ll>m;
    while(t--){
        string s;cin>>s;
        m[s]++;
    }
    cout<<"AC"<<" x "<<m["AC"]<<"\n";
    cout<<"WA"<<" x "<<m["WA"]<<"\n";
    cout<<"TLE"<<" x "<<m["TLE"]<<"\n";
    cout<<"RE"<<" x "<<m["RE"]<<"\n";
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int r;
    cin>>r;
    cout << r*r;
}

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

int n, m, q;
std::vector<int> a, b, c, d;

int dfs(std::vector<int> A = std::vector<int>(1, 1), int ans = -1) {
  if ((int)A.size() == n + 1) {
    int now = 0;
    for (int i = 0; i < q; ++i) {
      if (A[b[i]] - A[a[i]] == c[i])
        now += d[i];
    }
    return std::max(ans, now);
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    ans = dfs(A, ans);
    A.back()++;
  }

  return ans;
}

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

  int ans = dfs();
  std::cout << ans << std::endl;
}


Measured memory_bytes: 3192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// Data :
type Data struct {
	f, t int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	return p[i].f < p[j].f
}

func lowerBound(a []int, x int) int {
	l := 0
	r := len(a) - 1
	for l <= r {
		m := (l + r) / 2
		if a[m] >= x {
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return l
}

func upperBound(a []int, x int) int {
	l := 0
	r := len(a)
	for l <= r {
		m := (l + r) / 2
		if len(a) == m {
			break
		}
		if a[m] <= x {
			l = m + 1
		} else {
			r = m - 1
		}
	}
	return l
}

const maxN = 200100
const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = getInt()
	}

	pos := make([][]int, maxN)
	for i := 0; i < N; i++ {
		pos[c[i]] = append(pos[c[i]], i)
	}

	// out(c)
	// out(pos[:10])

	dp := make([]int, N+1)
	dp[0] = 1
	for i := 1; i <= N; i++ {
		dp[i] += dp[i-1]
		dp[i] %= mod

		col := c[i-1]
		idx := lowerBound(pos[col], i-1)
		// out(col, pos[col], idx)
		if idx > 0 {
			j := pos[col][idx-1]
			if (i-1)-j > 1 {
				// out("add", i, j, "val", dp[j+1])
				dp[i] += dp[j+1]
				dp[i] %= mod
			}
		}
		// out(dp[1 : N+1])
	}
	out(dp[N])
}


Measured memory_bytes: 12160
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,q,ans[202020];
vector<pair<int, pair<int,int>>> v;
set<int> s;
map<int,int> mp;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

        cin >> n >> q;
        for(int i=1;i<=n;i++){
                int x,y,z;
                cin >> x >> y >> z;
                v.pb( { z, {x,y}  } );
        }
        sort(all(v));

        for(int i=1;i<=q;i++){
                int d;
                cin >> d;
                s.insert(d);
                mp[d]=i;
        }

        for(int i=0;i<n;i++){
                int mn = v[i].sc.fs;
                int mx = v[i].sc.sc;
                int x = v[i].fs;

                while(true){
                        if(s.size()){
                                auto it = s.lower_bound( mn - x );
                                if( it == s.end() )break;
                                if( (*it) < mx-x ){
                                        //cout << (*it) << " " << mn << " " << mx << " " << x << endl;
                                        ans[ mp[ (*it) ] ]=x;
                                        s.erase(it);
                                }
                                else break;
                        }
                        else break;
                }

        }

        for(int i=1;i<=q;i++){
                if(ans[i]==0)ans[i]=-1;
                cout << ans[i] << endl;
        }

return 0;
}
///....


Measured memory_bytes: 31468
n=input()
m=len(n)
if m%2==0:
    ans=0
    for i in range(m//2):
        ans+=9*(10**(2*i))
    print(ans)
else:
    ans=0
    for i in range(m//2):
        ans+=9*(10**(2*i))
    ans+=int(n)-10**(m-1)+1
    print(ans)

Measured memory_bytes: 3060
from fractions import gcd
from itertools import accumulate

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

# 先頭から連続する要素の最大公約数の列
L = list(accumulate([0] + A, gcd))
# 末尾から連続する要素の最大公約数
R = list(accumulate([0] + list(reversed(A)), gcd))

# Aの各要素について、それを使用しない場合の最大公約数の最大値をL, Rを用いて求める
ans = max(
    gcd(L[k], R[-(k + 2)])
    for k in range(N)
)

# 出力
print(ans)


Measured memory_bytes: 16152
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define mp make_pair
const ll mod = 1000000007;
const ll nmax=2525*1001;
#define int ll
int n;
long double s, x;
     
int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>x;
		s+=(double)1/x;
	}
	cout<<setprecision(10)<<fixed<<(double)1/s;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
table = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  table[u] += 1
  table[v] += 1

for i in range(N + 1):
  if table[i] % 2:
    print("NO")
    exit(0)
print("YES")

Measured memory_bytes: 41324
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int r; cin >> r;
    cout << 3*r*r<<endl;
    
 

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 

int main()
{
  //  freopen("input.txt","r",stdin);
   ios::sync_with_stdio(0);
// cin.tie(0);
ll n,w;
cin>>n>>w;
vector<ll>a(n),b(n);
REP(i,0,n-1)
cin>>a[i]>>b[i];
vector<vector<ll>>dp(w+1,vector<ll>(n+1));
for(int k=1;k<=n;++k){
  for(int i=1;i<=w;++i){
    if(i-a[k-1]>=0)
    dp[i][k]=max({dp[i][k],dp[i][k-1],dp[i-a[k-1]][k-1]+b[k-1]});
    dp[i][k]=max(dp[i][k],dp[i][k-1]);
  }
}

cout<<dp[w][n];
    return 0;
}

Measured memory_bytes: 85156
#include<bits/stdc++.h>
using namespace std;
map<char,int>s;
char a[200005],a2[200005];
int len;
int main()
{
    scanf("%s",a);
    scanf("%s",a2);
    len=strlen(a);
    for(register int i=0;i<=len-1;i++)
    {
        if(s[a[i]]==0) s[a[i]]=a2[i]-'a'+1;
        else if(s[a[i]]!=a2[i]-'a'+1)
        {
            printf("No\n");
            exit(0);
        }
    }
    s.clear();
    for(register int i=0;i<=len-1;i++)
    {
        if(s[a2[i]]==0) s[a2[i]]=a[i]-'a'+1;
        else if(s[a2[i]]!=a[i]-'a'+1)
        {
            printf("No\n");
            exit(0);
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 640
a, b, x = gets.split.map(&:to_f)
rad = if x <= 0.5 * a * a * b
  Math.atan2(b, (x / (0.5 * a * b)))
else
  Math.atan2((a * a * b - x) / (0.5 * a * a), a)
end
puts rad / Math::PI * 180.0


Measured memory_bytes: 1788
n=int(input())
a=list(map(int,input().split()))
cnt=1
state=0
for i in range(1,n):
    if state==0:
        if a[i-1]<a[i]:
            state=1
        elif a[i-1]>a[i]:
            state=-1
    if state==1:
        if a[i-1]>a[i]:
            state=0
            cnt+=1
    if state==-1:
        if a[i-1]<a[i]:
            state=0
            cnt+=1
print(cnt)

#copy

Measured memory_bytes: 14252
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
t = ns()
ss = s+s

print('Yes') if t in ss else print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){

    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double a = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    printf("%.8lf",a);

}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;


int main(){
  string S;cin>> S;
  string ABC="ABC";
  int N=S.size();

  ll dp[N+1][4];

  for (int j=0;j<4;++j){
    dp[N][j]=(j==3)?1:0;
  }

  for (int n=N-1;n>=0;n--){
    for (int j=0;j<4;++j){
      ll m=(S[n]=='?')? 3:1;
      dp[n][j]=m*dp[n+1][j];
      if((j!=3)&&(S[n]=='?'||S[n]==ABC[j])){
        dp[n][j]+=dp[n+1][j+1];
      }
      dp[n][j]%=MOD;
    }
  }


  cout << dp[0][0]<< endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define N 4010
int he[N],ne[N<<1],e[N<<1],cnt=1;
int St[N],Ed[N],d[N],w[N<<1],vis[N],n,m;
vector<int> b[N<<1],c[N<<1];
void add(int u,int v){ne[++cnt]=he[u];he[u]=cnt;e[cnt]=v;}
bool dfs(int x,int fa,int Ed,vector<int>& b){
	if (x==Ed)return 1;
	for (int i=he[x];i;i=ne[i])
		if (e[i]!=fa){
			b.push_back(i);
			if (dfs(e[i],x,Ed,b)) return 1;
			b.pop_back();
		}
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++){
		int x,y; scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	//	w[i*2]=0; w[i*2+1]=1;
	}
	for (int i=0;i<m;i++){
		scanf("%d%d",&St[i],&Ed[i]);
		dfs(St[i],0,Ed[i],b[i]);
		for (int j=0;j<b[i].size();j++){
			c[b[i][j]/2].push_back(i);
			d[b[i][j]/2]++;
		}
	}
//	for (int i=1;i<n;i++) printf("%d ",d[i]); puts("");
	int ans=0;
	for (int i=1;i<n;i++) ans+=min(2,d[i]);
	printf("%d\n",ans);
	for (;;){
	//	for (int i=1;i<n;i++) printf("%d ",w[i]); puts("");
		int p=0,q=-1;
		for (int i=1;i<n;i++)
			if (d[i]==1 && w[i*2]!=w[i*2+1]){
				p=i; break;
			}
		if (p==0){
			for (int i=1;i<n;i++)
				if (d[i]>=2){
					p=i;	break;
				}
		}
		if (p==0) break;
		for (int i=0;i<c[p].size();i++)
			if (!vis[c[p][i]]){ q=c[p][i]; break;}
		vis[q]=1;
		for (int i=0;i<b[q].size();i++)
			if (b[q][i]/2==p){
				if (w[b[q][i]]){
					swap(St[q],Ed[q]);
					for (int j=0;j<b[q].size();j++) b[q][j]^=1;
				}
				for (int j=0;j<b[q].size();j++){
					d[b[q][j]/2]--;
					w[b[q][j]]=1;
				}
				break;
			}
	}
	for (int i=0;i<m;i++) printf("%d %d\n",St[i],Ed[i]);
//	puts("");
	return 0;
}
			

Measured memory_bytes: 16000
#include<stdio.h>
#include<math.h>

int main(void){
    int n,m;
    scanf("%d%d", &n, &m);
    int k[m][n];
    int s[m];
    int p[m];
    for(int i = 0; i < m; i++){for(int j = 0; j < n+1; j++){k[i][j] = 0;}}
    for(int i = 0; i < m; i++){
        scanf("%d", &s[i]);
        for(int j = 0; j < s[i]; j++){
            scanf("%d", &k[i][j]);
        }
    }
    for(int i = 0; i < m; i++){scanf("%d", &p[i]);}
    
    
    int ar[n];
    int cnt[m];
    int ok = 0;
    int ans = 0;
    for (int i=0; i<pow(2,n); i++) {
	    for (int j=0; j<n; j++) {
			if ((1&i>>j) == 1){
			    ar[j] = 1;
			}else{
			    ar[j] = 0;
			}
		}

		
		for(int q = 0; q < m; q++){cnt[q] = 0;}

		ok = 0;
		for(int j = 0; j < m; j++){
		    for(int l = 0; l < s[j]; l++){
		        if(k[j][l] && ar[k[j][l]-1]){
		           cnt[j]++;
		        }
		    }
		    if(cnt[j]%2 == p[j]){ok++;}
		}
		
		if(ok == m){ans++;}
    }
    printf("%d\n", ans);
    
    return 0;
}


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct node {int to,cost; };

typedef vector< vector<node> > G;

inline void add_edge(G& g,int from,int to,int cost=1){
	node in; in.to=to; in.cost=cost;
	g[from].pb(in);
}

inline void add_both_edge(G& g,int from,int to,int cost=1){	
	add_edge(g,from,to,cost);
	add_edge(g,to,from,cost);
}

bool visit(const G& g,int v,vi& order, vi& color) {
	color[v]=1;
	rep(i,g[v].size()){
		if(color[g[v][i].to]==2) continue;
		if(color[g[v][i].to]==1) return false;
		if(!visit(g,g[v][i].to,order,color))return false;
	}
	order.pb(v); color[v] = 2;
	return true;
}

bool topologicalSort(const G& g, vi& order) {
	int v=g.size();
	vi color(v);
  	rep(i,v)if(!color[i]&&!visit(g,i,order,color)) return false;
  	reverse(order.begin(),order.end());
	return true;
}

int main(void){
	int n,m;
	cin >> n >> m;
	
	G graph(n);
	
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		add_edge(graph,a,b,1);
	}
	
	vi order;
	topologicalSort(graph,order);
	
	bool other=false;
	
	rep(i,order.size()-1){
		bool ok=true;
		int e=graph[order[i]].size();
		rep(j,e) if(graph[order[i]][j].to==order[i+1])ok=false;
		other|=ok;
	}
	rep(i,order.size()) cout << order[i]+1 << endl;
	cout << other << endl;
	return 0;
}

Measured memory_bytes: 2772
#include<bits/stdc++.h>
#define ll long long
#define pa pair<int,int>
using namespace std;
int n,m;
struct Ds{
    int a,b;
}w[100004];
inline bool dex(Ds A,Ds B){
    return A.a==B.a?A.b>B.b:A.a<B.a;
}
priority_queue<pa,vector<pa>,greater<pa> >q;
int main(){
    scanf("%d%d",&n,&m);
    while(!q.empty())q.pop();
    for(int i=1;i<=n;i++){
        scanf("%d%d",&w[i].a,&w[i].b);
        w[i].a=m-w[i].a+1;
    }
    sort(w+1,w+n+1,dex);
    ll ans=0;int ct=1;
    for(int i=1;i<=m;i++){
        while(ct<=n&&w[ct].a<=i){
            if(w[ct].a<=0){
                ct++;
                continue;
            }
            if(q.size()<i){
                q.push({w[ct].b,w[ct].a});
            }
            else{
                pa tp=q.top();q.pop();
                tp=max(tp,{w[ct].b,w[ct].a});
                q.push(tp);
            }
            ct++;
        }
    }
    while(!q.empty()){
        ans+=q.top().first;q.pop();
    }
    printf("%lld\n",ans);
    return 0;
}


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

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

    if (a == b) cout << "Draw" << endl;
    else if (a > b) {
        if (b == 1) cout << "Bob" << endl;
        else cout << "Alice" << endl;
    }
    else if (a < b) {
        if (a == 1) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
    
    return 0;
}

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

int main()
{
  int n, m, ans = 0;
  cin >> n >> m;
  int s[10][10];
  int p[10], k[10];
  for (int i = 0; i < m; i++)
  {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++)
      cin >> s[i][j];
  }
  for (int i = 0; i < m; i++)
    cin >> p[i];

  bool
      sw[10];

  for (int i = 0; i < (1 << n); i++)
  {
    int count = 0;
    for (int j = 0; j < n; j++)
    {
      if ((1 << j) & i)
        sw[j] = true;
      else
        sw[j] = false;
    }
    for (int j = 0; j < m; j++)
    {
      int cn = 0;
      for (int t = 0; t < k[j]; t++)
      {
        if (sw[s[j][t] - 1])
          cn++;
      }
      if (cn % 2 == p[j])
        count++;
    }
    if (count == m)
      ans++;
  }
  cout << ans << endl;
}

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

public class Test
{
	public static void Main()
	{
        string line = Console.ReadLine();
        string target = Console.ReadLine();
        string s = "";
        bool can = false;

        for(int i = 0 ; i < line.Length ; i++){
            if(line == target){
                can = true;
            }
            s = line[line.Length-1].ToString();
            line = s + line;
            line = line.Remove(line.Length-1, 1);
        }
        
        if(can){
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }                                                                                                                                   
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))

int main() {
    // input
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> B[i];
    REP(i, N) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    // calculation
    ll now_B, num_A, num_C, res = 0;
    ll idx_bound_A, idx_bound_C;

    for (ll i = 0; i < N; ++i) {
        now_B = B[i];
        num_A = 0;
        num_C = 0;

        // 1 段目: now_B 未満の数を求める
        auto iter_A = lower_bound(A.begin(), A.end(), now_B);
        idx_bound_A = distance(A.begin(), iter_A);
        num_A = (iter_A == A.end())? N: (idx_bound_A + 1) - 1;

        // 3 段目: now_B より大きい数
        auto iter_C = upper_bound(C.begin(), C.end(), now_B);
        idx_bound_C = distance(C.begin(), iter_C);
        num_C = (iter_C == C.end())? 0: N - idx_bound_C;

        res += num_A*num_C;
    }

    cout << res << "\n";

    return 0;
}

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

using namespace std;

#define ll long long

ll a[100010], b[100010], c[100010];

main()
{
    ll n, i, j, k, l, r=0;
    cin>>n;

    for(i=0; i<n; i++) scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);

    for(i=1; i<=n; i++)
    {
        if(b[i-1]>c[i-1]) a[i]+=b[i-1];
        else a[i]+=c[i-1];

        if(a[i-1]>b[i-1]) c[i]+=a[i-1];
        else c[i]+=b[i-1];

        if(a[i-1]>c[i-1]) b[i]+=a[i-1];
        else b[i]+=c[i-1];
    }

    if(a[n]>r) r=a[n];
    if(b[n]>r) r=b[n];
    if(c[n]>r) r=c[n];
    cout<<r<<endl;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
string t[2][2][2];
string u[192];
bool used[8];
int n,flg;

int checkch='A'-'a';

bool input();
string ra(string,int);
string rb(string,int);
string rc(string,int);
void dfs(int,int,int);

inline bool check_ch(char x,char y){
  return (x+checkch==y||x-checkch==y);
}

int main(){

  while(input()){
    for(int i=0;i<8;i++)used[i]=false;
    
    flg=0;
    dfs(0,0,0);
    if(flg)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

void dfs(int x,int y,int z){
  //cout<<x<<' '<<y<<' '<<z<<endl;
  if(x==2){x=0;y++;}
  if(y==2){y=0;z++;}
  if(x==0&&y==0&&z==2)flg=1;

  for(int j=0;j<8;j++){
    if(used[j])continue;
    for(int i=j*24;i<j*24+24;i++){
      if(flg)return;
      if(x>0)if(check_ch(t[x-1][y][z][2],u[i][3])==false)continue;
      if(y>0)if(check_ch(t[x][y-1][z][4],u[i][1])==false)continue;
      if(z>0)if(check_ch(t[x][y][z-1][0],u[i][5])==false)continue;

      used[j]=true;
      t[x][y][z]=u[i];
      dfs(x+1,y,z);
      used[j]=false;
    }
  }
}

bool input(){
  string in,str,str2;
  n=0;
  for(int i=0;i<8;i++){
    cin>>in;if(in=="0")return false;
    for(int j=0;j<6;j++){
      if(j<4)str=ra(in,j);
      else if(j==4)str=rb(in,1);
      else str=rb(in,3);
      for(int k=0;k<4;k++){
	str2=rc(str,k);
	u[n++]=str2;
      }
    }
  }
  return true;
}

string ra(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[3];
    str[3]=str[0];
    str[0]=str[2];
    str[2]=str[5];
    str[5]=tmp;
  }
  return str;
}
string rb(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[5];
    str[5]=str[4];
    str[4]=str[0];
    str[0]=str[1];
    str[1]=tmp;
  }
  return str;
}
string rc(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[1];
    str[1]=str[2];
    str[2]=str[4];
    str[4]=str[3];
    str[3]=tmp;
  }
  return str;
}

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

int main()
{
    int K,S;
    cin >> K >> S;
    int count=0;
    rep(x,K){
        rep(y,K){
            if(S-x-y<=K&&S-x-y>=0){
                count++;
            }
        }
    }
    cout << count << endl;
}

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

using namespace std;
using ll = long long;
const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> A(n);
    for (int i = 0; i < n; ++i) {
        int x, l;
        cin >> x >> l;
        A[i] = make_pair(x + l, x - l);
    }
    sort(A.begin(), A.end());
    int cnt = 0;
    int r = -2e9;
    for (int i = 0; i < n; ++i) {
        if (A[i].second >= r) {
            r = A[i].first;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(k: i32, s: String,);
    if s.len() <= k as usize {
        println!("{}", s);
    } else {
        println!("{}...", &s[0..k as usize]);
    }
}


Measured memory_bytes: 2116
#include <iostream>

using namespace std;

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int x = K; 0 <= x; --x) {
        for (int y = K; 0 <= y; --y) {
            int rest = S - (x + y);
            if (0 <= rest && rest <= K) ++count;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256