akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m{INT_MAX},M{},L{},r{INT_MAX},mi{},Mi{};
    cin>>n;
    vector<int> x(n),y(n);
    fr(i,n){
        cin>>x[i]>>y[i];
        if(x[i]>y[i]) swap(x[i],y[i]);
        if(chmin(m,x[i])) mi=i;
        chmax(L,x[i]);
        if(chmax(M,y[i])) Mi=i;
        chmin(r,y[i]);
    }
    ll ans{(0ll+L-m)*(M-r)};
    if(mi!=Mi){
        using P=pair<int,int>;
        set<P> st;
        st.emplace(y[mi],-1);
        st.emplace(x[Mi],-1);
        fr(i,n) if(i!=mi and i!=Mi){
            st.emplace(x[i],y[i]);
        }
        chmin(ans,ll(M-m)*(st.rbegin()->first-st.begin()->first));
        while(st.begin()->first<st.begin()->second){
            int x,y;
            tie(x,y)=*st.begin();st.erase(st.begin());
            st.emplace(y,x);
            chmin(ans,ll(M-m)*(st.rbegin()->first-st.begin()->first));
        }
    }
    cout<<ans<<'\n';
}

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

int main() {
  int64_t a, b, c, d, ans;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  ans = max(a*c, b*c);
  ans = max(ans, a*d);
  ans = max(ans, b*d);
  cout << ans;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;



#define N 100000

long long int binsearch_lower_bound(vector<long long int>& vec, int val) {
	long long int low = 0;            // 範囲の下限
	long long int high = vec.size();  // 範囲の上限。解はあれば [low, high] の中に存在する
	while (low < high) {
		long long int mid = (low + high) / 2;  // 中心点（この実装ではオーバーフローしうる。
									 // 　厳密には mid=low+(high-low)/2 とすべき）
		long long int midval = vec[mid];       // 中心での値

									 // 解の範囲を狭める
		if (midval < val) low = mid + 1;
		else high = mid;
	}
	return low;
}

int main(){
	long long int n, tmp;
	double middle;
	vector<long long int> a;
	cin >> n;
	for (long long int i = 0; i < n; ++i) {
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	if (n == 2) {
		cout << a[1] << " " << a[0];
		return 0;
	}
	double d = (double)a[n - 1];
	middle = d / 2;
	tmp = binsearch_lower_bound(a, middle);
	double b = (double)a[tmp], c = (double)a[tmp - 1];
	if (fabs(b - middle) < fabs(c - middle)) {
		cout << a[n - 1] << " " << a[tmp];
	}
	else {
		cout << a[n - 1] << " " << a[tmp - 1];
	}
	return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i <= (n); ++i)

using namespace std;
const string YES = "Yes";
const string NO = "No";

void solve(int N, int M, long K) {
  // greedy search
  rep(i, N)
    rep(j, M)
    if (i * M + j * N - i * j * 2 == K) {
      cout << YES << endl;
      return;
    }
  cout << NO << endl;
}

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

  int N, M;
  cin >> N >> M;
  long K;
  cin >> K;

  solve(N, M, K);
  return 0;
}


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

int main() {
  string S;
  cin >> S;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'a') A++;
    else if (S.at(i) == 'b') B++;
    else C++;
  }
  if (max(max(A, B), C) - min(min(A, B), C) > 1) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

int main() {
  int N;
  cin >> N;
  /*
  stringstream ss;
  if(N < 1000) ss << "ABC";
  else { ss << "ABD"; N-=999; }
  if(N < 100) ss << "0";
  if(N < 10) ss << "0";
  ss << N;
  */
  cout << (N<1000?"ABC":"ABD") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define pb push_back
using namespace std;
string s;
bool flag;
int main(){
	cin>>s;
	flag =true;
	for (int i=0;i<(int)s.size()-1;i++){
		if (s[i]==s[i+1]){
			cout <<i+1<<" "<<i+2<<endl;
			flag =false;
			break;
		}
		if (i!=(int)s.size()-2&& s[i]==s[i+2]){
			cout <<i+1<<" "<<i+3<<endl;
			flag =false;
			break;
		}
	}
	if (flag){cout <<"-1 -1"<<endl;}
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 0;
		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(sc.next());
			int tem = 0;
			for (; a % 2 == 0; a /= 2)
				tem++;
			if (tem < ans || i == 0)
				ans = tem;
		}
		System.out.println(ans);
	}
}

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }

    else if(a+b>=k){
        cout<<a<<endl;
    }else{
        cout<<a-k+a+b<<endl;
    }
}

Measured memory_bytes: 3596
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}


int main(void) {
	ll a[3], k;
	ll b[] = { 1,0,-1 };
	ll ans = 0;
	cin >> a[0] >> a[1] >> a[2] >> k;
	for (int i = 0; i < 3 && k > 0; ++i) {
		ans += min(a[i], k) * b[i];
		k -= min(a[i], k);
	}
	cout << ans;
}

/*

*/


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s, t;
    while(getline(cin, s), s != "."){
        getline(cin, t);
        int cnt = 0, offset = 0;
        if(s == t){
            puts("IDENTICAL");
            continue;
        }
        for (int i = 0; i < s.size(); ++i) {
            if(i+offset >= t.size()){
                cnt = 114514;
                break;
            }
            if(s[i] != t[i+offset]){
                cnt = 114514;
                break;
            }
            if(s[i] == '"'){
                string a, b;
                int y = i+1, z = i+offset+1;
                while(s[y] != '"') a += s[y++];
                while(t[z] != '"') b += t[z++];
                offset += z-y-offset;
                i = y;
                if(a != b && (!a.empty() || !b.empty())){
                    cnt++;
                }
            }
        }
        if(cnt == 1 && s.size()+offset == t.size()){
            puts("CLOSE");
        }else {
            puts("DIFFERENT");
        }
    }
    return 0;
}


Measured memory_bytes: 3152
# author:  Taichicchi
# created: 27.09.2020 23:51:44

import sys

N = int(input())

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

ans = 0

for i in range(N):
    tmp = sum(A1[:i + 1] + A2[i:])
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 9144
#include<iostream>
using namespace std;
long A,V,B,W,T;
main()
{
	cin>>A>>V>>B>>W>>T;
	if(V<=W)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	long D=V-W;
	long dist=A>B?A-B:B-A;
	cout<<(dist<=D*T?"YES":"NO")<<endl;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int N;
vector<string> ans;

void dfs(string s, char mx)
{
  if (s.size() == N)
    ans.push_back(s);
  else
  {
    for (char c = 'a'; c <= mx; c++)
    {
      dfs(s + c, ((c == mx) ? (mx + 1) : mx));
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N;
  dfs("", 'a');
  sort(ans.begin(), ans.end());
  for (auto &it : ans)
    cout << it << endl;
  return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

void YN(bool x){
  if(x) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

int main() {
  vector<string> K={"maerd","remaerd","esare","resare"};
  bool finish=true;
  string S; cin>>S;
  int s=S.size();
  reverse(S.begin(),S.end());
  for(int i=0;i<s;i++){
    
    if(S[i]=='r'){
      if(i+1>s-1)finish=false;
      if(S[i+1]!='e') finish=false;
      if(S[i+2]=='m'){
        if(i+6>s-1) finish=false;
        rep(j,7) if(S[i+j]!=K[1][j])finish=false;
        i+=6;
      }
      else if(S[i+2]=='s'){
        if(i+5>s-1) finish=false;
        rep(j,6) if(S[i+j]!=K[3][j])finish=false;
        i+=5;
      }
      else finish=false;
    }
    
    else if(S[i]=='m'){
      if(i+4>s-1) finish=false;
      rep(j,5) if(S[i+j]!=K[0][j]) finish=false;
      i+=4;
    }
    
    else if(S[i]=='e'){
      if(i+4>s-1) finish=false;
      rep(j,5) if(S[i+j]!=K[2][j])finish=false;
      i+=4;
    }
    
    else finish=false;

    if(!finish) break;
    
  }
  YN(finish);
}


Measured memory_bytes: 3732
using System;

namespace ABC131 {
	class Program {
		static void Main(string[] args) {
			// 入力
			String s = Console.ReadLine();
			// 処理
			Boolean b = false;
			for (int i = 0; i < 3; i++) {
				if (s[i] == s[i + 1]) {
					b = true;
					break;
				}
			}
			if (b) {
				Console.WriteLine("Bad");
			} else {
				Console.WriteLine("Good");
			}
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
const int maxN = 100010;
const int maxM = 20;
const int INF = 1000000000;
int a[maxN];
int n,k; 
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int minc = INF;
	for(int i = 1;i<=n;i++)
	{
		int j = i+k-1;
		if(j>n) continue;
		
		int tmp = min(abs(a[i]),abs(a[j])) + abs(a[i] - a[j]);
		
		minc = min(minc,tmp);
	}
	printf("%d\n",minc);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <iomanip>
#define m 1000000007
using namespace std;
typedef long long ll;
vector<int> adj[1001];
int visited[1001]={0};

int main()
{
    ll n,j=2;
    cin>>n;
    double v[n],ans;
    for (int i = 0; i < n; ++i)
    {
        cin>>v[i];
    }
    sort(v,v+n);
    ans=(v[0]+v[1])/2.0;
    if(n==2)
        cout<<ans;
    else
    {
        while(j!=n)
        {
            ans=(ans+v[j])/2;
            j++;
        }
        cout<<ans;
    }
}


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

typedef long long ll;

using namespace std;

int dp[1010][1010];

int main(void){
	int W, N;
	int w[10010], v[10010];
	int c = 0;

	while(cin >> W){
		c++;
		if(!W) break;
		cin >> N;
		for(int i=0; i<N; ++i){
			scanf("%d,%d", &v[i], &w[i]);
		}

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

		for(int i=0; i<N; ++i){
			for(int j=0; j<=W; ++j){
				if(j < w[i]) dp[i+1][j] = dp[i][j];
				else {
					dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
				}
			}
		}

		int weight;
		for(int j=W; j>=0; --j){
			if(dp[N][j] == dp[N][W]) weight = j;
			else break;
		}

		cout << "Case " << c << ":" << endl << dp[N][W] << endl << weight << endl;

	}


	return 0;
}

Measured memory_bytes: 5208
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

x,a,b=[int(input()) for i in range(3)]
print((x-a)%b)

Measured memory_bytes: 38256
import numpy as np
H,W = [int(i) for i in input().split()]

C = np.zeros([1,H],dtype = object)

for i in range(H):
    C[0,i] = str(input())
    
C_d = np.zeros([1,2*H],dtype = object)

for i in range(2*H):
    C_d[0,i] = C[0,int(i//2)]
    
for i in range(2*H):
    print(C_d[0,i])
    

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  string t;
  
  for(int i=0;i<n;i++){
    if(s.at(i) != 'B'){
      t.push_back(s.at(i));
    }
    else if(t.size()>0){
      t.pop_back();
    }
  }
  cout << t <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;

char left_s[15]={'q', 'a', 'z', 'w', 's', 'x', 'e', 'd', 'c', 'r', 'f', 'v', 't', 'g', 'b'};
char right_s[11]={'y', 'h', 'n', 'u', 'j', 'm', 'i', 'k', 'o', 'l', 'p'};
int main() {
    string str;
    while(cin >> str, str!="#"){
        int n=str.size();
        int state=0, cnt=0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<15; ++j){
                if(left_s[j]==str[i]){
                    if(state!=-1) cnt++;
                    state = -1;
                }
            }
            for(int j=0; j<11; ++j){
                if(right_s[j]==str[i]){
                    if(state!=1) cnt++;
                    state=1;
                }
            }
        }
        cout << cnt-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
	int  [][] data;

	private int check(int x, int y) {
		int ans = 0,xlen = 5;
		for(int i = y; i < 5;i++){
			for(int j = x; j < xlen; j++){
				if(data[i][j] == 0){
					xlen = j;
					break;
				}
				ans = Math.max(ans, (i - y + 1) * (j- x + 1));
			}
		}
		return ans;
	}

	private void doIt() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			data = new int[5][5];
			for(int i=0; i < 5;i++){
				for(int j=0; j < 5; j++){
					data[i][j] = sc.nextInt();
				}
			}

			int max = 0;
			for(int i=0; i < 5; i++){
				for(int j=0; j < 5; j++){
					if(data[i][j] == 1){
						int temp = check(j,i);
						max = Math.max(max, temp);
					}

				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int dijkstra(int s, int g, int ticketNum, vector<vector<P>> &G){
    vector<vector<int>> dist(110, vector<int>(15, 1e9));
    queue<P> que;
    dist[s][0] = 0;
    que.push(P(s, 0));

    while(!que.empty()){
        int cv, cticket;
        tie(cv, cticket) = que.front();
        que.pop();

        for(auto x : G[cv]){
            int nv = x.first;
            int ncost = x.second;
            if(dist[cv][cticket] + ncost < dist[nv][cticket]){
                dist[nv][cticket] = dist[cv][cticket] + ncost;
                que.push(P(nv, cticket));
            }
            if(cticket < ticketNum && dist[cv][cticket] + ncost / 2 < dist[nv][cticket+1]){
                dist[nv][cticket+1] = dist[cv][cticket] + ncost / 2;
                que.push(P(nv, cticket+1));
            }
        }
    }

    int ans=1e9;
    for(int i=0; i<=ticketNum; i++){
        chmin(ans, dist[g][i]);
    }

    return ans;
}

int main(){
    while(1){
        int c, n, m, s, d; cin>>c>>n>>m>>s>>d;
        s--, d--;
        if(c == 0) return 0;

        vector<vector<P>> G(110);
        for(int i=0; i<m; i++){
            int a, b, f; cin>>a>>b>>f;
            a--, b--;
            G[a].eb(P(b, f));
            G[b].eb(P(a, f));
        }

        cout << dijkstra(s, d, c, G) << endl;
    }
}


Measured memory_bytes: 3160
import heapq
import bisect
import collections

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)

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

using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<ll> dp(n, (1e18L + 10));
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < min(k + i + 1,n); ++j) {
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

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

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ans(n, -1);
    if(n == 1 && m == 0){
        cout << 0 << endl;
        return 0;
    }
    rep(i, m){
        int s, c; cin >> s >> c;
        s--;
        if(ans[s] != -1 && ans[s] != c){ //矛盾
            cout << -1 << endl;
            return 0;
        }else{
            ans[s] = c;
        }
    }
    rep(i, n){
        if(i==0){
            if(ans[i] == -1) ans[i] = 1;
            if(ans[i] == 0 && n != 1){ //一番左が0ではいけない
                cout << -1 << endl;
                return 0;
            }
        }else{
            if(ans[i] == -1) ans[i] = 0; //決まっていないので0を入れる
        }
    }
    rep(i, n) cout << ans[i];
    cout << endl;
}




Measured memory_bytes: 256
N,M=map(int,input().split())
p=[0]*M
S=[0]*M
sei=[0]*N
pena=[0]*N
total=[0]*N

for i in range(M):
  p[i],S[i] = input().split()
  p[i]=int(p[i])

  if S[i]=="AC":
    if sei[p[i]-1]>=1:
      pass
    else:
      sei[p[i]-1] +=1
      
  else: # WAのとき
    if sei[p[i]-1]>=1:
      pass
    else: #0のとき
      pena[p[i]-1] +=1

for j in range(N):
  total[j]=sei[j]*pena[j]
  
print(sum(sei),sum(total))

Measured memory_bytes: 15636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,d;
	string ans="No";
	cin>>N;
	while(N>0){
		d=N%10;
		N=N/10;
		if(d==7){
			ans="Yes";
		}
	}
	cout<<ans;
	return 0;
} 

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> ans(n);
	for (int i = 1; i < n; ++i) {
		int a; cin >> a;
		++ans[a - 1];
	}
	for (int i = 0; i < n; ++i) cout << ans[i] << endl;

	return 0;
}

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

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N),y(M);
	for(int i(0);i<N;++i) cin >> x[i];
	for(int i(0);i<M;++i) cin >> y[i];
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	if(x[N-1] < y[0] && X < y[0] && Y > x[N-1]) cout << "No War" <<endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=107;

int n;

vector <int> graf[nax];

map <int,ll> mapa;

int odl[nax];

void dfs(int v, int o)
{
	if (o>=odl[v])
		return;
	odl[v]=o;
	for (int i : graf[v])
		dfs(i, o+1);
}

pair <int,ll> licz(vector <int> wek)
{
	mapa.clear();
	for (int i=1; i<=n; i++)
		odl[i]=1e9;
	for (int i : wek)
		dfs(i, 1);
	ll ret=1;
	int naj=0;
	
	for (int i=1; i<=n; i++)
	{
		naj=max(naj, odl[i]);
		ll ile=0;
		for (int j : graf[i])
			if (odl[j]==odl[i]+1)
				ile++;
		mapa[odl[i]]=max(mapa[odl[i]], ile);
	}
	//~ debug() << range(res+1, res+1+n);
	//~ debug() << mapa;
	for (auto i : mapa)
		if (i.second)
			ret*=i.second;
	
	return {naj, ret*wek.size()};
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	pair <int,ll> wyn={1e9, 0};
	for (int i=1; i<=n; i++)
	{
		wyn=min(wyn, licz({i}));
		for (int j : graf[i])
			if (j<i)
				wyn=min(wyn, licz({i, j}));
	}
	printf("%d %lld\n", wyn.first, wyn.second);
	return 0;
}


Measured memory_bytes: 256
n=int(input())

s,t=input().split()
c=''
i=0
j=0
f=0
for _ in range(len(s)+len(t)):
          if f==0:
             c+=s[i]
             i+=1
             f=1
          else:
              c+=t[j]
              j+=1
              f=0
print(c)

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

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  ll ans;
  ans = a*b;
  cout << ans << endl;
}


Measured memory_bytes: 3732
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
bool isPerfectSquare(long double x) 
{  
  long double sr = sqrt(x);  
  return ((sr - floor(sr)) == 0); 
}
int main()
{
    ll n,i,j,d,k,ans=0;
    cin>>n>>d;
    ll a[n][d];
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
            cin>>a[i][j];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            long double p=0;
            for(k=0;k<d;k++)
            {
                p+=((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
            }
            if(isPerfectSquare(p))
                ans++;
        }
    }
    cout<<ans;
    exit(0);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
s = [0 for i in range(n)]
for i in range(k):
    d, a = int(input()), list(map(int, input().split()))
    for a_i in a: s[a_i-1] += 1
print(s.count(0))

Measured memory_bytes: 66592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;cin>>n;vector<int> a(n);
  for(int i=0;i<n;i++){
    int k;cin>>k;
    a[k-1]=i+1;
  }
  for(int i=0;i<n;i++)cout<<a[i]<<" ";
}

Measured memory_bytes: 1152
toTuple :: [String] -> (Int, Int, Int)
toTuple xs = (read (xs!!0), read (xs!!1), read (xs!!2))

calculateBlueBalls :: (Int, Int, Int) -> Int
calculateBlueBalls (n, b, r) | b == 0 = 0
                             | otherwise = (n `div` (b + r) * b) + min b (n `mod` (b + r))

main :: IO ()
main = do
  line <- getLine
  let out = (show . calculateBlueBalls . toTuple . words) line
  putStrLn out


Measured memory_bytes: 508
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b;
  c=a*b;
  if(c%2!=0) 
    cout<<"Odd";
  else
    cout<<"Even"; 
  system("pause");
  return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;

int m[100005];
int isOk(int n, int p, int cap){
	int j = 0;
	for(int i = 0; i < p; i++){
		int temp = cap;
		while(m[j] <= temp && j < n){
			temp -= m[j];
			j++;
		}
	}
	return j == n ? 1 : 0;
}

int main(){
	int n, p, Max1 = 0;
	cin >> n >> p;
	for(int i = 0; i < n; i++){
		scanf("%d", m + i);
		Max1 += m[i];
	}
	int l = 0, r = Max1, mid;
	while(l < r){
		mid = (l + r) / 2;
		if(isOk(n, p, mid))
			r = mid;
		else
			l = mid + 1;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a < b) {
    puts("a < b");
  } else if (a > b) {
    puts("a > b");
  } else {
    puts("a == b");
  }
  return 0;
}



Measured memory_bytes: 2040
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
 
#define mem(a, b) memset(a, (b), sizeof(a))
 
using namespace std;
typedef long long ll;
 
const int N = 2e5 + 10;
const int Max = 1e9 + 10;
 
int a[40], b[40], c[40], d[15],e[15];
int main(){
	mem(a, 0);
	mem(b, 0);
	mem(c, 0);
	mem(d, 0);
	mem(e, 0);
	for(int i = 1; i < 40; i++){
		a[i] = i * i;
		//printf("%d\n", a[i]);
	}
	for(int i = 1; i < 20; i++)
		b[i] = i * i * i;
	for(int i = 1;i < 20; i++)
		c[i] = i * i * i * i;
	for(int i = 1; i < 11; i++){
		d[i] = pow(2, i);
		c[i] = pow(3 ,i);
	}
	
	int x;
	cin >> x;
	int maxx = 0;
	for(int i = 39; i > 0; i--){
		if(a[i + 1] > x && a[i] <= x){
			maxx = max(a[i],maxx);
		}
		if(b[i + 1] > x && b[i] <= x)
			maxx = max(b[i],maxx);
		if(c[i + 1] > x && c[i] <= x)
			maxx = max(c[i],maxx);
		if(d[i + 1] > x && d[i] <= x)
			maxx = max(d[i],maxx);
		if(e[i + 1] > x && e[i] <= x)
			maxx = max(e[i],maxx);

	}
	printf("%d\n", maxx);
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	char c='A',x,y;
	while(scanf("%c,%c",&x,&y)!=EOF){
		if(c==x){c=y;continue;}
		if(c==y)c=x;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100

void solve(){
	int n, m = 0, ans = 1;
	cin>>n;
	rep(i,1,n+1){	
		int cnt = 0;
		int t = i;
		while(t%2==0){
			cnt++;
			t/=2;
		}
		if(m<cnt){ m= cnt; ans = i;}
	}
	cout<<ans<<endl;	
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

vector<int> g[200005];

signed main()
{
  int n, m; //nに行きたい, m種類

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool f = false;
  for (auto v: g[1]) {
//    cout << v << endl;
    for (auto w: g[v]) {
//      cout << w << endl;
      if (w == n) {
        f = true;
        break;
      }
    }
  }

  if (f) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return (0);
}

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

using namespace std;

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans;

void dfs(vector<int> &v, int sz = 0) {
  if (sz == n) {
    int tot = 0;
    for (int i = 0; i < q; i++) {
      if (v[b[i]] - v[a[i]] == c[i]) {
        tot += d[i];
      }
    }
    ans = max(ans, tot);
    return;
  }

  for (int i = 1; i <= m; i++) {
    if (v.empty() || v.back() <= i) {
      v.emplace_back(i);
      dfs(v, sz + 1);
      v.pop_back();
    }
  }
}

int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }
  vector<int> v;
  dfs(v);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int a; string s;
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	else {
		cout << "red" << endl;
	}
	return 0;
}

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

#define el endl
#define fd fixed

using namespace std;

class Dice
{
private:
  int top;
  int face;
  int right;
  int left;
  int back;
  int bottom;
public:
  void setTop(int a);
  void setFace(int a);
  void setRight(int a);
  void setLeft(int a);
  void setBack(int a);
  void setBottom(int a);
  int getTop();
  int getFace();
  int getRight();
  int getLeft();
  int getBack();
  int getBottom();
  void roll(string s);
  void rollE();
  void rollN();
  void rollS();
  void rollW();
  void arrangeTop(int a);
  void arrangeFace(int a);
};

void Dice::setTop(int a) {
  top = a;
}

void Dice::setFace(int a) {
  face = a;
}

void Dice::setRight(int a) {
  right = a;
}

void Dice::setLeft(int a) {
  left = a;
}

void Dice::setBack(int a) {
  back = a;
}

void Dice::setBottom(int a) {
  bottom = a;
}

int Dice::getTop() {
  return top;
}

int Dice::getFace() {
  return face;
}

int Dice::getRight() {
  return right;
}

int Dice::getLeft() {
  return left;
}

int Dice::getBack() {
  return back;
}

int Dice::getBottom() {
  return bottom;
}

void Dice::roll(string s) {
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'E') rollE();
    if (s[i] == 'N') rollN();
    if (s[i] == 'S') rollS();
    if (s[i] == 'W') rollW();
  }
}

void Dice::rollE() {
  int tmp = top;
  top = left;
  left = bottom;
  bottom = right;
  right = tmp;
}

void Dice::rollN() {
  int tmp = top;
  top = face;
  face = bottom;
  bottom = back;
  back = tmp;
}

void Dice::rollS() {
  int tmp = top;
  top = back;
  back = bottom;
  bottom = face;
  face = tmp;
}

void Dice::rollW() {
  int tmp = top;
  top = right;
  right = bottom;
  bottom = left;
  left = tmp;
}

void Dice::arrangeTop(int a) {
  for (int i = 0; i < 3; i++) {
    if (top == a) break;
    roll("N");
    if (top == a) break;
    roll("E");
  }
}

void Dice::arrangeFace(int a) {
  for (int i = 0; i < 4; i++) {
    if (face == a) break;
    roll("NES");
  }
}

int main() {
  Dice d;
  int a[6], q;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> q;
  d.setTop(a[0]);
  d.setFace(a[1]);
  d.setRight(a[2]);
  d.setLeft(a[3]);
  d.setBack(a[4]);
  d.setBottom(a[5]);
  while (q--) {
    int t, f;
    cin >> t >> f;
    d.arrangeTop(t);
    d.arrangeFace(f);
    cout << d.getRight() << el;
  }
  return 0;
}

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

using namespace std;

int
main(void){
	int n; cin >> n;
	string s; cin >> s;
	vector<int> east(n);
	vector<int> west(n);
	for(int i = 0; i < n; i++){
		if(s[i] == 'W') west[i]++;
		else east[i]++;
	}
	for(int i = 1; i < n; i++){
		west[i] += west[i - 1];
		east[n - i - 1] += east[n - i];
	}
	int ans = INT_MAX;
	for(int i = 0; i < n; i++){
		if(i == 0){
			ans = min(ans, east[1]);
		}
		else if(i == n - 1){
			ans = min(ans, west[n - 2]);
		}
		else{
			ans = min(ans, east[i + 1] + west[i - 1]);
		}
	}
	cout << ans;
}

Measured memory_bytes: 2948
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    ll A, B, C, K;
    cin>>A>>B>>C>>K;
    ll ans;
    if(A>=K){
        cout<<K<<endl;
    }
    else{
        ans = A;
        K -= A;
        if(B>=K){
            cout<<ans<<endl;
        }
        else{
            K-=B;
            cout<<ans - K<<endl;
        }
    }
}



Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
int main(void){
    
    int N, R;
    cin >> N;
    
    cin >> R;
    int num_Max = INT_MIN;
    int num_Min = R;
    for(int i = 1; i < N; i++){
        cin >> R;
        num_Max = max(num_Max, R - num_Min);
        num_Min = min(num_Min, R);
    }
    
    cout << num_Max << endl;
}



Measured memory_bytes: 3132
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B, C, D;
int T[101][2];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B >> C >> D;
  int ctr = 0;
  for (int i=0; i<=200; i++) {
    if (A <= i && i < B &&
        C <= i && i < D) ctr++;
  }
  cout<< ctr<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ss, ee) for (int i = (ss); i < (ee); ++i)

void solve() {
  int N;
  cin >> N;
  string s = "ACL";
  string ans;
  rep(i, 0, N) { ans += s; }
  cout << ans << endl;
}

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

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define MOD 1000000007

long long DP[105][100005];
int arr[105];
int n,K;

int main(){
	scanf("%d%d",&n,&K);
	for (int i =1;i<=n;i++){
		scanf("%d",&arr[i]);
	}
	for(int i =0;i<=n;i++){
		for(int j = 0; j<=K;j++){
			if(i==0){
				DP[i][j] =0;
			} else if(j==0) DP[i][j] = 1; 
			else if(i==1){
				if(j<=arr[i])DP[i][j] = DP[i][j-1]+1;
				else DP[i][j] = DP[i][j-1];	
			} else {
				DP[i][j] = ((DP[i][j-1] + DP[i-1][j]) %MOD- (j-arr[i]-1>=0?DP[i-1][j-arr[i]-1]:0)+MOD)%MOD;
			}
		}
	}
	printf("%lld\n", (DP[n][K]-(K-1>=0?DP[n][K-1]:0)+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>
#include <stdlib.h>
int partititon(int [],int,int);
int main() {

  int i,j;
  int *A;
  int b;
  int p,r;
  int n;

  scanf("%d",&n);

  A=malloc(sizeof(int)*n+1);

  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
  }
  p=1;
  r=n;
  b=partition(A,p,r);

  for(i=0;i<n;i++){
    if((i+1)==b){
      printf("[%d] ",A[i+1]);
      continue;
    }
    printf("%d",A[i+1]);
    if((i+1)==n) break;
    printf(" ");
  }


  printf("\n");

  return 0;
}
int partition(int A[],int p, int r) {

  int x;
  int i,j,a;
  int b;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x) {
      i++;
      a=A[i];
      A[i]=A[j];
      A[j]=a;
    }
  }
  b=A[i+1];
  A[i+1]=A[r];
  A[r]=b;
  return i+1;
}
  

Measured memory_bytes: 996
#include<iostream>
using namespace std;
int main(){
	long long l[88]={2,1};
	int i,n;
	for(i=2;i<=86;i++){
		l[i]=l[i-1]+l[i-2];
	}
	cin >> n;
	cout << l[n] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define all(x) x.begin(),x.end()

int const N = 2e5;
int n , a[N],b[N],c[N];
ll dp[N][4];

ll go(int i , int prv){
      if(i == n)return 0 ;
      ll &ret = dp[i][prv];
      if(ret + 1)return ret;
      ret = 0 ;
      if(prv == 1){ // previous day was A 
         ret += max(go(i+1,3)+c[i], go(i+1,2)+b[i]);
         return ret;
      }
      if(prv == 2) { // previous day was B
         ret += max(go(i+1,1)+a[i],go(i+1,3)+c[i]);
         return ret;
      }
      if(prv == 3){
        ret += max(go(i+1,1)+a[i],go(i+1,2)+b[i]);
        return ret;
      }
      if(!prv) {
          ret += max(go(i+1,1)+a[i],max(go(i+1,2)+b[i],go(i+1,3)+c[i]));
          return ret;
      }
      return ret;
}


int main(){
     scanf("%d",&n);
     for(int i=0;i<n;++i){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
     }
     memset(dp,-1,sizeof dp);
     ll an = go(0,0);
     cout << an ;
	   return 0 ; 
}

Measured memory_bytes: 11520
n=int(input())
ans=0 #this is the answer
for i in range (1,n+1,2): #think about the number from 1 to n
  cnt=0 #this counts the divisors
  for j in range (1,n+1): #check all the numbers and find divisors
    if i%j==0 : #the condition whether it is a divisor of n or not
      cnt+=1
  if cnt==8 and i%2==1:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
int main(){
    int n,m,x;
    int a[101];
    scanf("%d%d%d",&n,&m,&x);
    for (int i=1;i<=m;i++){
        scanf("%d",&a[i]);
    }
    int pos=1;
    while (pos <= m && a[pos]<x){
        pos++;
    }
    int cnt=m+1-pos;
    printf("%d\n", cnt>m-cnt?m-cnt:cnt);
    return 0;
}


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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(), b = sc.nextLong();
        int len = 50;

        long ans = 0;
        for (int i = 0; i < len; i++) {
            long ab = f(a - 1, i);
            long bb = f(b, i);
            ans |= ((bb - ab) % 2) << i;
            debug(ab, bb);
        }
        debug(Integer.toBinaryString(435));
        System.out.println(ans);
    }

    // 0101...
    // 00110011...
    // 00001111...
    long f(long n, int b) {
        if (n < (1L << b)) return 0;
        long cnt = (n / (1L<<(b + 1))) << b;
        long r = n / (1L<<(b + 1));
        long tmp = n - r * (1L<<(b + 1));

        long add = tmp >= (1L<<b) ? tmp - (1L<<b) + 1 : 0;

        debug(n, tmp, b, cnt, r, add);
        return (cnt + add);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

void solve() {
    ll n;
    cin >> n;
    vector<double> v(n);
    forn(n) {
        cin >> v[i];
    }
    vector<double> prev(n + 1, 0);
    prev[0] = 1;
    for (int i = 0; i < n; ++i) {
        vector<double> temp(n + 1);
        for (int j = 0; j <= n - 1; ++j) {
            temp[j + 1] += (prev[j] * v[i]);
        }
        for (int j = 0; j <= n; ++j) {
            prev[j] *= (1 - v[i]);
            prev[j] += temp[j];
        }
    }
    double ans = 0;
    for (int i = (n / 2) + 1; i <= n; ++i) {
        ans += prev[i];
    }
    cout << fixed << setprecision(12) << ans << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
map<int,int>mp;
int x,n;
int main(){
	cin>>x>>n;
	rep(i,n){
		int tp;
		cin>>tp;
		mp[tp]++;
	}
	int ans=INF;
	for(int i=x-105;i<=x+105;i++){
		if(!mp[i]){
			if(abs(ans-x)>abs(i-x)||(abs(ans-x)==abs(i-x)&&i<ans)){
				ans=i;
			}
		}
	}
	cout<<ans<<endl;
	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 w = sc.nextInt();
		int[] nums = new int[w];
		for(int i = 0; i < w; i++){
			nums[i] = i+1;	
		}
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			String input = sc.next();
			String[] resultInput = input.split(",");
			int a = Integer.parseInt(resultInput[0]);
			int b = Integer.parseInt(resultInput[1]);
			nums = swap(nums, a, b);
		}
		for(int i = 0; i < w; i++){
			System.out.println(nums[i]);
		}
	}

	public static int[] swap(int[] nums, int a, int b){
		a -= 1;
		b -= 1;
		int tmp = nums[a];
		nums[a] = nums[b];
		nums[b] = tmp;
		return nums;
	}
}

Measured memory_bytes: 26208
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

#標準入力
n,m = imap()
ab = np.array([iarr() for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1

#隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa,bb in zip(a,b):
    g[aa].append(bb)
    g[bb].append(aa)


anss = [0]*n
know = [0]*n; know[0] = 1
q = col.deque([0])
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]: continue
        else: know[next] = 1; anss[next] = now; q.append(next)

print('Yes')
for ans in anss[1:]: print(ans+1)





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


int main()
{
  int n;
  cin >> n;
  vector<string> w(n);
  for(int i = 0; i < n;i++){
    cin >> w[i];
  }
  bool flag = 1;
  for(int i = 1;i < n;i++){
    int l1 = w[i-1].size();
    if(w[i - 1][l1-1] != w[i][0]) flag = 0;
  }
  for(int i = 0;i < n;i++){
    for(int j = i+1;j < n;j++){
      if(w[i] == w[j]) flag = 0;
    }
  }
  if(flag) cout << "Yes" << endl;
  if(flag == 0) cout << "No" << endl;

  return 0;

}


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

int main() {
    int a;
    cin >> a;
    int h = a / 60 / 60;
    int m = a / 60 % 60;
    int s = a % 60;
    cout << h <<":" << m <<":"<< s<< endl;
 }    



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>
#include <ctype.h>

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

using namespace std;
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;

	int l = a + b;
	int r = c + d;

	if (l > r) {
		cout << "Left" << endl;
	}
	else if (l < r) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N;
    char S[1024];
    int i;

    int ans = 0;

    scanf("%d",&N);
    scanf("%s",S);

    for(i=0;i<N;i++){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    ans++;
                }
            }
        }
    }

    printf("%d\n",ans);
}

Measured memory_bytes: 128