akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S=["" for i in range(N)]

for i in range(N):
    S[i]=input()

count=0

for l in range(N):
    JUDGE=1
    for j in range(N):
        for k in range(j+1,N):
            
            if S[j][k-l]!=S[k][j-l]:
                JUDGE=0
                break
        if JUDGE==0:
            break

    if JUDGE==1:
        count+=1

print(count*N)


Measured memory_bytes: 42076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
typedef  long long ll;
using namespace std;

int main(void) {
	string S;
	getline(cin,S);

	for (int i = 0; i < S.length(); i++)
	{
		if (isalpha(S[i]))
		{
			if ( islower(S[i])) S[i] = toupper(S[i]);
			else S[i] = tolower(S[i]);
		}
	}

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m1, m2, d1, d2;
  cin >> m1 >> d1;
  cin >> m2 >> d2;
  if(m2!=m1 && d2==1 ) cout << "1" << endl;
  else cout <<"0" << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <cstdio>
#define top 10000
int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	for(int i = 1; i <= top; i++) {
		if((b*i+c) % a == 0) {
			printf("YES\n");
			return 0;
		}
	}
	printf("NO");
	return 0;
}


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

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

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

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

int k, s;

int main()
{
	cin >> k >> s;
	vector <int> T(k + 1);
	ll cnt = 0;
	rep(i, k + 1){
		T[i] = s - i;
	}

	sort(T.begin(), T.end());
	rep(i, k + 1) {
		rep(j, k + 1) {
			if (binary_search(T.begin(), T.end(), i + j))  cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;
    
    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
    }

    ll minLen = INF;  // サイクルの長さの最小値
    vl ans;
    rep(sv, n) { // 始点をsvとする
        vl dist(n, -1);  // dist[v] : 頂点svから頂点vへの最短距離(-1のとき未訪問)
        dist[sv] = 0;
        vl pre(n, -1);  // pre[v] : vの1つ前の頂点
        queue<ll> Q;
        Q.push(sv);
        while(!Q.empty()) {
            ll v = Q.front();
            Q.pop();
            for(auto u : G[v]) {
                if(dist[u] == -1) {
                    dist[u] = dist[v] + 1;
                    pre[u] = v;
                    Q.push(u);
                }
            }
        }
        rep(gv, n) {  // 終点をgvとする
            if(sv == gv || dist[gv] == -1) {
                continue;
            }
            for(auto u : G[gv]) {
                if(u == sv) {
                    vl tmp;
                    tmp.pb(sv);
                    ll now = gv;
                    while(now != sv) {
                        tmp.pb(now);
                        now = pre[now];
                    }
                    if(tmp.size() < minLen) {
                        minLen = tmp.size();
                        ans = tmp;
                    }
                }
            }
        }
    }

    if(minLen == INF) {
        out(-1);
        re0;
    }
    
    out(minLen);
    for(auto p : ans) {
        out(p+1);
    }
    
    re0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  sort(v.begin(), v.end());
  ll ans = 0;
  rep(i, n) {
    if (i < n-1) {
      if (m >= v.at(i)) {
        ans++;
        m -= v.at(i);
      }
    } else {
      if (m == v.at(i)) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    bool judge = true;
    if (c < d)
    {      //先にBが動く(ABCD)
        FOR(i, b + 1, d)
        {
            if (s[i-1] == '#' && s[i] == '#'){
                judge = false;
            }
        }
        FOR(i,a+1,c){
            if (s[i-1] == '#' && s[i]=='#'){
                judge = false;
            }
        }
    }
    else
    { //先にAが動く(ABDC)
        judge = false;
        FOR(i, b+1, d+2)
        {
            if (s[i-2] == '.' && s[i-1] == '.' && s[i]=='.'){
                judge = true;
                break;
            }
        }
        FOR(i, b + 1, d)
        {
            if (s[i-1] == '#' && s[i] == '#')
            {
                judge = false;
            }
        }
        FOR(i, a + 1, c)
        {
            if (s[i-1] == '#' && s[i] == '#')
            {
                judge = false;
            }
        }
    }
    if (judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); REP(i, n) cin >> a[i];
  while (k--) {
    if (*min_element(ALL(a)) == n) break;
    vector<int> nx(n + 1, 0);
    REP(i, n) {
      ++nx[max(i - a[i], 0)];
      --nx[min(i + a[i] + 1, n)];
    }
    FOR(i, 1, n + 1) nx[i] += nx[i - 1];
    a.swap(nx);
    a.pop_back();
  }
  REP(i, n) cout << a[i] << " \n"[i + 1 == n];
  return 0;
}


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

map<string, int> m;

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

    int cnt = 0;
    for(int i = 0; i < N; i++) {
        string str;
        cin >> str;
        cnt = max(cnt, ++m[str]);
    }

    for(pair<string, int> p : m) {
        if(p.second == cnt) cout << p.first << endl;
    }
}


Measured memory_bytes: 25216
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] arr = new int[q];
        for (int i=0; i<q; i++) arr[i] = sc.nextInt()-1;

        int[] person = new int[n];

        for (int i=0; i<n; i++){
            person[i] = k;
        }

        int[] point = new int[n];

        for (int i=0; i<q; i++){
            point[arr[i]]++;
        }

        for (int i=0; i<n; i++){
            if (person[i]>(q-point[i])){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }


    }
}

Measured memory_bytes: 72096
#include<stdio.h>
int main (void){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b)
    {
        printf("a < b\n");
    }else if (a>b)
    {
        printf("a > b\n");
        
    } else
    {
        printf("a == b\n");
        
    }
    return 0;
    
    
    
}


Measured memory_bytes: 2068
N = int(input())
A = list(map(int, input().split()))

cands = [False for i in range(0, 1000000 + 1)]
dir_cands = [False for i in range(0, 1000000 + 1)]
for a in A:
    if dir_cands[a]:
        cands[a] = True
    dir_cands[a] = True

    if cands[a]:
        continue

    x = 2 * a
    while x <= 1000000:
        cands[x] = True
        x += a

res = 0
for a in A:
    if not cands[a]:
        res += 1

print(res)


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);

        int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        
        out.println(a+b>=c ? b+c : a+2*b+1);
    }
}


Measured memory_bytes: 22612
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
count=[0]*(10**5+1)
c=Counter(a).items()
s=sum(a)
q=int(input())

for p in c:
    count[p[0]]+=p[1]
for i in range(q):
    b,c=mp()
    s+=(c-b)*count[b]
    count[c]+=count[b]
    count[b]=0
    print(s)

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


int main() {

  int N;
  cin>>N;
  vector<int64_t> M(N+1);
  M.at(0)=2;
  M.at(1)=1;
  for(int i=0;i<N-1;i++){
   M.at(i+2)=M.at(i+1)+M.at(i);
  }
  cout<<M.at(N)<<endl;
}


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

using namespace std;

int main()
{
	int n, q;
	cin >> n >> q;
	vector<vector<int>> g(n);
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> c(n);
	for (int i = 0; i < q; ++i)
	{
		int p, x;
		cin >> p >> x;
		c[p - 1] += x;
	}
	queue<int> qu;
	qu.push(0);
	vector<int> parent(n, -1);
	while (!qu.empty())
	{
		int u = qu.front();
		qu.pop();
		for (auto v : g[u])
		{
			if (v != parent[u])
			{
				parent[v] = u;
				qu.push(v);
				c[v] += c[u];
			}
		}
	}
	for (auto ans : c)
	{
		cout << ans << " ";
	}
}

Measured memory_bytes: 16372
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
	//	 static int mod =  (int) (Math.pow(10,9)+7);
		 static int mod =  2019;
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        
	        long N = sc.nextLong();
	        for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
	        long M = sc.nextLong();
	        int[] a = new int[(int) M];
	        int[] b = new int[(int) M];
	        for(int i=0;i<M;i++) {
	        	a[i]=sc.nextInt()-1;
	        	b[i]=sc.nextInt()-1;
	        	list.get(a[i]).add(b[i]);
	        	list.get(b[i]).add(a[i]);
	        }
	        long ans=0;
	        for(int i=0;i<M;i++){
		        boolean[] visited = new boolean[(int)N];
				LinkedList<Integer> q= new LinkedList<Integer>();
				q.add(0);
				q.add(-1);
				visited[0]=true;
		        while(!q.isEmpty()) {
		        	int now=q.poll();
		        	int parent=q.poll();
		    		for(int j=0;j<list.get(now).size();j++) {
		    			int next = list.get(now).get(j);
		    			if(next == parent)continue;
		    			if(next == a[i] && now == b[i])continue;	
		    			if(next == b[i] && now == a[i])continue;
		    			if(visited[next]==true)continue;
		    			visited[next]=true;
		    			q.add(next);
		    			q.add(now);
		    		}
		        }
	        	
	        	for(int j=0;j<N;j++) {
	        		if(visited[j]==false) {
	        			ans++;
	        			break;
	        		}
	        	}
	        }
	        
	    	System.out.println(ans);
	    	
	        		
	    }
	    

	}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll= long long;
using ld= long double;
using vl= vector<ll>;
using vd= vector<ld>;
using vs= vector<string>;
using vb= vector<bool>;
using vvl= vector<vector<ll>>;
using vvd= vector<vector<ld>>;
using vvs= vector<vector<string>>;
using vvb= vector<vector<bool>>;
using pll= pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

template <class T>
inline void chmin(T &a, T b) {
    if(a > b) { a= b; }
}

template <class T>
inline void chmax(T &a, T b) {
    if(a < b) { a= b; }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll T;
    cin >> T;
    REP(jksnd,T){
        ll N,M,A,B;
        cin >> N >> M >> A >> B;
        cout << floor_sum(N,M,A,B) << "\n";
    }
}

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

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

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

        ll ans = 1;
        for (int i = 0; i < N; ++i) {
                ans = lcm(ans, T[i]);
        }
        cout << ans << endl;

}


Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        K : i32,
        S : i32,
    }
    let mut ans = 0;
    for X in 0..K+1{
        for Y in 0..K+1{
            let Z = S - X -Y;
            if 0<= Z && Z <= K{
                ans += 1;
            }
        }
    }
    println!("{}",ans)
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int n, m;
    int ans = 0;
    cin >> n >> m;
    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>(10));
    rep(i, m) {
        cin >> k[i];
        rep(j, k[i]) {
            int si;
            cin >> si;
            si--;
            s[i][si] = 1;
        }
    }

    rep(i, m) cin >> p[i];

    for(int i = 0; i < 1 << n; i++) {
        bool flag = true;
        for(int sw = 0; sw < m; sw++) {
            if(!flag) break;
            int cnt = 0;
            for (int j = 0; j < n; j++) {
                if((i & 1 << j) and s[sw][j] == 1) cnt += 1;
            }
            if(cnt % 2 != p[sw]) flag = false;
        }
        if(flag) ans += 1;
    }

    cout << ans << endl;
}



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


int main(){
    int ans=0, n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,n-2){
        if(s.substr(i,3)=="ABC"){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

int x = 100000,y,n = 1;
cin >> y;

while(n <= y){
  if(x % 1000 == 0){
    x = x*1.05;}
  else {
  x =(x - x % 1000 + 1000)*1.05;}
  ++n;}

if(x % 1000 == 0) {cout << x << endl;}
 else {cout << x - x % 1000 + 1000 << endl;}

return 0;
}



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

int main() {
  int N;
  cin >> N;
  string ans = "second";
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 1) {
      ans = "first";
      break;
    }
  }
  cout << ans << endl;
}

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

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  rep(i,N) cin>>vec.at(i);
  int count=0;
  sort(vec.begin(),vec.end());
  vector<pair<int,int>> num={make_pair(1,vec.at(0))};
  rep(i,N){
    if(i==0) continue;
    else if(vec.at(i)==vec.at(i-1)) num.at(num.size()-1).first++;
    else num.push_back(make_pair(1,vec.at(i)));
  }
  if(num.size()<K) cout<<0<<endl;
  else{
    sort(num.begin(),num.end());
    int count=0;
    rep(i,num.size()-K) count+=num.at(i).first;
    cout<<count<<endl;
  }
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
bool cmp(int x, int y){
    return x > y;
}
long long n, m, a[111], sum;
int main(){
    n = read(), m = read();
    for (int i = 1; i <= n; i++){
        a[i] = read();
        sum += a[i];
    }
    sort (a+1, a+n+1, cmp);
    a[0] = 0;
    double k = sum / 4.0 / m;
    for (int i = 1; i <= m; i++){
        if (a[i] < k){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    vector<P> ab;
    for(int i=0; i<n; i++){
        ll a,b;
        cin>>a>>b;
        ab.push_back(P(a,b));
    }
    sort(ab.begin(),ab.end());
    priority_queue<ll> pq;
    ll j = 0;
    ll ans = 0;
    for(int i=1; i<=m; i++){
        for(;j<n&&ab[j].first<=i;j++){
            pq.push(ab[j].second);
        }
        if(!pq.empty()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout<<ans;
    return 0;
}

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

int main() {
	// your code goes here
	int x, n, a;
	if(n == 0){
		cout << x << endl;
		return 0;
	}
	cin >> x >> n;
	set<int> s;
	for(int i = 0;i < n; ++i){
		cin >> a;
		s.insert(a);
	}
	int ans1 = x, ans2 = x;
	while(true){
		if(!s.count(ans1)){
			cout << ans1 << endl;
			return 0;
		}
		if(!s.count(ans2)){
			cout << ans2 << endl;
			return 0;
		}
		--ans1;
		++ans2;
	}
	return 0;
}

Measured memory_bytes: 3636
while True:

    n,x = map(int,input().split())

    if n == 0 and x == 0 :
        break

    ans = 0

    for i in range(n):

        for j in range(i):

            for k in range(j):

                if i + j + k + 3 == x:

                    ans += 1

    print (ans)



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

string name;

int solve(string s){

	for(unsigned int i = 1; i < s.size(); i++){
		for(unsigned int j = 0; j < s.size(); j++){
			string str;
			for(unsigned int k = j; k < s.size(); k += i){
				str += s[k];
			}
			string::size_type it = str.find(name);
			if(it != string::npos)
				return 1;
		}
	}
	return 0;
}

int main()
{
	int n, ans = 0;
	cin >> n;
	cin >> name;
	string s;
	for(int i = 0; i < n; i++){
		cin >> s;
		ans += solve(s);
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  double ans = (n / 2 + n % 2) / (n*1.0);
  printf("%.8f\n", ans);
  return 0;
}

Measured memory_bytes: 256
# 深さ優先探索
N = int(input())
links = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    links[a].append((b, c))
    links[b].append((a, c))

Q, K = map(int, input().split())

d = [float('inf')] * (N + 1)
d[K] = 0
q = [K]
while q:
    i = q.pop()
    for j, c in links[i]:
        if d[i] + c < d[j]:
            d[j] = d[i] + c
            q.append(j)

result = []
for _ in range(Q):
    x, y = map(int, input().split())
    result.append(d[x] + d[y])
#print('\n'.join(str(v) for v in result))
print(*result, sep='\n')

Measured memory_bytes: 54236
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <set>
#define MAX_L 5005

using namespace std;

int n,K;
char s[MAX_L];
set<string> st;

int main()
{
	scanf("%s%d",s+1,&K);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		string t;
		for(int j=i;j<=min(n,i+4);j++)
		{
			t+=s[j];
			st.insert(t);
		}
	}
	set<string>::iterator it=st.begin();
	for(int i=1;i<K;i++) it++;
	cout<<(*it)<<endl;
}


Measured memory_bytes: 1664
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i32,
    a: [i32; n],
  }
  
  let (mut even, mut pass) = (0, 0);
  for i in a {
    if i % 2 == 0 {
      even += 1;
      if i % 3 == 0 || i % 5 == 0 {
        pass += 1;
      }
    }
  }
  
  println!("{}", if even == pass { "APPROVED" } else { "DENIED" });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 605
#define M 4000005
#define mod 1000000007
int n, m, k, a[N], ans;
int main ()
{
    scanf("%d", &n);
    fo (i, 1, n)
        scanf("%d", &a[i]);
    std::sort(a + 1, a + n + 1);
    fo (i, 1, n - 1)
        ans += a[i];
    ans += a[n] / 2;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#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 P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int cnt0 = 0;
	int cnt1 = 0;
	rep(i, s.size()) {
		if (s[i] == '0')cnt0++;
		else cnt1++;
	}
	cout << min(cnt0, cnt1) * 2 << endl;
	return 0;
}


Measured memory_bytes: 512
n,q = gets.chomp.split(' ').map(&:to_i)
s = gets.chomp.split('')

sum = [0]

s.each_cons(2) do |arr|
  sum << sum.last
  sum[-1] += 1 if arr.join == "AC"
end

q.times do
  l,r = gets.chomp.split(' ').map(&:to_i)
  puts sum[r-1] - sum[l-1]
end


Measured memory_bytes: 14844
use std::io;
use std::io::prelude::*;

fn main() {
    let mut buf = String::new();
    let stdin = io::stdin();
    let mut lock = stdin.lock();

    lock.read_to_string(&mut buf);

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let s: Vec<u8> = iter.next().unwrap().into();

    let mut i = 1;
    let mut answer = 0;
    while i < n {
        if s[i - 1] != s[i] {
            answer += 1;
            i += 2;
        } else {
            i += 1;
        }
    }

    println!("{}", answer);
}



Measured memory_bytes: 5036
#include <stdio.h>
int main(void){
   int W,H,x,y,r,a,b,c,d;
   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
   a=x-r;
   b=y-r;
   c=x+r;
   d=y+r;
   if(a<0){
       puts("No");
   }
   else if(b<0){
       puts("No");
   }
   else if(c>W){
       puts("No");
   }
   else if(d>H){
       puts("No");
   }
   else {
       puts("Yes");
   }
 
   return 0;
   }


Measured memory_bytes: 2104
n=int(input())
abc=[list(map(int,input().split())) for _ in range(n)]

for i in range(1,n):
    abc[i][0]=abc[i][0]+max(abc[i-1][1],abc[i-1][2])
    abc[i][1]=abc[i][1]+max(abc[i-1][0],abc[i-1][2])
    abc[i][2]=abc[i][2]+max(abc[i-1][0],abc[i-1][1])
print(max(abc[-1]))

Measured memory_bytes: 30580
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,ds[100010]={},rds[100010],ans=0;

void init(){
	cin>>n;
	rep(i,n){
		ll d;
		cin>>d;
		ds[d]++;
	}
}

int main(void){
	init();
	rds[100001]=0;
	irep(i,100001){
		rds[i]=rds[i+1]+ds[i];
		if(rds[i]==n/2)ans++;
		// cerr<<rds[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int H, W, N; 
string T, A;
int R, C;

bool check(int l, int s, char add, char sub) {
	int mi = 1, ma = l;
	for (int i = N-1; i >= 0; i--) {
		if (A[i] == add) {
			mi--;
		} else if (A[i] == sub) {
			ma++;
		}
		mi = max(mi, 1), ma = min(ma, l);
		if (T[i] == add) {
			ma--;
		} else if (T[i] == sub) {
			mi++;
		}
		if (mi > ma) return false;
	}
	return mi <= s && s <= ma;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> H >> W >> N;
	cin >> R >> C;
	cin >> T >> A;
	if (check(H, R, 'D', 'U') && check(W, C, 'R', 'L')) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 920
def resolve():
  A = [[int(item) for item in input().split()] for i in range(3)]
  N = int(input())
  B = [int(input()) for i in range(N)]
  
  table = [[a in B for a in row] for row in A]
  
  for i in range(3):
    if table[i][0] == table[i][1] == table[i][2] == True:
      print("Yes")
      return
    if table[0][i] == table[1][i] == table[2][i] == True:
      print("Yes")
      return
    
  if table[0][0] == table[1][1] == table[2][2] == True or table[0][2] == table[1][1] == table[2][0] == True:
    print("Yes")
    return 
  
  print("No")
  
resolve()

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef pair<int, int> ii;

int i, n;
set<char> s;
char c;
string str[] = {"One", "Two", "Three", "Four"};
vi v;
int main() {
	cin >> n;
	for(i = 0; i < n; i++) {
		cin >> c;
		s.insert(c);
	}
	cout << str[s.size()-1] << endl;
	return 0;
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node *NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  /* your code */
   NodePointer cur=nil->next;
  while(cur!=nil && cur->key!=key)
  {
    cur=cur->next;
  }
  
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  //検索したノードを削除
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

int main() {
	int x, y;
	cin >> x >> y;

	if (x == 2) {
		if (y == 2)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	else {
		if (y == 1 || y == 3 || y == 5 || y == 7||y==8||y==10||y==12)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}



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

const int INF = 1001001001;

int main(){
    int d;
    cin>>d;
    int c[26];
    for(int i=0;i<26;i++)cin>>c[i];
    int s[d][26];
    for(int i=0;i<d;i++)for(int j=0;j<26;j++){
        cin>>s[i][j];
    }
    int score=0;
    int last[26]={};
    for(int i=1;i<=d;i++){
        int holding=-1, maxs=-INF;
        for(int j=0;j<26;j++){
            int t=0;
            t+=(i-last[j])*c[j];
            t+=s[i-1][j];
            if (t>maxs){
                t=maxs;
                holding=j;
            }
        }
        score+=maxs;
        cout<<holding+1<<endl;
    }
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    ll h, w;
    cin>>h>>w;
    if (w == 1 || h == 1) cout<<1<<endl;
    else {
        if (w % 2 == 0) cout<<h * w / (ll)2<<endl;
        else cout<<h * (w / (ll)2) + (h + (ll)1) / (ll)2<<endl;
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<long> a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int i=0;
  for(int j=0; j<n; j++){
    if(max(a[n-1]-a[i]*2,a[i]*2-a[n-1])>max(a[n-1]-a[j]*2,a[j]*2-a[n-1])){
      i=j;
    }
  }
  cout << a[n-1] << ' ' << a[i] << endl;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}
#[allow(unused_macros)]
macro_rules !chmax {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_max =max !($($cmps ) ,+) ;if $base <cmp_max {$base =cmp_max ;true } else {false } } } ;}

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ab: [(usize, usize); h]
    }

    let mut s = (1..=w).map(|i| (i, i)).collect::<BTreeSet<(usize, usize)>>();
    let mut v = (1..=w).map(|i| (0, i)).collect::<BTreeSet<(usize, usize)>>();

    for (i, &(a, b)) in ab.iter().enumerate() {
        let mut x = 0;
        while let Some(&(end, start)) = s.range((a, 0)..=(b, w)).next() {
            chmax!(x, start);
            s.remove(&(end, start));
            v.remove(&(end - start, start));
        }
        if x != 0 && b != w {
            s.insert((b + 1, x));
            v.insert((b + 1 - x, x));
        }
        if let Some((m, _)) = v.iter().next() {
            println!("{}", m + i + 1);
        } else {
            println!("-1");
        }
    }
}


Measured memory_bytes: 22116
#include <stdio.h>

int main(){
	
	
	char str1[200],str2[200],judgement[3][10]={"IDENTICAL","CLOSE","DIFFERENT"};
	int count1,count2,flag1,flag2,judge;

	for(;;){

		judge=0;
		
		count1=0;
		count2=0;

		scanf("%s",str1);
		if(str1[0]=='.')break;
		scanf("%s",str2);

		for(;;){

			if(str1[count1]!=str2[count2])judge=2;

			if(str1[count1]=='\0' || str2[count2]=='\0')break;

//printf("aa");

			if(str1[count1]=='"'){///””の中

				count1++;
				count2++;
				flag1=0;
				flag2=0;

				for(;;){
					if(str1[count1]!=str2[count2]){
						if(judge==1){
							judge=2;
							break;
						}
						judge=1;
						break;
					}

					if(str1[count1]=='"')flag1=1;
					if(str2[count2]=='"')flag2=1;
					if(flag1+flag2>=1)break;
				
					count1++;
					count2++;

				}
				if(flag1==0)for(;str1[count1]!='"';count1++);
				if(flag2==0)for(;str2[count2]!='"';count2++);
			}

		if(judge==2)break;

		count1++;
		count2++;
		}

		printf("%s\n",judgement[judge]);
	}



	return 0;
}


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

int main()
{
    //freopen("in.txt","r",stdin);
    /*
    vector<bool> s(14),h(14),c(14),d(14);
    int n;
    cin >> n;
    while(n--)
    {
        char  t;
        int i;
        cin >> t >> i;
        if(t=='S')
        {
            s[i] = true;
        }
        else if(t=='H')
        {
            h[i] = true;
        }
        else if(t=='C')
        {
            c[i] = true;
        }
        else if(t=='D')
        {
            d[i] = true;
        }
        for(int i=1; i<=13; i++)
        {
            if(!s[i])
            {
                cout << "S " << i << endl;
            }

        }
        for (int i = 1; i <= 13; i++)
            if (!h[i]) cout << "H " << i << endl;
        for (int i = 1; i <= 13; i++)
            if (!c[i]) cout << "C " << i << endl;
        for (int i = 1; i <= 13; i++)
            if (!d[i]) cout << "D " << i << endl;



    }
    */

    vector<bool> s(14), h(14), c(14), d(14);
    int n; cin >> n;
    while (n--) {
        string t; int i; cin >> t >> i;
        if (t == "S") s[i] = true;
        if (t == "H") h[i] = true;
        if (t == "C") c[i] = true;
        if (t == "D") d[i] = true;
    }
    for (int i = 1; i <= 13; i++)
        if (!s[i]) cout << "S " << i << endl;
    for (int i = 1; i <= 13; i++)
        if (!h[i]) cout << "H " << i << endl;
    for (int i = 1; i <= 13; i++)
        if (!c[i]) cout << "C " << i << endl;
    for (int i = 1; i <= 13; i++)
        if (!d[i]) cout << "D " << i << endl;



    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int x;
	cin >> x;
	cout << (x == 0 ? 1 : 0) << "\n";

	return 0;
}


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

using namespace std;
int main() 
{
        int n;
        cin>>n;
        for(int i=1;i<=9;i++)
        {
            if(n%i == 0 && (n/i) <= 9)
                {
                    cout<<"Yes";
                    return 0;
                }
        }
         cout<<"No";
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n; int v_max = (1 << n);
    vector<long> v(v_max), u;
    rep(i, v_max) cin >> v[i];
    sort(all(v), greater<long>());

    bool used[v_max];
    memset(used, 0, sizeof(used));
    u.push_back(v[0]); used[0] = true;
    rep(i, n){
        int m = 1 << i; int l = 0;
        rep(j, m){
            while(true){
                l++;
                if(l == v_max){
                    out("No"); return 0;
                }
                if(used[l]) continue;
                if(v[l] < u[j]){
                    used[l] = true;
                    u.push_back(v[l]);
                    break;
                }
            }
        }
        sort(all(u), greater<long>());
    }
    out("Yes");
}

Measured memory_bytes: 4724
X,Y,Z,K = gets.split.map(&:to_i)

A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

s = []

for i in 0..X-1 do
  for j in 0..Y-1 do
        s.push( A[i] + B[j] )
  end
end

s.sort!.reverse!

t = []

imax = [K-1, X*Y-1].min

for i in 0..imax do
  for j in 0..Z-1 do
    t.push( s[i] + C[j])
  end
end

t.sort!.reverse!

for i in 0..K-1 do
  puts t[i]
end


Measured memory_bytes: 70140
/**
  *  Worg
  */
#include <iostream>
#include <algorithm>

int main() {
  int a, b, c, x, y;
  std::cin >> a >> b >> c >> x >> y;

  int answer = 0;

  //  Vedem cate cumparam la pachet
  if (c * 2 < a + b) {
    int d = std::min(x, y);

    answer += d * (c * 2);

    x -= d; y -= d;
  }

  //  Ne ocupam de A-urile ramase
  if (x >= 0) {
    if (c * 2 < a) {
      answer += x * (c * 2);
    } else {
      answer += x * a;
    }
  }

  //  Ne ocupam de B-urile ramase
  if (y >= 0) {
    if (c * 2 < b) {
      answer += y * (c * 2);
    } else {
      answer += y * b;
    }
  }

  std::cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 256
r, c = gets.chomp.split.map(&:to_i)
b = 0
d = Array.new()
e = 0
r.times do
    a = gets.chomp.split
    a.each do |i|
        print "#{i} "
        b += i.to_i
    end
    puts "#{b}"
    e += b
    b = 0
    d << a
end
i = 0
d.transpose.each do |j|
    j.each do |k|
        i += k.to_i
    end
    print "#{i} "
    i = 0
end
print "#{e}"
puts ""
#e = d.transpose
#puts "#{e}"
#puts ""

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

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

Measured memory_bytes: 3832
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int x = sc.nextInt(), y = sc.nextInt();
		sc.close();
		long ans = 0;
		if(a + b <= c * 2) {
			ans = (long)x * a + (long)y * b;
		}
		else {
			if(x>=y) {
				ans = (long)y * 2 * c + (long)(x - y) * Math.min(2*c,a);
			}
			else {
				ans = (long)x * 2 * c + (long)(y - x) * Math.min(2*c,b);				
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  long long a,b;cin >> a >> b;
  long long d = __gcd(a,b);
  int ans = 1;
  int c = sqrt(d);
  for(int i = 2;i<=c;i++){
    if(d % i == 0){
      //cout << d<<" " << i << endl;
      ans++;
      while(d%i==0) d/= i;
    }
  }
  if(d!=1) ans += 1;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mod 
#define maxm 
#define maxn 
int a[100010];
int main()
{
	int n, m;
	
	scanf("%d%d", &n, &m);
	int fg = 0;
	scanf("%d", &a[0]);
	int x = a[0];
	for (int i = 1; i < n; i++) {
		scanf("%d", &a[i]);
		x = __gcd(x, a[i]);
	}
	sort(a, a + n);
	if (a[n - 1] >= m && x == __gcd(x, m))
		puts("POSSIBLE");
	else 
		puts("IMPOSSIBLE");
} 

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100010],dp[100][100];

struct edge{ll to,cost;};
vector<edge> vec[100010];

void dfs(int v,int p,ll cost){
  d[v] = cost;
  rep(i,0,vec[v].sz){
    edge e = vec[v][i];
    if(e.to == p)continue;
    dfs(e.to,v,cost+e.cost);
  }
}

int main(){
  cin >> n;
  rep(i,0,n-1){
    ll a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    vec[a].pb((edge){b,c});
    vec[b].pb((edge){a,c});
  }
  cin >> m >> l;
  l--;
  dfs(l,-1,0);
  rep(i,0,m){
    ll x,y;
    cin >> x >> y;
    print(d[x-1]+d[y-1]);
  }
  return 0;
}

Measured memory_bytes: 14336