akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int N;
int dp[105][25][25][25];
bool ok (string checker){
  if (checker.find("AGC") != string::npos) return false;
  for (int i = 0; i < checker.size() - 1; i++){
    swap(checker[i], checker[i + 1]);
    if (checker.find("AGC") != string::npos) return false;
    swap(checker[i], checker[i + 1]);
  }
  return true;
}
string dna = "ACTG";
int solve(int I, string last){
  if (dp[I][last[0] - 'A'][last[1] - 'A'][last[2] - 'A'] != -1) return dp[I][last[0] - 'A'][last[1] - 'A'][last[2] - 'A'] % MOD;
  if (I >= N) return 1;
  long long ans = 0;
  if (I < 3){
    for (int i = 0; i < 4; i++){
      if (last[I] == 'z') {
        last[I] = dna[i];
        if (ok(last)) ans += solve(I + 1, last) % MOD;
        last[I] = 'z';
      }
    }
  } else {
    for (int i = 0; i < 4; i++){
      if (ok(last + dna[i])) {
        string bak = last;
        last[0] = last[1];
        last[1] = last[2];
        last[2] = dna[i];
        ans += solve(I + 1, last) % MOD;
        last = bak;
      }
    }
  }
  return dp[I][last[0] - 'A'][last[1] - 'A'][last[2] - 'A'] = ans % MOD;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, "zzz") << '\n';
  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll LINF = 1e18;
const ll MOD = 86400;
double EPS = 1e-8;
const double PI = acos(-1);

string strN[60];
string strM[60];
int dp[60][60];
int N,M;

bool check(int x, int y){

	bool match = true;
	dp[x][y] = 1;

	for(int i=x; i<x + M; i++){
		for(int j=y; j<y + M; j++){
			if(strN[i][j] != strM[i-x][j-y]) match = false;
		}
	}

	return match;
}


bool dfs(int x, int y){

	if(dp[x][y] == 1) return false;

	if(x + M - 1>= N  or y + M - 1>= N ) return false;

	if(check(x, y)) return true;

	if(dfs(x + 1, y)) return true;
	if(dfs(x, y + 1)) return true;

	return false;
}



int main(){

	cin >> N >> M;

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

	for(int j=0; j<M; j++){
		cin >> strM[j];
	}

	bool rlt = dfs(0, 0);

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

}

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

int
main()
{
    std::ios::sync_with_stdio(false);

    std::size_t playerCount;
    std::cin >> playerCount;

    std::vector<long long> friendliness(playerCount);

    for (std::size_t i = 0; i<playerCount; ++i)
    {
        std::cin >> friendliness[i];
    }

    std::sort(friendliness.rbegin(), friendliness.rend());

    auto totalComfort = friendliness[0];
    auto countToIndex = (playerCount-1-1)/2;
    for (std::size_t i = 1; i<=countToIndex; ++i)
    {
        totalComfort += 2*friendliness[i];
    }
    if ((playerCount-1-1)%2==1)
    {
        totalComfort += friendliness[countToIndex+1];
    }

    std::cout << totalComfort << "\n";

    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int w, a, b;

int main() {
	cin >> w >> a >> b;
	
	int ans = 0;
	if(b < a - w) { ans = (a - w) - b; }
	if(b > a + w) { ans = b - (a + w); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = []
def lucas(n):
  for i in range(0, n+1):
    if i==0:
      ans.append(2)
    if i == 1:
      ans.append(1)
    if i >= 2:
      ans.append(ans[i-1]+ans[i-2])
  return ans[-1]
print(lucas(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n;
    cin>>n;
    cout<<n*800-n/15*200<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n ,a ,i ,max ,min;
  long long int sum = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&a);
    sum += a;

    if(i == 0){
      max = a;
      min = a;
    }

    if(a < min){
      min = a;
      
    }if( a > max){;
      max = a;
    }
  }

  printf("%d %d %ld\n",min ,max ,sum);

  return 0;

}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vector<P> p(n);
  vll l(n), r(n);
  rep(i, n) {
    cin >> p[i].first >> p[i].second;
    l[i] = p[i].first;
    r[i] = p[i].second;
  }

  // sort(all(p));
  sort(all(l));
  sort(all(r));
  reverse(all(r));

  ll ans = -1;
  if (n % 2) {
    ans = (r[n / 2] - l[n / 2]) + 1;
  } else {
    rep(i, n) {
      l[i] *= 2;
      r[i] *= 2;
    }
    ll i1 = n / 2 - 1;
    ll i2 = n / 2;
    ll left = (l[i1] + l[i2]) / 2;
    ll right = (r[i1] + r[i2]) / 2;
    ans = right - left + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9496
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
using namespace std;

int main() {
	int a, b, c;
	char f;
	cin >> a >> f >> b >> f >> c;
	if (b>4) {
		cout<<"TBD"<<endl;
	}
	else {
		cout << "Heisei" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[101];
int main(void){
    int n,k;
    cin >> n >> k;
    
    int d;
    for(int i=0;i<k;i++){
        cin >> d;
        for(int k=0;k<d;k++){
            int an=-1;
            cin >> an;
            if( a[ an-1 ] != 1) a[an-1] = 1;
        }
    }
    
    int c=0;
    for(int i=0;i<n;i++){
        if(a[i] != 1) c++;
    }
    
    cout << c << endl;
    
    return 0;
}


Measured memory_bytes: 3620
somedt_N,powder_X = input().rstrip().split()
lst_donut = [int(input()) for i in range(int(somedt_N))]

sum_dt_gram = sum(lst_donut)
rec = int(somedt_N)
powder_X = int(powder_X) - sum_dt_gram

doNum = 0
for i in lst_donut:
  if doNum <= int(powder_X / int(i)):
    doNum = int(powder_X / int(i))

rec += doNum
print(rec)

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


int main() {
  int n;
  cin >> n;
  vector<string> data(n);
  rep(i,n) {
   cin >> data.at(i);
   }
   
   sort(data.begin(), data.end());
   
   int count = 1;
   rep(i,n-1) {
    if(data.at(i) != data.at(i + 1)) {
     count++;
     }
     }
 cout << count;    
     
}

Measured memory_bytes: 9600
/*
.   Bismillahir Rahmanir Rahim
.   Author - Marajul islam
.   created- 

*/ 
#include<bits/stdc++.h>
using namespace std;


 
int sc1() {int x; scanf("%d", &x); return x;}
long long sc2() {long long x; scanf("%lld", &x); return x;}

const int mod= 1e9 + 7;
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (long long)a * b % mod;}
 
#define F               first
#define S               second 
#define mp              make_pair
#define pb              push_back
#define pf              push_front
#define speed_up        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x)           (int)x.size()
#define all(x)          x.begin(), x.end()
#define debug           cerr << "OK\n";
#define ub              upper_bound
#define lb              lower_bound
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define Int             sc1()
#define LL              sc2()
#define For(n)          for(int i=0;i<n;i++)
#define Forj(n)         for(int j=0;j<n;j++)
#define Fork(n)         for(int k=0;k<n;k++)
#define For1(n)         for(int i=1;i<=n;i++)

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef set <int>       si;
typedef set <ll>        sll;
typedef multiset <int>  msi;
typedef multiset <ll>   msll;
typedef map <int, int>  mi;
typedef map <ll, ll>    mll;

  
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
 
 
int solve() {
 
	string s;
	cin>>s;
	if(s[0]=='7' || s[1]=='7' || s[2]=='7') puts("Yes");
	else puts("No");

 
	return 0;
}
 
 
 
 
int main()
{
	//speed_up;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner Ent = new Scanner(System.in);
        int a = Ent.nextInt();
        int b = Ent.nextInt();
        int c = Ent.nextInt();
        
        int div = b / a;
        
        if(div > c){
            System.out.println(c);
        }else{
            System.out.println(div);
        }
        
    }
    
}


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

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

    for(int i = 0; i < s.length(); ++i)
    {
        if(i % 2 == 0)
        {
            cout << s[i];
        }
    }    
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String input1 = scanner.next();
		String input2 = scanner.next();
		scanner.close();

		int A = Integer.valueOf(input1);
		int B = Integer.valueOf(input2);

		// 対称性によりAが大きい方とする
		if(A < B) {
			int tmp = A;
			A = B;
			B = tmp;
		}
		// 2つめはどっちかなのでこれで決まる
		int result1 = A + A - 1;
		int result2 = A + B;
		if(result1 >= result2) {
			System.out.println(result1);
		} else {
			System.out.println(result2);
		}
	}

}


Measured memory_bytes: 21332
#include<map>
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int n,S,W,Q;scanf("%d%d%d%d",&n,&S,&W,&Q),n;){
		static int a[100000];
		int g=S;
		rep(i,n){
			a[i]=(g/7)%10;
			if(g%2==0) g=(g/2);
			else       g=(g/2)^W;
		}

		int ans=0;
		if(Q<10){
			// dp[i+1][j] := ( a[i] を右端とする部分文字列で, 十進整数として見たときに mod Q == j となるものの個数 )
			static int dp[100001][10];
			rep(i,n+1) rep(j,Q) dp[i][j]=0;
			rep(i,n){
				if(a[i]!=0) dp[i+1][a[i]%Q]++;
				rep(j,Q) dp[i+1][(j*10+a[i])%Q]+=dp[i][j];
				ans+=dp[i+1][0];
			}
		}
		else{
			map<int,int> f;
			int sum=0,ten=1;
			for(int i=n-1;i>=0;i--){
				sum=(a[i]*ten+sum)%Q;
				if(a[i]!=0) f[sum]++;
				ten=ten*10%Q;
			}
			sum=0; ten=1;
			int tar=0;
			for(int i=n-1;i>=0;i--){
				ans+=f[tar];
				sum=(a[i]*ten+sum)%Q;
				if(a[i]!=0) f[sum]--;
				tar=(a[i]*ten+tar)%Q;
				ten=ten*10%Q;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 9548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll dp[100010][4];

int main()
{
	string s;
	cin >> s;
	dp[0][0] = 1;
	int n = s.length();
	int mod = 1e9 + 7;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			dp[i + 1][j] = dp[i][j];
		}
		if (s[i] == 'A')
		{
			dp[i + 1][1] += dp[i][0];
		}
		else if (s[i] == 'B')
		{
			dp[i + 1][2] += dp[i][1];
		}
		else if (s[i] == 'C')
		{
			dp[i + 1][3] += dp[i][2];
		}
		else
		{
			for (int j = 0; j < 4; j++)
			{
				dp[i + 1][j] = 3 * dp[i][j];
			}
			dp[i + 1][1] += dp[i][0];
			dp[i + 1][2] += dp[i][1];
			dp[i + 1][3] += dp[i][2];
		}
		for (int j = 0; j < 4; j++)
		{
			dp[i + 1][j] %= mod;
		}
	}
	cout << dp[n][3] << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(){
        char S[2];
        for(int i=0;i<3;i++){
                scanf("%c",&S[i]);
        }
        int count=0;
        for(int i=0;i<3;i++){
                if(S[i]=='1'){
                        count++;
                }
        }
        printf("%d",count);
        return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))

#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template <typename T> void _dbg(const char *_s, T _h) {
  cerr << _s << " = " << _h << "\n";
}

template <typename T, typename... Ts>
void _dbg(const char *_s, T _h, Ts... _t) {
  int _b = 0;

  while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
    cerr << *_s++;

  cerr << " = " << _h << ",";
  _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
  vector<int> vec(5);
  for (int i = 0; i < 5; ++i) {
    cin >> vec[i];
    if (vec[i] != i + 1) {
      cout << i + 1 << '\n';
    }
  }
}

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

  int q = 1;

  for (int i = 0; i < q; ++i) {
    solve();
  }
}

Measured memory_bytes: 3168
#include <iostream>
#include <climits>

using namespace std;

static const int MAX = 25;
int H, W;
int A[MAX][MAX];

int distance(int k, int l) {
    int d = 0;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            d += A[i][j] * min(abs(i - k), abs(j -l));
        }
    }
    return d;
}

int main() {
    int mind = INT_MAX;
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            mind = min(mind, distance(i, j));
        }
    }
    cout << mind << endl;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>

using namespace std;

int N;
int main(){
    cin >> N;
    int a = -1;
    int b = -1;
    for(int i=0; i<N; i++){
        int x,y;
        cin >> x >> y;
        if( x > a ){
            a = x;
            b = y;
        };
    }

    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
       
		String s=sc.next();
       
		String[] s1=s.split("");
    	
 	if(s1[0].equals(s1[1])&&s1[2].equals(s1[3])&&!(s1[0].equals(s1[2]))){
    		System.out.println("Yes");
    	}else if(s1[0].equals(s1[3])&&s1[2].equals(s1[1])&&!(s1[0].equals(s1[2]))){
     		System.out.println("Yes");
   	 }else if(s1[0].equals(s1[2])&&s1[1].equals(s1[3])&&!(s1[0].equals(s1[1]))){
    System.out.println("Yes");
    }else{
 
    	System.out.println("No");
    }
    }
}

Measured memory_bytes: 21844
#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() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  // set<int> s;
  // rep(i,n) s.insert(a[i]);
  // if (s.size() == n) cout << "YES" << endl;
  // else cout << "NO" << endl;
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  if (a.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1024
s = gets.chomp

s = s.split('')

list = []
['', '+'].repeated_permutation(s.length-1) do |a|
  list << a
end

total = 0
list.each do |al|
  moji = []
s.each_with_index do |sa, i|
  moji << sa
  moji << al[i] if i < al.length
end

total += eval(moji.join)
end
puts total

Measured memory_bytes: 2812
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"

ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  char c;while(cin>>c){
  	cout<<char(((c-'A')+N)%26+'A');
  }cout<<"\n";
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

from collections import deque
class Dinic:
    def __init__(self,n):
        self.__n=n
        self.__E=[[] for _ in range(n)]
        self.__depth=None
        self.__progress=None

    def add_link(self,u,v,w):
        self.__E[u].append([v,w,len(self.__E[v])])
        self.__E[v].append([u,0,len(self.__E[u])-1])

    def __bfs(self,s):
        depth=[-1]*self.__n
        depth[s]=0
        Q=deque([s])
        while(Q):
            v=Q.popleft()
            for nv,w,rev in self.__E[v]:
                if(w>0 and depth[nv]<0):
                    depth[nv]=depth[v]+1
                    Q.append(nv)
        self.__depth=depth

    def __dfs(self,v,t,flow):
        if(v==t): return flow
        for i in range(self.__progress[v],len(self.__E[v])):
            self.__progress[v]=i
            nv,w,rev=self.__E[v][i]
            if(w==0 or self.__depth[v]>=self.__depth[nv]): continue
            d=self.__dfs(nv,t,min(flow,w))
            if(d==0): continue
            self.__E[v][i][1]-=d
            self.__E[nv][rev][1]+=d
            return d
        return 0

    def flow(self,s,t):
        flow=0
        while(True):
            self.__bfs(s)
            if(self.__depth[t]<0): return flow
            self.__progress=[0]*self.__n
            current_flow=self.__dfs(s,t,INF)
            while(current_flow):
                flow+=current_flow
                current_flow=self.__dfs(s,t,INF)

def resolve():
    n=int(input())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    CD=[tuple(map(int,input().split())) for _ in range(n)]

    # bipartite の maximum matching で解く
    mf=Dinic(2*n+2)
    for i in range(n):
        mf.add_link(0,i+1,1)
        mf.add_link(n+i+1,2*n+1,1)
    for i in range(n):
        a,b=AB[i]
        for j in range(n):
            c,d=CD[j]
            if(a<c and b<d):
                mf.add_link(i+1,n+j+1,1)

    print(mf.flow(0,2*n+1))
resolve()

Measured memory_bytes: 44248
n=int(input())
nextlist=[[] for _ in range(n)]
ablist=[]
for i in range(n-1):
    a,b=map(int,input().split())
    ablist.append((a,b))
    nextlist[a-1].append(b)
    nextlist[b-1].append(a)

nc=0

for i, next in enumerate(nextlist):
    tmp=len(next)
    if tmp>nc:
        nc=tmp
        nci=i+1
print(nc)

linedic={}

seen=set()
todo=[[[nci,0]],[]]
seen.add(nci)

i=0
while todo[i] != []:
    if i ==0:
        x=1
    else:
        x=0
    todo[x]=[]
    
    for to in todo[i]:
        tmp=to[1]
        k=1
        for next in nextlist[to[0]-1]:
            if not next in seen:
                if k == tmp:
                    k +=1
                seen.add(next)
                todo[x].append([next,k])
                linedic[(min(to[0],next),max(to[0],next))]=k
                k += 1
                
    i=x

for ab in ablist:
    print(linedic[ab])

Measured memory_bytes: 49604
#include<iostream>
using namespace std;
int main()
{
	int N,n;
	cin>>N;
	if(N>=1&&N<=1000)
	{
		if(N>=3)
		{
			n=N/3;
		}
		else
		{
			n=0;
		}
	}
	cout<<n;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;

// Range Minimum Query
class SegmentTree {
    int n;
    vector<int> dat;

    // i は接点の番号、l, rはその接点が[l, r)に対応していることを示す
    int query_sub(int a, int b, int i, int l, int r) {
        if (r <= a || b <= l) return 1<<30;
        if (a <= l && r <= b)
            return dat[i];
        else {
            int vl = query_sub(a, b, i * 2 + 1, l, (l + r) / 2);
            int vr = query_sub(a, b, i * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }

public:
    // 葉がn個のセグメント木
    // 実際の葉の数は完全二分木にしているので少し増える
    SegmentTree(int n_) {
        n = 1;
        while (n < n_) n *= 2;
        dat = vector<int>(2 * n - 1, 1<<30);
    }
    // i に x を入れる
    void update(int i, int x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
    // [a, b) の最小値を求める
    int query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    // 配列にアクセス
    int at(int i) { return dat[i + n - 1]; }
};

int main(){
    int N;
    cin >> N;
    vector<int> p(N), pinv(N);
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
        pinv[p[i]] = i;
    }

    SegmentTree st[2] = {SegmentTree(N), SegmentTree(N)};

    for(int i=0; i<N; i+=2)
        st[0].update(i, p[i]);
    for(int i=1; i<N; i+=2)
        st[1].update(i, p[i]);

    vector<int> ans;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;
    pq.push(make_tuple(st[0].query(0, N), 0, N-1));
    while(!pq.empty()){
        int mn_ev, mn_od, l, r;
        tie(mn_ev, l, r) = pq.top();
        pq.pop();

        int id_ev, id_od;
        id_ev = pinv[mn_ev];
        mn_od = st[(id_ev+1)%2].query(id_ev+1, r+1);
        id_od = pinv[mn_od];
        ans.push_back(mn_ev);
        ans.push_back(mn_od);

        if(l != id_ev){
            int mn = st[l%2].query(l, id_ev);
            pq.push(make_tuple(mn, l, id_ev-1));
        }
        if(r != id_od){
            int mn = st[(id_od+1)%2].query(id_od+1, r+1);
            pq.push(make_tuple(mn, id_od+1, r));
        }
        if(id_od != id_ev+1){
            int mn = st[(id_ev+1)%2].query(id_ev+1, id_od);
            pq.push(make_tuple(mn, id_ev+1, id_od-1));
        }
    }
    for(auto x : ans)
        cout << x+1 << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 8616
<?php

fscanf(STDIN, "%d %d", $n, $m);

$to = array();
$dis = array();
$pre = array();
for ($i=0; $i < $n; $i++) {
  $to[$i] = array();
  $dis[$i] = 100100100;
  $pre[$i] = -1;
}

for ($i=0; $i < $m; $i++) {
  fscanf(STDIN, "%d %d", $a, $b);
  $a--;
  $b--;
  $to[$a][] = $b;
  $to[$b][] = $a;
}

$q = new SplQueue();
$q->enqueue(0);
$dis[0] = 0;
while (!$q->isEmpty()) {
  $p = $q->dequeue();
  foreach ($to[$p] as $point) {
    if ($dis[$point] != 100100100) continue;
    $dis[$point] = $dis[$p] + 1;
    $pre[$point] = $p;
    $q->enqueue($point);
  }
}

echo 'Yes' . PHP_EOL;
for ($i=0; $i < $n; $i++) {
  if ($i == 0) continue;
  echo $pre[$i] + 1 . PHP_EOL;
}


Measured memory_bytes: 69108
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define mod 1000000007
using namespace std;

int main()
{
    //freopen("1.txt", "r", stdin);
    int n, m; cin >> n >> m;
    vector<vector<int>> g;
    vector<bool> flag(n, true);
    g.resize(n);
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> foo, bar;
    foo.push_back(0);
    bar.push_back(g[0][0]);
    flag[0] = flag[g[0][0]] = false;
    bool f = true;
    while (f) {
        f = false;
        for (int i = 0; i < g[foo.back()].size(); ++i) {
            if (flag[g[foo.back()][i]]) {
                flag[g[foo.back()][i]] = false;
                foo.push_back(g[foo.back()][i]);
                f = true;
                break;
            }
        }
    }
    f = true;
    while (f) {
        f = false;
        for (int i = 0; i < g[bar.back()].size(); ++i) {
            if (flag[g[bar.back()][i]]) {
                flag[g[bar.back()][i]] = false;
                bar.push_back(g[bar.back()][i]);
                f = true;
                break;
            }
        }
    }
    cout << foo.size() + bar.size() << '\n';
    for (int i = bar.size() - 1; i > -1; --i) cout << 1 + bar[i] << ' ';
    for (int i = 0; i < foo.size(); ++i) cout << 1 + foo[i] << ' ';
    return 0;
}


Measured memory_bytes: 6844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 
string A[100005];
vector<char>ans;
int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m,a,b,c;

	cin >> n >> a >> b >> c;

	for(i=1;i<=n;i++)
		cin >> A[i];

	for(i=1;i<=n;i++)
	{
		if(A[i]=="AB")
		{	
			if(a>b)
				a--,b++,ans.pb('B');
			else if(a<b)
				a++,b--,ans.pb('A');
			else
			{
				if(i<n)
				{
					if(A[i+1]=="AB")
					{
						a++,b--,ans.pb('A');
					}
					if(A[i+1]=="AC")
					{
						a++,b--,ans.pb('A');
					}
					if(A[i+1]=="BC")
					{
						a--,b++,ans.pb('B');	
					}
				}
				else
					a--,b++,ans.pb('B');
			}
		}
		if(A[i]=="AC")
		{
			if(a>c)
				a--,c++,ans.pb('C');
			else if(a<c)
				a++,c--,ans.pb('A');
			else
			{
				if(i<n)
				{
					if(A[i+1]=="AB")
					{
						a++,c--,ans.pb('A');
					}
					if(A[i+1]=="AC")
					{
						a++,c--,ans.pb('A');
					}
					if(A[i+1]=="BC")
					{
						a--,c++,ans.pb('C');
					}
				}
				else
					a--,c++,ans.pb('C');				
			}				
		}
		if(A[i]=="BC")
		{
			if(c>b)
				c--,b++,ans.pb('B');
			else if(c<b)
				c++,b--,ans.pb('C');
			else
			{
				if(i<n)
				{
					if(A[i+1]=="AB")
					{
						c--,b++,ans.pb('B');
					}
					if(A[i+1]=="BC")
					{
						c--,b++,ans.pb('B');
					}
					if(A[i+1]=="AC")
					{
						c++,b--,ans.pb('C');
					}
				}
				else
					c--,b++,ans.pb('B');			
			}			
		}

		if(a<0 || b<0 || c<0)
		{
			cout<<"No"<<endl;
			return 0;
		}	
	}

	cout<<"Yes"<<endl;
	for(i=0;i<sz(ans);i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 6912
N, K = list(map(int, input().split()))
height = list(map(int, input().split()))
height2=height.copy()
ans = 10 ** 10
if N==K:
    cost=0
    for i in range(1,N):
        tarou=max(height2[:i])
        if tarou>=height2[i]:
            cost+=tarou-height2[i]+1
            height2[i]=tarou+1
    print(cost)
    exit()
for i in range(2 ** N):
    cost = 0
    height2 = height.copy()
    if bin(i).count("1")==K:
        for j in range(1,N):
            if i >> j & 1:
                if N==K:
                    if height2[j-1]>=height2[j]:
                            cost+=height2[j-1]-height2[j]+1
                            height2[j]+=height2[j-1]-height2[j]+1
                else:
                    tarou=max(height2[:j])
                    if height2[j]<=tarou:
                        cost+=tarou-height2[j]+1
                        height2[j]=tarou+1

        if ans > cost:
            ans = cost

print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

N, M = map(int, input().split())

error = False
ans = [-1 for n in range(N)]

for i in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == -1:
    ans[s-1] = c
  elif ans[s-1] != c:
    error = True
    break

# N>1で先頭桁が0の場合はエラー
if N > 1 and ans[0] == 0:
  error = True

if error:
  print(-1)
  exit()

# -1の桁を0に置き換える（N>1では先頭桁は1に置換）
ans = list(map(lambda n: 0 if n == -1 else n, ans))
if N > 1 and ans[0] == 0:
  ans[0] = 1

# 答えを計算
result = 0
for idx, elm in enumerate(ans):
  result += 10**(N-idx-1) * elm
print(result)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	s := readLine()
	t := readLine()

	if s == t[:len(t)-1] {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}
}

func readLine() string {
	if sc.Scan() {
		return sc.Text()
	}
	return "error"
}

func readInt() int {
	n, err := strconv.Atoi(readLine())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = (1LL<<60);
const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

unsigned int xor128()
{
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11)); x=y; y=z; z=w; 
  return( w=(w^(w>>19))^(t^(t>>8)) );
}

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  /*
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);
  */
  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = -INF;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = score(tmp);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  int cnt = 0;
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    REP(loop, 100){
      cnt++;
      //int d = rand365(mt);
      //int q = rand26(mt);
      int d = xor128() % 365;
      int q = xor128() % 26;
      int old = T[d];
      T[d] = q;
      ll tmp = score_2(T, max_score, d, old, q);
      if(max_score<tmp){
        max_score = tmp;
        FOR(i,d,D){
          if(T[i]==old) break;
          last[i+1][old] = last[d][old];
        }
        FOR(i,d,D){
          if(i!=d && T[i]==q) break;
          last[i+1][q] = (d+1);
        }
      }else{
        T[d] = old;
      }
    }
  }
  cerr << "loop: " << cnt << endl;
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


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

int main(){
  int N=0;
  cin >> N;
  int p[N];
  int i=0, j=0;
  int dwn=-1;
  int swapp=0;
  

  
  for(i=0;i<N;i++){
    cin >> p[i];
  }
  
  for(j=0;j<N-1;j++){
    if(p[j]!=j+1){
      dwn=j;
      break;
    }
  }
  
  if(dwn==-1){
    cout << "YES";
    return 0;
  }else{
    swapp=p[p[dwn]-1];
    p[p[dwn]-1]=p[dwn];
    p[dwn]=swapp;
    for(j=0;j<N;j++){
      if(p[j]!=j+1){
        cout << "NO";
        return 0;
      }
    }
    cout << "YES";
    return 0;
  }
}


Measured memory_bytes: 256
queue = []

n, q = map(int, input().split())
for i in range(n):
  name, time = input().split()
  queue.append([name, int(time)])

t = 0
while len(queue) > 0:
  entry = queue.pop(0)
  t += min(entry[1], q)
  entry[1] -= q
  if entry[1] > 0:
    queue.append(entry)
  else:
    print("{} {}".format(entry[0], t))

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N, long long M, std::vector<long long> s, std::vector<long long> c)
{
    rep(x, 1000)
    {
        ll keta = 1;
        ll nx = x / 10;
        vector<ll> d(1, x % 10);
        while (nx)
        {
            keta++;
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (keta != N)
            continue;
        reverse(d.begin(), d.end());
        bool ok = true;
        rep(i, M)
        {
            if (d[s[i] - 1] != c[i])
            {
                ok = false;
            }
        }
        if (ok)
        {
            cout << x << endl;
            return;
        }
    }
    cout << -1 << endl;
    return;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &s[i]);
        scanf("%lld", &c[i]);
    }
    func(N, M, std::move(s), std::move(c));
    return 0;
}


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

int main()
{
	int n;
	cin >> n;

	long long sum = 0;
	for( int i = 0; i < n; ++i ){
		int input;
		cin >> input;
		sum += input;
	}

	cout << sum / n << endl;

	return 0;
}

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

int main() {
	int w,h,x,y,r;
	
	cin >>w>>h>>x>>y>>r;

	//upper right Lower left side
	if(y+r>h || x+r>w || y-r<0 || x-r<0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


int main() {
	int N;
	while (cin >> N, N)
	{
		VI c = VI(N + 2);
		for (int i = 1; i <= N; i++) cin >> c[i];

		int mx = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= 3; j++) {
				int l = i - 1, r = i + 1, tmp = 0, cnt = 1, col = j;
				while (true)
				{
					while (c[l] == col) l--, cnt++;
					while (c[r] == col) r++, cnt++;
					if (cnt < 4) break;
					tmp += cnt;
					if (c[l] != c[r]) break;
					cnt = 0;
					col = c[r];
				}
				mx = max(mx, tmp);
			}
		}

		cout << N - mx << endl;
	}

	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009
#define pll pair <long long, long long>

using namespace std;

typedef long long int lli;
vector <vector <pll>> adj(N, vector <pll>());
bool color[N];
bool visited[N];

void dfs(int i, int sofar){
	if(sofar % 2) color[i] = 0;
	else color[i] = 1;

	for(pll p: adj[i]){
		int chi = p.fi;
		int dist = p.sc;
		if(!visited[chi]){
			visited[chi] = 1;
			dfs(chi, sofar+dist);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=0; i<n-1; i++){
		int x, y, z;
		cin >> x >> y >> z;
		adj[x].pb(mp(y, z));
		adj[y].pb(mp(x, z));
	}

	visited[1] = 1; 
	dfs(1, 0);
	for(int i=1; i<=n; i++) cout << color[i] << endl;

	return 0;
}

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

int main(){
	int a,f=0;
	cin>>a;
	for(int i=1;i<=9;i++){
		if((a/i)>0 && a%i==0&&(a/i)<10)f=1;
	} 
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    set<string> m;
    for (int i = 0; i < n; ++i) {
        cin>>s;
        m.insert(s);
    }
    cout<<m.size()<<"\n";
    return 0;
}


Measured memory_bytes: 19184
import sys


fin = sys.stdin.readline
n = int(fin())
price_list = [int(fin()) for _ in range(n)]
min_price_so_far = float('inf')
max_profit = float('-inf')
for price in price_list:
    profit = price - min_price_so_far
    max_profit = max(max_profit, profit)
    min_price_so_far = min(min_price_so_far, price)
print(max_profit)



Measured memory_bytes: 13616
import java.util.*;

public class Main{
    static int count;
    static int N;
    static int n;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        sc.close();
        count = 0;
        dfs("");
        System.out.println(count);
    }
    static void dfs(String s){
        if(s != ""){
            if(Long.valueOf(s) <= N && s.contains("3") && s.contains("5") && s.contains("7")){
                count++;
            }
            if(s.length() < String.valueOf(N).length()){
                dfs(s + "3");
                dfs(s + "5");
                dfs(s + "7");
            }
        } else{
            dfs(s + "3");
            dfs(s + "5");
            dfs(s + "7");
        }
    }
}

Measured memory_bytes: 28500
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int vi[]=new int[n];
        int ci[]=new int[n];
        for(int i=0;i<n;i++)
        {
            vi[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++)
        {
            ci[i]=sc.nextInt();
        }
        int x=0;
        int y=0;
        for(int i=0;i<n;i++)
        {
            if(vi[i]>ci[i])
            {
                x=x+vi[i];
                y+=ci[i];
            }
        }
        System.out.println(x-y);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='+'){
            printf("%d\n", a+b);
        }else if(op=='-'){
            printf("%d\n", a-b);
        }else if(op=='*'){
            printf("%d\n", a*b);
        }else if(op=='/'){
            printf("%d\n", a/b);
        }if(op=='?')break;
    }
    return 0;
} 

Measured memory_bytes: 1812
#include<bits/stdc++.h>
using namespace std;
signed main(){
    string a,b,c;char turn,ans;
    cin>>a>>b>>c;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    turn = 'a';
    while(1){
        if(turn=='a'){if(a.empty()){ans = 'A';break;}turn =a.back();a.pop_back();}
        if(turn=='b'){if(b.empty()){ans = 'B';break;}turn =b.back();b.pop_back();}
        if(turn=='c'){if(c.empty()){ans = 'C';break;}turn =c.back();c.pop_back();}
    }
    cout<<ans<<endl;
}


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

using namespace std;

int N,M;
char map[110][110];
int ans;

void dfs(int x,int y,char ch){
    if(x<1||x>N||y<1||y>M||map[x][y]!=ch) return;
    map[x][y]='.';
    dfs(x+1,y,ch);
    dfs(x-1,y,ch);
    dfs(x,y+1,ch);
    dfs(x,y-1,ch);
}

int main(){
    while(cin>>N>>M&&(N!=0||M!=0)){
        int x,y;
        ans=0;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=M;j++){
                cin>>map[i][j];
            }
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=M;j++){
                if(map[i][j]!='.'){
                    dfs(i,j,map[i][j]);
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main() {
  int w,h,n;
  cin>>w>>h>>n;
  int x,y,a;
  pair<int,int> mi(0, 0), ma(w, h);
  REP(i,n) {
    cin>>x>>y>>a;
    if (a==1) mi.first = max(x, mi.first);
    else if(a==2) ma.first = min(x, ma.first);
    else if(a==3) mi.second = max(y, mi.second);
    else ma.second = min(y, ma.second);
  }

  cout << max(0,(ma.first - mi.first)) * max(0,(ma.second - mi.second)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    
    if(B<A){cout<<0<<endl; return 0;}
    
    long long num=0;
    long long M=A+B*(N-1);
    long long m=A*(N-1)+B;
    
    if(N==1){
        if(A!=B){cout<<0<<endl; return 0;}
        cout<<1<<endl;
        return 0;
    }else if(N==2){
        cout<<1<<endl;
        return 0;
    }
    
    cout<<M-m+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef  long long ll;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
int const N = 1000006;
ll const M = 998244353;
long double const ep = .000000000000000001;
ll a , k , arr[N] , cul[N];
ll test(ll y){
	ll re = y * k;
	int p = a;
	re += 5 * (cul[p] - cul[p-y]);
	p -= y;
	for(int i = 5 ; i < 10000000 ; i+=2){
		if(y >= p){
			re += i * cul[p];
			if(re < 0)return 1e18;
			return re;
		}else{
			re += i * (cul[p] - cul[p-y]);
			p -= y;
			if(re > 1e18)return 1e18;
		}
	}
}
int main() {
	
	scanf("%d%d",&a , &k);
	for(int i = 1 ; i <= a ; i++)scanf("%lld" , arr+i);
	for(int i = 1 ; i <= a ; i++)cul[i] = cul[i-1] + arr[i];
	ll ans = 1e18;
	for(int i = 1 ; i <= a ; i++){
		ans = min(ans , test(i));
	}
	printf("%lld\n", ans + a * k);
	return 0;	
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	double a;
	while(1){
		cin >> a;
		if (a < 0) break;
		if(a>pow(2,8)){
			cout<<"NA"<<endl;
			continue;
		}
		string ans="";
		for(int i=7;i>=-4;i--){
			if(a/pow(2,i)>=1){
				ans+='1';
				a-=pow(2,i);
			}else ans+='0';
		}
		//o(ans);
		//o(a);
		if(a!=0.0){
			cout<<"NA"<<endl;
			continue;
		}
		rep(i,0,8) cout<<ans[i];
		cout<<".";
		rep(i,0,4) cout<<ans[8+i];
		cout<<endl;
	}
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

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

	array<int,3> v;
	REP(i,3){
		v[i] = in();
	}
	sort(ALL(v));
	int k=in();
	for(int i=0;i<k;i++){
		v[2] *= 2;
	}
	
	cout << accumulate(ALL(v),0) << endl;
	return 0;
}


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

int count;
int main() {
    string s;
    cin >> s;
    if (s[0]==s[1] && s[0]==s[2]) cout << "Yes" << endl;
    else if (s[1]==s[2] && s[1]==s[3]) cout << "Yes" << endl;
    else cout  << "No" << endl;
}


Measured memory_bytes: 256