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

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

    vector<tuple<int, int, int, int>> ans;
    bool has_coin = false;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int jt;
            if(i%2!=0) jt = W-1-j;
            else jt = j;

            if(M[i][jt]%2!=0){
                if(has_coin){
                    M[i][jt]++;
                    has_coin = false;
                } else{
                    M[i][jt]--;
                    has_coin = true;
                }
            } 

            if(i==H-1&&j==W-1 && has_coin){
                M[i][jt]++;
                has_coin = false;
            } 

            if(has_coin){
                if(j==W-1)
                    ans.push_back(make_tuple(jt, i, jt,   i+1));
                else if(i%2!=0)
                    ans.push_back(make_tuple(jt, i, jt-1, i));
                else
                    ans.push_back(make_tuple(jt, i, jt+1, i));
            }       
        }
    }
    
    cout << ans.size() << "\n";
    for(auto i : ans){
        cout << get<1>(i) + 1 << " "  << get<0>(i)+1 << " "  << get<3>(i) +1 << " " << get<2>(i) + 1 << endl;
    }    
}

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

int main()
{
	int count = 0;
	int syear,eyear;
	while(cin >> syear && cin >> eyear){
		if(syear == 0)
			break;
		else{
			if(count!=0)
				cout << endl;
		}			
		bool flag = false;
		for(int i=syear;i<=eyear;i++){
			if(i%4==0){
				if(i%400==0){
					flag = true;
					cout << i << endl;
				}
				else if(i%100==0){
				}
				else{
					flag = true;
					cout << i << endl;
				}
			}
		}
		if(flag==false)
			cout << "NA" << endl;
		count++;
	}
	return 0;
}

Measured memory_bytes: 0
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    con=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for o in range(j+1,n+1):
                if i+j+o==x:
                    con+=1
    print(con)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    string s, t;
    cin >> s >> t;
    vstr ans;
    int n = s.length();
    int nt = t.length();
    rrep(i, n - (nt-1)) {
        bool check = true;
        rep(j, nt) {
            if (s[i+j] != '?' && s[i+j] != t[j]) {
                check = false;
                break;
            }
        }
        if (check) {
            string tmp = s;
            rep(j, nt) {
                tmp[i+j] = t[j];
            }
            rep(i, n) {
                if (tmp[i] == '?') tmp[i] = 'a';
            }
            ans.push_back(tmp);
        }
    }
    if (ans.size() == 0) {
        puts("UNRESTORABLE");
        return 0;
    }
    sort(all(ans));

    cout << ans.front() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		int n;
		int cnt=0;
		Scanner sc=new Scanner(System.in);
		while (true){
			n=sc.nextInt();
			if (n==0) break;
			double s=0.0;
			int [][] ver=new int[n][2];
			for (int i=0;i<n;i++){
				ver[i][0]=sc.nextInt();
				ver[i][1]=sc.nextInt();
				if(i>0){
					s+=cal(ver[i],ver[i-1]);
				}
			}
			s+=cal(ver[0],ver[n-1]);
			cnt++;
			System.out.println(cnt+" "+Math.abs(s/2));
		}
	   
	}
	private static double cal(int [] a,int [] b){
		return(a[0]*b[1]-a[1]*b[0]);
	}
}

Measured memory_bytes: 29360
#include<stdio.h>
int n,ans=100000;
int ok[10]={0};

void dfs(int a){
  if(a>=n){
    ans=ans>a?a:ans;
    return;
  }
  for(int i=0;i<=9;i++){
    if(a==0&&i==0)continue;
    if(ok[i]==0) dfs(a*10+i);
  }
  return;
}

int main(){
  int k,i;
	scanf("%d%d",&n,&k);
	for(int j=1;j<=k;j++){
		scanf("%d",&i);
		ok[i]=1;
	}
  dfs(0);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long int ans=0;
	ans=(-1.0 + sqrt(1.0 + 8.0 * (double)n ))/2.0;
	if((ans*(ans+1))/2 == n){
		cout<<ans;
	}
	else{
		cout<<ans+1;
	}
}

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

namespace ALDS1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var targetList = new List<int>();
            for(int i = 0; i < n; i++)
            {
                targetList.Add(int.Parse(Console.ReadLine()));
            }
            ShellSort(targetList, n);
        }
        
        public static int InsertionSort(List<int> valueList,int valueLength,int interval)
        {
            int cnt = 0;
            for(int i=1; i<valueLength; i++)
            {
                int comparisonValue = valueList[i];
                int j = i - interval;
                while(j >= 0 && comparisonValue < valueList[j])
                {
                    valueList[j + interval] = valueList[j];
                    j = j - interval;
                    cnt++;
                }
                valueList[j + interval] = comparisonValue;
                
            }
            return cnt;
        }

        public static void ShellSort(List<int>valueList,int valueLength)
        {
            int cnt = 0;
            var intervalList = new List<int>();
            int interval = valueLength - 1;
            int intervalCandidate = 1;
            while(true)
            {
                if (intervalCandidate > valueLength)
                    break;
                intervalList.Add(intervalCandidate);
                intervalCandidate = intervalCandidate * 3 + 1;
            }
            Console.WriteLine(intervalList.Count());
            //Console.WriteLine(' ');
            for(int i=intervalList.Count()-1; i>=0;i--)
            {
                Console.Write(intervalList[i]);
                Console.Write(' ');
                cnt = InsertionSort(valueList, valueLength, intervalList[i]) + cnt;
            }
            Console.WriteLine();
            Console.WriteLine(cnt);
            //Console.WriteLine(' ');
            Output(valueList);
        }

        public static void Output(List<int>targetList)
        {
            for(int i=0; i<targetList.Count(); i++)
            {
                Console.WriteLine(targetList[i]);
                //Console.WriteLine(' ');
            }
        }

    }
}



Measured memory_bytes: 27860
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    int N, K;
    cin >> N >> K;

    vector<int> h(N);
    int nfriend = 0;
    for(int i = 0 ; i < N ; i++){
        cin >> h[i];
        if( K <= h[i] ) nfriend++;
    }

    cout << nfriend << endl;

}

Measured memory_bytes: 640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
count = 0
for i in range(n):
    if (i+1) % 2 != 0: 
        divisors = make_divisors(i+1)
        if len(divisors) == 8:
            count += 1

print(count)

Measured memory_bytes: 3060
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        Console.WriteLine(getAns() ? "YES" : "NO");
    }
    static bool getAns()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var hs = new HashSet<int>();
        for (int i = 0; i < n; i++)
            if (!hs.Add(a[i])) return false;
        return true;
    }
}


Measured memory_bytes: 35408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if((c+b-1)/b > (a+d-1)/d) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    
    
    

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long

template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = 1001001001001001001LL;

const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {-1, 0, 1, 0};

signed main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    using pii = pair<int, int>;
    queue<pii> q;
    q.push({0, 0});
    vector<vector<int>> dist(H, vector<int>(W, INF));
    dist[0][0] = 0;
    while (q.size()) {
        int y, x;
        tie(y, x) = q.front(); q.pop();
        for (int dir = 0; dir < 4; dir++) {
            int yy = y + DY[dir];
            int xx = x + DX[dir];
            if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue;
            if (S[yy][xx] == '#') continue;
            if (chmin(dist[yy][xx], dist[y][x] + 1)) {
                q.push({yy, xx});
            }
        }
    }
    int white = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                white++;
            }
        }
    }
    if (dist[H - 1][W - 1] == INF) {
        cout << -1 << endl;
    } else {
        int ans = white - (dist[H - 1][W - 1] + 1);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define MODB 998244353
#define INF 9223372036854775807

signed main()
{
  int x=0,y=1,z=0,w=0,n=0,m=0;
  std::vector<int> v(40000);
  std::cin >> x;
  rep(i,40000){
    v[i]=(i+1)*(i+1);
  }
  for(int i=v.size()-1;i>=0;i--){
    if(v[i]<=x){
      std::cout << v[i] << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>

using namespace std;

typedef pair<char,int> P;

int main()
{
    string instr;
    queue<P> que;

    cin >> instr;

    int cnt=1;

    for(int i=1; i<(int)instr.size(); ++i) {
        if(instr[i]==instr[i-1]) ++cnt;
        else {
            que.push(make_pair(instr[i-1],cnt));
            cnt=1;
        }
    }
    que.push(make_pair(instr[instr.size()-1],cnt));

    int ans=0;

    while(!que.empty()) {
        P p=que.front(); que.pop();
        if(p.first!='J') continue;
        int len=p.second;
        if(que.empty()) break;
        p=que.front();
        if(p.first!='O'){
            if(p.first=='I') que.pop();
            continue;
        }
        que.pop();
        if(p.second>len) continue;
        len=p.second;
        if(que.empty()) break;
        p=que.front();
        if(p.first!='I') continue;
        que.pop();
        if(len>p.second) continue;
        ans=max(ans,len);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11980
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+7,maxm=2e5+7;
int c[2][maxn][maxn];
vector<int> G[maxn];
int a[maxm],b[maxm];
void dfs(int x,int st,int ptr,bool typ){
	if(!c[typ][st][x]) c[typ][st][x]=ptr;else return ;//cout<<st<<' '<<x<<endl;
	for(int y:G[x]) if(!c[typ][st][y]) dfs(y,st,ptr,typ);
}
int main(){
	int n,m;cin>>n>>m;
	for(int i=1;i<=m;++i) scanf("%d%d",&a[i],&b[i]),G[a[i]].push_back(b[i]);
	for(int x=1;x<=n;++x) {
		c[0][x][x]=c[1][x][x]=1;
		for(auto y:G[x]) dfs(y,x,y,0);
		reverse(G[x].begin(),G[x].end());
		for(auto y:G[x]) dfs(y,x,y,1);
	}
	for(int i=1;i<=m;++i){
		bool flag=(c[0][b[i]][a[i]]>0);//cout<<flag<<endl;
		if(c[0][a[i]][b[i]]!=c[1][a[i]][b[i]]) flag^=1;//cout<<c[0][3][4]<<' '<<c[1][3][4]<<' '<<a[i]<<' '<<b[i]<<endl;
		if(flag) puts("diff");else puts("same");
	}
	return 0;
}

Measured memory_bytes: 14728
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = s.size();
  int ans = N*(N-1)/2+1;

  map<char, int> m;
  REP(i, N) m[s[i]]++;

  for(auto p : m){
    ans -= p.second*(p.second-1)/2;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 58;

vector< int > g[5000];
int N, A[5000];
vector< bool > latte[5000];
vector< int64 > malta[5000];

void chmin(int64 &a, int64 b) { a = min(a, b); }

void dfs(int idx, int par) {
  for(auto &to : g[idx]) {
    if(to == par) continue;
    dfs(to, idx);
  }

  latte[idx].emplace_back(A[idx] > 0);
  for(auto &to : g[idx]) {
    if(to == par) continue;
    if(A[to] > 0) {
      vector< bool > nxt(latte[idx].size() + latte[to].size());
      for(int i = 0; i < latte[idx].size(); i++) {
        for(int j = 0; j < latte[to].size(); j++) {
          if(latte[idx][i] & latte[to][j]) {
            nxt[i + j] = true;
          }
        }
        for(int j = 0; j < malta[to].size(); j++) {
          if(!latte[idx][i] || malta[to][j] >= 0) continue;
          nxt[i + j + 1] = true;
        }
      }
      latte[idx].swap(nxt);
    } else {
      vector< bool > nxt(latte[idx].size() + latte[to].size());
      for(int i = 0; i < latte[idx].size(); i++) {
        for(int j = 0; j < malta[to].size(); j++) {
          if(!latte[idx][i] || malta[to][j] >= 0) continue;
          nxt[i + j + 1] = true;
        }
      }
      latte[idx].swap(nxt);
    }
  }


  malta[idx].emplace_back(A[idx]);
  for(auto &to : g[idx]) {
    if(to == par) continue;
    vector< int64 > nxt(malta[idx].size() + malta[to].size(), INF);
    for(int i = 0; i < malta[idx].size(); i++) {
      for(int j = 0; j < latte[to].size(); j++) {
        if(latte[to][j]) chmin(nxt[i + j + 1], malta[idx][i]);
      }
      for(int j = 0; j < malta[to].size(); j++) {
        if(malta[idx][i] == INF) continue;
        if(malta[to][j] == INF) continue;
        chmin(nxt[i + j], malta[idx][i] + malta[to][j]);
      }
      for(int j = 0; j < malta[to].size(); j++) {
        if(malta[idx][i] == INF) continue;
        if(malta[to][j] >= 0) continue;
        chmin(nxt[i + j + 1], malta[idx][i]);
      }
    }
    malta[idx].swap(nxt);
  }

}


int main() {
  cin >> N;
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  dfs(0, -1);
  for(int i = 0; i < latte[0].size(); i++) {
    if(latte[0][i] || malta[0][i] < 0) {
      cout << i << endl;
      exit(0);
    }
  }
}


Measured memory_bytes: 84736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;

bool G[50][50];
bool visited[50];
int N, M;

void dfs(int v) {
    //dump(v);
    visited[v] = true;
    rep(i, N) {
        if (G[v][i] == true && visited[i] == false)
        dfs(i); 
    }
}

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

    cin >> N >> M;
    int a[M], b[M];
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }

    int ans = 0;
    rep(i, M) {
        G[a[i]][b[i]] = false;
        G[b[i]][a[i]] = false;
        rep(j, 50) visited[j] = false;
        dfs(0);
        int flag = 0;
        rep(j, N) {
            //dump(visited[j]);
            if (visited[j] == false) flag = 1;
        }
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
        ans += flag;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A[200000], xor_sum = 0;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        xor_sum ^= A[i];
    }
    REP(i, N) {
        cout << (A[i] ^ xor_sum) << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

bool judge(string S){
    string S2 = S;
    reverse(ALL(S));
    return S2 == S;
}

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

    string S;
    cin >> S;

    bool ans = judge(S);

    string S2 = "", S3 = "";
    rep(i, (len(S) - 1) / 2) S2 += S[i];
    for (ll i = (len(S) + 3) / 2 - 1; i < len(S); ++i) S3 += S[i];

    ans = ans and judge(S2) and judge(S3);

    if(ans) print("Yes");
    else print("No");

    return 0;
}

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

int main() {
	//cout<<"GfG!";
	int n, a[100], f = 1, b[100];
	cin>>n;
	for (int i = 0; i < n; i++)
	{
	    cin>>a[i];
	}
	for (int i = 0; i < n; i++)
	{
	    if (a[i] % 2 == 0)
	    {
	       if (a[i] % 3 == 0 || a[i] % 5 == 0)
	            f = 1;
	        else
	        {
	             f = 0; break;
	        }
	    }
	}
	if (f)
	    cout<<"APPROVED";
	else
	    cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d", &N);
    
    if(N % 2 == 0){
        printf("%d\n", (N / 2) * (N / 2));
    }else{
        printf("%d\n", (N / 2) * (N / 2 + 1));
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
using namespace std;
int l,r,d,cnt; 
int main(){
	scanf("%d%d%d",&l,&r,&d);
	for(int i=l;i<=r;++i){
		if(i%d==0)++cnt;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 1728
#include <stdio.h>

#define MAX 250

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i + 1;
}

int main(){
  int H;
  int i;
  int A[MAX];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i) <= H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i) <= H){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }
return 0;
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int ans, x;
	for (int i = 0; i < 5; i++) {
		scanf("%d", &x);
		if (x == 0) ans = i + 1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long
#define ii pair <int, int>
#define dl pair <ll, ll>
#define vi vector <int>
#define vl vector <ll>
#define vii vector <ii>
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; i < b; i += c)

using namespace std;

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

    string s, t;
    cin >> s >> t;
    int cont = 0;
    int mayor = 0;
    int n, m;
    n = s.size();
    m = t.size();
    REP(0, n - t.size() + 1) {
        cont = 0;
        REP2(i, i + t.size()) {
            if (s[j] == t[j - i]) cont++;
        }
        mayor = max(mayor, cont);
    }
    cout << m - mayor << "\n";
	return 0;
}

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

#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, m, n) for(int i = m;i < n;i++)

int main(){
  string s;
  cin>>s;
  int n=s.size()-1-8;
  for(int i=0;i<=n;i++){
    cout<<s[i];
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    while True:
        N = input()    
        if N == 0:
            break
        points = [Vector(map(int, raw_input().split())) for _ in xrange(N)]
        seq = [Vector([0, -1]), Vector([0, 0])]
        while len(points) != 0:
            pre = seq[-1] - seq[-2]
            points.sort(key=lambda x: abs(x-seq[-1]), reverse=True)
            points.sort(key=lambda x: (x-seq[-1]).norm() * pre.norm())
            p = map(lambda x: (x-seq[-1]).norm() * pre.norm(), points)
            seq += [points.pop()]
        print round(sum(abs(v2 - v1) for v1, v2 in zip(seq[1:], seq[2:])), 1)

class Vector(tuple):

    def __neg__(self):
        return Vector([-x for x in self])

    def __abs__(self):
        return sum(x ** 2 for x in self) ** 0.5

    def __add__(self, v):
        if len(self) != len(v):
            raise ValueError, "Same dimension is required."
        return Vector([x1 + x2 for x1, x2 in zip(self, v)])

    def __sub__(self, v):
        return self.__add__(-v)
    
    def norm(self):
        a = self.__abs__()
        return Vector([x / a for x in self])

    def __mul__(self,  v):
        """dot product"""
        if len(self) != len(v):
            raise ValueError, "Same dimension is required."
        #  sum(x1 * x2 for x1, x2 in zip(self, v))
        return round(sum(x1 * x2 for x1, x2 in zip(self, v)), 14)

if __name__ == "__main__":
    main()

Measured memory_bytes: 4468
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cctype>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1000 + 10 ;
const int MOD = 1e9+7 ;
const int INF = 0x3f3f3f3f ;
int a[maxn], s[maxn], n, ans, top;
int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","+aw",stdout);
	while(~scanf("%d",&n)){
		ans=0;
		top=0;
		for(int i=0;i<n;i++){
			scanf("%d",&s[i]);
			ans+=s[i];
			if(s[i]%10){
				a[top++]=s[i];
			}
		}
		if(0==(ans%10)){
			if(0==top){
				ans=0;
			}else{
				sort(a,a+top);
				ans-=a[0];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1e9

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, ans;
map<pair<ll, ll>, ll> A;

ll first(ll n)
{
    while (n>9)
        n/=10;
    return n;
}

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

    cin>>n;
    for (ll i=1; i<=n; i++)
    {
        A[{first(i), i%10}]++;
    }
    for (ll i=1; i<=9; i++)
    {
        for (ll j=1; j<=9; j++)
        {
            ans += A[{i, j}] * A[{j, i}];
        }
    }
    cout<<ans;
    return 0;
}

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

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

  string s;
  cin >> s;

  sort(s.begin(), s.end());
  if (s == "abc") cout << "Yes\n";
  else cout << "No\n";

  return (0);
}


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

/*
 (imin,imax] -> imax
 return minimum index such that v[index] >= value
 auto f(int mid) {return v[mid] >= value;}
 */
template<class F>
auto  minimize(Int imin,Int imax,F &f){
    while(imax - imin > 1){
        Int mid = imin + (imax - imin)/2;
        if(f(mid)) imax = mid;
        else imin = mid;
    }
    return imax;
}
int main(){
    Int N, K;
    cin >> N >> K;
    vector<Int>A(N),F(N);
    for(auto& e : A)
        cin >> e;
    for(auto& e : F)
        cin >> e;
    if(accumulate(A.begin(), A.end(),0LL) <= K)
        return puts("0") * 0;
    sort(A.begin(),A.end());
    sort(F.begin(),F.end(), greater<>());
    auto comp = [&](Int mid){
        Int tK = K;
        bool valid = false;
        Int mid_ = mid;
        for(Int i = 0; i < N; ++i){
            if( mid_ < F[i]){
                
                tK -= A[i];
                
            } else if(mid_ == F[i]){
                
                valid = true;
                tK -= (A[i] - 1);
                
            }else /*if(mid_ > F[i])**/ {
                if( mid_ > A[i] * F[i]){
                    
                    
                } else if(mid_ == A[i] * F[i]){
                    valid = true;
                } else /*A[i] * F[i] > mid_ */ {
                    Int idx = mid_ / F[i];
                    if(mid_ % F[i] == 0) valid = true;
                    if(A[i] - idx < 0)  return false;
                    tK -= (A[i] - idx);
                }
            }
        }
        return tK >= 0;;
    };
    Int ub = (1LL << 60);
    cout << minimize(0LL,ub,comp)<< endl;
    
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[6],i,j,k;
	for(i=1;i<=5;i++) cin>>a[i];
	cin>>k;
	for(i=1;i<=5;i++)
	for(j=i+1;j<=5;j++)
	{
		if(a[j]-a[i]>k) {cout<<":("<<endl;return 0;} 
	}
	cout<<"Yay!"<<endl;
}

Measured memory_bytes: 256
#xCy=x!/y!(x-y)!
def com(x,y):
    bunb = 1
    buns = 1
    for i in range(y):
        buns = buns * (x-i) % mod
        bunb = bunb * (i+1) % mod

    bunb_inv = pow(bunb,mod-2,mod)
    d = (buns * bunb_inv) % mod
    return buns*pow(bunb,mod-2,mod)
    
n,a,b = map(int,input().split())
mod = 10**9 + 7

ans = pow(2,n,mod) - 1
ans -= com(n,a) + com(n,b)

print(ans%mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  cin>>t;
  if(t>=30)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = 100*(n-m)+1900*m;
    int y = (int)Math.pow(2,m);
    System.out.println(x*y);
  }
}


Measured memory_bytes: 35592
N = int(input())
a_lst = list(map(int, input().split()))

M = 0
ans_lst = [0] * N

for i in range(N-1, -1, -1):
    if sum(ans_lst[i::i+1]) % 2 != a_lst[i]:
        ans_lst[i] = 1
    

m = sum(ans_lst)    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1) + " "
print(ans_str)




Measured memory_bytes: 9144
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

int main(void) {
	string T; cin >> T;

	rep(i, T.length())if (T[i] == '?')T[i] = 'D';

	cout << T << endl;

	return 0;
}


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

int main()
{
    int K;
    string S;
    cin >> K;
    cin >> S;
    if (S.size() > K)
    {
        cout << S.substr(0, K) << "..." << endl;
    }
    else
    {
        cout << S << endl;
    }
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;


#define EPS 1e-7

bool equal(double f1, double f2) {
    return abs(f1 - f2) < EPS;
}

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

    if (c - a - b <= 0) {
        cout << "No" << endl;
        ret();
    }

    ll ab = a * b * 4;
    ll cab2 = c * c - c * a - c * b
              - a * c + a * a + a * b
              - c * b + a * b + b * b;

    if (ab < cab2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
n=int(input())
l=[int(k) for k in input().split()]
lnew={}
for i in l:
  if i in lnew:
    lnew[i]+=1
  else:lnew[i]=1
Sum=0
for num,val in lnew.items():
    Sum+=num*val
k=int(input())
for i in range(k):
  a,b=input().split()
  a=int(a)
  b=int(b)
  if a in lnew:
    Sum-=lnew[a]*a
    c=0
    if b in lnew:
      c=lnew[b]
      Sum-=lnew[b]*b
    lnew[b]=c+lnew[a]
    Sum+=lnew[b]*b
  lnew.pop(a,None)
  
  print(Sum)

Measured memory_bytes: 20952
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define gc getchar
#define ll long long
#define db double
#define pii pair<int,int>
#define fi first
#define se second
#define Vi vector<int>
#define Vp vector<pii>

using namespace std;

inline void cmax(int &x,int y){y>x?x=y:0;}
inline void cmin(int &x,int y){y<x?x=y:0;}

int read(){
	char ch=gc(); int x=0,op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}

const int N=2e5+10;
int n,m,x,f[N],tp,q[N]; Vi G[N];

void dfs(int u){
	for (auto v:G[u]) dfs(v);
	tp=0;
	for (auto v:G[u]) q[++tp]=f[v];
	sort(q+1,q+1+tp,greater<int>());
	rep (i,1,tp) f[u]=max(f[u],q[i]+i);
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep (i,2,n) cin>>x,G[x].push_back(i);
	dfs(1);
	printf("%d\n",f[1]);
	return 0;
}


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

vector<int> A, S;
int sz;

bool check(int n, int K){
    int pt = lower_bound(A.begin(), A.end(), n) - A.begin();
    int avail = S[pt] + n*(sz-pt);
    return (avail >= n*K);
}

int main(){
    int N;
    map<int, int> mp;
    cin >> N;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    for(auto& p : mp) A.push_back(p.second);
    sort(A.begin(), A.end());
    sz = A.size();
    S.push_back(0);
    for(int a : A) S.push_back(S.back() + a);
    
    for(int K=1; K<=N; K++){
        int ng = N/K+1, ok = 0;
        while(ng-ok>1){
            int mid = (ng+ok)/2;
            (check(mid, K) ? ok : ng) = mid;
        }
        cout << ok << endl;
    }
    return 0;
}


Measured memory_bytes: 18032
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
   int x,s=1;
   cin >> x;
   if(x<4){
       cout << x << endl;
   }
   else{
   for(int i=x; i<x*2; i++){
       for(int j=i/2; j>1; j--){
           if(i%j==0){
               break;
           }
           if(j==2){
               s++;
           }
       }
       if(s==2){
           cout << i << endl;
           break;
       }
   }
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

bool f(int A, int B, int C, int D){
  if(A < B) return false;
  if(D < B) return false;
  if(B-1 <= C) return true;

  int g = __gcd(B, D);
  int MAX = (B-A%g+g-1)/g*g+A%g-g;
  if(C < MAX) return false;
  return true;
}

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

  int A, B, C, D;
  REP(i, N){
    cin >> A >> B >> C >> D;
    f(A, B, C, D)? Yes: No;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,a[100],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    for (i = 0; i < n; i++)
    {
        if(a[i] % 2 == 0 && (a[i] % 5 != 0 && a[i] % 3 != 0))break; 
    }
    if(i == n)printf("APPROVED");
    else printf("DENIED");
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int N, M, H[100005];
vector<int> adj[100005];

int main() {
    cin >> N >> M;
    for_(i,0,N) cin >> H[i];

    for_(i,0,M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ans = 0;
    for_(i,0,N) {
        bool flag = true;
        for (int x : adj[i]) flag &= (H[i] > H[x]);
        if (flag) ++ans;
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    std::string S;
    std::cin >> N >> S;

    int64_t sum_r[N] = {0};
    int64_t sum_g[N] = {0};
    int64_t sum_b[N] = {0};

    for (size_t i = 0; i < S.size(); ++i) {
        const char c = S[i];
        if (i == 0) {
            if (c == 'R') {
                sum_r[i] = 1;
            } else if (c == 'G') {
                sum_g[i] = 1;
            } else {
                sum_b[i] = 1;
            }
        } else {
            if (c == 'R') {
                sum_r[i] = sum_r[i-1] + 1;
                sum_g[i] = sum_g[i-1];
                sum_b[i] = sum_b[i-1];
            } else if (c == 'G') {
                sum_r[i] = sum_r[i-1];
                sum_g[i] = sum_g[i-1] + 1;
                sum_b[i] = sum_b[i-1];
            } else {
                sum_r[i] = sum_r[i-1];
                sum_g[i] = sum_g[i-1];
                sum_b[i] = sum_b[i-1] + 1;
            }
        }
    }

    int64_t sum = 0;
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            if (S[i] == S[j]) {
                continue;
            }

            if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
                sum += (sum_b[N-1] - sum_b[j]);
                if (((2 * j - i) < N) && S[2*j -i] == 'B') {
                    sum--;
                }
            }
            else if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')) {
                sum += (sum_g[N-1] - sum_g[j]);
                if (((2 * j - i) < N) && S[2*j -i] == 'G') {
                    sum--;
                }            
            }
            else if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')) {
                sum += (sum_r[N-1] - sum_r[j]);
                if (((2 * j - i) < N) && S[2*j -i] == 'R') {
                    sum--;
                }
            }
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 3728
use std::collections::HashMap;
use std::iter::FromIterator;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut map = HashMap::new();
    for _ in 0..n {
        let x:usize = read();
        *map.entry(x).or_insert(0) += 1;
    }
    let v = Vec::from_iter(map);
    println!("{}", v.iter().filter(|&&(_, v)| v % 2 != 0).count());
}


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

int main(){
    int r, c;
    cin >> r >> c;
    int a[101][101] = {};
    for(int i = 0 ; i < r ; i++){
        for(int j = 0 ; j < c ; j++){
            cin >> a[i][j];
        }
    }
  
    for(int i = 0 ; i < r ; i++){
        for(int j = 0 ; j < c ; j++){
            a[r][c] = a[r][c] + a[i][j];
        }
    }
    for(int i = 0 ; i < r ; i++){
        int s = 0;
        for(int j = 0 ; j < c ; j++){
            s = s + a[i][j];
            a[i][c] = s;
        }
    }
    for(int j = 0 ; j < c ; j++){
        int s = 0;
        for(int i = 0 ; i < r ; i++){
            s = s + a[i][j];
            a[r][j] = s;
        }
    }
    for(int i = 0 ; i <= r ; i++){
        for(int j = 0 ; j <= c ; j++){
            if(j) cout << " ";
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>

#include <limits.h>

int main(void) {

    int n;
    scanf("%d", &n);
    long long int *a = (long long int *)malloc(n * sizeof(long long int));
    for (int i = 0; i < n; i ++) {
        scanf("%lld", &a[i]);
    }
    //printf("%ld\n", LONG_MAX);
    

    long long int ret = 1L;
    for (int i = 0; i < n; i ++) {
        if (a[i]>1000000000000000000/ret) {
            ret = -1;
            break;
        }
        ret *= a[i];

        //printf("%ld\n", ret);
    }
    for (int i = 0; i < n; i ++) {
        if (a[i] == 0) {
            ret = 0;
        }
    }


    printf("%lld", ret);

    return 0;
}

Measured memory_bytes: 2512
# -*- coding: utf-8 -*-
X, Y, A, B, C = map(int, input().split())
red_oishisa = list(map(int, input().split()))
green_oishisa = list(map(int, input().split()))
no_oishisa = list(map(int, input().split()))

red_oishisa = list(sorted(red_oishisa))[::-1]
green_oishisa = list(sorted(green_oishisa))[::-1]
no_oishisa = list(sorted(no_oishisa))[::-1]

oishisa_s = []

i=1
j=1
k=1
while(True):
    if len(oishisa_s) == X+Y:
        break
    
    hikaku_dict = dict()
    if i <= X:
        hikaku_dict['red'] = red_oishisa[i-1]
    if j <= Y:
        hikaku_dict['green'] = green_oishisa[j-1]
    if k <= C:
        hikaku_dict['no'] = no_oishisa[k-1]
    
    max_key, max_value = max(hikaku_dict.items(), key=lambda x:x[1])
    oishisa_s.append(max_value)
    if max_key == 'red':
        i += 1
    elif max_key == 'green':
        j += 1
    elif max_key == 'no':
        k += 1

print(sum(oishisa_s))

Measured memory_bytes: 23328
a = []

while line = gets
  a << line.chomp.split(',').map(&:to_i)
end

dp = Array.new(100) { Array.new(100, 0) }

dp[0][0] = a[0][0]

for i in 1...a.size
  for j in 0...a[i].size
    dp[i][j] = dp[i - 1][j] + a[i][j]
    dp[i][j] = [dp[i][j], dp[i - 1][j - 1] + a[i][j]].max if i <= a.size / 2 && j - 1 >= 0
    dp[i][j] = [dp[i][j], dp[i - 1][j + 1] + a[i][j]].max if i > a.size / 2
  end
end

puts dp[a.size - 1][0]

Measured memory_bytes: 8704
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int a,b,c;
    
    cin >> a >> b >> c;
    
    
    if ((a+b)>=c){
    
    cout << "Yes" << endl;
    
    }else{
    
    cout << "No" << endl;
    
    }
    
    
    
    
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())

def dist(x,y):
    ans = 0
    for i in range(d):
        ans += (x[i] - y[i])**2
    return math.sqrt(ans)

points = []
for i in range(n):
    points.append(list(map(int, input().split())))


cnt = 0
for i in range(n):
    for j in range(i+1,n):
        if dist(points[i],points[j]).is_integer():
            cnt += 1

print(cnt)

Measured memory_bytes: 3064
/*
*/
#include<bits/stdc++.h>
using namespace std;
#define maxn 300010
#define ll long long
#define pii pair<ll,ll>
int a[maxn]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
int n;
char s[maxn];
void dfs(int now)
{
	if(now==n+1)
	{
		cout<<s+1<<endl;
		return ;
	}
	if(now==1) 
	{
		s[now]='a';
		dfs(now+1);
	}
	else
	{
		int maxx=0;
		for(int i=1;i<=now-1;i++) maxx=max(maxx,(int)s[i]);
		for(int i='a';i<=maxx+1;i++)
		{
			s[now]=i;
			dfs(now+1);
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	dfs(1);
	return 0;
}



Measured memory_bytes: 1536