akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef pair<int,int> pii;
int main() {
  int n,k;
  cin >> n >> k;
  if (2*k>n) {
    cout << -1 << endl;
    return 0;
  }
  set<pii> se[k+1];
  se[0].insert(pii(1,2));
  int start = 4;
  if (n%2) {
    se[0].insert(pii(2,3));
    start = 5;
  }
  for (int i=start; i<=n; i+=2) {
    for (int j=1; j<=min(i/2-1, k); ++j) {
      se[j-1].insert(pii(i-1, j));
      se[j-1].insert(pii(i, i/2-1+j));
    }
    if (i/2<=k) {
      int hoge = i/2-1;
      se[hoge].insert(pii(i-1, i));
      for (int j=1; j<=i/2-1; ++j) {
        se[hoge].insert(pii(i, j));
        se[hoge].insert(pii(i-1, i/2-1+j));
      }
      se[hoge].insert(pii(i-1,i-2));
    }
  }
  REP(i,k) {
    if (i)puts("");
    FOR(it, se[i]) {
      printf("%d %d\n",it->first, it->second);
    }
  }
}

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

typedef long long ll;

int dp[3050][3050];
int bt[3050][3050][2];
int solve(int i, int j, string &a, string &b)
{
  if (dp[i][j] != -1)
    return dp[i][j];
  if (i == a.size() || j == b.size())
    return 0;
  int res;
  if (a[i] == b[j])
  {
    res = 1 + solve(i + 1, j + 1, a, b);
    bt[i][j][0] = i + 1, bt[i][j][1] = j + 1;
  }
  else
  {
    int l1 = solve(i + 1, j, a, b);
    int l2 = solve(i, j + 1, a, b);
    res = max(l1, l2);
    bt[i][j][0] = i + 1, bt[i][j][1] = j;
    if (l2 > l1)
      bt[i][j][0] = i, bt[i][j][1] = j + 1;
  }
  return dp[i][j] = res;
}

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

  string a, b, ans;
  cin >> a >> b;
  memset(dp, -1, sizeof(dp));
  solve(0, 0, a, b);
  int i = 0, j = 0, ni, nj;
  while (i != a.size() && j != b.size())
  {
    if (a[i] == b[j])
      ans += a[i];
    ni = bt[i][j][0], nj = bt[i][j][1];
    i = ni, j = nj;
  }
  cout << ans;
}

Measured memory_bytes: 111880
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul  unsigned long long

#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)

string parse(vector<string> s) {
	// sを、並べ方のパターンを表したstring(例 : "XYYXXY")に分解し返す。
	// X pattern : 
	//	a
	//	a
	// Y pattern : 
	//	aa
	//	bb
	int n = s[0].size();
	string pattern = "";
	for (int i = 0; i < n; i++) {
		if (s[0][i] == s[1][i]) {
			pattern += "X";
		}
		else {
			pattern += "Y";
			i++;
		}
	}

	return pattern;
}

vector<int> numberOfCases(string pattern) {
	// 並べ方のパターンを表したstringを受け取り、各パターンでの色分けの場合の数をvectorに格納して返す
	int n = pattern.length();
	vector<int> cases = vector<int>(n);
	if (pattern[0] == 'X') {
		cases[0] = 3;
	}
	else {
		cases[0] = 6;
	}
	for (int i = 1; i < n; i++) {
		if (pattern[i-1] == 'X') {
			cases[i] = (pattern[i] == 'X') ? 2 : 2;
		}
		else {
			cases[i] = (pattern[i] == 'X') ? 1 : 3;
		}
	}
	return cases;

}
ul product(vector<int> caseNumbers) {
	// caseNumbersに格納された数をすべてかけ合わせる。なお計算結果はmod 1000000007 される
	const ul M = 1000000007;
	int n = caseNumbers.size();
	ul product = caseNumbers[0];
	for (int i = 1; i < n; i++) {
		product *= caseNumbers[i];
		product %= M;
	}
	return product;
}

int main() {
	int n;
	vector<string> s = vector<string>(2);
	cin >> n;
	cin >> s[0];
	cin >> s[1];
	string pattern = parse(s);
	vector<int> caseNumbers = numberOfCases(pattern);
	

	cout << product(caseNumbers);
	return 0;
}





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

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var a = read();

		var s = a.Sum();
		foreach (var d in Divisors(s))
		{
			var m = a.Select(x => x % d).OrderByDescending(x => x).ToArray();
			if (m.Skip(m.Sum() / d).Sum() <= h[1]) { Console.WriteLine(d); return; }
		}
	}

	static IEnumerable<int> Divisors(int v)
	{
		var d = new List<int>();
		for (int i = 1, j, rv = (int)Math.Sqrt(v); i <= rv; i++)
			if (v % i == 0)
			{
				d.Add(i);
				if ((j = v / i) != i) yield return j;
			}
		for (int i = d.Count - 1; i >= 0; i--) yield return d[i];
	}
}


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

int a[110][100], dp[110][100];

int main() {
	for(int i = 0; i < 110; i++) {
		for(int j = 0; j < 100; j++) {
			a[i][j] = dp[i][j] = 0;
		}
	}
	string s;
	int line = 0;
	while(getline(cin, s)) {
		s += ",";
		int j = 0, b = 0;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == ',') {
				a[line][j] = b;
				j++;
				b = 0;
			}
			else {
				b *= 10;
				b += s[i] - '0';
			}
		}
		line++;
	}

	dp[0][1] = a[0][0];
	for(int i = 1; i < line; i++) {
		if(i < line / 2 + 1) {
			for(int j = 1; j < i+1 +1; j++) {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-1]) + a[i][j-1];
			}
		}
		else {
			for(int j = 1; j < line-i+1; j++) {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j+1]) + a[i][j-1];
			}
		}
	}

	int res = 0;
	for(int i = 0; i < 90; i++)
		res = max(dp[line-1][i], res);
	cout << res << endl;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  ll a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a, a+n, greater<ll>());
  ll ans = a[0];
  for(int i=1; i<n-1; i++){
    ans += a[(i+1)/2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5168
package main

import (
        "fmt"
)

func solution(n, a, b int) int {
        if a > b {
                return 0
        }

        if a == b {
                return 1
        }
        l := n - 2
        if l < 0 {
                return 0
        }
        return l*b - l*a + 1
}

func main() {
        var n, a, b int
        fmt.Scan(&n, &a, &b)
        fmt.Println(solution(n, a, b))
}

Measured memory_bytes: 1768
//File Name: A.cpp
  //Author: long
  //Mail: 736726758@qq.com
  //Created Time: 2016年10月24日 星期一 19时16分29秒
                                   
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 105;
char s[MAXN];
int solve(){
	int res = 0;
	int len = strlen(s);
	for(int i=0;i<len;i++){
		if(res == 0 && s[i] == 'C') res = 1;
		else if(res == 1 && s[i] == 'F') res = 2;
	} 
	return res;
}
int main(){
	scanf("%s",s);
	if(solve() == 2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

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

		outer:
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int[] e = new int[3];
			StringTokenizer st = new StringTokenizer(line);
			for (int i = 0; i < e.length; i++) {
				if ((e[i] = Integer.parseInt(st.nextToken())) == 0) {
					break outer;
				}
			}
			Arrays.sort(e);
			int diagonal = (int) (Math.pow(e[0], 2) + Math.pow(e[1], 2));

			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				int radius = Integer.parseInt(br.readLine());
				if (Math.pow(radius * 2, 2) > diagonal) {
					System.out.println("OK");
				} else {
					System.out.println("NA");
				}
			}
		}
	}
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i=0; i<N; i++) cin >> p[i];
  
  double s=0;
  for(int j=0; j<K; j++) s+=(double)(p[j]+1)/2;
  
  double ans=s;
  for(int i=1; i+K<=N; i++){
    double minus=(double)(p[i-1]+1)/2;
    double plus=(double)(p[i+K-1]+1)/2;
    s=s-minus+plus;
    ans=max(s, ans);
  }
  cout << fixed << setprecision(10) <<ans<<endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,ac=0,wa=0,tle=0,re=0; cin>>n;
  for(int i=0;i<n;i++){
    string s; cin>>s;
    if(s=="AC") ac++;
    if(s=="WA") wa++;
    if(s=="TLE") tle++;
    if(s=="RE") re++;
  }
  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 1; i <= N; i += 2) {
    int st = 0;
    for(int j = 1; j <= i; j++) {
      if(i % j == 0) ++st;
    }
    sum += st == 8;
  }
  cout << sum << endl;
}


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

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

constexpr int INF = (1 << 29);

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

	int n, m, w, t;
	cin >> n >> m >> w >> t;

	unordered_map<string, int> converter;
	vector<int> v(m), p(m);

	for(int i = 0; i < m; ++i) {
		string name;
		cin >> name >> v[i] >> p[i];
		converter[name] = i;
	}

	vector<vector<int>> value(n, vector<int>(m, 0));
	vector<int> x(n), y(n);

	for(int i = 0; i < n; ++i) {
		int l;
		cin >> l >> x[i] >> y[i];

		while(l--) {
			string name;
			int q;
			cin >> name >> q;

			const int idx = converter[name];
			chmax(value[i][idx], p[idx] - q);
		}
	}

	const int mask = (1 << n) - 1;
	vector<int> dist(1 << n, INF);
	vector<vector<int>> tsp(n, vector<int>(1 << n, INF));

	for(int i = 0; i < n; ++i) {
		tsp[i][1 << i] = abs(x[i]) + abs(y[i]);
	}

	for(int bit = 1; bit < (1 << n); ++bit) {
		for(int shop = 0; shop < n; ++shop) {
			if(!(bit & (1 << shop))) continue;
			chmin(dist[bit], tsp[shop][bit] + abs(x[shop]) + abs(y[shop]));

			for(int to = 0; to < n; ++to) {
				if(bit & (1 << to)) continue;
				chmin(tsp[to][bit | (1 << to)], tsp[shop][bit] + abs(x[to] - x[shop]) + abs(y[to] - y[shop]));
			}
		}
	}

	vector<long long> dp(t + 1, 0);

	for(int bit = 1; bit < (1 << n); ++bit) {
		vector<int> max_value(w + 1, 0);

		for(int shop = 0; shop < n; ++shop) {
			if(!(bit & (1 << shop))) continue;

			for(int i = 0; i < m; ++i) {
				if(value[shop][i] == 0) continue;

				for(int j = 0; j <= w - v[i]; ++j) {
					chmax(max_value[j + v[i]], max_value[j] + value[shop][i]);
				}
			}
		}

		const int tmp = *max_element(begin(max_value), end(max_value));
		for(int i = 0; i <= t - dist[bit]; ++i) {
			chmax(dp[i + dist[bit]], dp[i] + tmp);
		}
	}

	cout << *max_element(begin(dp), end(dp)) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1360
c00, c01, c02 = [int(x) for x in input().split()]
c10, c11, c12 = [int(x) for x in input().split()]
c20, c21, c22 = [int(x) for x in input().split()]

t1 = c00 + c11 - c01 - c10
t2 = c00 + c12 - c02 - c10
t3 = c00 + c21 - c01 - c20
t4 = c00 + c22 - c02 - c20

if t1 == 0 and t2 == 0 and t3 == 0 and t4 == 0:
    print('Yes')
else:
    print('No')


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

int main(){
    typedef pair<int, int> P;
    
    struct abc{
        int L, R, D;
    };
    
    int n, m;
    cin >> n >> m;
    vector<vector<P>> node(n);
    vector<abc> ans(m);
    
    vector<int> distance(n, 0);
    vector<bool> check(n, true);
    
    int l, r, d;
    for (int i = 0; i < m; i++){
        cin >> l >> r >> d;
        l--;
        r--;
        ans[i] = {l, r, d};
        node[l].push_back({r, d});
        node[r].push_back({l, -d});
    }
    
    for (int i = 0; i < n; i++){
        if (check[i]){
            check[i] = false;
            queue<int> que;
            que.push(i);
            while (que.size() > 0){
                int x = que.front(); que.pop();
                int k = (int)node[x].size();
                for (int i = 0; i < k; i++){
                    int s = node[x][i].first;
                    int t = node[x][i].second;
                    if (check[s]){
                        check[s] = false;
                        que.push(s);
                        distance[s] = distance[x] + t;
                    }
                }
            }
        }
    }
    
    for (int i = 0; i < m; i++){
        l = ans[i].L;
        r = ans[i].R;
        d = ans[i].D;
        if (distance[r] - distance[l] != d){
            cout << "No" << endl;
            exit(0);
        }
    }
    
    cout << "Yes" << endl;
    
}



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


int main() {
  int x;
  cin >> x;
  int a, b, c, d, e, f, g;
  a = x % 100;
  b = a / 5;
  c = a % 5 / 4;
  d = a % 5 % 4 / 3;
  e = a % 5 % 4 % 3 / 2;
  f = a % 5 % 4 % 3 % 2;
  if (105 * b + 104 * c + 103 * d + 102 * e + 101 * f <= x)
    cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
        S = new string[0];
    }

    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}

public class Magatro
{

    public void Scan()
    {
    }

    public void Solve()
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                Console.WriteLine(Anser(i, j));
            }
        }
    }

    private string Anser(int i,int j)
    {
        return string.Format("{0}x{1}={2}", i,j,i*j);
    }

}

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

string s;

int main(){
    cin >> s;
    ll count=0;
    for(ll i=0;i<3;i++){
        if(s[i]=='R') count++;
    }
    if(count==3){
        cout << 3 << endl;
        return  0;
    }
    if(count==0){
        cout << 0 << endl;
        return 0;
    }
    if(count ==1 ){
        cout << 1 << endl;
        return 0;
    }
    if(count==2&&s=="RSR"){
        cout << 1 << endl;
        return 0;
    }
    else{
        cout << 2 << endl;
        return 0;
    }
}  


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(void){
    int n,l;
    cin>>n>>l;
    
    int a[n];
    int i;
    int sum=0;
    int min=101;
    for(i=0; i<n; i++){
        a[i]=l+i;//味を配列に入れる
        //cout<<a[i];
        sum=sum+a[i];
    }
    
    for(i=0; i<n; i++){
        if(a[i]==0){
            cout<<sum;
            goto end;
        }
    }
    if(0<l){
        cout<<sum-a[0];
    }
    else if(l<0){
        cout<<sum-(a[n-1]);
    }
    
    end:
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

int main(){
    ll N,M;
    cin >> N >> M;
    ll c_max = M/2;
    if (N > c_max) {
        cout << c_max << endl;
    }else{
        ll rest = M - 2*N;
        cout << N + rest/4 << endl;
    }

    return 0;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad\n";
    else cout << "Good\n";
    return 0;
}

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

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 6;
string v[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   int n,m,len;
    cin>>n>>m>>len;
    for(int i=0;i<n;i++)cin>>v[i];
    int ans=0;
    for(int r=0;r < (1<<n);++r){
        for(int c=0;c < (1<<m);++c){
            int cnt=0;
            for(int i=0;i<n;++i){
                for(int j=0;j<m;++j){
                    if((r & (1<<i)) || (c & (1<<j)))continue;
                    cnt+=v[i][j]=='#';
                }
            }
            if(cnt==len)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

int main(){
    int N,x; cin >> N >> x;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    long long cnt=0;
    if(a[0]>=x){
        cnt+=a[0]-x;
        a[0]=x;
    }
    for(int i=0;i<N-1;i++){
        //cout << a[i] << endl;
        if(a[i+1]+a[i]>x){
            cnt+=a[i+1]-(x-a[i]);
            a[i+1]=x-a[i];
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 200000;

int main(){
  int x, y, sum = 0;
  cin >> x >> y;
  rep(i, 2){
    if(x > y){
      sum += x;
      x--;
    }else{
      sum += y;
      y--;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  char a[3];
  cin >> a;
  for(int i=0;i<3;i++){
    if(a[i]=='7'){
      cout << "Yes"<< endl;
      return 0;
    }
  }
  cout << "No" <<endl;
  return 0;
}

Measured memory_bytes: 3544
#include <stdio.h>
int main(void) {
    int a[200000];
    int n, k;
    int ans=0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i <n ; ++i) {
        scanf("%d", &a[i]);
        if(a[i] >= k ){
            ans++;
        }
        }
    printf("%d", ans);
}

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

int main(void){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        for(int i=0;i<k;++i){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}



Measured memory_bytes: 3576
#include <stdio.h>

int gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}

int main()
{
    int k;
    scanf("%d",&k);

    int a,b,c;
    long long ans = 0;
    for (a = 1; a <= k; a++)
    {
        for (b = 1; b <= k; b++)
        {
            for (c = 1; c <= k; c++)
            {
                ans += gcd(gcd(a,b),c);
            }
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1732
n, k = map(int, input().split())
cnt = 0
l = n//k
for i in range(k):
    if (i*3)%k == i%k:
        if i==0:
            cnt +=l**3
        elif i%k <= n%k:
            cnt += (l+1)**3
        else:
            cnt += l**3
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    string S,T;
    cin >>S>>T;
    
    cout << T <<S<< endl;


    return 0;
    

}

Measured memory_bytes: 3572
n,*l=map(int,open(0).read().split())
from heapq import *
l.sort()
q=[-l.pop()]
a=0
for _ in range(n-1):
  m=heappop(q)
  a-=m
  t=-l.pop()
  heappush(q,t)
  heappush(q,t)
print(a)

Measured memory_bytes: 31468
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


template<typename T>
class BIT{
    public:
        vector<T> x_list;
        ll n;

        BIT(ll n=1, T fill_value=0): n(n){
            x_list.resize(n+1);
            fill(x_list.begin(), x_list.end(), fill_value);
        }

        void add(ll idx, T v){
            for(ll x=idx; x<= n;x += (x & -x)){
                x_list[x] += v;
            }
        }

        ll get_sum(ll idx){
            T v = 0;
            for(ll x=idx;x>0;x-=(x & -x)){
                v += x_list[x];
            }
            return v;
        }
};

void Main(){
    ll N, Q, c, l, r;
    cin >> N >> Q;
    vector<ll> as(N);
    vector<ll> cs(N, -1);
    vector<vector<ll>> ps(N);
    vector<vector<pll>> qs(N);
    rep(i, N){
        sll(c);
        -- c;
        l = cs[c];
        if(l != -1){
            ps[l].emplace_back(i);
        }
        as[i] = c;
        cs[c] = i;
    }

    rep(i, Q){
        sll(l);
        sll(r);
        -- l;
        -- r;
        qs[l].emplace_back(r,i);
    }

    BIT<ll> bit(N);

    vector<ll> ans(Q);
    for(ll i=N-1;i>=0;--i){
        for(auto p:ps[i]){
            bit.add(p, 1);
        }
        for(auto q:qs[i]){
            ans[q.second] = (q.first-i+1) - bit.get_sum(q.first);
        }
    }

    rep(i, Q){
        cout << ans[i] <<endl;
    }

}

int main(){
    Main();
}

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

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

using namespace std;

// input
vector<int> S, T;

int main()
{
    // input, S is ascending
    int n, q;
    cin >> n;
    while (n--)
    {
        int a;
        cin >> a;
        S.push_back(a);
    }
    cin >> q;
    while (q--)
    {
        int a;
        cin >> a;
        T.push_back(a);
    }

    // binary search
    int C = 0;
    r(i, T.size())
    {
        if (binary_search(S.begin(), S.end(), T[i]))
            C++;
    }

    cout << C << endl;
}


Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=max(a,c);
  int y=min(b,d);
  //cout<<x<<" "<<y<<endl;
  int ans=y-x;
  if(ans<0)ans=0;
  cout<<ans<<endl;
 
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a[3];
    rep(i,3){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]*a[1]/2<<endl;

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

int main(void){
  char input[1000];
  fgets(input,1000,stdin);
  
  
  int data[100]={0};
  int stack_size=0,num_flag = 0;
  
  for(int i=0;i<strlen(input);++i){
    if('0' <= input[i] && input[i] <='9'){
      if(num_flag == 0){
        data[stack_size] = input[i]-48; 
        stack_size++;
        num_flag=1;
      }else{
        data[stack_size-1]*=10;
        data[stack_size-1]+=input[i]-48;
      }
    }else if(input[i] == '+'){
      data[stack_size-2] = data[stack_size-2]+data[stack_size-1];
      stack_size--;
    }else if(input[i] == '-'){
      data[stack_size-2] = data[stack_size-2]-data[stack_size-1];
      stack_size--;
    }else if(input[i] == '*'){
      data[stack_size-2] = data[stack_size-2]*data[stack_size-1];
      stack_size--;
    }else{
      num_flag = 0; 
    }
    
  }
  
  printf("%d\n",data[0]);
  
  return 0;
}

Measured memory_bytes: 3184
w = gets.chomp.to_i
n = gets.chomp.to_i
ary_swap = Array.new
n.times { ary_swap << gets.chomp.split(",").map(&:to_i) }

answer = Array.new

(1..w).each do |i|
  present_position = i
  ary_swap.each do |ary_swap_temp|
    next unless ary_swap_temp.include?(present_position)
    present_position = ary_swap_temp[1 - ary_swap_temp.index(present_position)]
  end
  answer[present_position - 1] = i
end

print answer.join("\n")
print "\n"

Measured memory_bytes: 6112
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		sc.close();

		Map<Long, Integer> map = new TreeMap<Long, Integer>();

		for (long x = 1; x <= 100; x++) {
			for (long y = 1; y <= 100; y++) {
				for (long z = 1; z <= 100; z++) {
					long num = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
					if (map.containsKey(num)) {
						map.put(num, map.get(num) + 1);
					} else {
						map.put(num, 1);
					}
				}
			}
		}

		for (long i = 1; i <= N; i++) {
			if (map.containsKey(i)) {
				System.out.println(map.get(i));
			} else {
				System.out.println(0);
			}
		}
	}
}


Measured memory_bytes: 61540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long h = long.Parse(Console.ReadLine());

			long tmp = 1;

			while (h >= tmp)
			{
				tmp = tmp * 2;
			}


			Console.WriteLine(tmp - 1);
		}

	}

}


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

using namespace std;
#define ll long long int


int main()
{
   ll t;
   t = 1;	
//    cin t;
   while(t--){
        ll n;
        cin >> n;
        ll ans = 0;
        for(int i = 1; i <=n ; i ++)
        {
            ll x = n / i;
            ans += (i + i * x) * x / 2;
        }

        cout << ans << endl;   
   }
}


Measured memory_bytes: 3584
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int k,z;
		do {
			k = stdIn.nextInt();
			z = stdIn.nextInt();
		}while(k<1||k>100||z<1||z>100000);
		if(500*k>=z) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N string
	fmt.Scan(&N)
	result := "No"

	for _, v := range strings.Split(N, "") {
		if v == "7" {
			result = "Yes"
		}
	}

	fmt.Println(result)
}

Measured memory_bytes: 1820
/*
Author: miitbh1
*/
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;
const int N=100001;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cout<<fixed<<setprecision(10);
    string a, b, tmp="";
    cin>>a>>b;
    int n=a.length();
    bool flag=true;
    rep(i, n-1){
        if(a[i]!=b[i]){
            flag=false;
            break;
        }
    }
    if(n==1){
        if(a[0]!=b[0])
            flag=false;
    }
    if(flag)p("Yes");
    else p("No");
    return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumberString = Arrays.asList(br.readLine().split(" "));
            int A = Integer.parseInt(inputNumberString.get(0));
            int B = Integer.parseInt(inputNumberString.get(1));

            List<String> postNumber = Arrays.asList(br.readLine().split("-"));

            if (postNumber.size() != 2) {
                System.out.println("No");
                return;
            }

            if (postNumber.get(0).length() != A) {
                System.out.println("No");
                return;
            }

            if (postNumber.get(1).length() != B) {
                System.out.println("No");
                return;
            }

            System.out.println("Yes");
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 23124
n, m, q = map(int, input().split())
L = []
for i in range(q):
    a,b,c,d = map(int, input().split())
    a -= 1
    b -= 1
    L.append((d, c, a, b))

import itertools
ans = -1
for p in itertools.combinations_with_replacement(range(1, m+1), n):
    #print(p)
    temp = 0
    for d, c, a, b in L:
        if p[b]-p[a] == c:
            temp += d
    ans = max(ans, temp)
print(ans)


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

using namespace std;

int main() {
  string s;
  cin >> s;
  for( int i = 0; i < 3; i++ ) {
    if ( s[i] == '1' )
      s[i] = '9';
    else
      s[i] = '1';
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;


int main() {
	int A,B;
	cin>>A>>B;
	if(A<=8&&B<=8)cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	ll ans = n / (a + b) * a;
	ans += min(a, n - n / (a + b) * (a + b));
	printf("%lld\n", ans);

	Please AC;
}


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

const int Maxn = 100005;

int n;
int a[Maxn], res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int cur = 1;
    for (int i = n - 2; i >= 0; i--) {
        cur = a[i] >= a[i + 1]? cur + 1: 1;
        res = max(res, cur - 1);
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 640
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans = 0

if N == K:
    start,end = x[0],x[-1]
    if end <= 0:
        ans = abs(start)
    elif start <= 0:
        ans = 2*min(abs(start), end)+max(abs(start), end)
    else:
        ans = end

else:
    ans = 10**9
    for i in range(N-K+1):
        start,end = x[i],x[i+K-1]
        if end <= 0:
            ans = min(ans, abs(start)) 
        elif start <= 0:
            ans = min(ans, 2*min(abs(start), end)+max(abs(start), end))
        else:
            ans = min(ans, end)

print(ans)


Measured memory_bytes: 14568
#include <stdio.h>
#include <inttypes.h>

#define INF UINT64_C(1111111111111111111)
#define LIMIT UINT64_C(1000000000000000000)

uint64_t add(uint64_t a, uint64_t b) {
	uint64_t x = a + b;
	return x > INF ? INF : x;
}

uint64_t mul(uint64_t a, uint64_t b) {
	uint64_t r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int main(void) {
	int N, i;
	uint64_t answer = 1;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		uint64_t A;
		if (scanf("%" SCNu64, &A) != 1) return 1;
		answer = mul(answer, A);
	}
	if (answer > LIMIT) puts("-1"); else printf("%" PRIu64 "\n", answer);
	return 0;
}


Measured memory_bytes: 1732
import math

N, M = map(int, input().split())
AS = list(map(int, input().split()))

cond = sum(AS) / (4 * M)
AS = sorted(AS, reverse=True)

origin = AS[0:M]
result = list(filter(lambda a: a >= cond, origin))

if origin == result:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
A,B,C,D,E,F = map(int,input().split())
mxc = 0
ans = (min(100*A,100*B),0)
for i in range(31):
    for j in range(31):
        for k in range(101):
            for l in range(101):
                w = 100*A*i + 100*B*j
                s = C*k + D*l
                if s > E*w/100 or w+s > F or w == 0:
                    break
                if 100*s/(s+w) > mxc:
                    mxc = 100*s/(s+w)
                    ans = (s+w,s)
print(" ".join(map(str,ans)))

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  char a[20];
  char * str = a;
  char b[20];
  int i;
  int count = 0;

  scanf("%s",a);

  while(*str != '\0')
    {

     str++;
     count++;
    }
   for(i=0;i<count;i++)
    {
    str--;
    b[i] = *str;

    }

    for(i=0;i<count;i++)
    {
    printf("%c",b[i]);


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

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int n;
long long f[87];
int main()
{
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n;i++)
        f[i]=f[i-1]+f[i-2];
    cout<<f[n];
}

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

typedef long long ll;
const int inf = 1000000000; // 10^9

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

  ll N,A,B,cnt=0,p=0;
  cin>>N>>A>>B;

  char s[N];
  cin>>s;

  for(int i=0; i<N; i++) {
    if(s[i]=='c') {
      cout<<"No"<<'\n';
    }
    else if(s[i]=='a') {
      if(cnt<(A+B)) {
        cnt++;
        cout<<"Yes" << '\n';
      }
      else {
        cout<<"No" << '\n';
      }
    }
    else if(s[i]=='b') {
      if(cnt<A+B && p+1<=B) {
        cnt++;
        p++;  
        cout<<"Yes"<<'\n';
      }
      else {
        cout<<"No"<<'\n';
      }
    }
  }

  return 0;
}



Measured memory_bytes: 3696
import sys
sys.setrecursionlimit(10000000)

V, M = map(int,input().split())
L = [[] for _ in range(V+1)]
DP = [-1 for _ in range (V + 2)]
for _ in range(M):
    x,y = map(int,input().split())
    L[x-1].append(y-1)

def rec(v):
    if DP[v] != -1: return DP[v]
    ret = 0
    for x in L[v]:
        ret = max(ret,rec(x)+1)
    DP[v] = ret
    return DP[v]
ans = 0
for i in range(V):
    ans = max(ans, rec(i))
print(ans)


Measured memory_bytes: 59056
#include<cstdio> 
#include<algorithm>
#include<cstring>
using namespace std;
struct Edge
{
	int to;
	int nxt;
}e[4005];
int n,m,edgenum,head[2005],pa[2005],dep[2005],a[4005],b[4005],tot;
int d[2005],c[2005],f[2005];
bool flag[2005],used[4005];
void add(int u,int v)
{
	e[++edgenum].to=v;
	e[edgenum].nxt=head[u];
	head[u]=edgenum;
}
void dfs(int node)
{
	dep[node]=dep[pa[node]]+1;
	for(int hd=head[node];hd;hd=e[hd].nxt)
	{
		int to=e[hd].to;
		if(to==pa[node])continue;
		pa[to]=node;
		dfs(to);
	}
}
void solve()
{
	int u=0;
	for(int i=1;i<=n;i++)
	{
		if(flag[i])continue;
		if(d[i]==1)
		{
			u=i;
			break;
		}
	}
	if(u==0)return;
	if(c[u]==0)
	{
		for(int hd=head[u];hd;hd=e[hd].nxt)
		{
			int to=e[hd].to;
			if(flag[to])continue;
			d[to]--;
		}
		flag[u]=1;
		solve();
		return;
	}
	if(c[u]==1)
	{
		for(int hd=head[u];hd;hd=e[hd].nxt)
		{
			int to=e[hd].to;
			if(flag[to])continue;
			d[to]--;
		}
		flag[u]=1;
		for(int i=1;i<=tot;i++)
		{
			if(used[i])continue;
			if(b[i]==u)swap(a[i],b[i]);
			if(a[i]!=u)continue;
			int v=0;
			for(int hd=head[u];hd;hd=e[hd].nxt)
			{
				int to=e[hd].to;
				if(!flag[to])
				{
					v=to;
					break;
				}
			}
			if(b[i]!=v)
			{
				a[i]=v;
				c[u]--,c[v]++;
				solve();
				if(a[i]==v)a[i]=u;
				else b[i]=u;
			}
			else
			{
				c[u]--,c[v]--;
				used[i]=1;
				solve();
			}
			return;
		}
	}
	int x=0,y=0;
	for(int i=1;i<=tot;i++)
	{
		if(used[i])continue;
		if(b[i]==u)swap(a[i],b[i]);
		if(a[i]!=u)continue;
		if(!x)x=i;
		else if(!y)y=i;
		else break;
	}
	used[x]=used[y]=1;
	if(b[x]==b[y])
	{
		swap(a[y],b[y]);
		c[u]-=2;
		c[a[y]]--,c[b[x]]--;
		solve();
	}
	else
	{
		int now=++tot;
		a[now]=b[x];
		b[now]=b[y];
		c[u]-=2;
		solve();
		if(a[now]==b[x])swap(a[x],b[x]);
		else swap(a[y],b[y]);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
		d[u]++,d[v]++;
	}
	dfs(1);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		if(dep[a[i]]<dep[b[i]])swap(a[i],b[i]);
		int u=a[i],v=b[i];
		while(dep[u]>dep[v])
		{
			f[u]++;
			u=pa[u];
		}
		while(u!=v)
		{
			f[u]++,f[v]++;
			u=pa[u],v=pa[v];
		}
		c[a[i]]++,c[b[i]]++;
	}
	tot=m;
	solve();
	tot=0;
	for(int i=1;i<=n;i++)tot+=min(2,f[i]);
	printf("%d\n",tot);
	for(int i=1;i<=m;i++)printf("%d %d\n",a[i],b[i]);
	return 0;
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())


//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	LL prev, now;

	cin >> prev;

	vector<LL> sukima;
	for (int i = 1; i < n; i++) {
		cin >> now;

		LL diff = now - (prev + 1);

		prev = now;

		sukima.push_back(diff);
	}

	sort(sukima.begin(), sukima.end());

	LL ans = n;

	LL x = n - k;

	for (int i = 0; i < x; i++) {
		ans += sukima[i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3896
import math

math.gcd(2,10)
N =int(input())
total = 0
a=1
b=1
c=1
while a <=N:
	b=1
	while b <=N:
		c=1
		while c <=N:
			if math.gcd(a,b)==1:
				total += N
				break
			total += math.gcd(a,math.gcd(b,c))
			c+=1
		b+=1 
	a+=1
print(total)


Measured memory_bytes: 9104
#include<stdio.h>


int main(void) {
	int n, m, i,count=0;
	int h[100000], a[100000], b[100000], max[100000] = {};
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%d %d\n", &a[i], &b[i]);
		if (max[a[i]-1] < h[b[i]-1]) max[a[i]-1] = h[b[i]-1];
		if (max[b[i]-1] < h[a[i]-1]) max[b[i]-1] = h[a[i]-1];
	}
	for (i = 0; i < n; i++) {
		if (max[i] < h[i]) count++;
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>

void f(char s[]) {
  int i;
  for (i = 0; i < 5; i++) printf("%c", s[i]);
  printf(" ");
  for (i = 6; i < 13; i++) printf("%c", s[i]);
  printf(" ");
  for (i = 14; i < 19; i++) printf("%c", s[i]);
  printf("\n");
}

int main(void) {
  char s[19];
  scanf("%s", s);
  f(s);
  return 0;
}

Measured memory_bytes: 128
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

arr = seachPrimeNum(10**5 + 99999)
x = int(input())

for i in range(len(arr)):
    if arr[i] >= x:
        print(arr[i])
        break


Measured memory_bytes: 21412
//abc143_c.cpp
//Sun Oct 20 15:20:27 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	int ans = s.length();
	for (int i=0;i<n-1;i++){
		if (s[i]==s[i+1]){
			ans--;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B == C || B + C == A || C + A == B)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int num,s,ms;
	cin>>num;
	int seq[100000][2]={0};
	int fir[4][2]={0};
	for(int i=0;i<num;i++){
		cin>>s;
		seq[s][i%2]++;
	}
	for(int i=0;i<100000;i++){
		if(fir[1][0]<=seq[i][0]){
			fir[2][0]=fir[1][0];
			fir[3][0]=fir[0][0];
			fir[1][0]=seq[i][0];
			fir[0][0]=i+1;
		}
		else if(fir[2][0]<=seq[i][0]){
			fir[2][0]=seq[i][0];
			fir[3][0]=i+1;
		}
	}
	for(int i=0;i<100000;i++){
		if(fir[1][1]<=seq[i][1]){
			fir[2][1]=fir[1][1];
			fir[3][1]=fir[0][1];
			fir[1][1]=seq[i][1];
			fir[0][1]=i+1;
		}
		else if(fir[2][1]<=seq[i][1]){
			fir[2][1]=seq[i][1];
			fir[3][1]=i+1;
		}
	}
	if(fir[0][0]!=fir[0][1]){
		cout<<num-fir[1][0]-fir[1][1];
		return 0;
	}
	cout<<min(num-fir[1][0]-fir[2][1],num-fir[2][0]-fir[1][1]);
	return 0;
}

Measured memory_bytes: 1024
import numpy as np
x1, y1, x2, y2 = map(int, input().split())

R = np.array([[0,-1],[1,0]])

r1 = np.array([x2-x1, y2-y1])
r2 = np.dot(R, r1)
x3, y3 = r2 + np.array([x2, y2])
r3 = np.dot(R, r2)
x4, y4 = r3 + np.array([x3, y3])

print(x3, y3, x4, y4)

Measured memory_bytes: 21656