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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  string s;
  int ans = 0;

  while(cin >> s) {
    REP(i, s.size()) {
      if('0' <= s[i] && s[i] <= '9') {
	for(int j = 0; i+j < s.size(); j++) {
	  int now = i+j;
	  char n[5];
	  if('0' <= s[now] && s[now] <= '9') {
	    n[j] = s[now];
	    if('0' > s[now+1] || s[now+1] > '9' || now+1 == s.size()) {
	      ans += atoi(n);
	      i += j;
	      REP(i, 5) n[i] = '\0';
	      break;
	    }
	  }
	}
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
template <typename T, typename U>ostream &operator<<(ostream &out, const pair<T, U> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>void print(const ContainerType<ValueType, Args...> &c){for (const auto &v : c)cout << v << ' ';cout << '\n';} void print(){cout<<'\n';}
template <typename T, typename... Args>void print(T a, Args... args){cout << a << " ";print(args...);}
lli llipower(lli x, lli y, lli p = LLONG_MAX){lli res = 1;x = x % p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}

//8====================================D
lli fact[(int)2e6+20];
lli nck(lli n, lli k){
    lli num=fact[n];
    num=(num*llipower(fact[k],mod-2,mod))%mod;
    num = (num * llipower(fact[n-k], mod - 2, mod)) % mod;
    return num;
}
lli rec(lli n,lli k){
    lli ans=0;
    for(lli i=0;i<=n-k;i++){
        ans+=(nck(n,i+k)*llipower(25,n-k-i,mod));
        ans%=mod;
    }
    return ans;
}


int main()
{
    memset(fact,0,sizeof(fact));
    fact[1]=1;
    fact[0]=1;
    //print(fact[10], fact[2], nck(10, 2));
    for(lli i=2;i<=2e6+10;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    lli n;
    cin>>n;
    string s;
    cin>>s;
    lli x=s.size();
   // print(fact[10],fact[2],nck(10,2));
    cout<<rec(x+n,x)<<endl;

}   

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	map<int, int> mp;
	for(int i = 0; i < n; i++ ) {
		int t;
		cin >> t;
		mp[t]++;
	}
	int cnt = 0;
	for(auto i : mp){
		if(i.second % 2 == 1) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;	
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
static const int N=100;
int min(int,int);
int main(){
  int n,i,k;
  scanf("%d",&n);
  int A[N+1];
  for(i=1;i<=n;i++){
    scanf("%d%d",&A[i-1],&A[i]);
  }
  int m[N+1][N+1],s;
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(s=2;s<=n;s++){
    for(i=1;i<=n-s+1;i++){
      int j=i+s-1;
      m[i][j]=1e+9;
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+A[i-1]*A[k]*A[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}
int min(int k ,int s ){
  if(k<s)return k;
  else return s;
}



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

int main() {
     int n;
    cin>>n;
     int a[n],c=0;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        if(i%2==1&&a[i]%2==1)
        c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3632
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
count=0
money=0
for i in range(n):
    a,b=ab[i]
    if count+b<m:
        money+=a*b
        count+=b
    else:
        money+=a*(m-count)
        break
print(money)

Measured memory_bytes: 27756
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr char sp=' ';
constexpr ll mod=1000000007;

int N;
void dfs(string &S,int t){
	if(S.size()==N){
		cout<<S<<endl;
		return;
	}
	for(int i=0;i<t;i++){
		S.push_back('a'+i);
		dfs(S,t);
		S.pop_back();
	}
	S.push_back('a'+t);
	dfs(S,t+1);
	S.pop_back();
}

int main(){
	cin>>N;
	string S;
	dfs(S,0);
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i];
    }

    int cost = 1000000000;

    for (int i = 1; i <= 100; i++)
    {
        int c = 0;
        for (int j = 0; j < n; j++)
        {
            c += (x[j] - i)*(x[j] - i);
        }

        cost = min(cost, c);
        
    }

    cout << cost << endl;
    
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        
        for(int i =0; i<N; i++) {
        	A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        int e = 0;
        for(int w :A) {
        	e += w;
        }
        if(A[N-1] < (e - A[N-1])) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
    }
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

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

#define F(i, l, r) for(int i = (l); i < (r); i++)
#define DF(i, l, r) for(int i = (l); i >= (r); i--)
#define I(x, a) for(auto x : (a))
#define mp make_pair
#define X first
#define Y second
#define clean(x) memset((x), 0, sizeof(x))
#define ret return
#define cont continue
#define brk break
#define ins insert
#define all(x) (x).begin(),(x).end()
#define sync ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define y1 fjfg

const int MAXN = 2e2 + 2;

int match[MAXN];
int used[MAXN];
bool was[MAXN];
vector<int> gr[MAXN];
int n;
int cc;

bool dfs(int v){
	if(used[v] == cc)return false;
	used[v] = cc;
	for(auto u : gr[v]){
		if(match[u] == -1){
			was[v] = true;
			match[u] = v;
			return true;
		}

	}
	for(auto u : gr[v]){
		if(dfs(match[u])){
			was[v] = true;
			match[u] = v;
			return true;
		}
	}
	return false;

}

void kuhn(){
	cc = 0;
	for(int i = 0; i < n; i++){used[i] = 0; was[i] = false; match[i] = -1;}
	for(int run = 1; run;){
		cc++;
		run = 0;
		for(int i = 0; i < n; i++)used[i] = false;
		for(int i = 0; i < n; i++){
			if(!was[i] && dfs(i))run = 1;
		}
	}
}

pii a[MAXN], b[MAXN];
int nn;

signed main(){
	sync;
	cin >> nn;
	F(i, 0, nn)cin >> a[i].X >> a[i].Y;
	F(i, 0, nn)cin >> b[i].X >> b[i].Y;
	n = 2 * nn;
	F(i, 0, nn)
		F(j, 0, nn){
			if(a[i].X < b[j].X && a[i].Y < b[j].Y){gr[i].pb(j + nn); gr[j + nn].pb(i);}
		}
	kuhn();
	int ans = 0;
	F(i, 0, nn)if(match[i] != -1)ans++;
	cout << ans;
	ret 0;
}


Measured memory_bytes: 256
#python3
INF = int(1e9) 
def main():
    n = int(input())
    xs = [int(i) for i in input().split()] 
    ans = INF
    for p in range(0, 101):
        sum = 0
        for i in xs:
            sum += (i-p)**2
        ans = min(ans, sum)
    print(ans)
main()


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VL l(k), r(k);
	rep(i, k) cin >>l[i] >>r[i];
	
	VL dp(n+5), sm(n+5);
	dp[1] = sm[1] = 1;
	
	rep2(i, 2, n+1){
		rep(j, k){
			if(i-l[j] <0) continue;
			int li = max<ll>(i-r[j], 1);
			(dp[i] += sm[i-l[j]] +MD - sm[li -1]) %=MD;
		}
		sm[i] = (sm[i-1] + dp[i]) %MD;
	}
	cout <<dp[n] <<"\n";
	return 0;
}



Measured memory_bytes: 6372
#include <iostream>
#include <stdio.h>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <algorithm>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <string.h>
#include <stack>

using namespace std;

typedef double db;
typedef long long ll;
typedef pair<int, int> PII;

int a, b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a


const int MOD = 1e9 + 7;
const ll INF=1e10;
const db PI = acos(-1.0);
const db EPS = 1e-10;


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 MAXX(vector<ll> a,ll k) {
	ll max = 0;
	REP(i, k) {
		if (a[i] >= max) max = a[i];
	}
	return max;
}

ll MINN(vector<ll> a,ll k) {
	ll min = INF;
	REP(i, k) {
		if (a[i] <= min)min = a[i];
	}
	return min;
}

ll SUM(vector<ll> a, ll k) {
	ll sum = 0;
	REP(i, k) {
		sum += a[i];
	}
	return sum;
}

db AVE(vector<ll> a, ll k) {
	db ave = SUM(a,k)/(db)k;
	return ave;
}

db VAR(vector<ll> a, ll k) {
	db ave,ave2,var;
	db sum = 0;
	REP(i, k) {
		sum += a[i] * a[i];
	}
	ave2 =sum/ k;
	ave = AVE(a,k);
	ave = pow(ave,2);
	var = ave2 - ave;
	return var;
}


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;
}


void prime(int k) {
	int cnt = 0;
	for (int i = 2;i<k;i++) {
		if (k % i == 0) { cnt++; }
	}
	if (cnt == 0) cout << k << "は素数です。" << endl;
	else cout << k << "は素数ではありません。" << endl;
}


int main() {
	int n,sum=0;
	cin >> n;
	vector<int> v(n);
	REP(i, v.size()) {
		cin >> v[i];
	}
	sort(v.begin(),v.end(),greater<int>());
	REP(j,v.size()) {
		sum += v[j];
      	j++;
      	if(j>=n)break;
	}
	REP(k, v.size()) {
		k++;
		if (k >= n)  continue; 
		sum -= v[k];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n, limit, ans;
	cin >> n;
	limit = 1000000;
	ans = 0;

	for(int i = 2; i <= min(limit, n); i++)
	{
		int j = i;
		while(n%j == 0)
		{
			ans++;
			n = n/j;
			j = j*i;
		}

		while(n%i == 0)
		{
			n = n/i;
		}
	}

	cout << ans + (n>=limit);
	return 0;
}

Measured memory_bytes: 3664
import java.io.*;

public class Main{
	public static void main(String args[]) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in); 
		BufferedReader br = new BufferedReader(is);

		String[][] eArray = new String[2][4000];
		int i;
		int j = 0;
		int k;
		boolean flg = false;

		for(i = 0; i < 4000; i++) eArray[1][i] = "0";

		int in = Integer.parseInt(br.readLine());

		while(in != 0){
			for(i = 0; i < in; i++){

				String str = br.readLine();

				int sp1 = str.indexOf(" ");
				int sp2 = str.lastIndexOf(" ");

				String e = str.substring(0, sp1);
				int p = Integer.parseInt(str.substring(sp1 + 1, sp2));
				int q = Integer.parseInt(str.substring(sp2 + 1, str.length()));

				for(k = 0; k < j; k++){
					if(eArray[0][k].equals(e)){
						eArray[1][k] = String.valueOf(Integer.parseInt(eArray[1][k]) + p * q);
					}
				}
				if(k == j){
					eArray[0][j] = e;
					eArray[1][j] = String.valueOf(p * q);
					j++;
				}
			}
			for(i = 0; i < j; i++){
				if(Integer.parseInt(eArray[1][i]) >= 1000000){
					System.out.println(eArray[0][i]);
					flg = true;
				}
				eArray[0][i] = "";
				eArray[1][i] = "0";
			}
			if(flg == false) System.out.println("NA");
			flg = false;
			in = Integer.parseInt(br.readLine());
		}
	}
}


Measured memory_bytes: 28556
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

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

int main() {
  ll x;
  cin >> x;
  ll ans = x/11;
  ans *= 2;
  if(x%11 > 0) {
   ans++;
   if(x%11 > 6) 
     ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		int i;
		int co=0;
		for(i=1;i<n;i++){
			int sum=0;
			int j;
			for(j=i;;j++){
				sum+=j;
				if(sum==n){
					co++;
					break;
				}else if(sum>n)break;
			}
		}
		printf("%d\n",co);
	}
	return 0;
}

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

signed main(){
	int N; cin>>N;
	map<int,int> v;
	for(int i=0;i<N;i++){
		int a; cin>>a;
		v[a]++;
	}
	vector<pair<int,int>> A;
	for(auto p : v){
		if(p.second>=2)A.push_back(p);
	}
	sort(A.begin(),A.end());
	reverse(A.begin(),A.end());
	int ans=0;
	if(A.size()==0)ans=0;
	else{
		if(A.size()>=2)ans=max(ans,A[0].first*A[1].first);
		if(A[0].second>=4)ans=max(ans,A[0].first*A[0].first);
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 6528
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int[][] students = new int[100][100];
		boolean[][] min = new boolean[100][100];
		List<Integer> list = new ArrayList<Integer>();
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			int e;
			for (int i = 0; i < n; i++) { 
				list.clear();
				e = 1000000000;
				for (int j = 0; j < n; j++) {
					students[i][j] = sc.nextInt();
					if (students[i][j] < e) {
						e = students[i][j];
						list.clear();
						list.add(j);
					} else if (students[i][j] == e) {
						list.add(j);
					}
					min[i][j] = false;
				}
				for (int index : list)
					min[i][index] = true;
			}
			
			boolean flag = false;
			J:for (int j = 0; j < n; j++) {
				list.clear(); e = 0;
				for (int i = 0; i < n; i++) {
					if (students[i][j] > e) {
						e = students[i][j];
						list.clear();
						list.add(i);
					} else if (students[i][j] == e) {
						list.add(i);
					}
				}
				for (int index : list) {
					if (min[index][j]) {
						out.println(students[index][j]);
						flag = true;
						break J;
					}
				}
			}
			if (!flag)
				out.println(0);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main()
{
  int k, t; cin >> k >> t;
  
  int a[10005];
  for (int i=1; i<=k;i++)
  {
    cin >> a[i];
  }
  
  int ans=0;
  for (int i=1; i<=k; i++)
  {
    if (a[i] > ans)
    {
      ans = a[i];
    }
  }
  ans = max(ans-1-(k-ans),0);
  cout << ans << endl;
}    

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 int n;
  scanf("%d",&n);
  switch(n%10){
    case 0:
    case 1:
    case 6:
    case 8:puts("pon");break; 
    case 3: puts("bon");break;
    default:puts("hon");
  }
  return 0;
}


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

long long n, m, v, p;
vector<long long> a;

long long solve();

int main() {
  cin >> n >> m >> v >> p;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = p, sum = m;
  sort(a.begin(), a.end(), greater<long long>());
  for(int i = p; i < n; ++i) {
    sum -= (i - (p - 1)) * (a[i - 1] - a[i]);
    sum = max(0LL, sum);
    long long now = a[i] + m, rem = max(v - p, 0LL);
    if(now < a[p - 1]) continue;
    rem = max(0LL, rem - (n - 1 - (i + 1) + 1));
    if(a[i - rem] <= a[i])
      ++res;
    else if(sum >= rem * m)
      ++res;

    sum += m;
  }

  return res;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
    for(const auto& e:t)cout<<e<<" ";
    cout<<endl;
}
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll x,y;
    cin>>x>>y;
    ll l=2*x;
    ll r=4*x;
    if(y>=l && y<=r && y%2==0)
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";


    return 0;
}



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

int main()
{
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll A = a * x + b * y;
  ll B;
  if (x < y) B = c * x * 2 + (y - x) * b;
  else if(x > y) B = c * y * 2 + (x - y) * a;
  else B = c * y * 2;
  ll C = c * max(x, y) * 2;
  cout << min(C, min(A, B)) << endl;
  

  return 0;
}

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

int main(){
  int L = pow(10,5)+1;
  int prime[L] = {0};
  prime[2] = true;
  vector<int> v = {2};
  for(int i=3;i<L;i+=2){
    bool flag = true;
    for(x:v){
      if(i%x==0){flag = false; break;}
    }
    if(flag){ prime[i] = true; v.push_back(i); }
  }
  int check[L+1] = {0};
  int cumu[L+1] = {0};
  for(int i=3;i<L;i+=2){
    check[i] = ( prime[i] && prime[(i+1)/2] );
  }
  for(int i=3;i<L;i++){
    cumu[i] = cumu[i-1]+check[i];
  }
  int Q; cin >> Q;
  int l,r;
  REP(i,Q){
    cin >> l >> r;
    int count = cumu[r]-cumu[l-1];
    printf("%d\n",count);
  }
}


Measured memory_bytes: 1920
N, M = map(int, input().split())

n = M
# 約数列挙(1,N)も含まれる
prime, i = set(), 1
while i * i <= n:
    if n % i == 0:
        prime.add(i)
        prime.add(n//i)
    i += 1

ans = 1
l = list(prime)
for i in l:
    if i * N <= M:
        ans = max(ans, i)

print(ans)


Measured memory_bytes: 39280
N,M=map(int,input().split())
A=[]
for i in range(N):
    A.append(0)
for i in range(N):
    A[i]=list(map(int,input().split()))
    K=A[i][0]
    A[i].remove(K)
#print(A)
count=0
for i in range(M):
    count1=0
    for j in range(N):
        if A[j].count(i+1)==1:
            count1=count1+1
    if count1==N:
        count=count+1
    #print(count)
print(count)

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

string A3[3] = {"aab", "c.b", "cdd"};
string A4[4] = {"aacd", "bbcd", "efgg", "efhh"};
string A5[5] = {"aa.bc", "..dbc", "eedff", "ghh.j", "g.iij"};
string A7[7] = {"aab...e", "c.b...e", "cdd...f", "...aabf", "...c.bg", "...cddg", "eeffgg."};

vector<int> make_ins(int N){
	vector<int> ins(0);
	while(N > 10){
		ins.push_back(4);
		N -= 4;
	}
	if(N >= 8){
		ins.push_back(N / 2);
		N -= N / 2;
	}
	ins.push_back(N);
	N -= N;
	return ins;
}

vector<vector<char>> solve(int N){
	int i, j, k, l;
	vector<vector<char>> ans(N, vector<char>(N, '.'));
	if(N % 3 == 0){
		for(i = 0; i < N; i += 3){
			for(j = 0; j < 3; j++){
				for(k = 0; k < 3; k++){
					ans[i + j][i + k] = A3[j][k];
				}
			}
		}
		return ans;
	}
	vector<int> ins = make_ins(N);
	for(i = 0, j = 0; i < ins.size(); i++){
		if(ins[i] == 4){
			for(k = 0; k < 4; k++){
				for(l = 0; l < 4; l++){
					ans[j + k][j + l] = A4[k][l];
				}
			}
		}
		else if(ins[i] == 5){
			for(k = 0; k < 5; k++){
				for(l = 0; l < 5; l++){
					ans[j + k][j + l] = A5[k][l];
				}
			}
		}
		else{
			for(k = 0; k < 7; k++){
				for(l = 0; l < 7; l++){
					ans[j + k][j + l] = A7[k][l];
				}
			}
		}
		j += ins[i];
	}
	return ans;
}

int main(){
	int N, i, j;
	scanf("%d", &N);
	if(N == 2){
		printf("-1\n");
		return 0;
	}
	vector<vector<char>> res = solve(N);
	for(i = 0; i < N; i++){
		for(j = 0; j < N; j++){
			printf("%c", res[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<string.h>
  
int main(){
  int n,i=0,j=0;
  char s1[100], s2[100];
  scanf("%d",&n);
  while(scanf("%s %s", s1, s2)!=EOF)
  {
  if ( strcmp(s1,s2) == 0 ){
  i=i+1;
  j=j+1;
  }
  else if ( strcmp(s1, s2) > 0 ){
  i=i+3;
  }
  else if ( strcmp(s1, s2) < 0 ){
  j=j+3;
  }
  }
  printf("%d %d\n",i,j);
  return 0;
    
}


Measured memory_bytes: 2104
import numpy as np

def is_bingo(bingo):
  tate0 = bingo[0,0]+bingo[1,0]+bingo[2,0]==0
  tate1 = bingo[0,1]+bingo[1,1]+bingo[2,1]==0
  tate2 = bingo[0,2]+bingo[1,2]+bingo[2,2]==0
  yoko0 = bingo[0,0]+bingo[0,1]+bingo[0,2]==0
  yoko1 = bingo[1,0]+bingo[1,1]+bingo[1,2]==0
  yoko2 = bingo[2,0]+bingo[2,1]+bingo[2,2]==0
  naname0 = bingo[0,0]+bingo[1,1]+bingo[2,2]==0
  naname1 = bingo[2,0]+bingo[1,1]+bingo[0,2]==0
  tate = tate0 or tate1 or tate2
  yoko = yoko0 or yoko1 or yoko2
  naname = naname0 or naname1
  bingo = tate or yoko or naname
  return "Yes" if bingo else "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
bingo = np.array(bingo)

N = int(input())

for _ in range(N):
  b = int(input())
  i, j = np.where(bingo==b)
  bingo[i, j] = 0

print(is_bingo(bingo))

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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int mod = 1e9 + 7;
int qpow(int x, int y)
{
	int ret = 1;
	while(y)
	{
		if(y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}

const int maxn = 5111;
int dp[maxn][maxn][2], pre1[maxn][maxn][2], pre2[maxn];
int n, a, b;

inline void add(int &x, int y) { x += y; if(x >= mod) x -= mod; }
int main()
{
	get3(n, a, b);
	if(a > b) std::swap(a, b);
	if(a <= b)
	{
		dp[0][0][0] = dp[0][0][1] = 1;
		for(int i=0; i<=n; i++)
		{
			if(i > 0)
			{
				for(int j=0; j<=i; j++) for(int tp=0; tp<2; tp++)
				{
					add(pre1[i][j][tp], pre1[i-1][j][tp]);
					dp[i][j][tp] = pre1[i][j][tp];
				}
				add(pre2[i], pre2[i-1]);
				add(dp[i][i][0], pre2[i]);
			}
			
			for(int j=0; j<=i; j++) for(int tp=0; tp<2; tp++) if(dp[i][j][tp])
			{
				// dp[i][j][tp] -> dp[i+k][j][tp ^ 1]
				int lb = i + (tp == 1 ? a : 1), rb = std::min(n, j + b - 1);
				// printf("i= %d j= %d tp= %d dp= %d\n", i, j, tp, dp[i][j][tp]);
				if(lb <= rb)
				{
					add(pre1[lb][j][tp^1], dp[i][j][tp]);
					add(pre1[rb+1][j][tp^1], mod - dp[i][j][tp]);
				}
				
				if(tp == 1)
				{
					int lb = i + 1, rb = std::min(n, i + a - 1);
					// if(i == 2) printf("j= %d tp= %d lb= %d rb= %d\n", j, tp, lb, rb);
					if(lb <= rb)
					{
						add(pre2[lb], dp[i][j][tp]);
						add(pre2[rb+1], mod - dp[i][j][tp]);
					}
				}
			}
		}
		int ans = 0;
		for(int i=1; i<=n; i++) for(int j=0; j<2; j++) add(ans, dp[n][i][j]);
		ans = (qpow(2, n) + mod - ans) % mod;
		printendl(ans);
	}
	return 0;
}

Measured memory_bytes: 237872
#include <iostream>

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

using namespace std;

int main() {
	int n;
	cin >> n;
	
	while (n) {
		if (n % 10 == 7) {
			cout << "Yes\n";
			return 0;
		}
		else n /= 10;
	}
	
	cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3596
R = int(input())

ans = R*2*3.1415
# for i in range(1, k+1):
#   for j in range(1, k+1):
#     tmp = math.gcd(i,j)
#     for l in range(1, k+1):
#       ans += math.gcd(tmp, l)
print(ans)


Measured memory_bytes: 9088
import itertools
n=int(input())
l=list(map(int,input().split()))

c=list(itertools.combinations(list(range(1,n+1)),3))
ans=0
for i in c:
  if i[0]<i[1] and i[1]<i[2]:
    #print(i[0],i[1],i[2])
    s=sorted(set([l[i[0]-1], l[i[1]-1], l[i[2]-1]]))
    if len(s) == 3:
      if s[-1] < s[0]+s[1]:
        ans+=1
        #print([l[i[0]-1], l[i[1]-1], l[i[2]-1]])
      
print(ans)

Measured memory_bytes: 20508
//Ahadul Haque, MBSTU,ICT
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define TEST int test; cin >> test ;while(test--)
#define endl "\n"
int main()
{
    string s;
    cin>>s;
    int z=s.length();
    if(s[z-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;

    return 0;
}






Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  string w;
  cin >> w;
  int cnt = 0;
  bool flag = true;
  for (char c : w) {
    for (int i = 0; i < w.length(); i++) {
      if (c == w[i]) cnt++;
    }

    if (cnt % 2 != 0) {
      flag = false;
      break;
    }
  }

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


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

int main()
{
	int n, a[100010];

	cin >> n;

	a[0] = a[n + 1] = 0;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += abs(a[i - 1] - a[i]);
	}
	sum += abs(a[n] - a[n + 1]);

	for (int i = 1; i <= n; i++)
	{
		cout << sum + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vll a(N);
  Pll ma(0, -1 * INF), mi(0, INF);
  bool ok = true;
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
    if(i > 0 && a[i-1] > a[i]) ok = false;
    if(ma.second < a.at(i)) ma = Pll(i+1, a.at(i));
    if(mi.second > a.at(i)) mi = Pll(i+1, a.at(i));
  }
  if(ok){
    cout << 0 << endl;
    return 0;
  }
  if(mi.second >= 0){
    cout << N-1 << endl;
    for(int i = 2; i <= N; i++){
      cout << i-1 << ' ' << i << endl;
    }
  }
  else if(ma.second <= 0){
    cout << N-1 << endl;
    for(int i = N-1; i >= 1; i--){
      cout << i+1 << ' ' << i << endl;
    }
  }
  else if(ma.second > -1*mi.second){
    cout << 2 * N - 2 << endl;
    for(int i = 0; i < N; i++){
      if(i+1 == ma.first) continue;
      cout << ma.first << ' ' << i+1 << endl;
    }
    for(int i = 2; i <= N; i++){
      cout << i-1 << ' ' << i << endl;
    }
  }
  else{
    cout << 2 * N - 2 << endl;
    for(int i = 0; i < N; i++){
      if(i+1 == mi.first) continue;
      cout << mi.first << ' ' << i+1 << endl;
    }
    for(int i = N-1; i >= 1; i--){
      cout << i+1 << ' ' << i << endl;
    }
  }
}

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

using namespace std;

struct event {
  bool add;
  int time, x;
};

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<event> events;
  for (int i = 0; i < N; i++) {
    int s, t, x;
    cin >> s >> t >> x;
    events.push_back(event{true, s - x, x});
    events.push_back(event{false, t - x, x});
  }
  sort(events.begin(), events.end(), [](event &a, event &b) {
    if (a.time == b.time) {
      return a.add < b.add;
    }
    return a.time < b.time;
  });
  set<int> s;
  int ei = 0;
  auto forward_time = [&](int t) {
    event e = events[ei];
    while (ei < events.size() and events[ei].time <= t) {
      event e = events[ei];
      if (e.add) {
        s.insert(e.x);
      } else {
        s.erase(e.x);
      }
      ei++;
    }
  };
  vector<int> ans(Q);
  for (int i = 0; i < Q; i++) {
    int d;
    cin >> d;
    forward_time(d);
    if (s.empty()) {
      ans[i] = -1;
    } else {
      ans[i] = *s.begin();
    }
  }
  for (auto a : ans) {
    cout << a << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 17516
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <stack>
#include <iomanip>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n, cnt[100005];

int main() {
	while(cin >> n && n) {
		memset(cnt, 0, sizeof(cnt));

		vector<int> v(n+1);
		rep(i, n) cin >> v[i+1];

		stack<int> w, b;
		REP(i, 1, n+1) {
			if(i % 2 == 0 && v[i] != v[i-1]) {
				cnt[i-1]++;
				if(v[i] == 0) {
					if(w.size()) {
						int p = w.top();
						w.pop();
						cnt[p]--;

					}

					if(b.size()) b.pop();
				} else {
					if(b.size()) {
						int p = b.top();
						b.pop();
						cnt[p]--;

					}

					if(w.size()) w.pop();
				}
			}

			if(v[i] == 0) {
				if(w.size() && w.top() + 1 == i) {
					w.pop();
				}
				w.push(i);
			}
			else {
				if(b.size() && b.top() + 1 == i) {
					b.pop();
				}
				b.push(i);
			}

		}
		
		for(int i = n; i >= 1; i--) {
			cnt[i-1] += cnt[i];
		}


		REP(i, 1, n+1) {
			if(cnt[i]%2 == 0) continue;
			v[i] = !v[i];
		}

		int ans = 0;
		REP(i, 1, n+1) {
			ans += !v[i];
		}

		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1796
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, m;
    cin >> n >> m;
    vi a(m+1, 0);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int x;
            cin >> x;
            a[x]++;
        }
    }
    int cnt = 0;
    for(int i = 1; i <= m; i++) if(a[i] == n) cnt++;
    cout << cnt;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
string str;
char p='N';
int cnt;
int main()
{
	cin >> str;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] != p)
		{
			p = str[i];
			cnt++;
		}
	}
	cout << cnt - 1 << endl;
	return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, m;
int a[N], b[N], dp[N], s[N];
int c[N], id[N];
int fa[N], x[N];
vector <int> g[N];
int head[N], ver[M], nxt[M], tot;

inline bool cmp(int x, int y) {return c[x] < c[y];}

int getf(int u) {return fa[u] == u ? u : fa[u] = getf(fa[u]);}

void dfs(int u, int f)
{
	s[u] = b[u];
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = ver[i];
		if (v == f) continue;
		dfs(v, u);
		s[u] += s[v];
	}
}

void dfs1(int u, int f)
{
	if (!head[u]) dp[u] = b[u] + c[u];
	else dp[u] = 1e18;
	for (int i = head[u]; i; i = nxt[i])
	{
		int v = ver[i];
		if (v == f) continue;
		dfs1(v, u);
		dp[u] = min(dp[u], s[u] - s[v] + max(c[u], dp[v]));
	}
}

inline void add(int u, int v)
{
	ver[++tot] = v, nxt[tot] = head[u], head[u] = tot;
}

signed main()
{
	//File("");
	n = gi(), m = gi();
	for (int i = 1; i <= n; i+=1) a[i] = gi(), b[i] = gi(), c[i] = max(0ll, a[i] - b[i]), id[i] = i;
	sort(id + 1, id + 1 + n, cmp);
	for (int i = 1; i <= m; i+=1) {int u = gi(), v = gi(); g[u].push_back(v), g[v].push_back(u);}
//	for (int i = 1; i <= n; i+=1, puts(""))
//		for (int j = 0; j < g[i].size(); j+=1) cout << i << ' ' << g[i][j] << endl;
//	puts("?");
	for (int i = 1; i <= n; i+=1) fa[i] = i, x[id[i]] = i;
//	for (int i = 1; i <= n; i+=1) cout << c[i] << ' ' << id[i] << endl;
//	puts("!");
//	for (int i = 1; i <= n; i+=1) cout << x[i] << ' '; puts("$");
	for (int i = 1; i <= n; i+=1)
	{
		int u = id[i], sz = g[u].size();
		for (int j = 0; j < sz; j+=1)
		{
			int v = getf(g[u][j]);
//			cout << u << ' ' << v << endl;
            if (x[v] < x[u]) add(u, v), fa[v] = u;
		}
	}
//	for (int i = 1; i <= n; i+=1, puts("")) for (int j = head[i]; j; j = nxt[j]) cout << i << ' ' << j << endl;
	dfs(id[n], 0);
	dfs1(id[n], 0);
  	printf("%lld\n", dp[id[n]]);
	return 0;
}


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

A = [[0] * n for i in range(n)]

for i in range(n):
    row = [ int(r) for r in input().split()]
    u = row[0] - 1
    if (row[1] > 0):
        for j in range(row[1]):
            v = row[2 + j] - 1
            A[u][v] = 1
            
for i in range(n):
    print(" ".join([str(st) for st in A[i]]))


Measured memory_bytes: 5668
n = gets.to_i
h = gets.split(' ').map(&:to_i)

min_hight = 0
before_hight = 0
result = 'Yes'
h.each do |hight|
  if before_hight <= hight
    before_hight = hight
  elsif before_hight - 1 == hight && before_hight - 1 >= min_hight
    min_hight = before_hight - 1
    before_hight = hight
  else
    result =  'No'
  end
end

puts result

Measured memory_bytes: 11012
n, k = map(int, input().split())
a_b = []

for i in range(n):
    a, b = map(int, input().split())
    a_b.append([a, b])
    
a_b.sort()

cnt = 0
for i in range(n):
    cnt += a_b[i][1]
    
    if k <= cnt:
        print(a_b[i][0])
        break

Measured memory_bytes: 20104
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  arr <- sort <$> readIntList
  print . length $ dedup arr

dedup (x:y:rest)
  | x == y = dedup (y:rest)
  | otherwise = x: dedup (y:rest)
dedup [x] = [x]


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

#define rep(i,m,n) for(int i=m;i<n;i++)
#define ll long long
#define MOD 1000000007


int main(int argc, char *argv[]) {
  int n,k,m,i,u,v;
  cin >> n >> k;

  if(k > (n-1)*(n-2)/2) {
    cout << "-1" << endl;
    return 0;
  }

  m = n-1 + (n-1)*(n-2)/2 - k;
  cout << m << endl;
  for(i=0;i<n-1;i++) {
    cout << "1 " << i+2 << endl;
  }
  u = 2;
  v = 3;
  i = 0;
  while(i < (n-1)*(n-2)/2 - k) {
    cout << u << " " << v << endl;
    v++;
    if(v > n) {
      u++;
      v = u+1;
    }
    i++;
  }

  return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define in(type,a) type a;cin >> a

using ll = long long;

int main() {
    in(int, n);
    in(int, a);
    in(int, b);
    cout << min(b,a*n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n;
  int arr[100];
  int count = 0;
  int p;
  int temp;

  scanf("%d", &n);

  for(int i = 0 ; i < n; i++)
    {
      scanf("%d", &arr[i]);
    }
  
  for(int i = 0; i < n-1; i++)
    {
      p = i;
      for(int j = i; j < n; j++)
	{
	  if(arr[j] < arr[p])
	    {
	      p = j;
	    }
	}
      	  if(p != i)
	    {
	      temp = arr[i];
	      arr[i] = arr[p];
	      arr[p] = temp;
	      count++;
	    }
    }
  for(int i = 0; i < n; i++)
    {
      if(i == n-1)
	{
	  printf("%d\n", arr[i]);
	  break;
	}
      printf("%d ", arr[i]);
    }
  printf("%d\n", count);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> v(s.size());
    rep(i, s.size()) v[i] = s[i] - '0';

    vector<vector<int>> dp(s.size() + 1, vector<int>(2, 0));
    //0:10を下ろしてくることができない
    //0:10を下ろしてくることができる
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i, n)
    {
        dp[i + 1][0] = min(
            //それはそうな遷移
            dp[i][0] + v[i],
            dp[i][1] + 10 - v[i]);
        dp[i + 1][1] = min(
            //これはわかるやつ。桁上がりしてないから、この桁で桁上がりさせるしかなくて、そのためにはv[i]に1を足せばいい
            dp[i][0] + v[i] + 1,
            //ここがわからん
            dp[i][1] + 10 - (v[i] + 1));
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 59780
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	int d,e;
	if (a > b){
		d = a;
		e = b;
	} else {
		d = b;
		e = a;
	}
	
	if (e > c){
		d = e;
		e = c;
	}else if (d > c && e < c){
		d = c;
	}else {
	}
	printf("%d\n",d+e);
}

Measured memory_bytes: 128
l, r = gets.chomp.split.map(&:to_i)
m = 2019
l.upto(r) do |i|
  s = []
  l.upto(i-1) do |j|
    c = i * j % 2019
    if !s.include?(c)
      s << c
    else
      s = []
      break
    end
    if c < m
      m = c
    end
    if c == 0
      puts 0
      exit
    end
  end
end
puts m


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

int N;
vector<pair<int,int>> path[100001];
int ans[100001];

void dfs(int now,int dis){ // 今いるところ、頂点１からの距離
  //cout << now << " " << dis << endl;
  if (dis %2 == 0) ans[now] = 1;
  else ans[now] = 0;

  for (int i(0);i<path[now].size();i++){
    int next = path[now][i].first;
    if (ans[next] == -1) dfs(next,dis+path[now][i].second);
  }
}

int main(){
  cin>>N;
  for (int i(0);i<N-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    path[a].push_back({b,c});
    path[b].push_back({a,c});
  }
  memset(ans,-1,sizeof(ans));
  // 1番目が黒の場合
  ans[1] = 1;
  dfs(1,0);

  for (int i(1);i<=N;i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8448
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
static class Program
{
	static int[] ReadInts(this TextReader reader) => reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	static IEnumerable<int[]> ReadInts(this TextReader reader, int count)
	{
		for (long i = 0; i < count; ++i)
			yield return reader.ReadInts();
	}

	static IEnumerable<long[]> ReadLongs(this TextReader reader, long count)
	{
		for (long i = 0; i < count; ++i)
			yield return reader.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
	}
	
	public static void Main(string[] args)
	{
		var kn = Console.In.ReadInts();
		var k = kn[0]; var n = kn[1];
		var a = Console.In.ReadInts();
		var ld = Math.Max(a.Zip(a.Skip(1), (x, y) => y - x).Max(), k - a.Last() + a[0]);
		Console.WriteLine(k - ld);
	}
}

Measured memory_bytes: 34780
import Data.Functor( (<$>))
import Text.Printf( printf)
import Control.Monad( filterM)
import Data.List( unfoldr)

main = do
    datasets <- init . lines <$> getContents
    let
	stddev [nstr,scoresStr]
	  = let
		scores = read <$> words scoresStr
		n = read nstr
		ave = sum scores / n	    ::Double
		f now s = now + (ave - s)^2
	    in
		sqrt . (/n) . sum $ (^2) . (ave-) <$> scores

	sausage size list = unfoldr pack list
	  where
	    pack [] = Nothing
	    pack minced_meat = Just $ splitAt size minced_meat

    (printf "%.4f\n") `mapM_`  (stddev <$> sausage 2 datasets)



Measured memory_bytes: 5180
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, X);
    ll A = 1;
    REP1(A, 1000)
    {
        for (ll B = -1000; B <= 1000; ++B)
        {
            if (pow(A, 5) - pow(B, 5) == X)
            {
                cout << A << ' ' << B << endl;
                return 0;
            }
        }
    }
}

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

using namespace std;

const int N = 2010;

int q[N], ans[N], dist[N];
vector <int> adj[N];

int main() {
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);
  x--, y--;
  for (int i = 0; i < n - 1; i ++) {
    adj[i].push_back(i + 1);
    adj[i + 1].push_back(i);
  }
  adj[x].push_back(y);
  adj[y].push_back(x);
  memset(ans,0,sizeof ans);
  for (int s = 0; s < n; s++) {
  //cout << s << endl;
    int qt = 0;
    for (int i = 0; i < n; i++) dist[i] = 123456789;
    dist[s] = 0;q[qt++] = s;
    for (int qh = 0; qh < qt; qh++) {
      int u = q[qh];
      for (auto v : adj[u]) {
        if (dist[v] > dist[u] + 1) {
          dist[v] = dist[u] + 1;
          q[qt++] = v;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      ans[dist[i]]++;
    }
  }
  for (int i = 1; i < n; i++) {
    printf("%d\n", ans[i] / 2);
  }
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5){
        if((b==5&&c==7)||(b==7&&c==5)){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else if(a==7){
        if(b==5&&c==5){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0,r;
    cin>>n;
    while(n>0)
    {
        r=n%10;
        if(r==7)
        {
             c=1;
             break;
        }
        n=n/10;
    }
    if(c==1)
    {
        cout<<"Yes"<<endl;
    }else
    {
        cout<<"No"<<endl;
    }
}

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

int main(){
    int a,b,c,i,n=0;
    cin>>a>>b>>c;

    for(i=a;i<=b;i++){
        if(c%i == 0)n++;
    }
    cout<<n<<endl;
    
    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
using namespace std;

int main(void){
    int n,m,cantgo=0,count=0;
    cin >> n >> m;
    vector< pair<int,int> > order(m);
    int a,b;
    for(int i=0; i<m; i++){
        cin >> a >> b;
        order[i]=make_pair(b,a);
    }
    sort(order.begin(),order.end());
    for(int i=0; i<m; i++){
        if(order[i].second<cantgo)continue;
        count++;
        cantgo=order[i].first;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n;
  double k;
  cin >> n >> k;
  double p[n];
  rep(i,n)cin >> p[i];
  double ans=0.0;
  double temp=0.0;
  rep(i,k)temp+=(1.0+p[i])/2.0;
  ans=temp;
  for(int i=0;i+k<n;i++){
    temp-=(1.0+p[i])/2.0;
    temp+=(1.0+p[i+(int)k])/2.0;
    ans=max(ans,temp);
  }
  cout << setprecision(12) << ans << endl;
return 0;}

Measured memory_bytes: 1792