akhauriyash/Code-Regression huggingface dataset:
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = av[0];
    for i in 1..n {
        ans = gcd(ans, av[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,yes=0;cin>>n>>m;
  vector<string> a(n),b(m);
  for(int i=0;i<n;i++)cin>>a.at(i);
  for(int j=0;j<m;j++)cin>>b.at(j);
  for(int k=0;k<n-m+1;k++){
    for(int l=0;l<n-m+1;l++){
      int x=0;
      for(int p=0;p<m;p++){
        if(a.at(k+p).substr(l,m)!=b.at(p)){
          x++;
          break;
        }
      }
      if(x==0){
        cout<<"Yes"<<endl;
        yes=1;
        break;
      }
    }
    if(yes==1)break;
  }
  if(yes==0)cout<<"No"<<endl;
}
 


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String ans = "";
    if(a >= b) {
      for(int i = 0; i < a; i++) {
        ans += String.valueOf(b);
      }
    } else {
      for(int i = 0; i < b; i++) {
        ans += String.valueOf(a);
      }
    }
    System.out.println(ans);
  }
}

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

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n,g[2][N];

int main(){
	cin>>n;
	for(int i=0; i<2; ++i)
		for(int j=1; j<=n; ++j){
			scanf("%d",&g[i][j]);
			g[i][j]+=g[i][j-1];
		}
	int ans=0;
	for(int i=1; i<=n; ++i){
		ans=max(ans, g[0][i]+g[1][n]-g[1][i-1]);
	}
	cout<<ans<<endl;
	return 0;	
}

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

int main() {
 int alice = 0, bob = 0;
  int n;
  cin >> n;
  
  vector<int> cards(n);
  rep(i,n)
    cin >> cards.at(i);
  
  for(int i = 1; i < n; i++){
    for(int j = 0; j < i; j++){
      if(cards.at(i) > cards.at(j)){
        int tmp;
        tmp = cards.at(i);
        cards.at(i) = cards.at(j);
        cards.at(j) = tmp;
      }
    }
  }
  
  rep(i, n){
    if(i % 2 == 0)
      alice += cards.at(i);
    else
      bob += cards.at(i);
  }
  
  cout << alice - bob << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
/*cout<<setprecision(5)<<ret<<endl;で、数字部分を計5桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(5)<<ret<<endlで、小数部のみ5桁表示かつゼロ埋め有*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* [Shift+Command+b]（コンパイル）ー＞[Ctrl+Shift+^]（ターミナル起動）ー＞[./a.out] */


//////////////////
//  A
/*int main(void){
    int n,a,b;cin>>n>>a>>b;
    int ret=(b>n*a)? n*a : b;
    cout<<ret<<endl;
    return 0;
}*/
//////////////////
//  B
int main(void){
    int n,d;cin>>n>>d;
    vector<vector<int>> map(n,vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin>>map[i][j];
        }
    }
    
    int ret=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            //距離求める
            ll dis=0LL;
            rep(x,d){
                dis+=pow((map[i][x]-map[j][x]),2);
            }
            //整数かCheck
            for(ll y=0LL; y<=dis; y++){
                if(pow(y,2)==dis){
                    ret++;
                    break;
                }
            }
        }
    }
    cout<<ret<<endl;

    return 0;
}
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
    int H[300], W[300], n=0, i, j, k;
    
    while(1){
        scanf("%d %d", &H[n], &W[n]);
        if(H[n]==0 && W[n]==0){
            break;
        }
        n++;
    }
    
    for(k=0; k<n; k++){
        for(i=0; i<H[k]; i++){
            for(j=0; j<W[k]; j++){
            printf("#");
            }
            putchar('\n');
        }
        putchar('\n');
    }
    
    return 0;
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 1003
ll a, b, c, sum[3], k;


int main(){
    cin >> a >> b >> c >> k;
    if(k % 2 == 0){
        cout << a - b << endl;
    }
    else if(k % 2 == 1){
        cout << b - a << endl;
    }

    return 0;
}




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


int main(){
  
  int hcount = 0 , bcount = 0;
  string r , a;
  
  while(1){
    
    cin >> r >> a;
    if( r == "0" && a == "0" ) break;
    
    for( int i = 0; i < 4; i++ ){
      for( int j = 0; j < 4; j++ ){
	if( i == j && r[i] == a[j] ) hcount++;
	else if( r[i] == a[j] ) bcount++;
      }
    }
    
    
    cout << hcount << " " << bcount << endl;
    
    hcount = 0;
    bcount = 0;
    
  }
  
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 1000

int main(void) {
  ld x;
  ll a, b;
  cin >> n;

  FOR(i, 0, n) {
	cin >> a >> b;
	x = sqrt(a*b) * 2;
	ans = x;
	if (x == ans && a != b) ans--;
	ans -= 2;
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
	int x1,x2,x3,x4,x5;cin>>x1>>x2>>x3>>x4>>x5;
	int s=x1+x2+x3+x4+x5;
	cout<<15-s;
}	
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

int main() {
  int n; cin >> n;
  int d[n]; for ( int i = 0; i < n; i++) cin >> d[i];
  set<int> count;
  for ( int i = 0; i < n; i++) count.insert(d[i]);
  cout << count.size() << endl;
}
    

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

int main() {
    vector <char> s(3);
    int count = 0;

    
    for (int i = 0; i < s.size(); i++){
        cin >> s.at(i);
    }
    for (int i = 0; i < s.size(); i++){
        if(s.at(i) == '1'){
            count += 1;
        }
    }cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
using namespace std;
int main() {
  long long n, p = 0, l = 0;
  cin >> n;
  vector<int> a(n);
  for (long long i=0; i<n; i++) {
    cin >> a[i];
    p += a[i];
  }
  for (long long i=0; i<n-1; i++) {
    p -= a[i];
    l += (a[i]%1000000007)*(p%1000000007);
    l %= 1000000007;
  }
  cout << l << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>

using namespace std;

struct Edge {
	int to;
	double d;
	Edge (int _t, double _d) : to(_t), d(_d) {}
};

bool operator > (const Edge& e1, const Edge& e2) {
	if (e1.d > e2.d) return true;
	return false;
}

struct Buil {
	int id;
	double x, y;
	Buil (int _i, double _x, double _y) : id(_i), x(_x), y(_y) {}
};

double builDist(const Buil& b1, const Buil& b2) {
	return sqrt((b1.x - b2.x)*(b1.x - b2.x) + (b1.y - b2.y)*(b1.y - b2.y));
}

int n, m;
vector< Buil > buils;
vector< vector<Edge> > G;

double INF = 1e9;
double dist[1010];
int prev[1010];

void dks(int s, int g) {
	fill(dist, dist + 1010, INF);
	memset(prev, -1, sizeof(prev));	
	
	priority_queue<Edge, vector<Edge>, greater<Edge> > que;
	que.push(Edge(s, 0));
	dist[s] = 0;
	
	while (!que.empty()) {
		Edge e1 = que.top(); que.pop();
		
		for (int i = 0; i < G[e1.to].size(); i++) {
			Edge e2 = G[e1.to][i];
			
			if (dist[e2.to] > e1.d + e2.d) {
				dist[e2.to] = e1.d + e2.d;
				prev[e2.to] = e1.to;
				que.push(Edge(e2.to, e1.d + e2.d));
			}
		}
	}
	
	if (dist[g] == INF) cout << "NA" << endl;
	else {
		vector<int> path;
		path.push_back(g);
		int cnt = 0;
		for (int u = prev[g]; u != -1; u = prev[u]) {
			path.push_back(u);
		}
		int size = (int)path.size();
		for (int i = 0; i < size - 1; i++) {
			cout << path[size - 1 - i] << " ";
		}
		cout << path[0] << endl;
	}	
}

int main() {
	while (1) {
		cin >> n; if (n == 0) break;
		
		buils.clear();
		for (int i = 0; i < n; i++) {
			int b, x, y; cin >> b >> x >> y;
			buils.push_back(Buil(b, x, y));
		}
		
		G.assign(1010, vector<Edge>());
		for (int i = 0; i < (int)buils.size(); i++) {
			for (int j = i + 1; j < (int)buils.size(); j++) {
				double d = builDist(buils[i], buils[j]);
				if (d > 50) continue;
				G[buils[i].id].push_back(Edge(buils[j].id, d));
				G[buils[j].id].push_back(Edge(buils[i].id, d));
			}
		}
		
		cin >> m;
		for (int i = 0; i < m; i++) {
			int s, g; cin >> s >> g;
			dks(s, g);
		}
	}
	
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("io\\in.txt", "r", stdin);
    freopen("io\\out.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ret = 0;
    const int mod = 1000000007;

    rep(i, 60) {
        int cnt0 = 0, cnt1 = 0;
        rep(j, n) if (a[j] >> i & 1) cnt1++; else cnt0++;
        ret = (ret + (1ll << i) % mod * cnt0 % mod * cnt1) % mod;
    }

    cout << ret;

    return 0;
}


Measured memory_bytes: 5496
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    int count=0;
    for(int i=0;i<=n/r;i++){
        int m=n-i*r;
        for(int j=0;j<=m/g;j++){
            int s=m-j*g;
            if(s%b==0) count++;

        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  var n = io.StdIn.readInt
  var ss = Range(0,n).map(t=>io.StdIn.readLine.split("").sorted.mkString(""))
  val words = collection.mutable.Map[String,Int]()
  ss.foreach{s=>
    words += s -> (words.getOrElse(s,0)+1)
  }
  println(words.values.map{x=>x.toLong*(x.toLong-1L)/2}.sum)
}

Measured memory_bytes: 90172
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    std::cin >> n;
    int c=0;
    std::cin >> s;
    rep(i,s.size()-2){
        if(s.substr(i,3)=="ABC")c++;
    }
    std::cout << c << std::endl;
}

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

using namespace std;

int main()
{
  string g;
  int y,m,d;
  string b("#");
  
  while(1){
    cin>>g;
    if(g == b){
      break;
    }

    cin>>y;
    cin>>m;
    cin>>d;

    if(y - 30 <= 0){
      cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }
    else{
      if(y == 31 && m < 5){
        cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
      }
      else{
        y = y - 30;
        cout<<"?"<<" "<<y<<" "<<m<<" "<<d<<endl;
      }
    }
  } 

  return 0;
}


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


int main() {
    int N; cin >> N;
    int cnt = 0;
    int check[60000];
    rep(i, 60000){
        check[i] = 1;
    }
    for (int i = 2; i < 60000; i++){
        if(check[i] == 1){
            for (int j = i+i; j < 60000; j+=i){
                check[j] = 0;
            }
            if(i % 5 == 1){
                cout << i << endl;
                cnt++;
                if(cnt == N){
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
int main(void) {
	unsigned long a,c,d;
	int b;
	b = 0;
	scanf("%lu", &a);
	d = a;
	while (a != 0) {
		c = a % 10;
		b += (int)c;
		a /= 10;
	}
	if (d % b == 0)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;
typedef long long ll;
int n,a[N],s,ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),s^=a[i];
	for(int i=29;~i;i--)if(s>>i&1)
		for(int j=1;j<=n;j++)if(lb(a[j])==1<<i){ans++,s^=(1<<i+1)-1;break;}
	if(s)puts("-1");else cout<<ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> isPrime(300000, 1);
        isPrime[0] = isPrime[1] = 0;
        for(int i = 2; i < isPrime.size(); i++)
        {
            if(not isPrime[i]) continue;
            for(int j = 2 * i; j < isPrime.size(); j += i) isPrime[j] = 0;
        }
        int cnt = 0;
        for(int i = n + 1; i <= 2 * n; i++)
        {
            if(isPrime[i]) cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}




Measured memory_bytes: 4280
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n,m,x,y=map(int,input().split())
    xx=list(map(int,input().split()))
    yy=list(map(int,input().split()))
    for z in range(x+1,y+1):
        if all(p<z for p in xx) and all(q>=z for q in yy):
            print('No War')
            return
    print('War')

main()

Measured memory_bytes: 3060
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] d = new int[n];
		for(i=0;i<n;i++) {
			d[i] = parseInt(sc.next());
		}
		sc.close();
		int sum=0;
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++) {
				if(i==j)continue;
				sum+=d[i]*d[j];
			}
		}
		out.println(sum/2);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main ()
{
    long H,W,Ans;
    scanf("%ld%ld",&H,&W);
    if(H==1||W==1){
        Ans=1;
    }
    else if((H*W)%2==1){
        Ans=H*W/2+1;
    }
    else{
        Ans=H*W/2;
    }
    printf("%ld",Ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string S; cin >> S;
    for(int i = 2; i < N;i++){
        if(S.substr(i-2,3) == "ABC") res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define N 210000
#define L 4600
#define inf 1e9+7
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0,flag=1;
    char ch=0;
    while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*flag;
}
ll mo=inf;
ll x,y,fac[N];
ll exgcd(ll a,ll b)
{
	if(!b)
	{
		x=1;
		y=0;
		return a;
	}
	ll d=exgcd(b,a%b);
	ll t=x;
	x=y;
	y=t-(a/b)*y;
	return d;
}
ll inv(ll o)
{
	exgcd(o,mo);
	return (x%mo+mo)%mo;
}
ll c(ll a,ll b)
{
	ll up=fac[a];
	ll down=(fac[b]*fac[a-b])%mo;
	return (up*inv(down))%mo;
}
ll a[N],b[N],dp[L][L];
int main()
{
	ll n,i,j,ans=0;
	n=read();
	for(i=1,fac[0]=1;i<=200000;i++)fac[i]=(fac[i-1]*i)%mo;
	for(i=1;i<=n;i++)
	{
		a[i]=read();b[i]=read();
		dp[-a[i]+2200][-b[i]+2200]++;
		ans=(ans-c(2*a[i]+2*b[i],2*a[i])+mo)%mo;
	}
	for(i=1;i<=4500;i++)
	  for(j=1;j<=4500;j++)
	  dp[i][j]=(dp[i][j]+((dp[i-1][j]+dp[i][j-1])%mo))%mo;
	for(i=1;i<=n;i++)
	ans=(ans+dp[a[i]+2200][b[i]+2200])%mo;
	ans=(ans*inv(2))%mo;
	printf("%lld",ans);
	return 0;
} 

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

using namespace std;

const int MOD = 1e9 + 7;
const int N = 3e3 + 10;
const int rev2 = (MOD + 1) / 2;

int n, m;
int f[N][N];
int a[N];

int main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++) f[i][j] = (a[i] > a[j]);
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        for(int z = 1; z <= n; z++) if (z != x && z != y) {
            f[x][z] = f[y][z] = 1LL * (f[x][z] + f[y][z]) * rev2 % MOD;
            f[z][x] = f[z][y] = 1LL * (f[z][x] + f[z][y]) * rev2 % MOD;
        }
        f[x][y] = f[y][x] = 1LL * (f[x][y] + f[y][x]) * rev2 % MOD;
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = i + 1; j <= n; j++) ans = (ans + f[i][j]) % MOD;
    for(int i = 1; i <= m; i++) ans = (ans * 2) % MOD;
    cout << ans;
}


Measured memory_bytes: 35584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll r, D, x;
    cin >> r >> D >> x;

    rep(i, 10){
        x = r * x - D;
        cout << x << endl;
    }


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;
#define MAXN 101010
using namespace std;

vi g[MAXN];

vi used(MAXN , 0);
vi p(MAXN);
void dfs(int cur , set<int> & visited , vi & marks){
	used[cur] = 1;
	visited.insert(cur);
	marks.pb(p[cur]);
	for(auto & to : g[cur]){
		if(!used[to]){
			dfs(to , visited , marks);
		}
	}
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , m;
	cin >> n >> m;
	

	rep(i , n)cin >> p[i], --p[i];
	
	rep(i , m){
		int u , v;
		cin >> u >> v;
		--u, --v;
		g[u].pb(v);
		g[v].pb(u);
	}
	
	int ans = 0;
	
	rep(i , n){
		if(!used[i]){
			set<int> visited;
			vi marks;
			dfs(i , visited , marks);
			for(auto u : marks){
				ans += (visited.find(u) != visited.end());
			}
		}
	}
	
	cout << ans << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 15608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x,ct,p,q,r;
    string a,b;
    cin>>p;
    cin>>a>>b;
    for(ll i=0;i<p; i++)
    {
        cout<<a[i];
        cout<<b[i];
    }
    cout<<endl;
}







Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d,x,flag=0;
  cin>>a>>b>>x;
  if(a+b>=x){
    if(a<=x){
      cout<<"YES"<<'\n';
      flag=1;
    }
  }
  if(flag==0){
    cout<<"NO"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int N;
bool graph[60][60];
bool visited[60];

void dfs(int v)
{
    if (visited[v]) return;

    visited[v] = true;

    for (int i = 0; i < N; i++)
    {
        if (graph[v][i]) dfs(i);
    }
}


int main(int argc, const char *argv[])
{
    int M, a[60] = {}, b[60] = {};
    cin >> N >> M;

    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < M; i++)
    {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for(int j = 0; j < N; j++) visited[j] = false;

        dfs(0);

        for(int j = 0; j < N; j++) {
            if (!visited[j]) {
                ans ++;
                break;
            }
        }
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    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++)

int a, b;
int n;
bool maze[22][22];
int x, y;
int dp[22][22];

inline bool check(int hx, int hy){ return 0 <= hx && hx < a && 0 <= hy && hy < b; }

int rec(int s, int t)
{
  if(dp[s][t] > 0) return dp[s][t];
  if(s == 0 && t == 0) return dp[s][t] = 1;
  int ret = 0;
  if(check(s - 1, t) && !maze[s - 1][t]) ret += rec(s - 1, t);
  if(check(s, t - 1) && !maze[s][t - 1]) ret += rec(s, t - 1);
  return dp[s][t] = ret;
}

int main()
{
  while(cin >> a >> b, a){
    rep(i, a) rep(j, b) maze[i][j] = false;
    cin >> n;
    rep(i, n){
      cin >> x >> y;
      maze[x - 1][y - 1] = true;
    }

    rep(i, a) rep(j, b) dp[i][j] = -1;
    cout << rec(a - 1, b - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <map>
using namespace std;
int Molecule();
int Cule();
string s;
int p,flag;
map<string,int> m;

int main(){
  while(1){
    cin>>s;
    if(s=="END_OF_FIRST_PART") break;
    cin>>p;
    m.insert(make_pair(s,p));
  }
  while(1){
    cin>>s;
    if(s=="0") break;
    s=s+'$';
    p=flag=0;
    int r=Molecule();
    if(flag) cout<<"UNKNOWN"<<endl;
    else cout<<r<<endl;
  }
  return 0;
}

int Molecule(){
  int r=Cule();
  while(('A'<=s[p]&&s[p]<='Z')||s[p]=='(') r+=Cule();
  return r;
}

int Cule(){
  if(s[p]=='('){
    p++;
    int r=Molecule();
    p++;
    int num=Cule();
    return r*num;
  }
  if('A'<=s[p]&&s[p]<='Z'){
    string str;
    str+=s[p];
    int num=1,res;
    p++;
    if('a'<=s[p]&&s[p]<='z') str+=s[p],p++;
    if('0'<=s[p]&&s[p]<='9') num=Cule();
    if(m.find(str)!=m.end()) res=m[str]*num;
    else flag=1,res=0;
    return res;
  }
  if('0'<=s[p]&&s[p]<='9'){
    int num=0;
    while('0'<=s[p]&&s[p]<='9') num=num*10+s[p]-'0',p++;
    return num;
  }
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <map>

int main() {
  int ans = 0, n = 0;
  scanf("%d", &n);
  std::map<int, int> val;
  for (int i = 0; i < n; i++) {
  	int x;
    scanf("%d", &x);
    x = -x;
    auto iter = val.upper_bound(x);
    if (iter == val.end()) {
      ans++;
      if (val.find(x) == val.end()) {
        val[x] = 1;
      } else {
        val[x] += 1;
      }
    } else {
      iter->second--;
      if (iter->second == 0) {
        val.erase(iter);
      }
      if (val.find(x) == val.end()) {
        val[x] = 1;
      } else {
        val[x] += 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

int main(){
    int n;
    while(cin>>n && n){
        vector<int> chars;
        int c,count;
        int tmp=0;
        for(int i=0;i<n;++i){
            cin>>c;
            chars.push_back(c);
        }
        int maxsum=0;
        for(int i=1;i<n-1;++i){
            int curb=i,curf=i;
            int color=chars[i-1];
            int dsum=0;
            int back=1,forwd=0;            
            while(true){                
                while(curb-back>=0&&chars[curb-back]==color) ++back;
                while(curf+forwd<n-1&&chars[curf+forwd+1]==color) ++forwd;
                if(back+forwd<4) break;
                dsum += back + forwd;                
                curb -= back;curf += forwd;color=chars[curb];
                back=0;forwd=0;
            }
            maxsum=max(maxsum,dsum);
        }
        cout<<chars.size()-maxsum<<endl;
    }
    return 0;
}

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

int beris[305];
int beris2[305];
int res[305][305];
int h,w ,k;

void sol(int ind) {
  if(ind >= h-1) return;
  if(beris2[ind+1] == 0) sol(ind+1);
  for(int i = 0; i < w; i++) res[ind][i] = res[ind+1][i];

  if(res[ind][0] != 0) beris2[ind] = 1;
}

void sol2(int ind) {
  if(ind < 0) return;
  if(beris2[ind-1] == 0) sol2(ind-1);
  for(int i = 0; i < w;i++) res[ind][i] = res[ind-1][i];
  beris2[ind] = 1;
}

signed main() {
  cin >> h >> w >> k;
  string arr[h];
  for(int i = 0; i < h;i++) cin >> arr[i];

  for(int i = 0; i < h;i++) {
    for(int j = 0; j < w; j++) {
      if(arr[i][j] == '#'){ beris[i]++; beris2[i]++;}
    }
  }

  int num = 1;
  for(int i = 0; i < h; i++) {
    if(beris[i] == 0) continue;
    for(int j = 0; j < w; j++) {
      if(arr[i][j] == '#') {
        beris[i]--;
        res[i][j] = num;
        if(beris[i] != 0) num++;
      }
      else res[i][j] = num;
    }
    num++;
  }
  for(int i = 0; i < h; i++) {
    if(beris2[i] == 0){sol(i);}
  }
  //for(int i = 0; i < h;i++) cout << beris2[i] << " ";cout <<endl;
  for(int i = h-1; i>= 0; i--) {
    if(beris2[i] == 0) sol2(i);
  }
  for(int i = 0; i < h;i++) {
    for(int j = 0; j <w;j++) cout << res[i][j] << " ";cout <<endl;
  }


}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int hen(vector<ll> p){
    int ans = 1;
    ll mi = p[1];
    rep(i,2){
        if (mi > p[i+2]){
            mi = p[i+2];
            ans = i+2;
        }
    }
    return ans;
}

int main() {
    int n; cin >> n;
    if (n == 1) cout << "Hello World" << endl;
    else if (n == 2){
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vll x(n),y(m);
  rep(i,n) cin>>x[i];
  rep(i,m) cin>>y[i];
  ll sx=0;
  ll sy=0;
  rep(i,n-1){
    sx+=(i+1)*(n-i-1)*abs(x[i+1]-x[i]);
    sx%=MOD;
  }
  rep(i,m-1){
    sy+=(i+1)*(m-i-1)*abs(y[i+1]-y[i]);
    sy%=MOD;
  }
  COUT(sx*sy%MOD);
}

Measured memory_bytes: 4836
using System;
using System.Collections.Generic;
using System.Linq;

public class Program {
	public static void Main() {
		new Calc().calc();
	}
	public class Calc {
		public Calc() { }
		public void calc() {
			int X = int.Parse(Console.ReadLine());
			var list = new List<int>();
			list.Add(0);
			int homeTime = 0;
			while ((homeTime + 1) * homeTime / 2 < X) homeTime++;
			Console.WriteLine(homeTime);
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
	string s;
	cin >>s;
	for(int i=0;i<s.length();i++) {
		cout << 'x';
	}
	cout <<'\n';

}

signed main() {
	boost;
	solve();
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<int,int>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

int n,m;
vector<vector<ll>> v;
priority_queue<ll> qt;

void input(){
    cin>>n>>m;
    int a,b;
    v.resize(100010);
    rep(i,n){
        cin>>a>>b;
        v.at(a).push_back(b);
    }
}
void src(){
    ll sum=0;
    rep(day,m){
        if(!v.at(day+1).empty()){
            for(auto i:v.at(day+1)){
                qt.push(i);
            }
        }
        if(!qt.empty()){
            sum+=qt.top(); qt.pop();
        }
    }
    cout<<sum;
    return;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 5632
def node(hen, sin):
    if hen == 0 or sin == 0:
        return 0
    return 100 * sin / (hen + sin)


a, b, c, d, e, f = [int(i) for i in input().split()]
node_ans = 0
water_ans = 0
sugar_ans = 0
for A in range(0, f, a * 100):
    for B in range(0, f, b * 100):
        water = A + B
        max_sugar = water * e
        for C in range(0, f, c):
            for D in range(0, f, d):
                sugar = C + D
                if max_sugar < sugar*100 or f < water + sugar or water == 0:
                    break
                elif node_ans <= node(water, sugar):
                    node_ans = node(water, sugar)
                    sugar_ans = sugar
                    water_ans = water

print(water_ans + sugar_ans, sugar_ans)


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

int main() {
	int n;
	int x;
	cin>>x>>n;
	int arr[n];
	if(n==0){
		cout<<x<<endl;
	}else{
		for(int i=0;i<n;i++){
			cin>>arr[i];
		}
		sort(arr,arr+n);
		//for(int a=0;a<n;a++){
			//cout<<arr[a]<<" ";
		//}
		//cout<<endl;
		int pos =-1;
		for(int j=0;j<n;j++){
			if(arr[j] ==x){
				pos = j;
			}
		}
		//cout<<"pos: "<<pos<<endl;
		if(pos==-1)cout<<x<<endl;
		if(pos!=-1){
			int cnt =1;
			while(true){
				//cout<<"arr[p-c]: "<<arr[pos-cnt]<<" x-c: "<<x-cnt<<" arr[p+c]: "<<arr[pos+cnt]<<" x+c: "<<x+cnt<<endl;
				//if(pos-cnt>=0 or pos+cnt<n){
					if(arr[pos-cnt]!=x-cnt and pos-cnt>=0){
						cout<<x-cnt<<endl;
						break;
					}else if(arr[pos+cnt]!=x+cnt and pos+cnt<n){
						cout<<x+cnt<<endl;
						break;	
					}else if(pos-cnt<0){
						cout<<x-cnt<<endl;
						break;
					}else if(pos+cnt>=n){
						cout<<x+cnt<<endl;
						break;
					}else{
						cnt++;
					}
				//}
			}
		}
	}
}

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

int main(){
    int g_cnt=0;
    string str;

    cin>>str;
    for(int i=0; i<str.length(); i++){
        if(str[i]=='g')g_cnt++;
    }
    cout<<g_cnt-ceil((str.length())/2.0)<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int x[5][5];
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<2;j++){
            if(x[i][j]==1)a++;
            if(x[i][j]==2)b++;
            if(x[i][j]==3)c++;
            if(x[i][j]==4)d++;
        }
    }
    if(a<3&&a>0){
        if(b<3&&b>0){
            if(c<3&&c>0){
                if(d<3&&d>0)cout<<"YES"<<endl;
                else cout<<"NO"<<endl;
            }
            else cout<<"NO"<<endl;
        }
        else cout<<"NO"<<endl;
    }
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
main = do
    _ <- getLine
    line <- getLine
    line2 <- getLine
    let (x : y : _) = map read . words $ line
    let hs = map read . words $ line2
    putStrLn . show $ solve x y hs

-- |
-- >>> solve 12 5 [1000, 2000]
-- 1
-- >>> solve 21 (-11) [81234, 94124, 52141]
-- 3

solve :: Int -> Int -> [Int] -> Int
solve t a (h:hs) = fst . foldl min' (1, (1, delta h)) $ hs
    where
        temp h' = (realToFrac t) - (realToFrac h') * 0.006
        delta h'' = abs (realToFrac a - temp h'')
        min' (xa, (xb, xc)) y
            | xc < delta y = (xa, (xb + 1, xc))
            | otherwise   = (xb + 1, (xb + 1, delta y))


Measured memory_bytes: 1404
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> set = new HashSet<>();
        int res = 0;
        for(int i = 0; i < N; i++) {
            String s = sc.next();
            if(!set.contains(s)) {
                set.add(s);
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 77448
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

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

using namespace std;
typedef long long ll;
const int MAX = 60;

int main() {
	int H, W;
	int ans = 0;
	char s[MAX][MAX];
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] == '#') {
				if (s[i - 1][j] != '#'&&s[i + 1][j] != '#') {
					if (s[i][j - 1] != '#'&&s[i][j + 1] != '#') {
						ans = 1;
					}
				}
			}
		}
	}
	if (ans == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
W = [int(i) for i in input().split()]
lw = W[0]
rw = sum(W[1:])
ans = abs(lw-rw)
for n in range(N-1):
    lw += W[n+1]
    rw -= W[n+1]
    ans_temp = abs(lw-rw)
    ans = min(ans,ans_temp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int ,int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b){
		cout << "delicious\n";
	}
	else if(b-a <= x){
		cout << "safe\n";
	}
	else
		cout << "dangerous\n";
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  vector<bool> fixed(N,false);
  fixed[0] = fixed[N-1] = true;
  if(N == 1){
    if(A[0] != B[0]){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int i=1; i<N-1; i++){
    if(A[i-1] < A[i]){
      if(A[i] > B[i]){
        cout << 0 << endl;
        return 0;
      }
      fixed[i] = true;
    }
    if(B[i] > B[i+1]){
      if(B[i] > A[i]){
        cout << 0 << endl;
        return 0;
      }
      fixed[i] = true;
    }
  }
  ll ans = 1;
  for(int i=0; i<N; i++){
    if(fixed[i]) continue;
    if(A[i] > B[i]){
      ans *= B[i];
    }else{
      ans *= A[i];
    }
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

pair<int, int> f(int x){
    int a = x%10; //末尾
    int b = 0;
    while(x){
        b = x; //先頭
        x /= 10;
    }
    return pair<int, int> (a, b);
}

int main(void){
    int n;
    cin >> n;
    map<pair<int,int>, int> freq;
    for(int i = 1; i <= n; i++){
        pair<int, int> p = f(i);
        freq[p]++;
    }
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        pair<int, int> p = f(i);
        pair<int, int> q(p.second, p.first);
        ans += freq[q];
    }
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if((A * B) % 2 == 0){
			System.out.println("No");
		}else{
			System.out.println("Yes");
		}
		
	}
}


Measured memory_bytes: 22996