akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+9;
const int INF = 0x3f3f3f3f;

int a[2][N], pos[N], d[2][N][32];

struct Node {
    int p, l, r;
    bool operator < (const Node& rhs) const {
        return p > rhs.p;
    }
};

void initRMQ(int n, int pa) {
    for (int i = 0; i < n; i++) d[pa][i][0] = a[pa][i];
    for (int j = 1; (1 << j) <= n; j++) {
        for (int i = 0; i + (1 << j) - 1 < n; i++) {
            d[pa][i][j] = min(d[pa][i][j - 1], d[pa][i + (1 << (j - 1))][j - 1]);
        }
    }
}

int RMQ(int l, int r, int pa) {
    int k = 0;
    while ((1 << (k + 1)) <= r - l + 1) k++;
    return min(d[pa][l][k], d[pa][r - (1 << k) + 1][k]);
}


int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        a[i & 1][i] = p;
        a[(i & 1) ^ 1][i] = INF;
        pos[p] = i;
    }
    initRMQ(n, 0);
    initRMQ(n, 1);
    priority_queue<Node> q;
    int x = RMQ(0, n - 1, 0);
    q.push( {x, 0, n - 1} );
    while (!q.empty()) {
        Node u = q.top();
        q.pop();
        int v1 = u.p;
        int v2 = RMQ(pos[u.p] + 1, u.r, (pos[u.p] & 1) ^ 1);
        cout << v1 << " " << v2 << " ";
        v1 = pos[v1];
        v2 = pos[v2];
        if (u.l != v1) q.push( {RMQ(u.l, v1 - 1, u.l & 1), u.l, v1 - 1} );
        if (v1 + 1 != v2) q.push( {RMQ(v1 + 1, v2 - 1, (v1 + 1) & 1), v1 + 1, v2 - 1} );
        if (v2 != u.r) q.push( {RMQ(v2 + 1, u.r, (v2 + 1) & 1), v2 + 1, u.r} );
    }
    return 0;
}


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

using namespace std;

//#define FILE_IO

typedef long long LL;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    LL A, B;
    scanf("%lld%lld", &A, &B);

    if(A == B) { printf("1\n"); return 0; }

    int bt = 0;
    for(int b = 60; b >= 0; b--)
        if( ((1LL << b) & B) && (!((1LL << b) & A)) )
        {
            bt = b;
            break;
        }

    for(int b = bt + 1; b <= 60; b++)
        if( ((1LL << b) & B) && ((1LL << b) & A) )
        {
            A ^= (1LL << b);
            B ^= (1LL << b);
        }

    LL ans = (1LL << bt) - A;

    int btB = -1;
    for(int b = bt - 1; b >= 0; b--)
        if( ((1LL << b) & B) )
        {
            btB = b;
            break;
        }

    LL st1 = 0, dr1 = 0;

    if(btB != -1)
    {
        st1 = (1LL << bt);
        dr1 = (1LL << bt) + (1LL << (btB + 1)) - 1;
    }
    else
        st1 = dr1 = B;

    LL st2 = (1LL << bt) + A;
    LL dr2 = (1LL << (bt + 1)) - 1;

    if(st2 <= dr1)
        ans += max(dr1, dr2) - min(st1, st2) + 1;
    else
        ans += (dr1 - st1 + 1) + (dr2 - st2 + 1);

    printf("%lld\n", ans);


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
char s[MAXN];
int main(){
	SF("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i%2==0&&s[i]=='p')
			ans--;
		if(i%2==1&&s[i]=='g')
			ans++;
	}
	PF("%d",ans);
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    string a,b,c; cin >> a >> b >> c;
    int an=a.size(), bn=b.size();
    if(a[an-1]==b[0] && b[bn-1]==c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAX 3007

int dp[MAX][MAX];
int main()
{
    FastIO;
    string s, t;
    cin >> s;
    cin >> t;
    int x = s.size();
    int y = t.size();
    memset(dp, 0, sizeof(dp));
    for(int i=0; i<x+1; i++)
        dp[0][i] = 0;
    for(int i=1; i<y+1; i++)
        dp[i][0] = 0;
    string subSeq;
    for(int i=1; i<x+1; i++)
    {
        for(int j=1; j<y+1; j++)
        {
            if(s[i-1] == t[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    int h = x, k = y;
    while(h > 0 && k > 0)
    {
        if(s[h-1] == t[k-1])
        {
            subSeq.push_back(s[h-1]);
            h--;
            k--;
        }
        else if(dp[h-1][k] > dp[h][k-1])
            h--;
        else
            k--;
    }
    reverse(subSeq.begin(), subSeq.end());
    cout << subSeq << "\n";
   	
  	return 0;
}

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

int n;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = n; i <= 999; ++i) {
    string tmp_str = to_string(i);
    bool same = true;
    char last = tmp_str[0];
    for (int j = 1; j < tmp_str.size(); ++j) {
      same &= (last == tmp_str[j]);
      last = tmp_str[j];
    }
    if (same) {
      printf("%d\n", i);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    int n,r;
    cin >> n >> r;
    int ans = 0;
    while(n){
        n/=r;
        ans++;
    }
    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		int min,t,ans;//minはその時間までの最安値
		min=scan.nextInt();
		t=scan.nextInt();
		ans=t-min;
		if(t<min) min=t;
		for(int i=0;i<N-2;i++){
			t=scan.nextInt();
			if(ans<t-min){
				ans=t-min;
			}
			if(t<min){
				min=t;
			}
		}
		System.out.println(ans);
		scan.close();
	}
}

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

void print(const std::vector<int> &v){
   std::for_each(v.begin(), v.end(), [](int data){std::cout << data << " ";});
   std::cout << std::endl;
}

int main(){
   int N;
   std::cin >> N;
   std::vector<int> P(N);
   std::vector<int> Q(N);
   for (int i=0; i<N; i++){
      std::cin >> P.at(i);
   }
   for (int i=0; i<N; i++){
      std::cin >> Q.at(i);
   }
   std::vector<int> orgp(N);
   std::vector<int> orgq(N);
   for (int i=1; i<=N; i++){
      orgp.at(i-1) = i;
   }
   orgq = orgp;

   int cnta = 1;
   while (!(orgp == P)){
      std::next_permutation(orgp.begin(), orgp.end());
      cnta++;
   }

   int cntb = 1;
   while (!(orgq == Q)){
      std::next_permutation(orgq.begin(), orgq.end());
      cntb++;
   }

   std::cout << abs(cnta - cntb) << std::endl;
}



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

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}


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

//	freopen("name.in","r",stdin);
//	freopen("name.out","w",stdout);

    bool f = 0;
    int x,y;
    cin >> x >> y;
    for(int i=0;i<=x;i++)
    {
        if(i*2 + (x-i)*4 == y)
            f = 1;
    }
    if(f)
        cout << "Yes";
    else
        cout << "No";

	return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n;

signed main() {
	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

using namespace std;

int n;
int a[100010];
int pl;
int ps[100010];

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

    int prev = -1;

    for(int i = 0; i < n; i++) {
        if(a[i] == prev) {
            ps[pl] = a[i];
            pl++;
            prev = -1;
        } else {
            prev = a[i];
        }
    }

    if(pl - 2 < 0) {
        cout << 0 << endl;
    } else {
        cout << (long long) ps[pl - 1] * (long long) ps[pl - 2] << endl;
    }
    return 0;
}


Measured memory_bytes: 896
s = gets.chomp
k = gets.to_i
(s.length-1).times do |i|
    diff = (123 - s[i].ord) % 26
    if k >= diff
        s[i] = 'a'
        k -= diff
    end
end
s[-1] = ((s[-1].ord - 97 + k) % 26 + 97).chr
puts s

Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <cassert>
#include <map>
#define maxn 100005
using namespace std;
typedef long long ll;
int n,m,a[maxn];
ll ans;
map <int,int> cnt;
int main(){
  scanf("%d%d",&n,&m);
  cnt[0] = 1;
  for(int i = 1;i <= n;i++){
    scanf("%d",&a[i]);
    a[i] = (a[i - 1] + a[i]) % m;
    cnt[a[i] % m]++;
    ans += cnt[a[i] % m] - 1;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 200000000
#define LINF 1000000000000000000

using namespace std;

const int N = 2e5 + 10;

LL powers[N];
int main()
{
	LL n;
	cin >> n;
	n--;
	string s = "";
	LL sum = 0;
	powers[0] = 1;


	for (int i = 1;;i++) {
		powers[i] = powers[i - 1] * 26;
		sum += powers[i];
		s += 'a';
		if (sum > n) {
			sum -= powers[i];
			break;
		}
	}

	n -= sum;

	for (int i = 0;i < s.size();i++) {
		s[i] += n / powers[s.size() - i - 1];
		n %= powers[s.size() - i - 1];
	}

	cout << s << endl;
	cin >> n;
}

Measured memory_bytes: 3100
n = int(input())
m = int(input())

dp = [[float('inf') for _ in range(n)] for _ in range(n)]
for i in range(n):
    dp[i][i] = 0

for _ in range(m):
    a, b, c, d = map(int, input().split(','))
    dp[a - 1][b - 1] = c
    dp[b - 1][a - 1] = d

for k in range(n):
    for i in range(n):
        for j in range(n):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

s, g, v, p = map(int, input().split(','))

print(v - p - dp[s-1][g-1] - dp[g-1][s-1])



Measured memory_bytes: 5620
#include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353  
#define mod1 1e9 + 7  
using namespace std;

 

void func(){
  int r,c;
  cin >> r >> c;
  vector<string> vec(r);

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

  vector<vector<long long>> dp(r , vector<long long>(c));
  bool f = 0;
  for(int i = 0 ; i < r ; ++i){
    if(vec[i][0] == '#'){
      f = 1;
    }
    if(f == 1){
      dp[i][0] = 0;
    }
    else{
      dp[i][0] = 1;
    }
  }
  f = 0;
  for(int i = 0 ; i < c ; ++i){
    if(vec[0][i] == '#'){
      f = 1;
    }
    if(f == 1){
      dp[0][i] = 0;
    }
    else{
      dp[0][i] = 1;
    }
  }

  for(int i = 1 ; i < r ; ++i){
    for(int j = 1 ; j < c ; ++j){
        if(vec[i][j] == '#'){
          dp[i][j] = 0;
        }
        else{
          dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (1000000007);
        }
    }
  }

  cout << dp[r - 1][c - 1];

}

int main(){
    int t = 1 , cnt = 0 ;
    // cin >> t;
    
    while(t--){
        
        func();
    }
}

Measured memory_bytes: 9216
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    ans = max(a[i+1] - a[i],ans)
cor = (k - a[-1])+a[0]
if(ans < cor):
    ans = cor
print(k-ans)

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

int main(){
  ll n,m,i,a,b,ans;
  cin >> n >> m;
  ll h[n+1],g[n+1];
  for(i=1;i<=n;i++){
    cin >> h[i];
    g[i]=1;
  }
  for(i=1;i<=m;i++){
    cin >> a >> b;
    if(h[a]>=h[b]){
      g[b]=0;
    }
    if(h[a]<=h[b]){
      g[a]=0;
    }
  }
  ans=0;
  for(i=1;i<=n;i++){
    if(g[i]==1)ans+=1;
  }
  cout << ans;
}

Measured memory_bytes: 5184
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

#N = int(input())
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

if V <= W:
    print("NO")
    exit()
    
dist = abs(B - A)
chase = (V - W) * T

if chase >= dist:
    print("YES")
else:
    print("NO")








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

using namespace std;

#define INF 1e9

struct Edge{
    int src,dst,cost;
    Edge(int src,int dst,int cost) :
        src(src),dst(dst),cost(cost) {}
    bool operator < (const Edge &e)const{
        if(cost != e.cost){
            return cost > e.cost;
        }else if(src != e.src){
            return src < e.src;
        }else{
            return dst < e.dst;
        }
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int chinesePostman(const Graph &g){
    int sum = 0,size = g.size();
    vector<int> odds;
    for(int i = 0 ; i < size ; i++){
        for(auto x : g[i]){
            sum += x.cost;
        }
        if(g[i].size() % 2){
            odds.push_back(i);
        }
    }
    sum /= 2;
    int n = odds.size(), N = (1<<n);
    int d[n][n];
    for(int i = 0 ; i < n ; i++){
        int s = odds[i];
        vector<int> dist(size,INF),prev(size,-2);
        dist[s] = 0;
        priority_queue<Edge> Q;
        Q.push(Edge(-1,s,0));
        while(!Q.empty()){
            Edge e = Q.top(); Q.pop();
            if(prev[e.dst] != -2) continue;
            prev[e.dst] = e.src;
            for(auto x : g[e.dst]){
                if(dist[x.dst] > e.cost + x.cost){
                    dist[x.dst] = e.cost + x.cost;
                    Q.push(Edge(x.src,x.dst,dist[x.dst]));
                }
            }
        }
        for(int j = 0 ; j < n ; j++){
            d[i][j] = dist[odds[j]];
        }
    }
    vector<int> dp(N,INF);
    dp[0] = 0;
    for(int S = 0 ; S < N ; S++){
        for(int i = 0 ; i < n ; i++){
            if(S >> i & 1) continue;
            for(int j = i+1 ; j < n ; j++){
                if(S >> j & 1) continue;
                dp[S|(1<<i)|(1<<j)] =
                    min(dp[S|(1<<i)|(1<<j)],dp[S]+d[i][j]);
            }
        }
    }
    return sum + dp[N-1];
}

int main(){
    int V,E,s,t,d;
    cin >> V >> E;
    Graph g(V);
    for(int i = 0 ; i < E ; i++){
        cin >> s >> t >> d;
        g[s].push_back(Edge(s,t,d));
        g[t].push_back(Edge(t,s,d));
    }
    cout << chinesePostman(g) << endl;
    return 0;
}

Measured memory_bytes: 1280
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r,g=l+1,[i,l][l<H and A[i]<A[l]]
 if r<H and A[g]<A[r]:g=r
 if g!=i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 65608
import collections

n=int(input())
l=list(map(int,input().split()))
s=collections.Counter(l)
s=list(s.items())
s=sorted(s,key=lambda x:x[0])
#print(s)
f=[0]*len(s)
for i in range(len(s)):
    f[i]=s[i][1]
    if i>=1:
        if s[i-1][0]==s[i][0]-1:
            f[i]+=s[i-1][1]
    if i<=len(s)-2:
        if s[i+1][0]==s[i][0]+1:
            f[i]+=s[i+1][1]
print(max(f))

Measured memory_bytes: 16096
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;
const int MOD = 1000000007;

int resB[N], resC[N];
VI graf[N];
int a, b, n, i;

void go(int w, int p) {
	for (auto &w2 : graf[w]) if (w2 != p) go(w2, w);
	resB[w] = 1;
	resC[w] = 1;
	for (auto &w2 : graf[w]) if (w2 != p) {
		resB[w] = (resB[w] * 1LL * (resB[w2] + resC[w2])) % MOD;
		resC[w] = (resC[w] * 1LL * resB[w2]) % MOD;
	}
}

int main() {
scanf("%d", &n);
for (i=1;i<n;i++) {
	scanf("%d %d", &a, &b);
	a--;
	b--;
	graf[a].pb(b);
	graf[b].pb(a);
}
go(0, -1);
printf("%d\n", (resB[0] + resC[0]) % MOD);
return 0;
}

Measured memory_bytes: 13440
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include<algorithm>
#include<string.h>
#include<iostream>
#include<vector>
#include<deque>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define second ss
#define mp make_pair
#define line cout<<endl;
#define pb push_back
#define INT_SIZE sizeof(int)
#define INT_BITS INT_SIZE*8-1
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/


int main()
{
	ll n;
	cin>>n;
	string str;
	set<string>s;
	for(ll i=0;i<n;i++)
	{
		cin>>str;
		s.insert(str);
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 19124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
bool judge()
{
    if(b>d) return false;
    if(a<b) return false;
    ll k=__gcd(b,d),s=a-(a-c)/k*k-k,t=10;
    while(t--)
    {
        if(s>c&&s<b) return false;
        s+=k;
    }
    return true;
}
int main()
{
    int t;scanf("%d",&t);
    while(t--)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if(judge()) printf("Yes\n");
        else printf("No\n");
    }
}


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

const int INF = 1000000009;
const long long LINF = 1123456789012345678;

long long n;
long long a[405];
long long dp[405][405];
long long sum[405];

int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", &a[i]);
        sum[i+1] = sum[i] + a[i];
	}
	for(int j = 0; j < n-1; j++){
        dp[2][j] = a[j] + a[j+1];
        //printf("%3ld ", dp[2][j]);
    }
    //printf("\n");
    for(int i = 3; i <= n; i++){//connect i
        for(int j = 0; j < n-i+1; j++){//start from j
            dp[i][j] = LINF;
            for(int k = 1; k < i; k++){
                dp[i][j] = std::min(dp[i][j], dp[k][j] + dp[i-k][j+k] + (sum[i+j] - sum[j]));
            }
            //printf("%3ld ", dp[i][j]);
        }
        //printf("\n");
    }
	printf("%ld\n", dp[n][0]);
	return 0;
}

Measured memory_bytes: 1536
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

vector<pii> ps[112345];
const int nn=312345;
ll bit[nn+1];

ll sum(int i){ ++i;
  ll s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(int i,ll x){ ++i;
  while(i<=nn){
    bit[i]+=x;
    i+=i&-i;
  }
}



int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    ps[y-x+1].eb(x,y);
  }
  int cnt=0;
  reps(d,1,m+1){
    int re=n-cnt;
    for(int i=0;i<302345;i+=d) re+=sum(i);
    cnt+=ps[d].size();
    for(pii p:ps[d]) add(p.X,1), add(p.Y+1,-1);
    cout<<re<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,p[1000];
    scanf("%d %d",&n,&k);
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&p[i]);
    }
    sort(p,p+n);
    int sum=0;
    for(i=0;i<k;i++)
    {
        sum+=p[i];
    }
    printf("%d",sum);
}


Measured memory_bytes: 3872
package main

import "fmt"

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		fmt.Scan(&b[i])
	}
	a[0], a[n-1] = b[0], b[n-2]
	ans := a[0] + a[n-1]
	for i := 1; i < n-1; i++ {
		a[i] = min(b[i], b[i-1])
		ans += a[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll	        long long
#define all(v)      (v).begin() , (v).end()
#define vi          vector <ll>
#define vii         vector <pair<ll,ll>>
#define ii          pair<int,int>
#define lp(i,a,b)	for(int i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
const ll mod=1e9+7,MAX=2e5+7;
void fast();
int main()
{
    fast();
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll res=0;
    vector<int>r,g,b,vis(n+100,5),col[3];
    for(int i=0;i<n;++i){
        if(s[i]=='R')
            col[0].pb(i),vis[i]=0;
        else if(s[i]=='G')
            col[1].pb(i),vis[i]=1;
        else
            col[2].pb(i),vis[i]=2;
    }
    if(col[1].size()==0||col[0].size()==0||col[2].size()==0)
        return cout<<0,0;

    for(int i=0;i<col[0].size();i++){
        for(int j=0;j<col[1].size();j++){
            res+=col[2].size();
            int x=col[0][i],y=col[1][j];
            if(max(y,x)+abs(x-y)<n&&vis[max(y,x)+abs(x-y)]==2)
                res--;
            if(min(x,y)-abs(x-y)>=0&&vis[min(x,y)-abs(x-y)]==2)
                res--;
            if(abs(x-y)%2==0&&vis[min(x,y)+abs(x-y)/2]==2)
                res--;
        }
    }
    cout<<res;
}

void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += x - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>
//by Skeef79

typedef long long ll;
typedef long double ld;

typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SZ(a) int(a.size())
#define what_is(x) cout<<#x<<" is "<<x<<en;


using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];

}

void solve()
{
	ll n, m, k;
	cin >> n >> m >> k;

	vector<ll>a(n), b(m);
	input(a);
	input(b);

	vector<ll>pref(m);
	pref[0] = b[0];
	for (int i = 1; i < m; i++)
		pref[i] = pref[i - 1] + b[i];

	auto it = upper_bound(all(pref), k) - pref.begin();
	ll ans = it;

	for (ll i = 0; i < n; i++)
	{
		k -= a[i];
		if (k < 0)
			break;
		else
		{
			auto it = upper_bound(all(pref), k) - pref.begin();
			ans = max(ans, it + i + 1);
		}
	}
	cout << ans;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	//freopen("luigi.in", "r", stdin);
	//freopen("luigi.out", "w", stdout);

	int tst = 1;
	//cin >> tst;

	while (tst--)
		solve();
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> T(N);

    long long ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> S[i] >> T[i];
        ans += T[i];
    }

    string X;
    cin >> X;
    for(int i =0; i < N; i++){
        ans -= T[i];
        if(S[i] == X){
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char** argv){
  int x_num,a_num;
  std::cin>>x_num>>a_num;
  if(x_num<a_num){
    std::cout<<0<<std::endl;
  }
  else{
    std::cout<<10<<std::endl;
  }
  
  return 0;
}

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

const double rasian = M_PI*60.0/180.0;
  
typedef struct
{
  double x;
  double y;
}K;

void print(K plot)
{
  printf("%lf %lf\n",plot.x,plot.y);
}

void KochCurve(int n, K p1, K p2)
{
  if(n == 0) return;
  K s,t,u;
  
  s.x = (2.0*p1.x+1.0*p2.x)/3.0;
  s.y = (2.0*p1.y+1.0*p2.y)/3.0;

  t.x = (1.0*p1.x+2.0*p2.x)/3.0;
  t.y = (1.0*p1.y+2.0*p2.y)/3.0;

  u.x = (t.x-s.x)*cos(rasian)-(t.y-s.y)*sin(rasian)+s.x;
  u.y = (t.x-s.x)*sin(rasian)+(t.y-s.y)*cos(rasian)+s.y;
  
  KochCurve(n-1, p1, s);
  print(s);
  KochCurve(n-1, s, u);
  print(u);
  KochCurve(n-1, u, t);
  print(t);
  KochCurve(n-1, t, p2);
}

int main()
{
  int n;
  scanf("%d",&n);

  K plot1={0,0}; //init
  K plot2={100,0};

  print(plot1);
  KochCurve(n,plot1,plot2);
  print(plot2);
  
  return 0;
}



Measured memory_bytes: 2052
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[11];
	int i,a[10],mn,x,len;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<len;i++)	a[i]=s[i]-'0';
	mn=1000;
	for(i=0;i<len-2;i++)	{
		x=a[i]*100+a[i+1]*10+a[i+2]-753;
		if(x<0)	x=-x;
		mn=min(mn,x);
	}
	printf("%d\n",mn);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n, x; std::cin >> n >> x;
  std::vector< int > a(n); std::cin >> a;
  lint ret = 1L << 60;
  rep(t, 0, n) {
    cmn(ret, std::accumulate(all(a), 0LL) + (lint)t * x);
    auto b = a;
    rep(i, 0, n) {
      auto j = (i > 0 ? i - 1 : n - 1);
      cmn(b.at(i), a.at(j));
    }
    std::swap(a, b);
  }
  std::cout << ret << std::endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    long long ma = 0;
    long long mi = 1000000000;
    long long a;
    rep(i, N) {
        cin >> a;
        chmax(ma, a);
        chmin(mi, a);
    }

    cout << abs(ma - mi) << endl;
}

Measured memory_bytes: 256
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int a,b;

	cin >> a >> b;


	if( a+b<10) cout << a+b << endl;
	else cout << "error" << endl;

	return 0;
}

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

#ifndef M_PI
#define M_PI acos(-1)
#endif

double toDeg(double rad) {
	return rad * 180.0 / M_PI;
}

int main() {
	double a, b, x, res;
	cin >> a >> b >> x;
	x /= a;
	if (x <= b * a / 2) {
		double y = 2 * x / b;
		res = toDeg(atan(b / y));
	} else {
		double r = a * b - x;
		double y = 2 * r / a;
		res = toDeg(atan(y / a));
	}

	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())

home = [sx,sy]
goal = [tx,ty]
point = [sx,sy]

ans_li = []

def move_to(start,end):
  while start!=end:
    if start[0]>end[0]:
      start[0]-=1
      ans_li.append('L')
    if start[0]<end[0]:
      start[0]+=1
      ans_li.append('R')
    if start[1]>end[1]:
      start[1]-=1
      ans_li.append('D')
    if start[1]<end[1]:
      start[1]+=1
      ans_li.append('U')

move_to(home,[sx,ty])
move_to([sx,ty],[tx,ty])
move_to(goal,[tx,sy])
move_to([tx,sy],[sx,sy])

ans_li.append('L')
move_to([sx-1,sy],[sx-1,ty+1])
move_to([sx-1,ty+1],[tx,ty+1])
ans_li.append('D')
ans_li.append('R')
move_to([tx+1,ty],[tx+1,sy-1])
move_to([tx+1,sy-1],[sx,sy-1])
ans_li.append('U')

print(''.join(ans_li))

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**8)
N,M,Q = map(int ,input().split())
ls = [0]*Q
for i in range(Q):
  a,b,c,d = map(int, input().split())
  ls[i] = (a,b,c,d)
def f(l,cnt):
  if cnt>0:
    j = l[-1]
    ans  = 0
    for i in range(j,M+1):
      ans = max(f(l+[i],cnt-1),ans)
    return ans
  else:
    m  = 0
    for a,b,c,d in ls:
      if l[b-1]-l[a-1]==c:
        m += d
    return m
ans  = 0
for i in range(1,M+1):
  ans = max(ans,f([i],N-1))
print(ans)

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

#include <math.h>
#include <stdlib.h>


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

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


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll t1, t2;
    cin >> t1 >> t2;

    ll a1, a2;
    cin >> a1 >> a2;

    ll b1, b2;
    cin >> b1 >> b2;

    if(a1 < b1){
        swap(a1, b1);
        swap(a2, b2);
    }


    ll d1 = a1 * t1 + a2 * t2;
    ll d2 = b1 * t1 + b2 * t2;
    //Pattern1 
    if(d1 == d2){
        cout << "infinity" << endl;
        return 0;
    }

    //Pattern 2
    if(d1 > d2){
        cout << 0 << endl;
        return 0;
    }

    //Pattern 3
    ll vd = d2 - d1;
    ll dd = (a1-b1)*t1;

    if(dd%vd == 0){
        cout << dd / vd * 2 << endl;
    } else {
        cout << (dd / vd) * 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s0 = str(input())
from collections import Counter
dct = dict(Counter(s0))
#print(dct)

for i in range(n - 1):
  s = str(input())
  d = Counter(s)
  for x in dct.items():
    if d.get(x[0]) != None:
      dct[x[0]] = min(x[1], d[x[0]])
    else:
      dct[x[0]] = 0

dct_sorted = sorted(dct.items(), key=lambda x: x[0])
#print(dct_sorted)

ans = ''
for x in dct_sorted:
  if x[1] > 0:
    ans += x[0] * x[1]
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) -= (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i <= n / 7; i++)
        if (!((n - i * 7) % 4))
            return !(cout << "Yes");
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> A(N+1);
	A[0] = 0;
	for(int i=1;i<N+1;i++){
		cin >> A[i];
	}
	vector<int> B(N+1);
	for(int i=N;i>=1;i--){
		int cnt = 0;
		for(int j=2;j*i<=N;j++){
			if(B[j * i])cnt++;
		}
		if(cnt % 2 != A[i])B[i] = 1;
	}
	int cnt = 0;
	for(int i=0;i<N+1;i++){
		if(B[i])cnt++;
	}
	cout << cnt << endl;
	int ocnt = 0;
	for(int i=1;i<N+1;i++){
		if(B[i]) {
			cout << i;
			ocnt++;
			if(ocnt < cnt) cout << " ";
		}
	}
	if(cnt > 0)cout << endl;
}

Measured memory_bytes: 2432
//#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstring>
#define FAST_IO ios::sync_with_stdio(false)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int maxn = 105;

int n;
struct node{
	int x,y;
}p1[maxn],p2[maxn];
int g[maxn][maxn],vis[maxn],nxt[maxn];

bool fd(int x){
	for(int i=1;i<=n;i++){
		if(g[x][i]&&!vis[i]){
			vis[i] = 1;
			if(nxt[i]==0||fd(nxt[i])){
				nxt[i] = x;		//第i个人匹配的是x 
				return 1;
			}
		}
	}
	return 0;
}

int match(){
	int ans = 0;
	for(int i=1;i<=n;i++){
		mem(vis);
		if(fd(i)) ans++;
	}
	return ans;
}

int main(){
	FAST_IO;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> p1[i].x >> p1[i].y;
	}
	for(int i=1;i<=n;i++){
		cin >> p2[i].x >> p2[i].y;
		for(int j=1;j<=n;j++){
			if(p1[j].x<p2[i].x&&p1[j].y<p2[i].y){
				g[i][j] = 1;
			}
		}
	}
	cout << match() << endl; 
    return 0;
}

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

#define MAX 10

int main(void)
{
  char *S = malloc(0x10);
  fscanf(stdin,"%s",S);
  int length = strlen(S);
  int ok;
  int max=0;

  for(int ix=0;ix!=length;++ix){
    for(int jx=ix;jx!=length;++jx){

      ok = 1;
      for(int kx=ix;kx<=jx;++kx){
        if(S[kx]!='A' && S[kx]!='G' && S[kx]!='C' && S[kx]!='T'){
          ok = 0;
          break;
        }
      }
      if(ok==1 && jx-ix+1>=max)
        max = jx-ix+1;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n,m;
  cin >> n>>m;
  vector<vector<bool > > like(n,vector<bool>(m,false));
  REP(i, n){
    int k;
    cin >> k;
    REP(j, k){
      int tmp;
      cin >> tmp;
      like[i][tmp - 1] = true;
    }
  }
  // cout << "test" << endl;
  // REP(i, n){
  //   REP(j, m){
  //     cout << like[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << "end test" << endl;
  int ans = 0;
  REP(i, m){
    bool flag = true;
    REP(j, n){
      if(!like[j][i]){
	flag = false;
	break;
      }
    }
    if(flag){
      ans ++ ;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s=list(input())
n=len(s)

if s[0]=="A" and "C" in s[2:n-1]:
    check=s[1:]
    check.remove("C")
    s="".join(check)
    if s==s.lower():
        print("AC")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    c = readi(3, 3)
    d = list(zip(*c))
    print(
        "Yes"
        if all(
            len(set(i - j for i, j in zip(c[n], c[m]))) == 1
            for n in range(3)
            for m in range(n)
        )
        and all(
            len(set(i - j for i, j in zip(d[n], d[m]))) == 1
            for n in range(3)
            for m in range(n)
        )
        else "No"
    )


if __name__ == "__main__":
    main()


Measured memory_bytes: 3828
#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>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll r, d, x;
	cin >> r >> d >> x;
	vector<ll> y;
	y.push_back(x);
	rep(i, 11) {
		ll z = y.back();
		y.push_back(r * z - d);
	}
	reps(i, 1, 11) cout << y.at(i) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();
		int count = 0;
		for (int i = 0; ; i++) {
			int r = R * i;
			if (N < r) break;
			int left = N - r;
			for (int j = 0; ; j++) {
				int g = G * j;
				if (left < g) break;
				int b = left - g;
				if (b % B != 0) continue;
				count += 1;
			}
		}
		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);

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

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

ll N, A, B, Q, X, Y, Z;

template<typename T> class SegmentTree {
public:
  ll n;
  T e;
  T (*op)(T, T);
  vector<T> dat;

  SegmentTree(T _e, T(*_op)(T, T), ll _n) {
    e = _e;
    op = _op;
    n = 1;
    while(n < _n) n *= 2;
    REP(i, 0, 2 * n - 1) dat.push_back(e);
  }

  T query(ll a, ll b) { return rquery(a, b, 0, 0, n); };

  void update(ll k, T a) {
    k += n - 1;
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

private:
  T rquery(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) return e;
    if(a <= l && r <= b) return dat[k];
    T vl = rquery(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = rquery(a, b, k * 2 + 2, (l + r) / 2, r);
    return op(vl, vr);
  }
};

ll opmin(ll a, ll b) { return min(a, b); };

int main(void) {
  SegmentTree<ll> sa(INF, opmin, 200000), sb(INF, opmin, 200000);

  cin >> N;
  REP(i, 0, N) {
    cin >> A;
    sa.update(i, A);
    // cout << A << endl;
  }
  REP(i, 0, N) {
    cin >> B;
    sb.update(i, B);
    // cout << B << endl;
  }
  cin >> Q;

  // REP(i, 0, N) cout << sa.dat[i] << " ";
  // cout << endl;
  // REP(i, 0, N) cout << sb.dat[i] << " ";
  // cout << endl;

  vector<ll> u;
  REP(i, 0, N) u.push_back(i);

  // REP(j, 0, N) cout << sa.query(j, j + 1) << " ";
  // cout << endl;
  // REP(j, 0, N) cout << sb.query(j, j + 1) << " ";
  // cout << endl;

  REP(q, 0, Q) {
    cin >> X >> Y >> Z;
    // cout << "  " << X << " " << Y << " " << Z << endl;
    if(X == 1) { // update A[Y] = Z
      sa.update(Y - 1, Z);
      u.push_back(Y - 1);
    }
    if(X == 2) { // update B[Y] = Z
      sb.update(Y - 1, Z);
      u.push_back(Y - 1);
    }
    if(X == 3) { // max(A[Y], ..., A[Z])
      cout << sa.query(Y - 1, Z) << endl;;
    }
    if(X == 4) { // max(B[Y], ..., B[Z])
      cout << sb.query(Y - 1, Z) << endl;
    }
    if(X == 5) { // copy A <- B
      REP(i, 0, u.size()) sa.update(u[i], sb.dat[u[i] + sb.n - 1]);
      u.clear();
    }
    if(X == 6) { // copy B <- A
      REP(i, 0, u.size()) sb.update(u[i], sa.dat[u[i] + sa.n - 1]);
      u.clear();
    }
    // REP(j, 0, N) cout << sa.query(j, j + 1) << " ";
    // cout << endl;
    // REP(j, 0, N) cout << sb.query(j, j + 1) << " ";
    // cout << endl;
  }
}

Measured memory_bytes: 14812