akhauriyash/Code-Regression huggingface dataset:
// 2011/05/04 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(!cin.eof()){
		string str;
		getline(cin, str);
		if(str.empty())
			continue;

		istringstream ist(str);
		char brd[3][3];
		for(int i=0; i<3; i++)
			for(int j=0; j<3; j++)
				ist >> brd[i][j];

		if(brd[0][0]=='o'&&brd[0][1]=='o'&&brd[0][2]=='o')
			cout << 'o' << endl;
		else if(brd[1][0]=='o'&&brd[1][1]=='o'&&brd[1][2]=='o')
			cout << 'o' << endl;
		else if(brd[2][0]=='o'&&brd[2][1]=='o'&&brd[2][2]=='o')
			cout << 'o' << endl;
		else if(brd[0][0]=='o'&&brd[1][0]=='o'&&brd[2][0]=='o')
			cout << 'o' << endl;
		else if(brd[0][1]=='o'&&brd[1][1]=='o'&&brd[2][1]=='o')
			cout << 'o' << endl;
		else if(brd[0][2]=='o'&&brd[1][2]=='o'&&brd[2][2]=='o')
			cout << 'o' << endl;
		else if(brd[0][0]=='o'&&brd[1][1]=='o'&&brd[2][2]=='o')
			cout << 'o' << endl;
		else if(brd[0][2]=='o'&&brd[1][1]=='o'&&brd[2][0]=='o')
			cout << 'o' << endl;
		else if(brd[0][0]=='x'&&brd[0][1]=='x'&&brd[0][2]=='x')
			cout << 'x' << endl;
		else if(brd[1][0]=='x'&&brd[1][1]=='x'&&brd[1][2]=='x')
			cout << 'x' << endl;
		else if(brd[2][0]=='x'&&brd[2][1]=='x'&&brd[2][2]=='x')
			cout << 'x' << endl;
		else if(brd[0][0]=='x'&&brd[1][0]=='x'&&brd[2][0]=='x')
			cout << 'x' << endl;
		else if(brd[0][1]=='x'&&brd[1][1]=='x'&&brd[2][1]=='x')
			cout << 'x' << endl;
		else if(brd[0][2]=='x'&&brd[1][2]=='x'&&brd[2][2]=='x')
			cout << 'x' << endl;
		else if(brd[0][0]=='x'&&brd[1][1]=='x'&&brd[2][2]=='x')
			cout << 'x' << endl;
		else if(brd[0][2]=='x'&&brd[1][1]=='x'&&brd[2][0]=='x')
			cout << 'x' << endl;
		else
			cout << 'd' << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	long long int ans,x,a,b,n;
	cin>>a>>b>>n;
    if(n>=b)
    x=b-1;
    else
    x=n;
    int p=(a*x)/b;
    int q=a*(x/b);
    ans=p-q;
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    cin >> a;

    int cnt = 0;
    vector<vector<int>> moves;
    rep(i, h - 1) rep(j, w) if (a.at(i).at(j) % 2 == 1) {
        a.at(i).at(j)--;
        a.at(i + 1).at(j)++;
        cnt++;
        moves.push_back({i, j, i + 1, j});
    }
    rep(j, w - 1) if (a.at(h - 1).at(j) % 2 == 1) {
        a.at(h - 1).at(j)--;
        a.at(h - 1).at(j + 1)++;
        cnt++;
        moves.push_back({h - 1, j, h - 1, j + 1});
    }

    cout << cnt << endl;
    for (auto &m: moves) rep(i, 4) cout << m.at(i) + 1 << " \n"[i == 3];
}

Measured memory_bytes: 10032
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n;
  vector<int> ar(2*n);
  for(int i = 0; i<2*n; i++) cin>>ar[i];
  sort(ar.begin(), ar.end());
  int ans = 0;
  for(int i = 0; i<2*n; i+=2) ans += ar[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int h,w,n,sr,sc;
    cin>>h>>w>>n>>sr>>sc;
    sr--;sc--;
    
    string s,t;
    cin>>s>>t;
    
    int down=0,up=h;
    if(s[n-1]=='U') down++;
    if(s[n-1]=='D') up--;
    rrep(i,n-1){
        if(t[i]=='U') up=min(up+1,h);
        if(t[i]=='D') down=max(down-1,0);
        
        if(s[i]=='U') down++;
        if(s[i]=='D') up--;
        
        if(down>=up){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(down>sr || sr>=up){
        cout<<"NO"<<endl;
        return 0;
    }
    
    int left=0,right=w;
    if(s[n-1]=='L') left++;
    if(s[n-1]=='R') right--;
    rrep(i,n-1){
        if(t[i]=='L') right=min(right+1,w);
        if(t[i]=='R') left=max(left-1,0);
        
        if(s[i]=='L') left++;
        if(s[i]=='R') right--;
        
        if(left>=right){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(left>sc || sc>=right){
        cout<<"NO"<<endl;
        return 0;
    }
    
    cout<<"YES"<<endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
int n;
string s;
set<string>ss;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (int i=1;i<=n;i++) cin>>s,ss.insert(s);
	printf("%d\n",(int)ss.size());
return 0;	
}

Measured memory_bytes: 19336
#include<bits/stdc++.h>
#define d double
#define lli	long long int
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define rep(i,a,b)	for(i=a;i<b;i++)
using namespace std;
lli sod(lli n)
{
	lli ans=0;
	while(n)
	{
		ans+=(n%10);
		n/=10;
	}
	return ans;
}
int main()
{
	lli a,b,i,j,ii=2,ji=2;
	cin >> a >> b;
	i=a;
	j=b;
	while(i!=j)
	{
		if(i<j)
		{
			i=ii*a;
			ii++;
		}
		else
		{
			j=b*ji;
			ji++;
		}
	}
	cout << i << endl;
	
	
	
	
	return 0; 
}

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

int main(){
    string str;
    
    getline(cin,str);
    
    for(int i=0;i<(int)str.size();i++){
        if( islower(str[i]) ){
            str[i]=toupper(str[i]);
        }else if( isupper(str[i]) ){
            str[i]=tolower(str[i]);
        }
    }cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXM=500000+7;
const int INF = 1e9 + 9;
int A[MAXM];
int L[MAXM];
int R[MAXM];
int cmp_count;
void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i < n1; i++){
		L[i] = A[left+i];
	} 
	for(int i = 0; i < n2; i++){
		R[i] = A[mid+i];
	}
	L[n1] = INF;
	R[n2] = INF;
	int i = 0;
	int j = 0;
	int k;
	for(k = left; k < right; k++){
		cmp_count++;
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
		}else{
			A[k] = R[j];
			j++;
		}
	}
}
void mergeSort(int A[], int left, int right){
	int mid;
	if(left+1<right){
		mid = (left+right)/2;
		mergeSort(A, left, mid);
		mergeSort(A	, mid, right);
		merge(A, left, mid, right);
	}
} 
int main() {
	cmp_count = 0;
	int n;
	cin >> n;
	
	for(int i=0; i<n; i++){
		cin>>A[i];
	}
	mergeSort(A, 0, n);
	for(int i = 0; i < n; i++){
		if(i!=0) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cmp_count << endl;
	
	return 0;
}


Measured memory_bytes: 6932
#include<stdio.h>

int main()
{
	char s[13]={1,2,3,4,5,6,7,8,9,10,11,12,13},
		 h[13]={1,2,3,4,5,6,7,8,9,10,11,12,13},
		 d[13]={1,2,3,4,5,6,7,8,9,10,11,12,13},
		 c[13]={1,2,3,4,5,6,7,8,9,10,11,12,13},
	   	 check;

	int count,i,j;
	i=0;
	scanf("%d",&count);
	while(i!=count){
		scanf("%c %d",&check,&j);	
		if(check!='\n'){		//??\????????????\n????????????

			j-=1;

			switch (check){		//??\???????????????????????????,????????????????????°??????\0?????£??\
				case 'S':
					s[j]='\0';
					break;
				case 'D':
					d[j]='\0';
					break;
				case 'H':
					h[j]='\0';
					break;
				case 'C':
					c[j]='\0';
					break;
			}
			i++;
		}
	}
						
	for(i=0;i<13;i++)				//\0??\????????°?????????????????????
		if(s[i]!='\0')
			printf("S %d\n",s[i]);
			
	for(i=0;i<13;i++)
		if(h[i]!='\0')
			printf("H %d\n",h[i]);

	for(i=0;i<13;i++)
		if(c[i]!='\0')
			printf("C %d\n",c[i]);
			
	for(i=0;i<13;i++)
		if(d[i]!='\0')
			printf("D %d\n",d[i]);		

	return 0;

}

Measured memory_bytes: 596
a, b, k = map(int, input().split())

ans = []
for i in range(a, a+k):
    if i > b:
        break
    ans.append(i)

for i in range(b-k+1, b+1):
    if i < a:
        break
    if not(i in ans):
        ans.append(i)

for i in ans:
    print(i)


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

int main() {
    string s, t = "CODEFESTIVAL2016";
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

#define NUM(a) (a - '0')

bool month(char *str) {
    int num = NUM(str[0])*10 + NUM(str[1]);
    if(num > 0 && num <= 12) { return true; }
    return false;
}

int main(void){
    char *str = (char*)malloc(6*sizeof(char));
    scanf("%s", str);
    bool my = month(str), ym = month(str+2);
    if(my && ym) { printf("AMBIGUOUS\n"); }
    else if (my) { printf("MMYY\n"); }
    else if (ym) { printf("YYMM\n"); }
    else { printf("NA\n"); }
    free(str);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

#include<vector>

using namespace std;

int main(){

int n;

cin>>n;

vector<int>vi(n);

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

 vi[i]=0;

}

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

int x;

cin>>x;

vi[x-1]+=1;

}

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

 cout<<vi[i]<<endl;

}

return 0;

}

Measured memory_bytes: 4052
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int  INF=100000000;
int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int masu[100][100]={};
  rep(k,n){
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1){
      rep(i,h)rep(j,x){
	masu[i][j]=1;
      }
    }else if(a==2){
      rep(i,h)loop(j,x,w){
	masu[i][j]=1;
      }
    }else if(a==3){
      rep(i,y)rep(j,w){
	masu[i][j]=1;
      }
    }else{
      loop(i,y,h)rep(j,w){
	masu[i][j]=1;
      }
    }
  }
  int ans=0;
  rep(i,h)rep(j,w){
    if(masu[i][j]==0){
      ans++;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }
    ll ans = 0;
    k++;
    while (k) {
        k--;
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            if ((p[i].first | k) == k) sum += p[i].second;
        }
        ans = max(ans, sum);
        k = (k & (k + 1));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define PI 3.14159265
char a[25][25];
int find(int i,int j,int n,int m)
{
   //cout<<"good"<<endl;
   bool visited[n][m];
   int dis[n][m];
   for(int c=0;c<n;c++)
   {
       for(int d=0;d<m;d++)
        {
            dis[c][d]=-1;
            visited[c][d]=false;
        }
   }
   queue<pair<int,int>>q;
   q.push({i,j});
   visited[i][j]=true;
   dis[i][j]=0;
   while(!q.empty())
   {
       pair<int,int>p=q.front();
       q.pop();
       int x=p.first;
       int y=p.second;
       int kx[4]={1,-1,0,0};
       int ky[4]={0,0,1,-1};
       for(int c=0;c<4;c++)
       {
           int newx=kx[c]+x;
           int newy=ky[c]+y;
           if(newx>=0&&newx<n&&newy>=0&&newy<m&&!visited[newx][newy]&&a[newx][newy]=='.')
           {
               visited[newx][newy]=true;
               dis[newx][newy]=dis[x][y]+1;
               q.push({newx,newy});
           }
       }
   }
   int maxi=INT_MIN;
   for(int c=0;c<n;c++)
    {
      for(int d=0;d<m;d++)
      {
        maxi=max(maxi,dis[c][d]);
        //cout<<dis[c][d]<<" ";
      }
      //cout<<endl;
    }
    //cout<<"good"<<endl;
    return maxi;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    int sol=INT_MIN;
    for(int c=0;c<n;c++)
    {
        for(int b=0;b<m;b++)
        {
            if(a[c][b]=='.')
            {
                sol=max(sol,find(c,b,n,m));
            }
        }
    }
    cout<<sol;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main(string[] args) {
        int N = cin.Int();
        long M = cin.Long();
        var A = cin.ArrayLong(N);

        var sum = new long[100010];
        for (int i = 1; i <= N; i++) {
            sum[i] = A[i - 1] + sum[i - 1];
        }
        for (int i = 1; i <= N; i++) {
            sum[i] %= M;
        }

        var dic = new Dictionary<long, long>();
        dic[0] = 1;
        for (int i = 1; i <= N; i++) {
            if (dic.ContainsKey(sum[i])) dic[sum[i]]++;
            else dic[sum[i]] = 1;
        }

        long ans = 0;
        foreach (var k in dic.Values) { 
           ans += k * (k - 1) / 2;
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

Measured memory_bytes: 25824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    string ans = "Good";
    char prev = ' ';
    for (size_t i = 0; i < s.length(); i++)
    {
        char current = s[i];
        if (prev == current)
        {
            ans = "Bad";
            break;
        }
        prev = current;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n; cin >> n;
    vector<int> x(n);
    int center = 0;
    REP(i, n){
        cin >> x[i];
        center += x[i];
    }
    center /= n;
    ll ans1 = 0;
    ll ans2 = 0;
    REP(i, n){
        ans1 += (ll)pow(abs(x[i] - center), 2);
    }
    center += 1;
    REP(i, n){
        ans2 += (ll)pow(abs(x[i] - center), 2);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
int not_need[400][400];

int main()
{
    int n;
    cin >> n;
    ll graph[n][n];
    rep(i, 0, n)
    rep(j, 0, n)
        cin >> graph[i][j];

    rep(k, 0, n)
    rep(i, 0, n)
    rep(j, 0, n)
    if (i != k and k != j)
    {
        ll new_d = graph[i][k] + graph[k][j];

        if (new_d < graph[i][j])
        {
            cout << - 1 << endl;
            return 0;
        }
        else if (new_d == graph[i][j])
            not_need[i][j] = 1;
    }

    ll ans = 0;
    rep(i, 0, n)
    rep(j, i + 1, n)
    if (! not_need[i][j])
        ans += graph[i][j];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c,d;
  while(cin>>a>>b>>c,a||b||c){
    int n;cin>>n;
    int nn=a+b+c;
    vector<int>in(a+b+c+1,2);
    vector<int>tmp;
    rep(i,n){
      cin>>a>>b>>c>>d;
      if(d){
	in[a]=1;in[b]=1;in[c]=1;
      }else{
	tmp.pb(a);
	tmp.pb(b);
	tmp.pb(c);
      }
    }
    rep(i,tmp.size()/3){
      int co=0;
      a=tmp[3*i];b=tmp[3*i+1];c=tmp[3*i+2];
      if(in[a]!=1)co++;
      if(in[b]!=1)co++;
      if(in[c]!=1)co++;
      if(in[a]!=1&&co==1)in[a]=0;
      if(in[b]!=1&&co==1)in[b]=0;
      if(in[c]!=1&&co==1)in[c]=0;
      //cout<<co<<endl;
    }
    loop(i,1,nn+1)cout<<in[i]<<endl;
  }
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
long long a[N],sum[N];
inline long long s(int l,int r)
{
	return sum[r]-sum[l-1];
} 
int main()
{
	int n,l=1,r=3;
	long long ans=LLONG_MAX;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	for(int i=2;i<=n-2;i++)
	{
		while(l+1<i&&abs(s(1,l)-s(l+1,i))>=abs(s(1,l+1)-s(l+2,i)))
			l++;
		while(r+1<n&&abs(s(i+1,r)-s(r+1,n))>=abs(s(i+1,r+1)-s(r+2,n)))
			r++;
		long long b=s(1,l),c=s(l+1,i),d=s(i+1,r),e=s(r+1,n);
		ans=min(ans,max(max(b,c),max(d,e))-min(min(b,c),min(d,e)));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
   int n;
   cin >> n;
   vector<int> p(n);

   for (int i = 0; i < n; i++)
   {
       cin >> p[i];
   }
   
   int count =0;

   for (int i = 1; i < n-1; i++)
   {
       if((p[i-1] < p[i] && p[i] < p[i+1]) ||(p[i-1] > p[i] && p[i] > p[i+1]))
       {
           count++;
       }
   }
   cout << count <<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef priority_queue<long long> prque;
#define ain(i,n,a) for(long long i=0;i<(long long)(n);i++){cin>>a[i];}
#define aout(i,n,a) for(long long i=0;i<(long long)(n);i++){if(i){cout<<" ";}cout<<a[i];if(i==n-1){cout<<endl;}}
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define vsort(v) sort((v).begin(),(v).end())
#define vrsort(v) sort((v).rbegin(),(v).rend())
#define vreverse(v) reverse((v).begin(),(v).end())
#define pf(a) push_front(a)
#define pb(a) push_back(a)
#define INF 1998021900
#define mod 1000000007
ll dfs(ll k,const vvll&graph,ll now,ll from) {

 ll can_use_color_num;
 if(from==-1){
   can_use_color_num=k-1;
 }
 else{
   can_use_color_num=k-2;
 }
  
 if(k<graph[now].size()) {
   return 0;
 }else{
   ll case_num=1;
   for(auto e:graph[now]){
      if(e==from){continue;}
      case_num*=can_use_color_num;
      can_use_color_num--;
      case_num%=mod;
   }
   
   for(auto e:graph[now]){
      if(e==from){continue;}
      case_num*=dfs(k,graph,e,now);
      case_num%=mod;
   }
   
   return case_num;
  }
}
  
  

int main(){
  ll n,k,a,b;cin>>n>>k;
  vvll graph(n);
  rep(i,n-1){
    cin>>a>>b;a--;b--;
    graph[a].pb(b);
    graph[b].pb(a);
  }
  ll ans=k;
  ans*=dfs(k,graph,0,-1);
  ans%=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 11520
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

ll n,m,a,b,c,x,y,aa[100010],ba[100010];
bool r,br,ar;
string s;
char ca,cb;


int main(){
    cin>>s;
    cout<<"ABC"<<s<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int siharai;
  bool flag = false;
  while(cin >> siharai, siharai){
    if(flag){
      cout << endl;
    }else{
      flag = true;
    }
    int money[4];
    cin >> money[0] >> money[1] >> money[2] >> money[3];
    int all;
    all = money[0]*10 + money[1]*50 + money[2]*100 + money[3]*500;
    int turi;
    turi = all - siharai;
    int ans[4] = {0};
    if(turi >= 500){
      ans[3] = turi / 500;
      turi %= 500;
    }
    if(turi >= 100){
      ans[2] = turi / 100;
      turi %= 100;
    }
    if(turi >= 50){
      ans[1] = turi / 50;
      turi %= 50;
    }
    if(turi >= 10){
      ans[0] = turi / 10;
      turi %= 10;
    }

    if(money[0]-ans[0] > 0){
      cout << "10 " << (money[0]-ans[0]) << endl;
    }
    if(money[1]-ans[1] > 0){
      cout << "50 " << (money[1]-ans[1]) << endl;
    }
    if(money[2]-ans[2] > 0){
      cout << "100 " << (money[2]-ans[2]) << endl;
    }
    if(money[3]-ans[3] > 0){
      cout << "500 " << (money[3]-ans[3]) << endl;
    }    
  }
  
  return 0;
}

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

#define int long long 
#define pb push_back

const int N = 102;
const int mod = 1e9 + 7;

int32_t main(){
    string s;
    cin >> s;
    int d;
    cin >> d;
    int n = s.length();
    vector<vector<int>>dp(d,vector<int>(2,0));
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        vector<vector<int>>temp(d,vector<int>(2,0));
        for(int j=0;j<d;j++){
            for(int taken : {0,1}){
                for(int k=0;k<10;k++){
                    if(k > s[i]-'0' && !taken){
                        break;
                    }
                    temp[(j + k)%d][taken || (k < s[i]-'0')] += dp[j][taken];
                    temp[(j+k)%d][taken] %= mod;
                }
            }
        }
        dp = temp;
    }
    int ans = (dp[0][0] + dp[0][1])%mod;
    ans--;
    if(ans < 0){
        ans += mod;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC069B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int l = S.Length;

            Console.WriteLine(S.Substring(0, 1) + (l - 2) + S.Substring(l - 1, 1));

        }
    }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

int main(){

	lli k,x;
	cin>>k>>x;

	if(k*500>=x)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int u, v; cin >> u >> v;
    u--; v--;
    G.at(u).push_back(v);
  }
  int S, T; cin >> S >> T;
  S--; T--;
  const int INF = 1000000007;
  vector<vector<int>> D(N, vector<int>(3, INF));
  D.at(S).at(0) = 0;
  queue<pair<int, int>> q;
  q.push(make_pair(S, 0));
  while (!q.empty()) {
    int cur = q.front().first;
    int d = q.front().second;
    q.pop();
    int nd = (d + 1) % 3;
    for (int nx : G.at(cur)) {
      if (D.at(nx).at(nd) != INF) continue;
      D.at(nx).at(nd) = D.at(cur).at(d) + 1;
      q.push(make_pair(nx, nd));
    }
  }
  if (D.at(T).at(0) != INF) cout << D.at(T).at(0) / 3 << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 14328
import heapq

def d_manhattan(node_list):
    s = 0
    for i in range(9):
        x_goal = i%3
        y_goal = i//3
        x_now = (node_list[i] - 1)%3
        y_now = (node_list[i] - 1)//3
        if y_now == -1:
            y_now = 2
        dx = abs(x_now - x_goal)
        dy = abs(y_now - y_goal)
        s += dx + dy
    return s

def moveNodeE(node_list, space):
    node_tmp = node_list[:]
    node_tmp[space], node_tmp[space + 1] = node_tmp[space + 1], node_tmp[space]
    return node_tmp
def moveNodeW(node_list, space):
    node_tmp = node_list[:]
    node_tmp[space], node_tmp[space - 1] = node_tmp[space - 1], node_tmp[space]
    return node_tmp
def moveNodeN(node_list, space):
    node_tmp = node_list[:]
    node_tmp[space], node_tmp[space - 3] = node_tmp[space - 3], node_tmp[space]
    return node_tmp
def moveNodeS(node_list, space):
    node_tmp = node_list[:]
    node_tmp[space], node_tmp[space + 3] = node_tmp[space + 3], node_tmp[space]
    return node_tmp

class board:
    def __init__(self, node_list, g):
        self.node = node_list
        self.space = node_list.index(0)
        self.g = g
        self.h = d_manhattan(node_list)
        self.f = self.g + self.h

    def makeBoard(self):
        space = self.space
        cost_now = self.f
        x_s = space%3
        y_s = space//3
        if x_s < 2:
            node_tmp = moveNodeE(self.node, space)
            yield board(node_tmp, self.g + 1)
        if x_s > 0:
            node_tmp = moveNodeW(self.node, space)
            yield board(node_tmp, self.g + 1)
        if y_s < 2:
            node_tmp = moveNodeS(self.node, space)
            yield board(node_tmp, self.g + 1)
        if y_s > 0:
            node_tmp = moveNodeN(self.node, space)
            yield board(node_tmp, self.g + 1)

b_open = []
n_close = {}
n_goal = [1,2,3,4,5,6,7,8,0]
n_start = []

for i in range(3):
    inp = list(map(int, input().split()))
    n_start.extend(inp)

b_start = board(n_start, 0)
heapq.heappush(b_open, (b_start.f, b_start.h, 0, b_start))

i = 0
while b_open:
    _, _, _, b_now = heapq.heappop(b_open)
    if b_now.node == n_goal:
        b_goal = b_now
        break
    n_close["".join(map(str, b_now.node))] = i
    for b_new in b_now.makeBoard():
        if "".join(map(str, b_new.node)) in n_close:
            continue
        heapq.heappush(b_open, (b_new.f, b_new.h, i, b_new))
        i += 1

print(b_goal.g)

Measured memory_bytes: 10204
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 6 && a <= 12) b /= 2;
    else if (a <= 5) b = 0;
    cout << b << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

long long int solve(long long int h){
  if(h==1) return 1;
  else return 1+2*solve(h/2);
}

int main(){

  long long int h;
  cin >> h;

  cout << solve(h) << endl;

  /*
  int n,k;
  cin >> n >> k;
  int h[n];

  int i;
  for(i=0;i<n;i++){
    cin >> h[i];
  }

  sort(h,h+n);

  long long int ans=0;
  for(i=0;i<n-k;i++){
    ans += h[i];
  }

  cout << ans << endl;
  */



}


Measured memory_bytes: 4992
import math
n,m = list(map(int, input().split()))
n, m = max(n,m), min(n, m)

if n - m > 1:
    ans = 0
elif n - m == 1:
    k = math.factorial(m) % (10**9 + 7)
    ans = k*k*n % (10**9 + 7)
else:
    k = math.factorial(m) % (10**9 + 7)
    ans = k*k*2 % (10**9 + 7)
print(ans)

Measured memory_bytes: 4028
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}



use input::*;

fn search(graph: &Vec<Vec<(usize, isize)>>, ln: &mut Vec<isize>, n: usize) -> bool {
    let mut flag = false;
    for v in 0..graph.len() {
        for e in &graph[v] {
            let cost = e.1;
            let to = e.0;
            let from = v;
            if ln[from] != 999999999 && ln[to] > ln[from] + cost {
                ln[to] = ln[from] + cost;
            }
        }
    }
    flag
}

fn main() {
    let (n, m, p): (usize, usize, isize);
    input!(n, m, p);

    let mut graph = vec![Vec::new(); n];
    let mut longest = vec![999_999_999; n];
    longest[0] = 0;

    for _ in 0..m {
        let (a, b, c): (usize, usize, isize);
        input!(a, b, c);
        graph[a - 1].push((b - 1, p - c));
    }

    for _ in 0..n {
        search(&graph, &mut longest, n - 1);
    }
    let h = longest[n - 1];
    for _ in 0..n{
    search(&graph, &mut longest, n - 1);
    }
    let i = longest[n - 1];
    if h == i {
        println!("{}", std::cmp::max(0, -1 * longest[n - 1]));
    } else {
        println!("-1");
    }
}



Measured memory_bytes: 4476
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)


MY_NAMESPACE(testbed)
int main()
{
	const int modval = 998244353;

	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(s + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j <= s; j++)
		{
			dp[i + 1][j] += dp[i][j] * 2 % modval;
			if (j - a[i] >= 0)
			{
				dp[i + 1][j] += dp[i][j - a[i]];
			}
			dp[i + 1][j] %= modval;
		}
	}
	cout << dp[n][s] << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 73664
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::Included;
//use std::collections::VecDeque;

const MOD: i64 = 1_000_000_007;
fn main() {
    input! {
        Q:usize
    }
    let mut al = BinaryHeap::new();
    let mut ar = BinaryHeap::new();
    // first query
    input! {query:i64,a:i64,b:i64}
    al.push(a);
    // binary heap は最大値しかpopできないので、右側は逆順にしておく。
    ar.push(-a);
    let mut l = a;
    let mut r = a;
    let mut ans = 0;
    let mut bsum = b;

    for _ in 1..Q {
        input! {query:i64}
        if query == 1 {
            input! {a:i64,b:i64}
            bsum += b;
            if a < l {
                ans += l - a;
                al.push(a);
                al.push(a);
                r = al.pop().unwrap();
                ar.push(-r);
                l = *al.iter().next().unwrap();
            } else if a > r {
                ans += a - r;
                ar.push(-a);
                ar.push(-a);
                l = -ar.pop().unwrap();
                al.push(l);
                r = -*ar.iter().next().unwrap();
            } else {
                al.push(a);
                ar.push(-a);
                l = *al.iter().next().unwrap();
                r = -*ar.iter().next().unwrap();
            }
        } else {
            println!("{} {}", l, ans + bsum);
        }
    }
}


Measured memory_bytes: 10448
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
 
int main() {
	char str1[8], str2[8];
	for(int i = 0; i < 3; i++) scanf(" %c", &str1[i]);
	for(int j = 0; j < 3; j++) scanf(" %c", &str2[j]);
	if(str1[0] == str2[2] && str1[1] == str2[1] && str1[2] == str2[0]) {
		printf("YES\n");
	}
	else printf("NO\n");
}

Measured memory_bytes: 128
N = int(input())
Blue = {}
for _ in range(N):
    s = input()
    if s in Blue:
        Blue[s] += 1
    else:
        Blue[s] = 1

M = int(input())
Red = {}
for _ in range(M):
    t = input()
    if t in Red:
        Red[t] += 1
    else:
        Red[t] = 1

Max = 0
for item in Blue.items():
    s = item[0]
    v = item[1]
    if s in Red:
        v -= Red[s]
    Max = max(Max, v)
print(Max)

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

int N;
string S;
vector<int> X[3];
vector<int> A, B, C;
typedef long long ll;
const ll MOD = 998244353ll;

int color_id(char c)
{
  return c == 'R' ? 0 : c == 'G' ? 1 : 2;
}

int main()
{
  cin >> N >> S;
  for (int i = 0; i < 3 * N; ++i)
  {
    X[color_id(S[i])].push_back(i);
  }
  for (int i = 0; i < N; ++i)
  {
    int x[3] = {X[0][i], X[1][i], X[2][i]};
    sort(x, x + 3);
    A.push_back(x[0]);
    B.push_back(x[1]);
    C.push_back(x[2]);
  }
  ll res = 1;
  for (int i = 0; i < N; ++i)
  {
    ll k = upper_bound(A.begin(), A.end(), B[i]) - A.begin();
    res *= k - i;
    res %= MOD;
  }
  for (int i = 0; i < N; ++i)
  {
    ll k = C.end() - lower_bound(C.begin(), C.end(), B[N - 1 - i]);
    res *= k - i;
    res %= MOD;
  }
  for (int i = 1; i <= N; ++i)
  {
    res *= i;
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3324
N = int(input())
A = list(map(int, input().split()))

A_tmp = sorted(A, key=abs, reverse=True,)
total = 0
for i,v in enumerate(A_tmp):
    if (v <= 0) and (i < len(A_tmp)-1):
        A_tmp[i] = (-1) * A_tmp[i]
        A_tmp[i+1] = (-1) * A_tmp[i+1]
        total += A_tmp[i]
    else:
        total += v
print(total)

Measured memory_bytes: 19996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<vector<pii>> v(n);
	
	for(int i = 0; i < n; i++){
		int k;
		cin >> k;
		
		while(k--){
			int x, y;
			cin >> x >> y;
			x--;
			v[i].push_back({x, y});
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < (1 << n); i++){
		
		vector<bool> honest(n, false);
		vector<bool> liar(n, false);
		
		for(int j = 0; j < n; j++){
			if(i & (1 << j))
				honest[j] = true;
			else
				liar[j] = true;
		}
		
		bool ok = true;
		
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				for(auto &p : v[j]){
					if(p.second == 1){
						if(liar[p.first])
							ok = false;
					}
					else{
						if(honest[p.first])
							ok = false;
					}
				}
			}
		}
		
		if(ok)
			ans = max(ans, __builtin_popcount(i));
	}
	
	cout << ans << endl;

	return 0;
}


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

int main()
{
  int ans, n, d;
  cin>>n>>d;
  d = 2*d+1;
  if(n%d==0)
    ans = n/d;
  else
  	ans = n/d + 1;
  cout<<ans<<endl;
  return 0;
}

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

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

    long long N, M;
    cin >> N >> M;

    if (N == 1 && M == 1) {
        cout << 1 << endl;
    } else if (N == 1) {
        cout << M - 2 << endl;
    } else if (M == 1) {
        cout << N - 2 << endl;
    } else {
        cout << (N-2) * (M-2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long int D,N;
  scanf("%lld%lld", &D, &N);
  long long int i, t=1;
  for(i=0;i<D;++i) t *= 100;
  if(N <= 99) printf("%lld\n",t*N);
  else if(N==100) printf("%lld\n",t*101);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, now = 0;
  scanf("%lld", &n);
  char a[n + 10];
  bool b = true;
  scanf("%s", a);
  queue<ll> q, t;
  for(i = 0; i < n; ++i) {
    q.push(a[i] - '1');
    if(a[i] == '2') b = false;
  }
  while(q.size() != 1) {
    if(q.size() & 1) {
      t.push(q.front()), q.pop();
      while(q.size()) q.pop(), t.push(q.front()), q.pop();
    } else {
      now = q.front(), q.pop();
      while(q.size()) t.push(q.front() > now ? q.front() - now : now - q.front()), now = q.front(), q.pop();
    }
    while(t.size()) q.push(t.front()), t.pop();
  }
  printf("%lld", b ? q.front() : (q.front() & 1 ? 1 : 0));
  return 0;
}

Measured memory_bytes: 9744
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int d, e;
        scan(d, e);
        if(!d) return;

        double ans = 10^^7;

        foreach (x ; 0 .. d + 1) {
            int y = d - x;
            auto L = hypot(x, y);
            ans = min(ans, fabs(L - e));
        }

        writefln("%.8f", ans);
    }
}

void solve(int n, int a, int b, int[] p) {
    int difmax, ans;

    foreach (i ; a .. b + 1) {
        if (difmax <= p[i-1] - p[i]) {
            difmax = p[i-1] - p[i];
            ans = i;
        }
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

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

int main() {
	while (1) {
		string a, b;
		cin >> a >> b;
		if (a == "0"&&b=="0")break;
		vector<int>c(4);
		vector<int>d(4);
		for (int e = 0; e < 4; e++) {
			c[e] = a[e] - 48;
		}
		for (int e = 0; e < 4; e++) {
			d[e] = b[e] - 48;
		}
		int f = 10;
		int s = 0;
		for (int g = 0; g < 4; g++) {
			if (c[g] == d[g]) { s++; c[g] = f++; d[g] = f++; }
		}
		cout << s << " ";
		s = 0;
		for (int h = 0; h < 4; h++) {
			for (int i = 0; i < 4; i++) {
				if (c[h] ==d[i]) { s++; c[h] = f++; d[i] = f++; }
			}
		}
		cout << s << endl;
	}
}

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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var p = new List<int>();
            GeneratePrime(p, n / 2);
            var count = 0;
            for (int i = 0; i < p.Count(); i++)
                if (IsPrime(n - p[i])) count++;
            Console.WriteLine(count);
        }
    }
    public static void GeneratePrime(List<int> primeList, int m)
    {
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            primeList.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        primeList.AddRange(searchList);
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        else if (n == 2) return true;
        else if (n % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i <= sqrtNum; i += 2)
            if (n % i == 0) return false;
        return true;
    }
}

Measured memory_bytes: 14588
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> vec(N), num(N);
    map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        cin >> vec[i];
        cnt[vec[i]]++;
    }
    long long sum = 0;
    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        int c = itr->second;
        sum += (long long) c * (c-1) / 2;
    }
    for (int i = 0; i < N; i++) {
        int c = cnt[vec[i]];
        cout << sum - c + 1 << endl;
    }
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1);
    vector<ll> b(m+1);
    a[0]=0;
    b[0]=0;
    rep1(i,n){
        ll p;
        cin>>p;
        a[i]=a[i-1]+p;
    }
    rep1(i,m){
        ll q;
        cin>>q;
        b[i]=b[i-1]+q;
    }
    int ans=0;
    int v=m+1;
    rep(i,n+1){
        ll judge=k-a[i];
        if(judge<0) break;
        bool decide=false;
        per(j,v){
            if(judge>=b[j]) {
                v=j+1;
                decide=true;
                break;
            }
        }
        if(decide) ans=max(ans,i+v-1);
    }

    cout<<ans<<endl;

    
}

Measured memory_bytes: 6388
import java.util.Arrays;
import java.util.Scanner;

;

public class Main {
	static final int max = 1000000;

	public static void main(String[] args) {
		boolean numList[] = new boolean[max + 1];
		Arrays.fill(numList, true);

//		numList[0] = false;
//		numList[1] = false;

		for (int t = 2; t < max; t++) {
			if (numList[t]) {
				for (int i = t * 2; i < max; i += t) {
					numList[i] = false;
				}
			}
		}
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			long inputNum = sc.nextLong();
			int count = 0;

			for (int i = 2; i <= inputNum; i++) {
				if (numList[i]) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 27388
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cctype>
#include <ctime>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define eps 1e-9
#define SZ(x) ((int)x.size())
#define x first
#define y second

typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6;
map<int, int> my_map;
int n, m, a;
bool flag = true;

int main() {
#ifdef __AiR_H
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // __AiR_H
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) { scanf("%d", &a); ++my_map[a]; }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d", &a); if (!flag) { continue; }
        if (my_map[a] >= 1) { --my_map[a]; } else { flag = false; }
    }
    if (flag) { printf("YES\n"); } else { printf("NO\n"); }
    return 0;
}


Measured memory_bytes: 9600
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int N;
  string S;
  char s;
  cin >> N >> S;

  for(int i=0;i<S.length();i++){
    if(S[i] + N >= 91){
        S[i] = S[i] + N -26;
    }
    else{
    S[i] = S[i] + N;
    }
  }

  cout << S << endl;
 
}


Measured memory_bytes: 256