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

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;

int n;
int a[N];
int coun[N];
bool setwise,pairwise;
int ans,flag;

void factorize(int n)
{
    if(n%2==0)
    {
        coun[2]++;
        while(n%2==0)
        n/=2;
    }
    for(int i=3;i<=sqrt(n);i+=2)
    {
        if(n%i==0)
        {
            coun[i]++;
            while(n%i==0)
            n/=i;
        }
    }
    if(n>1)
    coun[n]++;
}
int main()
{
    scf(n);
    scf(a[0]);
    ans=a[0];
    rep(i,1,n)
    {
        scf(a[i]);
        ans=gcd(ans,a[i]);
    }
    if(ans==1)
    setwise=true;

    rep(i,0,n)
    {
        factorize(a[i]);
    }

    rep(i,2,N)
    {
        if(coun[i]>1)
        flag=1;
    }
    if(flag==0)
    pairwise=true;

    if(pairwise)
    printf("pairwise coprime");
    else if(setwise)
    printf("setwise coprime");
    else
    {
        printf("not coprime");
    }
    
return 0;
}

Measured memory_bytes: 11444
#include<stdio.h>
#include<stdlib.h>
#define TYPE int
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int A[100000];
int main() {
	int N;
	int num = 1;
	int i;
	int ans = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	qsort(A, N, sizeof(int), cmp);
	for (i = 0; i < N; i++)
	{
		while (A[i] == A[i + 1])
		{
			num++;
			i++;
		}
		if (num < A[i])
		{
			ans += num;
		}
		else if (num > A[i])
		{
			ans += num - A[i];
		}
		num = 1;
	}
	printf("%d\n", ans);

	return 0;
}

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

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n)cin>>a[i];
  int ans=a[0];
  rep(i,n){
    ans = gcd(ans,a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r,d) for(ll i=(l);i<(r);i+=(d))
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
char s[60][60];
int main(void){
    ll H, W;
    scanf("%lld %lld", &H, &W);
    rep(i, 1, H+1, 1) scanf("%s", s[i]+1);
    rep(i, 1, H+1, 1){
        rep(j, 1, W+1, 1){
            if(s[i][j]=='#'){
                if(s[i-1][j]!='#' && s[i+1][j]!='#' && s[i][j-1]!='#' && s[i][j+1]!='#'){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	vector<int>v(4);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9)cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,w,a[10005],ans[105][105],col;
vector<int> v;
int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&col);
	for(int i=1;i<=col;i++)
	{
		scanf("%d",&a[i]);
		for(int j=1;j<=a[i];j++)
		{
			v.push_back(i);
		}
	}
	for(int i=1;i<=w;i++)
	{
		if(i%2==1)
		{
			for(int j=1;j<=h;j++)
			{
				ans[j][i]=v[h*(i-1)+j-1];
			}
		}else
		{
			for(int j=h;j>=1;j--)
			{
				ans[j][i]=v[h*(i-1)+h-j];
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}

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

int main(void){
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    //cout << s << " " << t << endl;
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<random>

//#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define ALL(v) (v).begin() , (v).end()
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

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

#define int long long
const int mod = 1e9 + 7;

int sum(int a[] , int l , int r){

	int res = 0;
	for(int i = l ; i <= r; ++i)
		res += a[i];
	return res;
}
void solve(){

	int n ;
	cin>>n;
	int a[n];
	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];

	int dp[n+1][n+1];
	
	for(int i = 0 ; i < n ; ++i)
		for(int j = 0 ; j < n ; ++j)
			dp[i][j] = 1e18;

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

	for(int len = 2 ; len <= n ; ++len){

		for(int i = 0 ; i < n - len + 1 ; ++i){

			int j = i + len - 1;
			int tot = sum(a , i , j);
			for(int k = i ; k < j ; ++k){

				int x = min(dp[i][k] + dp[k+1][j] , dp[i][k] + dp[k+1][j]);

				dp[i][j] = min(dp[i][j] , x + tot);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
}

signed main(){

    fast;
    //freopen("output.txt" , "w" , stdout);
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>
#include<set>
#include <fstream>
#include<list>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define loopj(x,y) for(int j = x;j<(y);j++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define rloopj(x,y) for(int j = x;j>=(y);j--)


#define nl cout<<"\n";
#define ll long long int
#define mod  1000000007


using namespace std;

int main()
{

	ios :: sync_with_stdio(false);
	cin.tie(nullptr);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, D;
	cin >> n >> D;

	int count = 0;
	while (n--)
	{
		ll x, y;
		cin >> x >> y;
		double d = sqrt(1.0 * x * x + y * y);
		if (d <= D * 1.0)
			count++;
	}

	cout << count;
	return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		sc.close();
		int ans = a * b / 2;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22740
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
	char num[4];
	scanf("%s", num);

	if ((num[0] == num[1]) || (num[1] == num[2]) || (num[2] == num[3])) {
		printf("Bad");
	}
	else {
		printf("Good");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int a;
	cin>>s>>a;
	int cnt=0;
	for(int i=1;i<=a;i++){
		int b;
		cin>>b;
		if(b==1){
		    cnt++;
		}
		else {
			int c;
			char ch;
			cin>>c>>ch;
			if(c==1){
			 if(cnt%2==0)
			s.insert(s.begin(),ch);
			else s.insert(s.end(),ch);
			}
			else {
				if(cnt%2==0)
			s.insert(s.end(),ch);
			else s.insert(s.begin(),ch);}
		}
	}
	if(cnt%2==0)
	cout<<s<<endl;
	else {
	    reverse(s.begin(),s.end());
	    cout<<s<<endl;
	}
}

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

if N > 1 and M > 1:
    print(N*M-(2*(N+M)-4))
elif N == 1 and M > 1:
    print(M-2)
elif M == 1 and N > 1:
    print(N-2)
else:
    print(1)

Measured memory_bytes: 3060
N = int(input())
hList = [int(i) for i in input().split()]

ans = 0
height = 1
while(True):
    endFlag = True
    waterFlag = False
    for h in hList:
        if h >= height:
            if not waterFlag:
                ans += 1
            endFlag = False
            waterFlag = True
        elif h < height:
            waterFlag = False
    height += 1
    if endFlag:
        break

print(ans)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
main(){
	int h,w;cin>>h>>w;
	string s[10];
	for(int i=0;i<h;i++)cin>>s[i];
	bool flag=false;
	for(int i=1;i<h;i++)for(int j=1;j<w;j++)if(s[i][j-1]!='.'&&s[i-1][j]!='.')flag=true;
	cout<<(flag?"Impossible":"Possible")<<endl;
}

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

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

void no(){
	cout<<"No"<<endl;
	exit(0);
}
void yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

//KUPC2017J
//AOJDSL1A
//without rank
struct unionfind{
	vi p,s;
	int c;
	unionfind(int n):p(n,-1),s(n,1),c(n){}
	int find(int a){
		return p[a]==-1?a:(p[a]=find(p[a]));
	}
	//set b to a child of a
	bool unite(int a,int b){
		a=find(a);
		b=find(b);
		if(a==b)return false;
		p[b]=a;
		s[a]+=s[b];
		c--;
		return true;
	}
	bool same(int a,int b){
		return find(a)==find(b);
	}
	int sz(int a){
		return s[find(a)];
	}
};

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

	int n,m,q;cin>>n>>m>>q;

	vc<pi> dup;
	unionfind uf(n);
	rep(_,q){
		int u,v,f;cin>>u>>v>>f;
		if(f==0)
			uf.unite(u,v);
		else
			dup.eb(u,v);
	}

	if(m==n-1){
		if(dup.size())no();
		yes();
	}

	for(auto e:dup)
		if(uf.same(e.a,e.b))no();

	if(m<=n-uf.c+uf.c*(uf.c-1)/2)yes();
	else no();
}


Measured memory_bytes: 3956
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define MOD 1000000007
#define PI 3.14159265358979323846

ll n,k;
int t;
ll m, M;



int main() {
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	double a , b, h ,m ;
	cin >> a >> b >> h >> m;

	double m_deg = m * 6.0;
	double h_deg = h * 30.0 + (m/2.0);

	double diff = abs(m_deg - h_deg);
	diff = min(diff, 360-diff);


	double cos_theta = cos ( diff * PI / 180.0);

	double res = sqrt(a*a + b*b - 2*a*b*cos_theta);

	cout<<fixed<<setprecision(15);
	cout<< res<<endl;

	return 0;

}

Measured memory_bytes: 4220
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string k;
int d;

ll dp[10010][11][101];

ll solve() {
    dp[0][0][0] = 1;
    int len = (int)k.size();
    for (int i = 1; i <= len; i++) {
        for (int v = 0; v < 10; v++) {
            for (int r = 0; r < d; r++) {
                for (int u = 0; u < 10; u++) {
                    dp[i][v][r] += dp[i-1][u][(r-v%d+d)%d];
                    dp[i][v][r] %= mod;
                }
            }
        }
    }
    
    ll res = 0;
    for (int j = 0; j < (int)(k[0]-'0'); j++) {
        res += dp[len][j][0];
        res %= mod;
    }
    int sum = (int)(k[0]-'0') % d;
    for (int i = len-1; i > 0; i--) {
        for (int j = 0; j < (int)(k[len-i]-'0'); j++) {
            res += dp[i][j][(d-sum)%d];
            res %= mod;
        }
        sum += (int)(k[len-i]-'0');
        sum %= d;
    }
    if (sum == 0) {
        res += 1;
        res %= mod;
    }
    res += mod-1;
    res %= mod;
    return res;
}

void input() {
    cin >> k >> d;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 87040
#include <stdio.h>
void X(int S[],int N){
  int i;
  for (i=0;i<N;i++){
    if (i>0)
      printf (" ");
    printf ("%d",S[i]);
  }
  printf ("\n");
}
void Y(int A[], int N) {
  int i,j,v;
  for (i=1;i<N;i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 &&A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    X(A,N);
  }
}

int main()
{
  int A,i;
  int hi[100];

  scanf ("%d",&A);
  for (i=0;i<A;i++)
    scanf("%d",&hi[i]);
  X(hi,A);
  Y(hi,A);

  return 0;
}
  



Measured memory_bytes: 2048
//g++ -std=c++14 test.cpp -o test.out

//BIT
//できること：累積和を動的に更新しながら区間和をO(logN)で取れる
//区間ではなく一個の値ずつにしか加算できない
//セグ木より定数倍高速だが機能に制限あり

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//BIT
//できること：累積和を動的に更新しながら区間和をO(logN)で取れる
//区間ではなく一個の値ずつにしか加算できない
//セグ木より定数倍高速だが機能に制限あり
//BITの配列は必ず1-indexedなことに注意
//このライブラリは外からは0-indexedとみなして処理できるよう改造済み

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
    int n;
    vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    //要素iにxを足す
    void add(int i, T x) {
        i++;
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    T sum(int i) {
        i++;
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    //[l,r)の和をとる
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
    //格納されている数を表示　デバッグ用
    void debug(){
        cout << "bit:" << endl;
        for(int i=0;i<n;i++){
            cout << sum(i,i+1) << " ";
        }
        cout << endl;
    }
};

LL N,Q;
vector<LL> C;
//r,l,index
vector<tuple<LL,LL,LL>> RLI;

vector<LL> ans;

void solve(){
    sort(RLI.begin(),RLI.end());
    //色iが最後に出てきたインデックスをnum[i]とおく
    //-1ならまだ未登場
    vector<LL> num(N+1,-1);

    BIT<LL> bit(N+1);
    //今見ている領域の右端
    int now_right = 0;
    for(int i=0;i<Q;i++){
        LL left = get<1>(RLI[i]);
        LL right = get<0>(RLI[i]);
        while(now_right<=right){
            bit.add(now_right,1);
            if(num[C[now_right]]!=-1){
                bit.add(num[C[now_right]],-1);
            }
            num[C[now_right]] = now_right;
            now_right++;
        }
        int index = get<2>(RLI[i]);
        ans[index] = bit.sum(left,right+1);
    }
}

int main(){
    cin >> N >> Q;
    C = vector<LL>(N);
    RLI = vector<tuple<LL,LL,LL>>(Q);
    ans = vector<LL>(Q);
    for(int i=0;i<N;i++) cin >> C[i];
    for(int i=0;i<Q;i++){
        LL l,r;cin >> l >> r;
        l--;
        r--;
        RLI[i] = tuple<LL,LL,LL>(r,l,i);
    }

    solve();

    for(int i=0;i<Q;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 30328
A, B, C, D = map(int, input().split())
if A <= C <= B and A <= D <= B:
    print(D-C)
elif A <= C <= B and B <= D:
    print(B-C)
elif C <= A <= D and A <= D <= B:
    print(D-A)
elif C <= A and B <= D:
    print(B-A)
else:
    print(0)

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

int solve(
    int n,
    const std::vector<std::vector<int>>& switches,
    const std::vector<int>& ps)
{
  int result = 0;
  const int m = static_cast<int>(switches.size());
  const int max = 1 << n;
  for (int i = 0; i < max; ++i) {
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      const auto& v = switches[j];
      const auto count = std::count_if(
          v.begin(), v.end(), [i](int s) { return i & (1 << (s - 1)); });
      if (count % 2 != ps[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ++result;
  }

  return result;
}

int main()
{
  int n, m;
  std::cin >> n >> m;

  std::vector<std::vector<int>> switches(m);
  for (auto& v : switches) {
    int k;
    std::cin >> k;

    v.resize(k);
    for (auto& s : v) {
      std::cin >> s;
    }
  }

  std::vector<int> ps(m);
  for (auto& p : ps) {
    std::cin >> p;
  }

  std::cout << solve(n, switches, ps) << std::endl;
}


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

int main() {
  int n, m, x;
  std::cin >> n >> m >> x;

  auto gates = std::vector<bool>(n);
  for (int i = 0; i < m; i++) {
    int j;
    std::cin >> j;
    gates[j] = true;
  }

  int cnt = 0;
  for (int i = 0; i < x; i++) {
    if (gates[i]) cnt++;
  }
  std::cout << (cnt < m - cnt ? cnt : m - cnt) << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    ll n;
    cin >> n;
    ll right = 0;
    ll sum = 0;
    ll ans=0;
    vector<ll> a(n,0);
    FOR(i,0,n) cin >> a[i];
    for(ll left=0;left<n;left++){
        while((right<n) && ((sum^a[right])==(sum+a[right]))){
            //rightを審査し条件に合うなら進める
            sum+=a[right];
            right++;

        }
        
        //break した状態で right は条件を満たす最大なので ans に加える
        ans+=right-left;

        if(left==right){
            //right をい増やして再審査
            right++;
        }else{
            //left が right を追いかける
            sum-=a[left];
        }

    }
    
    cout << ans << endl;

}

//7373 
//10**12 9 1000

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String s = br.readLine();
            long n = Long.parseLong(s);
            long sn = 0;
            for (int i = 0; i < s.length(); i++) {
                long tmp = Long.parseLong(s.substring(i, i + 1));
                sn += tmp;
            }
            if (n % sn == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21204
import pprint
N=int(input())
A=list(map(int,input().split()))
bitlen=42
flag=1
exor=0
andsum=0
ex=[0]*bitlen
an=[0]*bitlen
num=0
for i in range(2,N):
    exor=exor^A[i]
andsum=(A[0]+A[1])-exor

if (andsum%2!=0)or(andsum<0):
    flag=0
else:
    andsum=andsum//2
    for i in range(bitlen):
        if (exor>>i)&1:
            ex[i]=1
        if (andsum>>i)&1:
            an[i]=1
    num=andsum
    for i in range(bitlen):
        if (an[i]==1)and(ex[i]==1):
            flag=0
            break
    if num>A[0]:
        flag=0
    for i in range(bitlen-1,-1,-1):
        if ex[i]==1:
            if num+pow(2,i)<=A[0]:
                num=num+pow(2,i)
    #print(num)
    if num==0:
        flag=0
if flag==0:
    print(-1)
else:
    print(A[0]-num)


Measured memory_bytes: 72044
(defun solve (s k &optional (cnt 0))
  (cond
    ((= cnt k) 1)
    ((not (equal (first s) #\1)) (first s))
    (t (solve (rest s)
              k
              (1+ cnt)))))

(defun main ()
  (let ((s (concatenate 'list (read-line)))
        (k (read)))
    (princ (solve s k))
    (fresh-line)))

(main)


Measured memory_bytes: 24588
loop = int(input())

tall = list(map(int, input().split()))
front = tall[0]
standard = front
result = 0


for i in range(1, loop):
  back = tall[i]
  
  if back-standard > 0:
    standard = back
  elif back-standard < 0:
    result += standard - back
  front = back

print(result)

Measured memory_bytes: 32368
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define debug(x) cerr << #x << ": " << (x) << endl
#define debug2(x, y) cerr << #x << ": " << (x) << " " << #y << ": " << y << endl;
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;
  VI ks(Q);
  REP (i, Q) cin >> ks[i];

  for (int k: ks) {
    int ans = 0;
    int sum = 0;
    int d = 0, m = 0;
    REP (i, k) {
      if (S[i] == 'D') {
        d++;
      } else if (S[i] == 'M') {
        sum += d;
        m++;
      } else if (S[i] == 'C') {
        ans += sum;
      }
    }
    REP (i, N - k) {
      if (S[i] == 'D') {
        sum -= m;
        d--;
      } else if (S[i] == 'M') {
        m--;
      }
      if (S[i + k] == 'D') {
        d++;
      } else if (S[i + k] == 'M') {
        sum += d;
        m++;
      } else if (S[i + k] == 'C') {
        ans += sum;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1948
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    int S=0;
    int T=N;
    while(T>0){
        S+=T%10;
        T/=10;
    }
    print(N%S==0?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, t[100], ta = 0;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	ta = t[0];
	for (int i = 0; i < n - 1; i++) {
		ta = lcm(ta, t[i + 1]);
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools
import fractions

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

def main():
    N,M = isRaw()
    isAC = [False]*N
    pena = [0]*N
    for idx in range(M):
        p,S = ssRaw()
        p = int(p)
        if S=="AC":
            isAC[p-1]=True
        if S=="WA":
            if not isAC[p-1]:
                pena[p-1]+=1
    numPena = sum([pena[idx] for idx in range(N) if isAC[idx]])
    return str(sum(isAC))+" "+str(numPena)
        


if __name__ == "__main__":
    print(main())


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  vector<pll> ai(n);
  rep(i,n)ai[i]={a[i],i+1};
  sort(rbegin(ai),rend(ai));

  auto dp = vec<ll>(n+1,n+1);
  for(int i=0;i<=n;++i)for(int j=0;j<=n;++j){
    if(i+j==0)continue;
    if(i+j>n)continue;
    auto [v,k] = ai.at(i+j-1);
    dump("i,j",i,j);
    dump("v,k",v,k);
    if(i){
      dp[i][j] = max(dp[i][j],dp[i-1][j]+v*abs(i-k));
      dump("left",v,abs(i-k));
    }
    if(j){
      dp[i][j] = max(dp[i][j],dp[i][j-1]+v*abs((n-j+1)-k));
      dump("right",v,abs((n-j+1)-k));
    }
    //dump(i,j,dp[i][j]);
  }
  ll ans = 0;
  for(int i=0;i<=n;++i){
    ans = max(ans,dp[i][n-i]);
  }
  cout<<(ans)<<endl;

  for(auto v:dp)dump(v);

}

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

int main(){
    int n = 0;
    string s;
    int flag=0;
    int a=0,b=0,c=0;
    cin >> s;

    for (int i = 0; i < s.length(); i++){
        if(s[i]=='a')a++;
        if(s[i]=='b')b++;
        if(s[i]=='c')c++;
    }
    if(a==1 && b==1 && c==1)flag=1;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	auto pi = acos(-1);

	double a, b, x;
	cin >> a >> b >> x;

	auto ans = 0.0;
	if (a * a * b >= x * 2)
	{
		ans = atan(2 * x / (a * b * b));
		ans = (ans * 180) / pi;
		ans = 90 - ans;
	}
	else
	{
		auto r = a * a * b - x;
		ans = atan(2 * r / (a * a * a));
		ans = (ans * 180) / pi;
	}

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 105

int M[N][N];
int l[N];
int queue[N];


void bfs(int n)
{
  int i;
  for(i=1;i<=n;i++)
    l[i]=-1;
  int qH=0,qT=0;
  queue[qT++]=1;
  l[1]=0;
  while(qH!=qT){
    int v=queue[qH++];
    for(i=1;i<=n;i++){
      if(l[i]==-1 && M[v][i]==1){
	l[i]=l[v]+1;
	queue[qT++]=i;
      }
    }
  }
}
int main()
{
  int n,i,j,u,v,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&r);
    for(j=0;j<r;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }
  bfs(n);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, l[i]);
  }
  return 0;
}



Measured memory_bytes: 2120
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

//#[proconio::fastout]
fn main() {
    input!(
        n: usize,
        s: Chars,
    );
    let s: Vec<_> = s.into_iter().map(|d| if d == 'E' { 0 } else { 1 }).collect();
    let mut scan = Vec::with_capacity(n);
    scan.push(s.iter().skip(1).fold(0, |count, &x| count + 1 - x));
    let mut pref = scan[0];
    for w in s.windows(2) {
        let (curr, next) = (w[0], w[1]);
        pref += curr + next - 1;
        scan.push(pref);
    }
    println!("{}", scan.iter().min().unwrap());
}


Measured memory_bytes: 4744
import java.util.*;

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

        int result = num1 <= 9 && num2 <= 9 ? num1 * num2 : -1;
        System.out.println(result);

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n, ans=0;
  cin >> n;
  string s;
  cin >> s;
  ll i=0;
  while(i < n-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
      ans++;
    i++;
  }
  cout << ans << endl;
}



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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if ((a * 100 + b * 10 + c) % 4 == 0) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

map<int, int> mp;
void input() {
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
}
int mem[MX + 3333];
void solve() {
  bool err = false;
  int ans = 1;
  rep(j, 0, N - 1) {
    int i = va[j];
    mem[i]++;

    if (i == 0) {
      if (mem[0] == 1) {
        ans *= 3;
      }
      if (mem[0] == 2) {
        ans *= 2;
      }
      if (mem[0] == 3) {
        ans *= 1;
      }
      if (mem[0] > 3) {
        err = true;
      }
      ans %= MOD;
      continue;
    }

    if (mem[i] - mem[i - 1] > 0) {
      err = true;
    }

    if (mem[i] - mem[i - 1] == 0) {
      ans = ans;  // no change
    }
    if (mem[i] - mem[i - 1] == -1) {
      ans *= 2;
    }
    if (mem[i] - mem[i - 1] == -2) {
      ans *= 3;
    }
    ans %= MOD;
  }

  if (err) {
    cout << 0 << endl;
    return;
  }
  cout << (ans) % MOD << endl;

  // int vali = 0;
  // for (auto x : va) {
  //   if (x==0){
  //     vali++;
  //   }
  //   mp[x]++;
  // }
  // for (auto x : mp) {
  //   cout << x.first << " : " << x.second << endl;
  // }
  // int ans = 1;
  // rep(i, 1, N - 1) {
  //   if (va[i - 1] == va[i]) {
  //     ans++;
  //   } else if (va[i - 1] == va[i] - 1) {
  //     ans = ans;
  //   } else {
  //     ans *= 3;
  //   }
  //   ans %= MOD;
  // }
  // cout << ans << endl;
  // ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,a=0,b=0,c=0,d=0,i;
    cin>>n;
    string s[100000];
    for(i=0;i<n;i++) cin>>s[i];
    for(i=0;i<n;i++)
    {
        if(s[i]=="AC") a++;
        else if(s[i]=="WA") b++;
        else if(s[i]=="TLE") c++;
        else if(s[i]=="RE") d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}

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

int main( void )
{
  int x;
  int ans;
  
  for( int i = 0; i < 5; i++ ) {
    cin >> x;
    if( x == 0 )
      ans = i + 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}

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;
    }
    string t=s.substr(0,n/2);
    string u=s.substr(n/2);
    if(t==u)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
inline int read(){
	char ch=getchar();
	int o=0;
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){
		o=(o<<3)+(o<<1)+(ch^48);
		ch=getchar();
	}
	return o;
}
int ans,n,k,h;
int main(){
	n=read();
	k=read();
	for(register int i=1;i<=n;i++)if(read()>=k)ans++;
	printf("%d",ans);
}

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


int main() {

    int n;
    ll Y;
    cin >> n >> Y;
    rep(x, n) {
        rep(y, n) {
            int z = n - x - y;
            if (z >= 0 && 10000*x+5000*y+1000*z == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

int main()
{
    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';
    m['C'] = 'G';
    m['G'] = 'C';

    char c;
    scanf("%c", &c);

    printf("%c\n", m[c]);

    return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b;

main() {
    cin >> a >> b;
    if (max(a,b) > 8) ct(":(")
    else ct("Yay!")
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC" << endl;
  }else if(r<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "algorithm"
#include "iostream"
#include "string"
#include "vector"

using namespace std; // std::を省略して書くことができる

int main() {
  int N, T;
  cin >> N >> T;
  int t[N];
  cin >> t[0];
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    cin >> t[i + 1];
    sum += min(T, t[i + 1] - t[i]);
  }
  cout << sum + T << endl;
}

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

Graph = {}
Node_list = []
visited = {}
d = {}
f = {}
t = 1

for i in range(N):
    
    tmp = input().split()
    id = tmp[0]
    Node_list.append(id)
    visited[id] = False

    if int(tmp[1]) != 0:
        Graph[id] = tmp[2:]
    else:
        Graph[id] = []
 


def dfs(node):
    global t

    if visited[node]:
        return

    visited[node] = True

    d[node] = t
    t += 1

    for no in Graph[node]:
        dfs(no)

    f[node] = t
    t += 1

for node in Node_list:
    dfs(node)

for node in Node_list:
    print(node, d[node], f[node])
    
    
    
    
    
    


Measured memory_bytes: 5712
from collections import defaultdict
from collections import Counter

H, W, N = map(int, input().split())

# 3*3マスの処理用リスト
dir = [[0, 0], [1, 0], [1, 1], [0, 1], [-1, 1],
       [-1, 0], [-1, -1], [0, -1], [1, -1]]

# そのマスを中心とする3*3グリッドに含まれる黒マスの数
dict = defaultdict(int)

for i in range(N):
    a, b = map(int, input().split())
    for dy, dx in dir:
        # 3*3グリッドは、H*Wの中に完全に含まれていなければならないことに注意
        if 2 <= a + dy <= H - 1 and 2 <= b + dx <= W - 1:
            dict[(a + dy, b + dx)] += 1

c = Counter(dict.values())
ans = [0 for _ in range(10)]

# ans[1], ans[2], ..., ans[9]を確定させる（ans[0]は後述）
for k, v in c.items():
    if v > 0:
        ans[k] = v

# 全体で作れる3*3グリッドは(H-2)*(W-2)個
# ans[1],...,ans[9]の総和を引くとans[0]になる
ans[0] = (H - 2) * (W - 2) - sum(ans[1:])

for i in range(10):
    print(ans[i])


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

using namespace std;

int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string ans;
  for (int i = 0; i < n; i++){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << "\n";
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 105;
int n, a[N], ans, k;
 
int main() {
	ios_base::sync_with_stdio(false);	
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];


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

			vector <int> v;
			int sum = 0, op = 0;

			for(int ii = 1; ii <= i; ii++)
				v.push_back(a[ii]), op++, sum += a[ii];
			for(int ii = n; ii >= j; ii--)
				v.push_back(a[ii]), op++, sum += a[ii];

			if(op > k) continue;
			
			sort(v.begin(), v.end());

			int i = 0;
			while(i < v.size() && op < k) {
				if(v[i] < 0) sum -= v[i];
				else break;
				op++;
				i++;
			}
			dbg(i, j, sum);
			ans = max(ans, sum);
		}
		cout << ans << '\n';
}	


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];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));

    }
    // for(int i=0;i<n;i++)
    //     cout<<dp[i]<<" "; 
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main( void ) {
	int n, sum, elmNum[ 9 ] = { 5, 3, 3, 3, 3, 3, 4, 3, 4 };
	char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

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

	while ( n-- ) {
		while ( scanf( "%c", &key ), key != '\n' ) {
			if ( key == '0' )
				continue;

			for ( sum = 0; scanf( "%c", &tmp ), tmp != '0'; sum++ ) ;
			putchar( ch[ key - '1' ][ sum % elmNum[ key - '1' ] ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 564