akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    int ans=1;
    rep(i,1,n){
        if(s[i]!=s[i-1])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <cstdio>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    if (n % 100 > 12 || n % 100 == 0) {
        if (n / 100 > 12 || n / 100 == 0) printf("NA\n");
        else printf("MMYY\n");
    } else {
        if (n / 100 > 12 || n / 100 == 0) printf("YYMM\n");
        else printf("AMBIGUOUS\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=2005;
int n,K,q,a[N],Ha[N],hs,tax[N],b[N],c[N];
void Hash(){
	sort(Ha+1,Ha+n+1);
	hs=1;
	for (int i=2;i<=n;i++)
		if (Ha[i]!=Ha[i-1])
			Ha[++hs]=Ha[i];
}
int find(int x){
	int L=1,R=hs,mid;
	while (L<=R){
		mid=(L+R)>>1;
		if (Ha[mid]==x)
			return mid;
		if (x>Ha[mid])
			L=mid+1;
		else
			R=mid-1;
	}
}
int main(){
	scanf("%d%d%d",&n,&K,&q);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),Ha[i]=a[i];
	Hash();
	for (int i=1;i<=n;i++)
		a[i]=find(a[i]);
	int ans=1e9+7;
	for (int t=0;t<=hs;t++){
		int tot=0;
		memset(tax,0,sizeof tax);
		for (int i=1,j=0;i<=n;i=j+1){
			if (a[i]<=t){
				j++;
				continue;
			}
			for (j=i;j<n&&a[j+1]>t;j++);
			for (int k=i;k<=j;k++)
				b[k]=a[k];
			sort(b+i,b+j+1);
			for (int k=i;j-k>=K-1;k++)
				c[++tot]=b[k];
		}
		if (tot<q)
			continue;
		sort(c+1,c+tot+1);
		ans=min(ans,Ha[c[q]]-Ha[c[1]]);
	}
	printf("%d",ans);
	return 0;
}

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

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)

#define pb push_back
#define ft first
#define sd second
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll a, ll b) {
    ll res = 1;
    while(b) {
        if(b % 2) {
            res *= a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int N = 1e5 + 5;
int n, m, k;
const ll mod = 998244353;

int cuts(vector<vector<int> > &pre, int mask) {
    int ct = __builtin_popcount(mask);
    vector<int> h;
    h.pb(0);
    for(int i=1; i<12; i++) {
        if(mask&(1<<(i-1))) h.pb(i);
    }
    h.pb(n);
    int prv = 0;
    int ans = ct;
    // debug(mask);
    for(int i=1; i<=m; i++) {
        for(int j=1; j<(int)h.size(); j++) {
            int bry = i, brx = h[j];
            int tly = prv+1, tlx = h[j-1]+1;
            int ct = pre[brx][bry] - pre[tlx-1][bry] - pre[brx][tly-1] + pre[tlx-1][tly-1];
            // debug(ct);
            if(ct > k) {
                int nprv = i - 1;
                // cout << '\n';
                if(nprv <= prv) return INT_MAX;
                else {
                    ans++;
                    // debug(ans);
                    prv = i-1;
                    i--;
                    break;
                }
            }
        }
    }
    // cout << "\n\n";
    return ans;
}

signed main() {
    cin >> n >> m;
    vector<vector<int> > mat(n+5, vector<int>());
    for(int i=0; i<n+5; i++) {
        mat[i].resize(m+5, 0);
    }
    cin >> k;
    string s;
    for(int i=1; i<=n; i++) {
        cin >> s;
        for(int j=1; j<=m; j++) {
            if(s[j-1] == '1') mat[i][j]++;
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            mat[i][j] = mat[i][j] + mat[i-1][j] + mat[i][j-1] - mat[i-1][j-1];
        }
    }
    int mn = 2e9;
    for(int mask=0; mask<(1<<(n-1)); mask++) {
        mn = min(mn, cuts(mat, mask));
    }
    if(mn == 2e9) cout << "-1\n";
    else cout << mn << '\n';
    return 0;
}


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

int main() {
  int A,B;
  int cnt = 0;
  cin >> A >> B;
  for(int i = A;i <= B;i++)
  {
    if((i / 10000) == ( i % 10) && ( (i % 10000) / 1000) == ( (i %100)/10))
    {
      cnt++;
    }
  
  }
     cout << cnt << endl;

}


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

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

    int n,a=0,b=0,c=0,ans=0;
    cin>>n;

    rep(i,n){
        string s;
        cin>>s;
        int t=s.size()-1;
        if(s[0]=='B')b++;
        if(s[t]=='A')a++;
        if(s[0]=='B'&&s[t]=='A')c++;

        rep(j,t){
            if(s[j]=='A'&&s[j+1]=='B')ans++;
        }
    }

    if(a==b&&b==c)a--;
    if(a<0)a=0;
    cout<<ans+min(a,b)<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 


int main() {

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	//     freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt=0;
	FOR0(i, n - 2){
		if (s.substr(i, 3)=="ABC") cnt++;
	}
	cout << cnt;


}
	




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

#define int long long
int n, m;

int gcd(int a, int b)
{
	if(a == 0)
		return b;
	else
	{
		if(a > b) return gcd(a % b, b);
		else return gcd(b % a, a);
	}
}

inline bool check( int mid ) {
	return n * mid <= m;
}

main()
{
	int n, m, mx = 1; cin >> n >> m;
	
	if(n == m) return cout << 1, 0;
	if(m % n == 0) return cout << m / n, 0;
	if(n == 1) return cout << m << endl, 0;
	
	for(int i = (m / n); i > 0; i--)
	{
		if((m - i * n) % i == 0)
		return cout << i << endl, 0;
	}
	cout << 1 << endl;
}


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

using namespace std;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int solve(int A, int B, int K)
{
    auto d = gcd(A, B);

//cout << "d = " << d << '\n';
    vector<int> ds;

    for (int i = d; i >= 1; --i)
        if (d % i == 0)
        {
//cout << "i = " << i << '\n';
            ds.push_back(i);
        }

    return ds[K - 1];
}

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

    int A, B, K;
    cin >> A >> B >> K;

    auto ans = solve(A, B, K);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
def main():

    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if A == B: return "YES"
    if V <= W: return "NO"
    else:
        if abs(B-A) <= (V-W) * T:
            return "YES"
        return "NO"


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int a;
  int b;
  cin >>a>>b;
  int x=b-a;
  int y=(x*(x-1))/2;
  cout<<y-a<< endl;
 // cout << x << " "<< y<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;                   

void solve() {       
    int sum = 0, mx = 10;
    for (int i = 1; i < 6; i++) {
        int x;
        cin >> x;
        mx = min(mx, (x % 10 ? x % 10 : 10));
        sum += x;
        sum += 10 - (x % 10 ? x % 10 : 10);
    }
    cout << sum - 10 + mx;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
int main(){
    int A[100000]={0};

    int n;
    std::cin>>n;
    int out=1;
    for(int i=0;i<n;++i){
        int hoge;
        std::cin>>hoge;
        A[hoge]++;
    }
    if(n%2==0){
        bool ans=true;
        for(int i=1;i<n;i+=2){
            if(A[i]!=2){
                ans=false;
                std::cout<<0<<std::endl;    
                break;
            }
        }
        if(ans){
            for(int i=0;i<(n/2);++i){
                out*=2;
                out%=1000000007;
            }
            std::cout<<out<<std::endl;
        }

    }else if(n%2==1){
        bool ans=true;
        if(A[0]!=1) {
            ans=false;
            std::cout<<0<<std::endl;
        }else{
            for(int i=2;i<n;i+=2){
                if(A[i]!=2){
                    ans=false;
                    std::cout<<0<<std::endl;    
                    break;
                }
            }
            if(ans){
                for(int i=0;i<((n-1)/2);++i){
                    out*=2;
                    out%=1000000007;
                }
                std::cout<<out<<std::endl;
            }
        }

    }
    
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int n, d, x, a[100];
    
    scanf("%d", &n);
    scanf("%d%d", &d, &x);
    for(int i=0; i<n; i++) scanf("%d", a+i);
    
    for(int i=0; i<n; i++) {
        x += ((d-1)/a[i]+1);
    }
    
    printf("%d", x);
    return 0;
}


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

int n;
vector<vi> to;

vi state;
vi vs;
bool dfs(int v) {
	if (state[v]) {
		if (state[v] == 1) {
			vs.erase(vs.begin(), find(vs.begin(), vs.end(), v));
			return true;
		}
		return false;
	}
	vs.push_back(v);
	state[v] = 1;
	for (int u : to[v]) {
		if (dfs(u)) return true;
	}
	state[v] = -1;
	vs.pop_back();
	return false;
}

void solve() {
	vector<int> nxt(n), visited(n), erased(n, 1);
	rep(i, vs.size()) {
		int v = vs[i];
		int u = vs[(i + 1) % vs.size()];
		nxt[v] = u;
		erased[v] = 0;
	}
	int v = vs[0];
	while (!visited[v]) {
		for (int u : to[v]) {
			if (erased[u]) continue;
			int nv = v;
			while (nxt[nv] != u) {
				nv = nxt[nv];
				erased[nv] = 1;
			}
			nxt[v] = u;
		}
		visited[v] = 1;
		v = nxt[v];
	}
	vi ans;
	int sv = v;
	while (1) {
		ans.push_back(v);
		v = nxt[v];
		if (v == sv) break;
	}
	cout << ans.size() << endl;
	for (int v : ans) cout << v + 1 << endl;
}

int main() {
	int m;
	cin >> n >> m;
	to.resize(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
	}

	state = vi(n);
	rep(i, n) if (!state[i]) {
		if (dfs(i)) {
			solve();
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}


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

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(ll x=in;x<n;x+=r)
#define ifr(x,n) for(ll x=0;x<n;x++)
#define dfr(x,n) for(ll x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

bool fun(pair<pair<string,ll>,ll> a,pair<pair<string,ll>,ll> b){
	if(a.ff.ff==b.ff.ff)
		return a.ff.ss>b.ff.ss;
	return a.ff.ff<b.ff.ff;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
	ll n,i;
	cin>>n;
	pair<pair<string,ll>,ll> s[n];
	ifr(i,n)cin>>s[i].ff.ff>>s[i].ff.ss,s[i].ss=i;
	sort(s,s+n,fun);
	ifr(i,n){
		cout<<s[i].ss+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    int w,h;
    char[][] tile;
    int sx,sy;
    ArrayList<Point> p;
    int[][] d;
    int[][] dist;
    int[][] dp;
    int INF = 100000000;

    class Point{
	int x,y;
	public Point(int x, int y){
	    this.x = x;
	    this.y = y;
	}
    }

    void solve(){
	Scanner sc = new Scanner(System.in);
	while(true){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0)break;

	    tile = new char[h][w];
	    p = new ArrayList<Point>();
	    for(int i=0; i<h; i++){
		String line = sc.next();
		for(int j=0; j<w; j++){
		    tile[i][j] = line.charAt(j);
		    if(tile[i][j]=='o'){
			sx = j; sy = i;
		    }
		    if(tile[i][j]=='*'){
			p.add(new Point(j,i));
		    }
		}
	    }
	    p.add(new Point(sx,sy));

	    d = new int[p.size()][p.size()];
	    for(int i=0; i<p.size(); i++) Arrays.fill(d[i],INF);
	    for(int i=0; i<p.size(); i++){
		dist = new int[h][w];
		for(int j=0; j<h; j++) Arrays.fill(dist[j],INF);
		bfs(i);
		for(int j=0; j<p.size(); j++){
		    d[i][j] = dist[p.get(j).y][p.get(j).x];
		}
	    }

	    dp = new int[1 << p.size()][p.size()];
	    for(int i=0; i<1<<p.size(); i++)Arrays.fill(dp[i],-1);

	    int ans = tsp(0,p.size()-1);
	    if(ans==INF)ans = -1;
	    System.out.println(ans);
	}
    }

    void bfs(int s){
	int[] dx = {0,0,1,-1};
	int[] dy = {1,-1,0,0};

	LinkedList<Point> q = new LinkedList<Point>();
	q.add(new Point(p.get(s).x,p.get(s).y));
	dist[p.get(s).y][p.get(s).x] = 0;

	while(q.size()>0){
	    Point point = q.poll();

	    for(int i=0; i<4; i++){
		int nx = point.x+dx[i];
		int ny = point.y+dy[i];
		if(nx>=0 && nx<w && ny>=0 && ny<h && tile[ny][nx]!='x' && dist[ny][nx]==INF){
		    q.add(new Point(nx,ny));
		    dist[ny][nx] = dist[point.y][point.x]+1;
		}
	    }
	}
    }

    int tsp(int S, int v){
	if(dp[S][v]>=0) return dp[S][v];

	if(S==(1<<p.size())-1) return dp[S][v] = 0;

	int res = INF;
	for(int i=0; i<p.size(); i++){
	    if((S>>i&1)==0){
		res = Math.min(res,tsp(S|1<<i,i)+d[v][i]);
	    }
	}

	return dp[S][v] = res;
    }

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

Measured memory_bytes: 12000
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N],B[N];
  REP(i,N)cin>>A[i];
  REP(i,N)cin>>B[i];
  int C[N];
  REP(i,N)C[i]=A[i]-B[i];
  lint SC=0;
  REP(i,N)SC+=C[i];
  if(SC<0){
    cout<<-1<<endl;
    return 0;
  } 
  sort(C,C+N);
  int ans=0;
  lint S=0;
  int j=N-1;
  for(int i=0;C[i]<0;i++){
    ans++;
    while(S+C[i]<0){
      S+=C[j];
      j--;
      ans++;
    }
    S+=C[i];
    // cerr<<i<<" "<<j<<" "<<S<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// AtCoder_A
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String S = sc.nextLine();
		int ans = 0;

		for(int i=0; i<3; i++) {
			if(S.charAt(i) == 'S') {
				if(ans != 0) {
					break;
				}
			} else if(S.charAt(i) == 'R') {
				ans++;
			}
		}
		// 出力
		System.out.println(ans);
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


Measured memory_bytes: 35588
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p = sorted(p, reverse=True)
p=p[:X]
q = sorted(q, reverse=True)
q=q[:Y]
p=p+q+r
p=sorted(p, reverse=True)
p=p[:X+Y]
ans=sum(p)
print(ans)

Measured memory_bytes: 23328
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

void solve() {
    int n;
    cin>>n;
    vector<string> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(all(arr));
    arr.erase(unique(all(arr)), arr.end());
    cout<<arr.size();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}

Measured memory_bytes: 9532
<?php
$ans = fgets(STDIN);
$input = explode(" ", $ans);
$input = array_map(function ($i) { return (int)$i; }, $input);

$sum = 0;

for ($i = 1; $i <= $input[0]; $i++) {
  $splited = array_map(function ($i) {return (int)$i;}, str_split($i.""));
  $_sum = 0;
  foreach ($splited as $val) {
  	$_sum += $val;
  }
  if ($input[1] <= $_sum && $_sum <= $input[2]) {
    $sum += $i;
  }
}

echo $sum;

Measured memory_bytes: 3576
import collections
import sys

def read_prob():
    inputs = []
    try:
        counter = 0
        while True:
            if counter == 0:
                line = input().strip()
                size = int(line)
            else:
                line = input().strip().split()
                a, b, c = line[0], line[1], line[2]
                inputs.append([int(a),  int(b), int(c)])
            counter += 1
    except EOFError:
        pass
    return inputs

def triangle(inputs):
    f = lambda x: x * x
    inputs = list(map(f, inputs))
    # print(inputs)
    a, b, c = inputs[0], inputs[1], inputs[2]
    if a + b == c:
        return True
    elif a + c == b:
        return True
    elif b + c == a:
        return True
    else:
        return False

if __name__ == '__main__':
    inputs = read_prob()
    for inp in inputs:
        if triangle(inp):
            print("YES")
        else:
            print("NO")



Measured memory_bytes: 6124
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


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
























int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i, h){
        cin >> s[i];
    }
    ll ans = 0;
    REP(i, (1 << h)){
        REP(j, (1 << w)){
            vector<string> c = s;
            REP(m, h){
                if(i & (1 << m)){
                    REP(n, w){
                        c[m][n] = 'a';
                    }
                }
            }
            REP(m, w){
                if(j & (1 << m)){
                    REP(n, h){
                        c[n][m] = 'a';
                    }
                }
            }
            ll cnt = 0;
            REP(m, h){
                REP(n, w){
                    if(c[m][n] == '#') cnt++;
                }
            }
            if(cnt == k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
int main()
{
	int n;cin>>n;
	int a[105];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int minn=inf;
	for(int i=0;i<=101;i++)
	{
		int sum=0;
		for(int j=0;j<n;j++)
		sum=sum+(a[j]-i)*(a[j]-i);
		minn=min(minn,sum);
	}
	cout<<minn<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

namespace comb {
	ll fact[500001];
	ll fact_inv[500001];
	const ll MOD = 998244353;

	ll modpow(ll a, ll b) {
		ll base = 1, kakeru = a;
		while (b > 0) {
			if (b & 1)base *= kakeru, base %= MOD;
			kakeru *= kakeru, kakeru %= MOD;
			b >>= 1;
		}
		return base;
	}

	void setup() {
		fact[0] = 1, fact[1] = 1;
		for (int i = 2; i <= 500000; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}

		fact_inv[500000] = modpow(fact[500000], MOD - 2);

		for (int i = 499999; i >= 0; i--) {
			fact_inv[i] = fact_inv[i + 1] * (i + 1);
			fact_inv[i] %= MOD;
		}

	}

	ll combination(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[b], ret %= MOD;
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll permutation(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll homogeneous(int a, int b) {
		return combination(a + b - 1, b);
	}

}

ll N, A, B, K;

int main() {
	comb::setup();

	cin >> N >> A >> B >> K;
	
	ll ans = 0;
	for (ll i = 0; i <= N && i * A <= K; i++) {
		if ((K - i * A) % B == 0) {
			ll j = (K - i * A) / B;
			if (j > N)continue;
			ans += ((comb::combination(N, i) * comb::combination(N, j))) % comb::MOD;
		}
		ans %= comb::MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    bool ok = false;
    ll a;
    REP(i, n) {
        cin >> a;
        if (a % 2 != 0) {
            ok = true;
            break;
        }
    }
    cout << (ok ? "first" : "second") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define LL long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair < int , int >

int n;
string s,t;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int ans = 0;
	cin >> s >> t;
	for ( int i = 0; i < s.size(); i++ ){
		if ( s[i] == t[i] ) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

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

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int a, b, h;
    cin >> a >> b >> h;

    int ans = (a+b) * h / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
deg=[0 for i in range(N)]
for i in range(N):
	for p in G[i]:
		deg[p]+=1
q=deque(i for i in range(N) if deg[i]==0)
res=[]
while q:
	u=q.popleft()
	res.append(u)
	for v in G[u]:
		deg[v]-=1
		if deg[v]==0:
			q.append(v)
if len(res)==N:
	print(-1)
	exit()
X={i for i in range(N)}
for st in range(N):
	pre=[-1 for i in range(N)]
	q=deque([st])
	flag=0
	while(q):
		r=q.popleft()
		for p in G[r]:
			if pre[p]==-1:
				pre[p]=r
				q.append(p)
			if pre[st]!=-1:
				Y={st}
				tmp=pre[st]
				while(tmp!=st):
					Y.add(tmp)
					tmp=pre[tmp]
				if len(Y)<len(X):
					X={i for i in Y}
				flag=1
				break
		if flag:
			break
print(len(X))
for i in X:
	print(i+1)

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
     int N;
    while((cin>>N,N)){
        vector<ll> A(N);
        rep(i,N){
            string c;cin>>c;
            if(c=="x")A[i]=INF;
            else A[i]=(ll)atoi(c.c_str());
        }
        ll l=-INF,r=INF-1;
        rep(i,N){
            if(A[i]!=INF){
                if(i!=0&&A[i-1]!=INF){
                    if(i%2==0&&A[i]>=A[i-1]){
                        cout<<"none"<<endl;goto END;
                    }else if(i%2==1&&A[i]<=A[i-1]){
                        cout<<"none"<<endl;goto END;
                    }
                }
                continue;
            }
            if(i!=0){
                if(A[i-1]==INF){
                cout<<"none"<<endl;goto END;
                }
                if(i%2==1)chmax(l,(ll)A[i-1]);
                else chmin(r,(ll)A[i-1]);
            }
            if(i!=N-1){
                if(A[i+1]==INF){
                cout<<"none"<<endl;goto END;
                }
                if(i%2==1)chmax(l,(ll)A[i+1]);
                else chmin(r,(ll)A[i+1]);
            }
        }
        if(r-l<2)cout<<"none"<<endl;
        else if(r-l>2)cout<<"ambiguous"<<endl;
        else cout<<(l+r)/2<<endl;
        END:;
    }
}

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


Measured memory_bytes: 3184
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    int a[6];
    rep(i,6)cin >> a[i];
    if(a[4] - a[0]<=a[5]){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int c[30];

int main() {
	string s;
	cin>>s;
	rep(i,sz(s))++c[s[i]-'a'];
	int o=0,sum=0;
//PUTLINE
	rep(i,30){
		if(c[i]%2==1){
			--c[i];
			++o;
		}
		c[i]/=2;
		sum+=c[i];
	}
//PUTLINE
	if(o>1){
		cout<<0<<endl;
		return 0;
	}
//PUTLINE
	Int res=1;
//PUTLINE
	repn(i,1,sum)res*=i;
//PUTLINE
	rep(i,30)if(c[i]!=0)repn(j,1,c[i])res/=j;
//PUTLINE
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

int main(){

  string str,tmp;
  int q;
  cin >>str;
  tmp=str;
  cin >>q;
  for(int i=0; i<q; i++){
    string m,p,t;
    int a,b;
    cin >>m;
    //a 文字目から b 文字目までを p に置き換え
    if(m=="replace"){
      cin >> a>> b>> p;
      str.replace(a,(int)p.size(),p);
      //cout <<"rp "<<str<<endl;
    }
    else{
      cin >> a>> b;
      //a 文字目から b 文字目までを出力
      if(m=="print"){
	for(int i=a; i<=b; i++){
	  cout <<str[i];
	}
	cout<<endl;
      }
      	//a 文字目から b 文字目までを逆順
      else{
	//	cout <<"before str "<<str<<endl;
	for(int i=a; i<=b; i++){
	  t+=str[i];
	}
	//cout <<"t "<<t<<endl;
	for(int i=b; i>=a; i--){
	  //cout <<"b-i "<<b-i;
	  str[i]=t[b-i];
	}
	//cout <<"after str "<<str<<endl;
      }
    }


  }

  return 0;
}



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

int main(){
  long long int n;
  vector<int> amari(10000);
  int count=0;
  cin >> n;
  string moji = "abcdefghijklmnopqrstuvwxyz";
  while(n > 0){
    //n->n-1にしたらうまくいく？
    amari.at(count) = (n-1) % 26;
    n = (n-1) / 26;
    count++;   
  }
  for(int i=count-1;i>=0;i--){
    cout << moji[amari.at(i)];
  }
  cout << endl;


}

Measured memory_bytes: 3656
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, a, b;
    bool flag1, flag2;

signed main(){
    cin >> N;
    a = N / 100;
    b = N % 100;
    if(1 <= a && a <= 12)flag1 = true;
    if(1 <= b && b <= 12)flag2 = true;
    if(flag1 && flag2){
        printf("AMBIGUOUS\n");
    }
    else if(flag1){
printf("MMYY\n");
    }
    else if(flag2){
printf("YYMM\n");
    }
    else {
printf("NA\n");
    }

    return 0;
}
/*



*/

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
string s;
bool can(ll x,ll y){
  rep(i,x,y){ 
    if(s[i]=='#'&&s[i+1]=='#'){
      return false;
    }
  }
  return true;
}

int main(){
  ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  cin>>s;
  s="#"+s+"#";
  if(!can(a,c)||!can(b,d)){
    cout<<"No"<<endl;return 0;
  }
  if(d<c){
    bool ok=false;
    rep(i,b,d+1){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
        ok=true;
      }
    }
    if(!ok){
      cout<<"No"<<endl;return 0;
    }
  }
  cout<<"Yes"<<endl;
}




Measured memory_bytes: 3856
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			list.add(scan.nextInt());
		}
		Collections.sort(list, Comparator.reverseOrder());

		int Alice = 0;
		int Bob = 0;
		for(int i = 0; i < N; i++){
			if(i%2 == 0){
				Alice += list.get(i);
			}else{
				Bob += list.get(i);
			}
		}
		System.out.println(Alice - Bob);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll s;
  cin>>s;
  set<ll> S;
  S.insert(s);
 for(ll i=2;i<10000000;i++) {
 if(s%2==0) {
s/=2;
 }
   else {
s=s*3+1;
   }
   if(S.count(s)) {
cout<<i<<endl;
     return 0;
   }
   
   S.insert(s);
 }
}
  

Measured memory_bytes: 3568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out){
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		out.println(a + b < c ? "No" : "Yes");
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string k;
    cin>>k;
    int n=k.size();
    string p="es";
    
    
        if(k[n-1]=='s')
        {
             k+=p;
        }
        else
        {
            k+='s';
        }
        
    
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 3624
//
// Created by Sakurayama Kazuhiro on 2020/08/02.
//


#include<iostream>
#include <math.h>       /* pow */
#include <set>

using namespace std;
int main(){
    int K;
    cin >> K;

    int cnt = 0;
    int a = 7;

    std::set<int> myset;
    bool solved = false;

    while (true){
        int a_ = a % K;
        if (a_ == 0) {
            solved = true;
            break;
        }
        if (myset.find(a_) != myset.end()) break;
        myset.insert(a_);
        cnt++;
        a = (int) a_*10+7;
    }

    if (solved) {
        cout << cnt+1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 50376
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <iterator>

#include <cstring>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < a; i++)

//char maze[100][101];

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

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

int ans = 0;
pair<int, int> red[101], blue[101];

/*
//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

int isPrime(int x) {
	int i;
	if (x < 2) return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0) return 0;
	return 1;
}

int v_find(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	if (itr != vec.end()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int ok = 1000; //解が存在する値
int ng = -1;   //解が存在しない値

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	ll c = 1;
	for (int i = 0; i < b; ++i) {
		c *= a;
	}
	return c;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

pair<int, int> Sc[50];

int MOD = 1000000007;
int imos[200001];
int br[100000];
int grid[1001][1001];
ll bigdp[1099][1099];
int used[1000][1000];

//逆元の計算用(pは素数のときb=p-2で逆元)
ll calc(int a, int b, int p) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll d = calc(a, b/2,p);
		return (d*d) % p;
	}
	else {
		return (a*calc(a, b - 1, p)) % p;
	}
}

int h, w;
ll dp[1000][1000];

ll f(int a, int b) {
	if (dp[a][b]) return dp[a][b];
	ll m = 1;
	if (a) if(grid[a-1][b]>grid[a][b]) m =(m+f(a-1,b))%MOD;
	if (b) if (grid[a][b-1]>grid[a][b]) m =(m+ f(a, b - 1))%MOD;
	if (a != h - 1) if (grid[a + 1][b]>grid[a][b]) m =(m+ f(a + 1, b))%MOD;
	if (b != w - 1) if (grid[a][b+1]>grid[a][b])  m =(m+ f(a, b + 1))%MOD;
	dp[a][b] = m;
	return m;
}
*/

int main() {
	int n;
	cin >> n;
	int a[100000] = { 0 };
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	cout << a[n - 1];
	int po = a[n - 1] / 2;
	int yo = a[n - 1] / 2;
	if (a[n - 1] % 2) {
		yo++;
	}
	int dis = 1000000001,id=-1;
	rep(i, n-1) {
		if (min(abs(a[i] - po), abs(a[i] - yo)) <= dis) {
			dis = min(abs(a[i] - po), abs(a[i] - yo));
			id = i;
		}
	}
	cout <<" "<< a[id] << endl;
	cin >> qqq;
}


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

const int ac = 1e6 + 10, mod = 1e9 + 7;
ll X[ac];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a, b, c; cin >> a >> b >> c;
	int x, y; cin >> x >> y;
	ll o = 1e18;
	for (int i = 0; i < 1e6; i++)
	{
		ll s = i * c;
		s += max(0ll, (x - i / 2) * a) + max(0ll, (y - i / 2) * b);
		o = min(s, o);
	}
	cout << o << '\n';
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
x = []
y = []
a = []
for i in range(n):
  xi, yi, ai = map(int, input().split())
  x.append(xi)
  y.append(yi)
  a.append(ai)
xmin = 0
xmax = w
ymin = 0
ymax = h
for i in range(n):
  if a[i] == 1:
    xmin = max(xmin, x[i])
  elif a[i] == 2:
    xmax = min(xmax, x[i])
  elif a[i] == 3:
    ymin = max(ymin, y[i])
  else:
    ymax = min(ymax, y[i])
print(max(0, xmax - xmin) * max(0, ymax - ymin))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n = int(input())
s = [0]*n
count = 0
each_count = {}

for i in range(n):
    tmp = list(str(input()))
    tmp.sort()
    s[i] = "".join(tmp)

for si in s:
    if each_count.setdefault(si, 0) == 0:
        each_count[si] = 1
    else:
        count += each_count[si]
        each_count[si] += 1

print(count)


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define INF ((1LL<<62)-(1LL<<31))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

ll dp[3001][3001];
int flag[3001][3001];
ll a[3001];

ll ddpp(int i,int j){
    //区間(i,j)でゲームをしたときの最適戦略
    if (flag[i][j]==1){
        return dp[i][j];
    }
    else{
        flag[i][j]=1;
        if (i==j){
            dp[i][j]=a[i];
            return a[i];
        }
        else{
            dp[i][j]=max(a[i]-ddpp(i+1,j),a[j]-ddpp(i,j-1));
            return dp[i][j];
        }
    }

}

int main() {
    ll n;
    cin>>n;
    //ll a[n+1];
    rep(i,n){
        cin>>a[i+1];
    }
    rep(i,n+1){
        rep(j,n+1){
            flag[i][j]=0;
            dp[i][j]=INF*(-1);
        }
    }
    //ddpp(1,n);
    ll ans=ddpp(1,n);
    /*for (int i=1;i<n+1;i++){
        cout<<a[i]<<endl;
        for (int j=i;j<n+1;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 105984
s = list(input())
x = []
i = 0
while(len(x)<len(s)):
    if s[i] == 'd':
        x += ['d','r','e','a','m']
        i = min(i+5,len(s)-1)
        if s[i] == 'e':
            x += ['e','r']
            i += 2
    elif s[i] == 'e':
        x += ['e','r','a','s','e']
        i = min(i+5,len(s)-1)
        if s[i] == 'r':
            x += 'r'
            i += 1
    elif s[i] == 'a':
        x += ['a','s','e']
        i = min(i+3,len(s)-1)
        if s[i] == 'r':
            x += 'r'
            i += 1
    else:
        break
print('YES' if s == x else 'NO')

Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define INP (1<<50)
#define mod 1000000007
int dp[1200][1200];
char s[1200][1200];
using namespace std;
int main()
{
    int a,b,c,i,j;
    cin>>a>>b;
    for(i=0; i<a; i++)
    {
        for(j=0; j<b; j++)
        {
            cin>>s[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(i=0; i<a; i++)
    {
        for(j=0; j<b; j++)
        {
            if(s[i+1][j]=='.' && s[i][j]!='#')
            {
                dp[i+1][j]+=dp[i][j];
                dp[i+1][j]%=mod;
            }
            if(s[i][j+1]=='.' && s[i][j]!='#')
            {
                dp[i][j+1]+=dp[i][j];
                dp[i][j+1]%=mod;
            }
        }
    }
    cout<<dp[a-1][b-1];
    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

#define max(a, b) (((a) > (b)) ? (a) : (b))

int main(void) {
	int i, j, k, l;
	int n, a[100][100];
	int sum[101][101] = {0}, max;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			scanf("%d", a[i] + j);

	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i - 1][j - 1];

	max = -10000;
	for (i = 1; i <= n; i++)
		for (j = 1; j <= n; j++)
			for (k = i; k <= n; k++)
				for (l = j; l <= n; l++)
					max = max(max, sum[k][l] - sum[k][j - 1] - sum[i - 1][l] + sum[i - 1][j - 1]);

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

	return 0;
}

Measured memory_bytes: 688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int A,B;
  cin >> A >> B;
  int ans = B;
  if (A <= 5) {
    ans = 0;
  }
  else if (6 <= A && A <= 12) {
    ans = B / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256