akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define N 100
int n,j,i,u,k,l,tmp;
int lengthlist[N];
int list[N][N];
void search(int y, int length);

int main(){
  scanf("%d",&n);
  for(l = 0; l<n; l++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j = 0;j < k ;j++){
      scanf("%d", &tmp);
      list[u-1][tmp-1] = 1;
	   }
    }
    for(l = 0; l<n; l++){
      lengthlist[l] = -1;
    }
    search(0,-1);

    for(j = 0; j<n ; j++){
      printf("%d %d\n",j + 1, lengthlist[j]);
    }
    return 0;
  }

  void search(int y, int length){
    int i;
    length++;
    lengthlist[y] = length;
    for(i = 0;i<n; i++){
      if(list[y][i] == 1){
	if(lengthlist[i] <= length && lengthlist[i] >= 0){
	  continue;
	}
	search(i,length);
      }
    }
  }



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  string s; cin >> s;
  int k; cin >> k;
  int n = s.size();

  rep(i,n) {
    int tmp = s[i] - 'a';
    tmp = 26 - tmp;
    tmp %= 26;
    if(k >= tmp){
      k -= tmp;
      s[i] = 'a';
    }
  }
  k %= 26;
  int tmp = k + (s[n-1] - 'a');
  tmp %= 26;
  s[n-1] = char('a' + tmp);

  cout << s << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int t, a, b, count = 0;
	cin >> t;
	bool ok = false;
	while (t--) {
		cin >> a >> b;
		if (a == b)
			count++;
		else
			count = 0;
		if (count == 3)
			ok = true;
	}
	if (ok)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp

int KnapsackProblem01(int N,int W,vector<int> v,vector<int> w) {
  vector<int> dp(W+1,0);
  for(int i=0;i<N;++i) {
    for(int j=W-w[i];j>=0;--j) {
      dp[j+w[i]] = max(dp[j+w[i]],dp[j]+v[i]);
    }
  }
  return dp[W];
}

int main() {
  int N,W;
  cin >> N >> W;
  vector<int> v(N),w(N);
  for(int i=0;i<N;++i) cin >> v[i] >> w[i];
  cout << KnapsackProblem01(N,W,v,w) << endl;
  return 0;
}

Measured memory_bytes: 1252
use proconio::input;
use std::collections::HashMap;
use std::iter::Iterator;
use std::iter::FromIterator;
 
fn main() {
  input! {
    n: usize,
    mut ss: [String;n]
  }
  
  let mut map: HashMap<String, usize> = HashMap::new();
  for s in ss {
    let mut chars: Vec<char> = s.chars().collect();
    chars.sort_by(|a, b| b.cmp(a));
    let sorted = String::from_iter(chars);
    let mut a = map.entry(sorted).or_insert(0);
    *a += 1;
  }
  
  let mut result = 0;
  for (_, v) in map {
    result += (v * (v-1)) / 2;
  }
  
  println!("{}", result);
}

Measured memory_bytes: 15180
#include <bits/stdc++.h>
using namespace std;
int main() {
 string s,ans;
 int K;
 cin>>K;
 cin>>s;
 
 if(s.size()>K){
  for(int i=0;i<K;i++){
    ans+=s[i];
  }
    ans+="...";
    cout<<ans<<endl;
}
 else if(s.size()<=K){
   ans=s;
   cout<<ans<<endl;
 }
 return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

ll money = 1000, share = 0;
ll A[100], N;


int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

  ll n,d,x,y,cnt=0;
  cin>>n>>d;
  while (n--) {
    cin>>x>>y;
    if(x*x + y*y <= d*d) cnt++;
  }
  cout<<cnt<<endl;










 return 0;
}


Measured memory_bytes: 3652
<?php
fscanf(STDIN, "%s", $S);
$arrS = str_split($S);
$cntS = count($arrS);

$arr = array_pad(array(), 26, 1);

for ($i = 0; $i < $cntS; $i++) {
    // echo ord($arrS[$i]) . PHP_EOL;
    $cd = ord($arrS[$i]) - 97;
    $arr[$cd] = 0;
}

for ($i = 0; $i < 26; $i++) {
    if ($arr[$i] === 1) {
        echo chr(97 + $i) . PHP_EOL;
        exit;
    }
}
echo "None\n";


Measured memory_bytes: 10744
#include "bits/stdc++.h"
#define ROOP(N) for(int i=0; i<N; i++)
#define INDEX_MAX 3

int main()
{
	int input[INDEX_MAX];
	ROOP(INDEX_MAX)
		std::cin >> input[i];

	std::stable_sort(input, input + INDEX_MAX);
	
	if (input[0] + input[1] == input[2] || input[0] == input[1] + input[2])
		std::cout << "Yes";
	else
		std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int maxn = 300 + 10;

int s(ll p){
	int ret = 0;
	while (p){
		ret += p % 10;
		p /= 10;
	}
	return ret;
}

ll f(ll p){
	vector<ll> cnd;
	cnd.push_back(p);
	ll tmp = p;
	ll q = 0, pw = 1;
	while (tmp){
		while (tmp % 10 < 9){
			tmp ++;
			cnd.push_back(pw * tmp + q);
		}
		pw = 10ll * pw;
		tmp /= 10;
		q = 10ll * q + 9;
	}
	int r = cnd.size();
	for (int i = 0; i < r; i++){
		bool bad = 0;
		for (int j = i + 1; j < r; j++){
			ll n = cnd[i], m = cnd[j];
			if (1ll * n * s(m) > 1ll * m * s(n)){
				bad = 1;
				break;
			}
		}
		if (bad == 0)
			return cnd[i];
	}
}

int main(){
	ios_base::sync_with_stdio (false);
	int k;
	cin >> k;
	ll now = 0;
	while (k){
		now = f(now + 1);
		cout << now << '\n';
		k --;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 f(i64 x) {
  return x == 0 ? 0 : x % 10 + f(x / 10);
}

int main() {
  i64 n;
  cin >> n;
  cout << (n % f(n) == 0 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
string s;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    getline(cin,s);int l=s.length();
    cout<<s[0]<<l-2<<s[l-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
//区間和を書いてます
struct segK{//非再帰
    int n;
    long long MIN;
    vector<long long> dat;
    segK(int n_){
        n = 1;
        MIN = -1;
        while(n < n_) n *= 2;
        dat.resize(2 * n);
        for(int i = 1; i < 2 * n; i++) dat[i] = MIN;
    }
    void update(int k, long long a){
        k += n;
        dat[k] = a;
        while(k > 0){
            k >>= 1;
            dat[k] = max(dat[k << 1 | 0], dat[k << 1 | 1]);
        }
    }
    long long query(int l, int r){
        long long res = 0;
        l += n;
        r += n;
        while(r > l){
            if(l & 1) res = max(res, dat[l++]);
            if(r & 1) res = max(res, dat[--r]);
            l >>= 1;
            r >>= 1;
        }
        return res;
    }
    int bin(int l, long long v) {
        l += n;
        long long zero = -1;
        do {
            while (l % 2 == 0) l >>= 1;
            if (dat[l] >= v) {
                while (l < n) {
                    l = (2 * l);
                    if (dat[l] < v) {
                        zero = max(zero, dat[l]);
                        l++;
                    }
                }
                return l - n;
            }
            zero = max(zero, dat[l]);
            l++;
        } while ((l & -l) != l);
        return -1;
    }
};

int main(){
    int N, Q;
    cin >> N >> Q;
    segK segtree(N);
    for(int i = 0; i < N; i++){
        long long a;
        cin >> a;
        segtree.update(i, a);
    }
    for(int i = 0; i < Q; i++){
        int t, x, v;
        cin >> t >> x >> v;
        x--;
        if(t == 1) segtree.update(x, v);
        else if(t == 2) {
            long long ans = segtree.query(x, v);
            cout << ans << endl;
        }
        else if(t == 3){
            int ans = segtree.bin(x, v);
            if(ans < x) cout << N + 1 << endl;
            else cout << ans + 1 << endl;
        }
    }
}

Measured memory_bytes: 7464
from collections import deque

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

li=[[] for i in range(n+1)]
ans=[0]*(n+1)

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

for i in range(q):
  p,x=map(int,input().split())
  ans[p]+=x

Q=deque([1])
sumi=set([1])

while Q:
#  print(Q)
  now=Q.pop()
  for i in li[now]:
    if i in sumi:
      continue
    else:
      sumi.add(i)
      Q.append(i)
      ans[i]+=ans[now]
print(*ans[1:])

Measured memory_bytes: 116204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

set<int> make_prime_set(int lim){//10^7:4.938 10^6:0.265sec 10^5:0.015sec lim > 2
	set<int> ps;
	bool pflag;
	int num;
	ps.insert(2);
	for(num = 3; num < lim; num++){
		pflag = true;
		for(int p : ps){
			if(p * p > num) break;
			if(num % p == 0){
				pflag = false;
				break;
			}
		}
		if(pflag == true) ps.insert(num);
	}
	
	return ps;
}

int main(){
	set<int> st;
	st = make_prime_set(55555);
	int n;
	cin >> n;
	vector<int> ans;
	for(int a : st){
		if(a % 5 == 1) ans.push_back(a);
		if((int)ans.size() == n)break;
	}

	rep(i, n){
		if(i != 0) cout << " ";
		cout << ans.at(i);
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 512
def main():
    n, m = map(int, input().split())
    if n == m == 1:
        r = 1
    elif n == 1:
        r = m - 2
    elif m == 1:
        r = n - 2
    else:
        r = (n - 2) * (m - 2)
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61888
#include <stdio.h>

int main(){
  char s[3],t[3];
  int ans=0;
  scanf("%s",s);
  scanf("%s",t);
  
  for (int i=0;i<3;i++){
    if (s[i]==t[i]){
      ans++;
    }
  }
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[233333];
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n;
	int cur=1,ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==cur)cur++;
		else ans++;
	}
	if(cur==1)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
A = list(map(int,input().split()))
A_l = [0,0]
A_l[1:1] = A
D = 0
for i in range(len(A_l) - 1):
  D += abs(A_l[i] - A_l[i + 1])
for i in range(n):
  print(D - abs(A_l[i] - A_l[i + 1])- abs(A_l[i + 1] - A_l[i + 2]) + abs(A_l[i] - A_l[i + 2]))

Measured memory_bytes: 14168
def main():
    import heapq
    n, m, *ab = map(int, open(0).read().split())
    l = [[] for _ in range(m + 1)]
    for i, j in zip(*[iter(ab)] * 2):
        if i <= m:
            heapq.heappush(l[i], -j)
    
    ans = 0
    h = []
    for i in range(1, m + 1):
        for j in l[i]:
            heapq.heappush(h, j)
        if len(h) > 0:
            x = heapq.heappop(h)
            ans += x

    print(-ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25496
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second
 
#define INF 2147483600
typedef pair<int, int> P;
 
int mat[1500][1500];
 
int main(){
  int h,w;
  cin>>h>>w;
 
  rep(i,h)rep(j,w) scanf("%d", &mat[i][j]);
 
  // convert matrix to vertiacl succeeding numbers
  rep(i,h)rep(j,w){
    if(i==0){
      mat[i][j] = !mat[i][j];
      continue;
    }
    if(mat[i][j]==0) mat[i][j] = mat[i-1][j]+1;
    else mat[i][j] = 0;
  }
 
  // see matrix row as a histogram to make the largert rectangle
  int res = 0;
  rep(i,h){
    mat[i][w] = 0;
    stack<P> st;
    rep(j,w+1){
      int d=mat[i][j];
      if(st.empty()) st.push(mp(j,d));
      else if(st.top().se < d) st.push(mp(j,d));
      else if (st.top().se > d){
        int last = j;
        while(!st.empty() && st.top().se > d){
          P p = st.top(); st.pop();
          res = max(res, (j-p.fi)*p.se);
          last = p.fi;
        }
        st.push(mp(last,d));
      }
    }
  }
 
  cout<<res<<endl;
 
  return 0;
}


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

int main() {

    string s;
    cin >> s;
    vector<string> v;

    for(int i = 0; i < s.size(); i++) {
        for(int j = i; j < s.size() && j < i+6; j++) {
            v.push_back(s.substr(i, j-i+1));
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    int k;
    cin >> k;
    cout << v[k-1] << endl;

    return 0;
}

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

int main() {
  int r, d, x;
  cin >> r >> d >> x;
  vector<int> X(11);
  X.at(0) = r*x-d;
  rep(i, 10) {
    X.at(i+1) = r*X.at(i) - d;
    cout << X.at(i) << endl;
  }   
}

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

int main() {
    int n;
    cin >> n;
    ll sum = 0;

    for (int i = 1;i <= n;i++) {
        if (i % 3!= 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n); for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int mi = a.at(0);
  for(int i = 0; i < n; i++){
    int m = 0;
    while(a.at(i) % 2 == 0){
      a.at(i) /= 2;
      m++;
    }
    mi = min(mi, m);
  }
  cout << mi << endl;
  
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    Int xx = c / b;
    if (c % b != 0) xx++;
    Int yy = a / d;
    if (a % d != 0) yy++;
    print(xx <= yy ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl

using namespace std;

int main(void) {

	int A,B;
	int X = 0;


	INPUT(A);
	INPUT(B);

	for(int i = 0 ; i < 2 ; i++){
		X += max(A,B);
		if(A>B){
			A--;
		}else{
			B--;
		}
	}


	OUTPUT(X);

}

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

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

    if ((s.at(2) == s.at(3)) && (s.at(4) == s.at(5))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    ll ans = 0;
    for(int i = 0; i < S.length() - 1; i++) {
        if(S[i] == S[i + 1]) {
            ans++;
        }
    }
    ans += 2 * K;
    cout << min(ans, (long long)S.length() - 1LL) << endl;
}

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

int main()
{
    string S;
    cin >> S;
    
    int count = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i]=='1'){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, A[MAX][3], dp[MAX][3];
int main(){
    scanf("%d", &N);
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &A[i][j]);
        }
    }
    for(int i = 0; i < 3; i++){
        dp[1][i] = A[1][i];
    }
    for(int i = 2; i <= N; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + A[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + A[i][2];
    }
    int ans = max(dp[N][0], dp[N][1]);
    ans = max(ans, dp[N][2]);
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  string N;
  cin >> N;
  for(int i=0;i<3;i++){
    if(N.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  
  }
  cout << "No" << endl;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;
	vector<bool> is_broken(n+1, false);
	rep(i, m) {
		ll a;
		cin >> a;
		is_broken[a] = true;
	}

	vector<ll> dp(n+1, 0);
	dp[0] = 1;
	dp[1] = is_broken[1] ? 0 : 1;
	repd(i, 2, n+1) {
		dp[i] = is_broken[i] ? 0 : ( (dp[i-2] + dp[i-1]) % 1000000007 ); 
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  std::string S;

  std::map<std::string, int> map;

  for (int i = 0; i < N; i ++) {
    std::cin >> S;

    map[S] ++;
  }

  std::cout << "AC"  << " x " << map["AC" ] << std::endl;
  std::cout << "WA"  << " x " << map["WA" ] << std::endl;
  std::cout << "TLE" << " x " << map["TLE"] << std::endl;
  std::cout << "RE"  << " x " << map["RE" ] << std::endl;

  return 0;
}


Measured memory_bytes: 3624
//ラブライブ！サンシャイン！！
//AT2274 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=9223372036854775807ll;

struct line{
	ll k,b;
	line(ll k=0,ll b=0):k(k),b(b){}
	ll get(ll x){return k*x+b;}
}st[300010],u;

int tp;

double its(line a,line b){
	return (b.b-a.b)/double(a.k-b.k);
}

int t[300010],n;
ll s[300010],f[300010],g[300010];
void dp(ll*f){
	int i;
	for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
	tp=1;
	st[1]=line(0,0);
	for(int i=1;i<=n;i++){
		while(tp>1&&st[tp].get(i)<=st[tp-1].get(i)) tp--;
		f[i]=max(st[tp].get(i)+((ll)i*i+i)/2-s[i],f[i-1]);
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
		st[++tp]=u;
	}
}
ll h[300010];
void solve(int l,int r){
	if(l==r){
		h[l]=1ll-t[l];
		return;
	}
	int mid,i,now;
	ll mx;
	mid=(l+r)>>1;
	solve(l,mid);
	solve(mid+1,r);
	tp=0;
	for(int i=l-1;i<mid;i++){
		u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
		while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
		st[++tp]=u;
	}
	now=1;
	mx=-inf;
	for(i=r;i>mid;i--){
		while(now<tp&&its(st[now],st[now+1])>=i)now++;
        mx=max(mx,st[now].get(i)+((ll)i*i+i)/2-s[i]+g[i+1]);
        h[i]=max(h[i],mx);
	}
	tp=0;
	for(i=mid+1;i<=r;i++){
        u=line(-i,g[i+1]+((ll)i*i+i)/2-s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
        st[++tp]=u;
    }
    now=tp;
    mx=-inf;
    for(i=l-1;i<mid;i++){
        while(now>1&&its(st[now],st[now-1])<=i)now--;
        mx=max(mx,st[now].get(i)+((ll)i*i-i)/2+s[i]+f[i]);
        h[i+1]=max(h[i+1],mx);
    }
}
int main(){
    int i,m,x,y;
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",t+i);
    dp(f);
    reverse(t+1,t+n+1);
    dp(g);
    reverse(t+1,t+n+1);
    reverse(g+1,g+n+1);
    for(i=1;i<=n;i++)s[i]=s[i-1]+t[i];
    solve(1,n);
    scanf("%d",&m);
    while(m--){
        scanf("%d%d",&x,&y);
        printf("%lld\n",max(f[x-1]+g[x+1],h[x]+t[x]-y));
    }
}

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

int main(){
  int N,M,K,A;
  cin>>N>>M;
  int i,j,num=0;
  vector<int> like(M,0);
  
  for(i=0;i<N;i++){
    cin>>K;
    for(j=0;j<K;j++){
      cin>>A;
      like.at(A-1)++;
    }
  }
  for(i=0;i<M;i++){
    if(like.at(i)==N) num++;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))

graph = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((H[b], b))
    graph[b].append((H[a], a))

cnt = 0
for i in range(n):
  graph[i].sort(reverse=True)
  if graph[i]:
    if graph[i][0][0] < H[i]:  
      cnt += 1
  else:
    cnt += 1
print(cnt)

Measured memory_bytes: 42340
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

inputList = list(inputa[0])



for i in range(len(inputList)):
    if inputList[i] == "1":
        inputList[i] = "9"
    elif inputList[i] == "9":
        inputList[i] = "1"

ans = "".join(inputList)
print(ans)

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

int main() {
    int R0, W0, C, R;
    while (cin >> R0 >> W0 >> C >> R) {
        if (R0 == 0) break;
        cout << max(0, (C*W0-R0+R-1) / R) << endl;
    }
    return 0;
}


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

int main() {
    int a, b, c, d, p, tota, totb;
    cin >> a; cin >> b; cin >> c; cin >> d; cin >> p;
    
    if (p > c) {
        totb = b + d*(p-c);
    } else {totb = b; }
    
    cout << min(a*p, totb) << endl;
}


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

# N が 2 で何回割れるか
def how_many_times(N):
    exp = 0
    while N % 2 == 0:
        N //= 2
        exp += 1
    return exp

result = min([how_many_times(v) for v in A])
print(result)

Measured memory_bytes: 9116
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <deque>

using namespace std;

int main() {
    string s;
    int q;
    cin >> s >> q;
    deque<char> ans;
    for (auto c : s) {
        ans.push_back(c);
    }
    bool flipped = false;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (t == 1) {
            flipped = !flipped;
            continue;
        }
        int f;
        char c;
        cin >> f >> c;
        if ((f == 1 && !flipped) || (f == 2 && flipped))
            ans.push_front(c);
        else
            ans.push_back(c);
    }
    if (flipped) reverse(ans.begin(), ans.end());
    for (auto c : ans) {
        cout << c;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int ans = 0;
            String s = in.next();
            char pre = s.charAt(0);
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != pre) {
                    ans++;
                    pre = s.charAt(i);
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



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


#define B

#ifdef B
int main(void)
{
	list<string> arr;

	string in;
	cin >> in;
	while (in != "-")
	{
		int n;
		cin >> n;
		for (size_t i = 0; i < n; i++)
		{
			int h;
			cin >> h;
			in = in.substr(h, -1) + in.substr(0, h);
		}
		arr.push_back(in);
		cin >> in;
	}
	for (auto a : arr) {
		cout << a << endl;
	}
	return 0;
}
#endif

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}

void Main()
{
  i64 l;
  cin >> l;
  cout << l*l*l/27.0 << endl;

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}



Measured memory_bytes: 256
n,m,l = map(int,input().split())
A = [0 for i in range(n)]
B = [0 for i in range(m)]
for i in range(n):
    A[i] = list(map(int,input().split()))
for i in range(m):
    B[i] = list(map(int,input().split()))

for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k]*B[k][j]
        print(c,end="")
        if j < l-1:
            print(" ",end="")
    print()



Measured memory_bytes: 6564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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 const INF = 1001001001;


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

ll X; cin >> X;

ll cur = 100;
for(int i = 1; i <= 5000; ++i) {
    ll add = cur/100;
    cur += add;
    if(cur >= X) {
        cout << i << endl;
        return 0;
    }
}

return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

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

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int main()
{
  int x, y;
  bool flag = false;

  cin >> x >> y;
  for (int i = 0; i * 2 <= y; i++)
  {
    for (int j = 0; i * 2 + 4 * j <= y; j++)
    {
      if (2 * i + 4 * j == y && i + j == x)
        flag = true;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3644
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let input1 : Vec<i32> = input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let input2 : Vec<i32> = input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    let mut count = 1;
    let mut height = 0;
    for i in input2 {
        height += i;
        if height <= input1[1]
        {
            count += 1;
        }
    }


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



Measured memory_bytes: 4352
#include <iostream>

using namespace std;

string st;

int main() {

  int n, s = 1e9, m = 0, l = 0;
  cin >> st;
  int j = st.size() - 1;
  for(int i = 0;i < st.size() / 2;i++){
    if(st[i] != st[j]){
      l++;
    }
    j--;
  }
  cout << l;
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){

	float a, b, c, d, e, f, x, y;
	
	while(scanf("%f%f%f%f%f%f", &a, &b, &c, &d, &e, &f) != EOF){

		y = (float) (c * d - f * a) / (b * d - a * e);
		x = (float) (c - b * y) / a;
		
		printf("%.3f %.3f\n", x, y);
	}
	
    return 0;
}

Measured memory_bytes: 648
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<unordered_map>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int MAX_M=100000+5;
const int INF=0x7fffffff;
const int inf=1000000000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int a[MAX_N];
int n,k;
int check(int x)
{
    int ans=0;
    int i;
    for(i=1; i<=n; i++)
    {
        if(a[i]>x)
        {
            ans+=a[i]/x;
            if(a[i]%x==0)
                ans--;
        }
        if(ans>k)
            return 1;
    }
    return 0;
}
int main()
{
    cin>>n>>k;
    int i;
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);
    int l=0;
    int r=1000000000;
    int mid=(l+r)/2;
    while(l<=r)
    {
        if(mid==0)
            break;
        if(check(mid))
        {
            l=mid+1;
        }
        else
            r=mid-1;
        mid=(l+r)/2;
    }
    cout<<mid+1<<endl;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m; cin >> n >> m;
  vector<ll> a(n); cin >> a;
  sort(all(a));
  ll ans = 0;
  rep(i, n-1) {
    if (m >= a[i]) {
      m -= a[i];
      ++ans;
    }
  }
  if (m == a.back()) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) if (i % k == 0) {
        cout << "OK";
        return 0;
    }
    cout << "NG";
}


Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const int mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int t;

int main(){
	cin>>t;
	for(int i=0;i<t;i++){
		int n,d;
		cin>>n>>d;
		cout<<(n-1)*127+((n%2==0)?d^127:d)<<endl;
	}
}

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

using namespace std;

int digit(int a) {
  int fst, snd, trd, foth, fith;
  int kaibun = 0;

  for (int i = 10000; i < a + 1; i++) {
    fst = i / 10000;
    snd = i % 10000 / 1000;
    trd = i % 1000 / 100;
    foth = i % 100 / 10;
    fith = i % 10;

    int gyaku = fith * 10000 + foth * 1000 + trd * 100 + snd * 10 + fst;

    if (i == gyaku) {
      kaibun++;
    }
  }
  return kaibun;
}

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

  cout << digit(b) - digit(a - 1) << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int a, p;
  cin >> a >> p;
  cout << (a * 3 + p) / 2 << endl;
}


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

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)



bool check(string s1,string s2){
	return s1 < s2;
}

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

	vector< string> S;
	S.resize(N);

	REP(i,N)cin >> S[i];
	sort(S.begin(),S.end(),check);
	REP(i,N)cout << S[i];


}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
def gcd(a,b):
  if a%b != 0:
    return gcd(b,a%b)
  else:
    return b
cur = A[0]
for i in range(N):
  cur = gcd(A[i],cur)
if max(A) < K:
  print('IMPOSSIBLE')
else:
  if K%cur != 0:
    print('IMPOSSIBLE')
  else:
    print('POSSIBLE')

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    if (B - A < 2 || K - A < 1) {
        cout << K + 1 << endl;
        return 0;
    }

    ll ans = A;
    K -= A - 1;
    ans += (B - A) * (K / 2);
    if (K % 2 == 1) ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a, b := scanInt(), scanInt()
	fmt.Fprintln(wr, max(a+b, max(a-b, a*b)))
}


Measured memory_bytes: 1776
#include <stdio.h>
#define MAX 100000

typedef struct{
  int parent;
  int left;
  int right;
}Node;

void Preorder(int);
void Inorder(int);
void Postorder(int);

Node T[MAX];
int c[2];
int n;

int main(){
  int l, m, i, j;

  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d", &l);
    for(j = 0; j < 2; j++){
      scanf("%d", &c[j]);
      if(c[j] != -1){
	T[c[j]].parent = l;
	if(j == 0) T[l].left = c[j];
	else T[l].right = c[j];
      }
    }
  }

  for(i = 0; i < n; i++) if(T[i].parent == -1) m = i;
  
  printf("Preorder\n");
  Preorder(m);
  printf("\n");

  printf("Inorder\n");
  Inorder(m);
  printf("\n");

  printf("Postorder\n");
  Postorder(m);
  printf("\n");
  
  return 0;
}

void Preorder(int u){
  if(u == -1) return;
  printf(" %d", u);
  Preorder(T[u].left);
  Preorder(T[u].right);
}

void Inorder(int u){
  if(u == -1) return;
  Inorder(T[u].left);
  printf(" %d", u);
  Inorder(T[u].right);
}

void Postorder(int u){
  if(u == -1) return;
  Postorder(T[u].left);
  Postorder(T[u].right);
  printf(" %d", u);
}

Measured memory_bytes: 620
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


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

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


  bool isans=true;

  // vector<bool> alphacount(26,false);

  map<string,long> alphacount;

  for (int i = 0; i < n-1; ++i){
    // if (alphacount[ w[i][0] ] ==false){
    //   alphacount[ w[i][0] ]=true;
    // }else{
    //   isans=false;
    // }
    if (alphacount.count(w[i])==0 ){
      alphacount[ w[i] ]=1;
    }else{
      isans=false;
    }

    if (w[i][ w[i].size()-1 ] != w[i+1][ 0])isans=false;
  }


    if (alphacount.count(w[n-1])==0 ){
      alphacount[ w[n-1] ]=1;
    }else{
      isans=false;
    }


  cout << (isans ? "Yes":"No");


  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mod = 10**9+7


p = 10 ** 9 + 7
N = (10 ** 5)*2 +10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


ttl = 0
for i in range(n-k+1):
    ttl += cmb(n-1-i,k-1,mod)*a[n-i-1]
    ttl %= mod
    #print(ttl)

for i in range(n-k+1):
    ttl -= cmb(n-1-i,k-1,mod)*a[i]
    ttl %= mod
    #print(ttl)


print(ttl)

Measured memory_bytes: 33368
class UnionFind:
    def __init__(self, node):
        self.parent = [-1 for _ in range(node)]

    def find(self, target):
        if self.parent[target] < 0:
            return target
        else:
            self.parent[target] = self.find(self.parent[target])
            return self.parent[target]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        root_x = self.find(x)
        root_y = self.find(y)
        if root_x == root_y:
            return
        if self.parent[root_x] > self.parent[root_y]:
            root_x, root_y = root_y, root_x
        self.parent[root_x] += self.parent[root_y]
        self.parent[root_y] = root_x

    def get_size(self, x):
        return -self.parent[self.find(x)]

    def get_root(self):
        return [i for i, root in enumerate(self.parent) if root < 0]


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        uf.union(a, b)
    ans = 0
    for i in range(n):
        ans = max(ans, uf.get_size(i))
    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dp[1001][1001];

int main()
{
    string s, t;
    cin >> s >> t;

    rep(i, 1001) dp[i][0] = i;
    rep(j, 1001) dp[0][j] = j;

    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < t.size(); j++)
        {
            if (s[i] == t[j])
                dp[i + 1][j + 1] = min({dp[i][j], dp[i + 1][j] + 1, dp[i][j + 1] + 1});
            else
                dp[i + 1][j + 1] = min({dp[i][j] + 1, dp[i + 1][j] + 1, dp[i][j + 1] + 1});
        }
    }

    OP(dp[s.size()][t.size()]);

    return 0;
}


Measured memory_bytes: 7120