akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

//CODE FESTIVAL 2016 Grand Final(Parallel)C

int main(void) {
    int n;
    cin >> n;
    vei a(n);
    rep(i,n) cin >> a[i];
 
    int x = 0;
    rep(i,n) x ^= a[i]; //XOR == 0: first:lose

 
    int ans = 0;
    for(int i = 35; i >= 0; i--) if(x & (1 << i)){
        rep(j,n){
            int t = a[j] ^ (a[j] - 1); //j+1番目(1-index)の山から取ったとき変えられるXOR
            if( t + 1 == ( 1 << (i + 1) ) ){
                x ^= t;
                ans++;
                break;
            }
        }
    }
    if(x == 0) cout << ans << endl;
    else cout << -1 << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0){
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin>>n>>s;
  vector<int>b(n+1),w(n+1);
  rep(i,n)
  {
    b[i+1]=b[i]+(s[i]=='#');
    w[i+1]=w[i]+(s[i]=='.');
  }
  int res=0;
  rep(i,n+1)
  {
    chmax(res,w[i]+b[n]-b[i]);
  }
  cout<<n-res<<endl;
  return 0;

}


Measured memory_bytes: 2196
#include<stdio.h>
void main(void)
{
  int n,i,a,b;
  long int total;
  total=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
  a=i%3;
  b=i%5;  
  if(a!=0&&b!=0)
  {
  total=total+i;
  }
  }
  printf("%ld",total);
}

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

using namespace std;
#define int long long
using ld = long double;
#define mod 1000000007
void dfs(vector<int> tree[], int v, int p, int dp[][2])
{
    dp[v][0] = dp[v][1] = 1;
    for(auto j : tree[v])
        if(j != p)
            dfs(tree, j, v, dp), dp[v][0] = dp[v][0]*(dp[j][0] + dp[j][1])%mod, dp[v][1] = dp[v][1]*dp[j][0]%mod;
}
signed main() {
    int n;
    cin >> n;
    vector<int> tree[n+1];
    int i;
    for(i=1;i<n;i++)
    {
        int x, y;
        cin >> x >> y;
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    int dp[n+1][2];
    for(i=1;i<=n;i++)
        dp[i][0] = dp[i][1] = 0;
    dfs(tree, 1, 0, dp);
    cout << (dp[1][0] + dp[1][1])%mod;
}


Measured memory_bytes: 17468
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        hitachi solver = new hitachi();
        solver.solve(1, in, out);
        out.close();
    }

    static class hitachi {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] str = in.next().toCharArray();
            int cnt = 0;
            for (int i = 0; i < str.length - 1; i++) {
                if (str[i] == 'h' && str[i + 1] == 'i') {
                    cnt++;
                }
            }
            if (cnt * 2 == str.length) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 32696
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    if(((b-a)>=k)||((b-a<k)&&(b%k)-(a%k)<0)||(a%k)==0||(b%k)==0)
    cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  return 0;
    }

Measured memory_bytes: 3596
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, x, m = map(int, input().split())
x_set = set()
x_list = []
for i in range(n):
    if x not in x_set:
        x_set.add(x)
        x_list.append(x)
    else:
        break
    x = x**2 % m
total = 0
start = n
for i in range(n):
    if x_list[i] == x:
        start = i
        break
    else:
        total += x_list[i]
if start != n:
    m = len(x_list) - start
    k = (n - start) // m
    total += k * sum(x_list[start:])
    for i in range(0, n - k * m - start):
        total += x_list[start + i]
print(total)

Measured memory_bytes: 13136
#include <iostream>
#include <utility>
#include <string>

auto gcd(const int x, const int y) {
    if (y == 0) {
        return x;
    }    
    return gcd(y, x % y);
}

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

    std::string buf;
    getline(std::cin, buf);

    const auto space = buf.find(" ");
    const auto x = std::stoi(buf.substr(0, space));
    const auto y = std::stoi(buf.substr(space + 1, buf.size()));
    const auto ret = gcd(x > y ? x : y, x > y ? y : x);
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  string s;
  string acgt = "ACGT";
  cin >> s;
  int max = 0;
  rep (i, s.size()) {
    if (acgt.find(s[i]) != string::npos) {
      int cnt = 1;
      for (int j = i + 1; j < s.size(); ++j) {
        if (acgt.find(s[j]) != string::npos) cnt++;
        else break;
      }
      if (max < cnt) max = cnt;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
l = [int(i) for i in input().split()]
d = l[0]
n = l[1]

if d == 0:
	if n != 100:
		print(n)
	else:
		print(n+1)
else:
	if n != 100:
		print((100**d)*n)
	else:
		print((100**d)*(n+1))

Measured memory_bytes: 3060
/*
 * ARC098_D.cpp
 *
 *  Created on: May 26, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

void quickSort(int l, int r, int* a, int* b) {
	if(l >= r) return;
	int piv = a[r];
	int i = l - 1;
	for(int j=l; j<r; j++) {
		if(a[j] <= piv) {
			i++;
			swap(a[i], a[j]);
			swap(b[i], b[j]);
		}
	}
	swap(a[i+1], a[r]);
	swap(b[i+1], b[r]);
	quickSort(l, i, a, b);
	quickSort(i+2, r, a, b);
}

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

	int N, K, Q;
	int a[2000];
	int order[2000];

	int xxx[2000];

	cin >> N >> K >> Q;
	REP(i, N) {
		cin >> a[i];
		xxx[i] = a[i];
		order[i] = i;
	}

	quickSort(0, N-1, xxx, order);

	int ans = 1<<30;
	REP(minX, N) {
		vector<int> split;
		REP(i, N) {
			if(a[i] < a[order[minX]]) {
				split.pb(i);
			}
		}
		split.pb(N);
		//↑列分割完成
		vector<int> seqMin;
		int spSz = SZ(split);
		int left = 0;
		REP(i, spSz) {
			vector<int> part;
			FOR(j, left, split[i]-1) {
				part.pb(a[j]);
			}
			sort(ALL(part));
			for(int j=0; j<split[i]-left-K+1; j++) {
				seqMin.pb(part[j]);
			}
			left = split[i]+1;
		}
		if(SZ(seqMin) >= Q) {
			sort(ALL(seqMin));
			ans = min(ans, seqMin[Q-1] - seqMin[0]);
		}
	}

	cout << ans << endl;
}






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

int main(){
  int N;
  cin >> N;
bool can = true;
int t, x, y;
t = x = y = 0;
for (int i = 1; i <= N; i++){
int ti, xi, yi;
cin >> ti >> xi >> yi;
int di = (ti - t) - abs(xi - x) - abs(yi - y);
if ((di < 0) || (di & 1 == 1)){
  can = false;
  break;
  }
}
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int a,b;
  string A,B;
  cin >> a >> b;
  for(int i=0; i<b; i++) A += to_string(a);
  for(int i=0; i<a; i++) B += to_string(b);
  if(A<=B) cout << A << endl;
  else cout << B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long double ld;
typedef long long ll;
const int inf = 1e9 + 1;
using namespace std;
int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cout << setprecision(20);
    int x;
    cin>>x;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(x == i*j){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    //    int n;
//    ll k;
//    cin >> n >> k;
//    vector<ll> a(n);
//    for (int i = 0; i < n; i++) {
//        cin >> a[i];
//    }
//    vector<ll> b(n);
//    for (int j = 0; j < n; j++) {
//        cin >> b[j];
//    }
//    sort(a.begin(), a.end());
//    sort(b.begin(), b.end());
//    ll ans = 0;
//
////    for (int i = 0; i < n; i++) {
////        cout << a[i] << " ";
////    }
////    cout << endl;
////    for (int j = 0; j < n; j++) {
////        cout << b[j] << " ";
////    }
////    cout << endl;
//    set<pair<ll,int>> x;
//    for (int i = 0; i < n; i++) {
//        if (k >= a[i]) {
//            k -= a[i];
//        } else {
//            ans += (a[i] - k) * b[n - 1 - i];
//            k = 0;
//        }
//        cout << ans << " ";
//    }
//    cout << ans;
    return 0;
}


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

int main(void){
	long long N,K;
	cin >> N >> K;
	vector<long long>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	long long res = 0;
	
	for(int d=60;d>=-1;--d){//d= -1 はx=Kの場合
		if(d != -1 && !(K>>d &1))continue;
		long long tmp = 0;
		for(int e = 60;e>=0;--e){
			long long mask = 1LL<<e;
			long long num = 0;
			for(int i=0;i<N;i++)if(A[i]&mask)++num;
			
			if(e>d){
				if(K&mask)tmp += mask*(N-num);
				else tmp += mask*num;
			}
			else if(e==d){
				tmp += mask*num;
			}
			else{
				tmp += mask*max(num,N-num);
			}
		}
		res = max(res,tmp);
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator 
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

int main() {
    int a,b,c;
    qr(a); qr(b); qr(c);
    pr2(max(0,c-(a-b)));return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++) {
        int cost1 = abs(h[i] - h[i - 1]);
        int cost2 = abs(h[i] - h[i - 2]);
        dp[i] = min(dp[i - 1] + cost1, dp[i - 2] + cost2);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

long long knapsackRecursive(vector<vector<long long>> &dp, vector<int> &profits,
                        vector<int> &weights, int capacity, int currentIndex) {
    // base checks
    if (capacity <= 0 || currentIndex >= profits.size()) {
      return 0;
    }

    // if we have already solved a similar problem, return the result from memory
    if (dp[currentIndex][capacity] != -1) {
      return dp[currentIndex][capacity];
    }

    // recursive call after choosing the element at the currentIndex
    // if the weight of the element at currentIndex exceeds the capacity, we shouldn't process this
    long long  profit1 = 0;
    if (weights[currentIndex] <= capacity) {
      profit1 = profits[currentIndex] + knapsackRecursive(dp, profits, weights,
                                                          capacity - weights[currentIndex],
                                                          currentIndex + 1);
    }

    // recursive call after excluding the element at the currentIndex
    long long  profit2 = knapsackRecursive(dp, profits, weights, capacity, currentIndex + 1);

    dp[currentIndex][capacity] = max(profit1, profit2);
    return dp[currentIndex][capacity];
  }

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 vector<vector<long long>> memo(N, vector<long long>(W+1, -1));
  long long res = knapsackRecursive(memo, v, w, W, 0);
  cout << res << endl; 
  
}
  


Measured memory_bytes: 79488
N = int(input())

n = 55555

prime = []
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, n + 1):
    if is_prime[i]:
        if i % 5 == 1:
            prime.append(i)

        for j in range(2 * i, n + 1, i):
            is_prime[j] = False

print(*prime[:N])


Measured memory_bytes: 40432
#include <bits/stdc++.h>
#define N 105
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n;
double res=0;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
   // freopen(task".inp","r",stdin);
   // freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n;
    for (int i=1;i<=n;i++) {
        double x;
        cin>>x;
        res+=(double) 1/x;
    }
    res=(double) 1/res;
    cout<<res;
    return 0;
}


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

int main(){
  
  int n,k,q;
  cin >> n >> k >> q;
  
  vector<int> players(n,k-q);
  
  for(int i=0; i<q; i++){
    int a;
    cin >> a;
    players.at(a-1) ++;
  }
  
  for(int i=0; i<n; i++){
    if(players.at(i) > 0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
inline void dump(){cout<<endl;}
template<class Head,class... Tail>inline void dump(Head&& head, Tail&&... tail){cout<<head<<", ";dump(forward<Tail>(tail)...);}
template<typename T>inline istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

main(){

  int n,y;
  cin>>n>>y;

  for(int a=0;a<=n;++a){
    for(int b=0;a+b<=n;++b){
      int c = n-a-b;
      if(c>=0){
        if(10000*a+5000*b+1000*c==y){
          cout<<a<<" "<<b<<" "<<c<<endl;return 0;
        }
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;

}

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

cnt = 0
i = 1
while i < n-1:
    if p[i] != max(p[i-1], p[i], p[i+1]) and p[i] != min(p[i-1], p[i], p[i+1]):
        cnt += 1
    i += 1

print(cnt)


Measured memory_bytes: 3060
import java.util.*;

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

    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    char[] c = line.toCharArray();
    int count = 0;
    for(int i = 0; i < c.length-1; i++) {
      if(c[i] != c[i+1]){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 26300
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        int x,t=1;
        Scanner sc = new Scanner(System.in);
        while(true){
            x=sc.nextInt();
            if(x == 0) break;
            System.out.println("Case "+ t++ +": "+x);
        }
    }
}


Measured memory_bytes: 42516
#include<iostream>
using namespace std;
#include<queue>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
bool b[2003];

#define REP(a) for(int i=0;i<a;i++)

int main()
{
	bool f=0;
	int x,m,n,j;
	int prev[2002],next[2002],p,v=1;
	string c,d;
	cin>>m>>n;
	while(m!=0||n!=0){
		x=m;
		REP(m){
			next[i]=(i+1)%m;
			prev[i]=(i+m-1)%m;
		}
		p=0;
		REP(n){
			cin>>c;
			if(f==0){
				if(c!="Fizz"&&(i+1)%3==0&&(i+1)%5!=0){
					v=0;
					m--;
				}
				else if(c!="Buzz"&&(i+1)%3!=0&&(i+1)%5==0){
					v=0;
					m--;
				}
				else if(c!="FizzBuzz"&&(i+1)%3==0&&(i+1)%5==0){
					v=0;
					m--;
				}
				else if(atoi(c.c_str())!=i+1&&(i+1)%3!=0&&(i+1)%5!=0){ 
					v=0;
					m--;
					//	cout<<'A';
				}

			}
			if(v==0) {
				prev[next[p]]=prev[p];
				next[prev[p]]=next[p];
				prev[p]=-1;
				v=1;
				
			}
			p=next[p];
			if(m==1) f=1;
		}
		REP(x){
		if(prev[i]!=-1){
		cout<<i+1;
		p=i;
		break;
		}
		}
		for(v=p+1;v<x;v++){
		if(prev[v]!=-1) cout<<" "<<v+1;
		}
		cout<<endl;
		cin>>m>>n;
		f=0;
		j=1;
	}
	return 0;
}

Measured memory_bytes: 1236
from collections import deque

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

ans = [-1 for _ in range(n)]
d = deque()
d.append(0)
while len(d) > 0:
    now = d.popleft()
    for v in to[now]:
        if ans[v] > -1:
            continue
        ans[v] = now
        d.append(v)

print("Yes")
for i in range(1, len(ans)):
    print(ans[i]+1)

Measured memory_bytes: 34208
#pragma region Imports
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#pragma endregion
#pragma region Macros
#pragma GCC optimize (2)
#define uns unsigned
#define out cout
#define in cin
#define au auto
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define elif else if
#define sz(x) x.size()
#define fl(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define fli(i, a, b, c) for(int (i)=a;(i)<(b);(i)+=(c))
#define fr(i, x) for(int (i)=(x)-1;(i)>=0;(i)--)
#define fb(i, x) for(int (i)=0;(i)<(x);(i)++)
#define fa(i, x) for(auto& (i):(x))
#define ia(a, n) for(int qw=0;qw<(n);qw++)cin>>(a)[qw];
#define oa(a, n) for(int qw=0;qw<(n);qw++)cout<<(a)[qw]<<" ";
#define im(a, n, m) fb(i,(n))fb(j,(m))cin>>(a)[i][j];
#define om(a, n, m) fb(i,(n))fb(j,(m))cout<<(a)[i][j]<<" \n"[j==(m)-1];
#define eb(v, x) (v).emplace_back(x);
#define seb(s, x) (s).emplace(x);
#define pr(x, y) pair<x,y>
#define vr(x) vector<x>
#define mp(x, y) make_pair(x,y)
#define hm(x, y) map<x,y>
#define um(x, y) unordered_map<x,y>
#define stk(x) stack<x>
#define qu(x) queue<x>
#define dq(x) deque<x>
#define pq(x) priority_queue<x>
#define pqm(x) priority_queue<x,vector<x>,greater<(x)>>
#define mem(a, x) memset(a,(x),sizeof(a));
#define fi(x) (x).first
#define se(x) (x).second
#define ql(x) int tc;tc=(x);if(tc==-1)cin>>tc;while(tc--)
#define srt(x) sort((x).begin(),(x).end());
#define pops(y, x) auto (y)=(x).front();(x).pop();
#define ppc(x) __builtin_popcount((x))
#define all(x) (x).begin(),(x).end()
#define sieve(b, n) bool (b)[(n)];mem((b),true);int sq=int(sqrt(n))+1;(b)[0]=(b)[1]=false;fl(i,2,sq)if((b)[i])fli(j,i*i,n,i)(b)[j]=false;
#define dbg(x) cout<<#x<<" "<<(x)<<"\n";
#pragma endregion
#pragma region Typedefs and Consts
typedef long long int ll;
typedef unsigned long long int ull;
typedef string stg;
typedef float flo;
typedef char chr;
typedef vector<int> vi;
const ull mod = 1000000007;
const int imx = INT_MAX;
const int imn = INT_MIN;
const ll lmx = LLONG_MAX;
const ll lmn = LLONG_MIN;
#pragma endregion
#pragma region Functions
inline ull powm(ull x,ull y,bool b=false,ull m=mod){ if(b){ ull t=1;x%=m;while(y>0){ if(y%2)t=(t*x)%m;y=y>>1;x=(x*x)%m; }return t; }else
    { ull t=1;while(y>0){ if(y&2)t*=x;y=y>>1;x*=x; }return t;}}
inline ll gcd(ll a,ll b){a=abs(a);b=abs(b); while(b!=0){ ll c=a%b;a=b;b=c;}return a;}
#pragma endregion

//cout<<"Case #"+to_string(tc+1)+": "+to_string(z)<<endl;
int main() {
    fio
    int n,w;
  	in>>n>>w;
  	ll a[n][2];
  	fb(i,n)
      in>>a[i][0]>>a[i][1];
  	ll z[n+1][w+1];
  	mem(z,0)
    fb(i,n)
      fb(j,w+1){
        z[i+1][j]=z[i][j];
        if(a[i][0]<=j)
          z[i+1][j]=max(z[i+1][j],z[i][j-a[i][0]]+a[i][1]);
      }
    ll m=z[n][0];
    fb(i,w+1)
    m=max(m,z[n][i]);
    out<<m;
    return 0;
}

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


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,id=1,ans[100];
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>ans[i];
        if(abs(ans[i])>abs(ans[id])) id=i;
    }
    cout<<2*n-1<<endl;
    for(int i=1;i<=n;i++) cout<<id<<" "<<i<<endl;
    if(ans[id]>0) {
        for(int i=1;i<n;i++) cout<<i<<" "<<i+1<<endl;
    }
    else {
        for(int i=n;i>1;i--) cout<<i<<" "<<i-1<<endl;
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 998244353;

const int MAX = 300300;

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}

LL F[MAX];
LL IF[MAX];

LL C(int n, int k)
{
	LL res = F[n];
	res *= IF[k];
	res %= MOD;
	res *= IF[n-k];
	res %= MOD;
	return res;
}

char A[4][MAX];
int n, m;

LL V[2][MAX];

void calcVals(int x, char* u, char* d, int m, LL* V)
{
	int y = 0;
	int z = 0;
	FOR (i, 0, m)
	{
		y += u[i];
		z += d[i];

		if (x == 0)
		{
			if (y == 0 && z == 0) V[i] = 1;
			else V[i] = 0;
		}
		else
		{
			V[i] = C(x + y + z - 1, x - 1);
		}
	}
}

LL solve(char* u, char* d, char* l, char* r)
{
	int x = 0;
	FOR (i, 0, n)
	{
		x += l[i];
	}

	calcVals(x, u, d, m, V[0]);

	x = 0;
	FOR (i, 0, n)
	{
		x += r[i];
	}

	reverse(d, d+m);
	reverse(u, u+m);

	calcVals(x, u, d, m, V[1]);

	reverse(d, d+m);
	reverse(u, u+m);
	reverse(V[1], V[1] + m);

	LL res = 0;
	LL sum = 0;

	FOR (i, 0, m)
	{

		if (i) sum += V[0][i-1];
		else
		{
			sum++;
		}
		sum = (sum * (u[i] + d[i])) % MOD;
		LL cur = 0;
		if (i < m - 1) cur = V[1][i+1];
		else cur = 1;

	//	cout<<i<<": "<<sum<<' '<<cur<<endl;

		cur *= sum;

		res = (res + cur) % MOD;
	}

	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	IF[0] = 1;
	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * i) % MOD;
		IF[i] = inv(F[i]);
	}

	scanf("%d%d", &n, &m);

	FOR (it, 0, 4)
	{
		scanf("%s", A[it]);
		int len = strlen(A[it]);
		FOR (j, 0, len)
		{
			A[it][j] -= '0';
		}
	}

	char* l = A[0];
	char* r = A[1];
	char* u = A[2];
	char* d = A[3];

	int ind = 0;
	FOR (i, 0, m)
	{
		if (u[i] == 0 && d[i] == 0) continue;
		u[ind] = u[i];
		d[ind] = d[i];
		ind++;
	}

	m = ind;

	ind = 0;
	FOR (i, 0, n)
	{
		if (l[i] == 0 && r[i] == 0) continue;
		l[ind] = l[i];
		r[ind] = r[i];
		ind++;
	}

	n = ind;

	//cout<<"!! "<<n<<' '<<m<<endl;

	if (n == 0 || m == 0)
	{
		LL res = 1;
		FOR (i, 0, m)
		{
			res = (res * (d[i] + u[i])) % MOD;
		}
		FOR (i, 0, n)
		{
			res = (res * (l[i] + r[i])) % MOD;
		}

		cout<<res<<endl;
		return 0;
	}

	LL res = solve(u, d, l, r);
	swap(n, m);
	res += solve(l, r, u, d);

	res %= MOD;
	cout<<res<<endl;



}


Measured memory_bytes: 9600
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

def lcm(a, b): return a * b // math.gcd(a, b)
def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a/b)*x
        return d, x, y
    else:
        return a, 1, 0


sys.setrecursionlimit(1000000)
MOD = 1000000007



def main():
    n, a, b = LI()

    a1, a2 = 1, 1
    for i in range(1, a+1):
        a1 = a1 * (n - i + 1) % MOD
        a2 = a2 * i % MOD
    b1, b2 = 1, 1
    for i in range(1, b+1):
        b1 = b1 * (n - i + 1) % MOD
        b2 = b2 * i % MOD
    nca = a1 * pow(a2, MOD-2, MOD) % MOD
    ncb = b1 * pow(b2, MOD-2, MOD) % MOD

    print((pow(2, n, MOD) - 1 - nca - ncb) % MOD)

main()


Measured memory_bytes: 67588
#include <stdio.h>
#include <stdlib.h>

int main(void){
    char a,b,c;
    scanf("%c%c%c", &a,&b,&c);
   int ans=0;
   if(b!='R'){
      if(a=='R'||c=='R'){
      ans=1;
     }
   }else{
    if(a=='R'&&c=='R'){
      ans=3;
     }else if(a=='R'||c=='R'){
      ans=2;
     }else{
        ans=1;
     }
   }

   
   
   
    printf("%d",ans);
    
}


Measured memory_bytes: 1652
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef long long Int;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
#define MOD 1000000007
ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}

vector<pair<ll,int>> factorize(ll n){
	vector<pair<ll,int>>res;
	for(ll i=2; i*i<=n; i++){
		if(n%i) continue;
		res.emplace_back(i,0);
		while(n%i==0){
			n/=i;
			res.back().second++;
		}
	}
	if(n!=1) res.emplace_back(n,1);
	return res;
}


int main(){
	ll a,b;
	cin>>a>>b;
	ll g = gcd(a,b);
	auto f = factorize(g);
	int ans=f.size()+1;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
A = [ list(map(int, input().split())) for _ in range(3) ]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
flag = False
for i in range(3):
    if sum( [ A[i][j] for j in range(3)] ) == 0:
        flag = True
    if sum( [ A[j][i] for j in range(3)] ) == 0:
        flag = True
if sum( [A[i][i] for i in range(3)] ) == 0 or sum( [A[2-i][i] for i in range(3)] ) == 0:
    flag = True
print("Yes") if flag else print("No")

Measured memory_bytes: 38384
import collections
I = [int(_) for _ in open(0).read().split()]
N, M = I[:2]
A, B = I[2::2], I[3::2]
G = collections.defaultdict(set)
for a, b in zip(A, B):
    G[a].add(b)
    G[b].add(a)
ans = []
seen = set()
x = 1
while True:
    ans += [x]
    seen.add(x)
    allseen = True
    for y in G[x]:
        if y not in seen:
            allseen = False
            x = y
            break
    if allseen:
        break
ans = ans[:0:-1]
x = 1
while True:
    ans += [x]
    seen.add(x)
    allseen = True
    for y in G[x]:
        if y not in seen:
            allseen = False
            x = y
            break
    if allseen:
        break
print(len(ans))
print(*ans)


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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

struct abcd {
	LL a, b, c, d;
};

LL mx = 0;

void get_val(vector<LL> v, const vector<abcd> &data) {
	LL scor = 0;
	for (LL i = 0; i < data.size(); ++i) {
		abcd e = data[i];
		if (v[e.b] - v[e.a] == e.c) {
			scor += e.d;
		}
	}
	mx = max(mx, scor);
}

void rec (vector<LL> v, LL ind, LL n, LL prev, LL m, const vector<abcd> &data) {
	if (ind == n) {
		get_val(v, data);
	}
	else {
		for (LL i = prev; i <= m; ++i) {
			v[ind] = i;
			rec (v, ind+1, n, i, m, data);
		}
	}
}

int main()
{
	LL n, m, q;
	cin >> n >> m >> q;

	vector<abcd> data(q);

	for (auto &e : data) {
		cin >> e.a >> e.b >> e.c >> e.d;
		e.a--, e.b--;
	}

	vector<LL> v(n);

	rec(v, 0, n, 1, m, data);

	cout << mx << "\n";

}



Measured memory_bytes: 3608
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        readInt
        val haystack = readLine.split(" ").map(_.toLong).toList
        readInt
        val needles = readLine.split(" ").map(_.toLong)
        println(needles.foldLeft(0) {(sum, v) => if (exists(v, haystack)) sum + 1 else sum})
    }
    def exists[T](needle: T, haystack: List[T]): Boolean = haystack match {
        case Nil => false
        case x :: xs if x == needle => true
        case x :: xs => exists(needle, xs)
    }
}


Measured memory_bytes: 48256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = intArray[0];
            int Y = intArray[1] / 1000;
            if(10 * N < Y)
            {
                Console.WriteLine("-1 -1 -1");
                return;
            }
            else if(10 * N == Y)
            {
                Console.WriteLine(Y / 10 + " 0 0");
                return;
            }
            for(int i = 0; i <= N; i++)
            {
                if(10 * i > Y)
                {
                    break;
                }
                for(int j = 0; j <= N -i; j++)
                {
                    if (10 * i + 5 * j > Y)
                    {
                        break;
                    }
                    int l = N - (i + j);
                    if (i + j + l == N && (10 * i) + (5 * j) + l == Y)
                    {
                        Console.WriteLine(i + " " + j + " " + l);
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27948
#!/usr/bin/env python3
 
N, M = map(int, input().split())
a = [0]*M
b = [0]*M
c = [0]*M
for m in range(M):
    a[m], b[m], c[m] = map(int, input().split())
    if a[m] > b[m]:
        a[m], b[m] = b[m], a[m]
        assert(a[m] < b[m])
    a[m] -= 1
    b[m] -= 1
#
temp = [10**7] * N
d = [temp[:] for i in range(N)]
 
for i in range(N):
    for j in range(i, N):
        assert(i<=j)
        if i == j:
            d[i][j] = 0
        else:
            for m in range(M):
                if a[m]==i and b[m]==j:
                    d[i][j] = c[m]
 
for k in range(N):
    for i in range(N):
        for j in range(i, N):
            assert(i<=j)
            if i <= k:
                dik = d[i][k]
            else:
                dik = d[k][i]
            if k <= j:
                dkj = d[k][j]
            else:
                dkj = d[j][k]
            if d[i][j] > dik + dkj:
                d[i][j] = dik + dkj
 
ans = 0
for m in range(M):
    if c[m] > d[a[m]][b[m]]:
        ans += 1
    elif c[m] < d[a[m]][b[m]]:
        raise Exception()
print(ans)

Measured memory_bytes: 44272
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
const ll MAX_N = 100000 + 1;
ll a[MAX_N];
ll b[MAX_N];
ll c[MAX_N];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N;  cin >> N;
  for(ll i = 1; i <= N; i++) cin >> a[i] >> b[i] >> c[i];

  ll dp[N + 1][3];
  fill(dp[0], dp[0] + 3, 0);
  
  for(ll i = 1; i <= N; i++) {
    for(ll j = 0; j < 3; j++) {
      ll k1, k2;
      if(j == 0) {k1 = 1; k2 = 2;}
      if(j == 1) {k1 = 0; k2 = 2;}
      if(j == 2) {k1 = 0; k2 = 1;}
      
      dp[i][j] = max(dp[i-1][k1], dp[i-1][k2]);

      if(j == 0) dp[i][j] += a[i];
      if(j == 1) dp[i][j] += b[i];
      if(j == 2) dp[i][j] += c[i];
    }
  }

  ll ans = 0;
  for(ll j = 0; j < 3; j++) ans = max(ans, dp[N][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7764
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;
	std::cout << (N * (N+1) / 2) << "\n";
}


Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Changing a Character
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

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

  k--;
  for (int i = 0; i < n; i++)
    putchar((i == k) ? s[i] - 'A' + 'a' : s[i]);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,m,d,t;
vector<int> s;
int len(int key,vector<int> shops)
{
  int s=0,e=shops.size();
  int c=(s+e)/2;
  while((e-s)>1)
  {
    if(shops[c]==key)
      return 0;
    if(shops[c]>key)
      e=c;
    else
      s=c;
    c=(s+e)/2;
  }
  return min(abs(key-shops[s]),abs(shops[e]-key));
}

int main(void)
{
  int sum;
  cin>>d;
  while(d!=0)
  {
    s.clear();
    s.push_back(0);
    sum=0;
    cin>>n;
    cin>>m;
    for(int i=0;i<n-1;i++)
    {
      cin>>t;
      s.push_back(t);
    }
    sort(s.begin(),s.end());
    s.push_back(d);
    for(int i=0;i<m;i++)
    {
      cin>>t;
      sum+=len(t,s);
    }
    cout<<sum<<endl;
    cin>>d;
  }
  return 0;
}

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

int main(){
    int w, n;
    cin >> w >> n;
    int ans[w+1];
    rep(i, w+1){
        ans[i] = i;
    }
    rep(i, n){
        int a, b;
        scanf("%d,%d", &a, &b);
        // cin >> a >> b;
        swap(ans[a], ans[b]);
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
    
    // printf("%d\n", N);
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define int long long

const int maxn=2e5+10;
int ans,s[100],n,m,now,dis[maxn][30];
char a[maxn],b[maxn];

signed main() {
	int i,j;
	memset(s,-1,sizeof(s));
	scanf("%s%s",a,b);
	n=strlen(a); m=strlen(b);
	for (i=n;i<n*2;i++) {
		a[i]=a[i-n];
	}
	for (i=n*2-1;i>=0;i--) {
//		s[a[i]-'a']=i;
		for (j=0;j<26;j++) 
			if (s[j]) dis[i][j]=s[j];
		s[a[i]-'a']=i;
}
	for (i=0;i<m;i++) 
		if (s[b[i]-'a']==-1) {
//			printf("%c\n",b[i]);
			printf("-1\n"); 
			return 0;
		}
	for (i=0;i<=n;i++) 
		if (a[i]==b[0]) break;
	now=i; ans+=now+1;
	for (i=1;i<m;i++) {
//		if (!dis[now%n][b[i]-'a']) printf("-1\n");
//		else {
			ans+=dis[now][b[i]-'a']-now;
			now=dis[now][b[i]-'a']%n;
//		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    char S[105];
    scanf("%s",S);
    int lens=strlen(S);
    int i,j;
    int cnt=0;
    for(i=0,j=lens-1;i<lens/2;i++,j--)
    {
        if(S[i]!=S[j])
        {
            cnt++;
        }

    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,ans=1e9,a[2][N];
char s[N];
int zh(int x,int l,int r)
{
	if(l>r)
		return 0;
	return a[x][r]-a[x][l-1];
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++)
	{
		int x=s[i]=='W';
		a[0][i]=a[0][i-1],a[1][i]=a[1][i-1];
		a[x][i]++;
	}
	for(int i=0;i<=n;i++)
	{
		int v1=zh(1,1,i),v2=zh(0,i+1,n);
		ans=min(ans,max(v1,v2));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5440
/*
    Friday | 24 July 2020
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define TryUntillAC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000009
int main(){
    TryUntillAC
    ll n; cin>>n;
    vector<ll>v(n);
    for(ll i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    ll cur = 1000, sell, md, buy, flag = false;
    for(ll i = 0; i < n-1; i++)
    {
        if(v[i] == v[i+1]) continue;
        if(v[i] < v[i+1] and !flag)
        {
            sell = cur/v[i];
            md = cur - (sell*v[i]);
            cur = md;
            flag = true;
        }
        if(v[i] > v[i+1] and flag)
        {
            cur += v[i]*sell;
            flag = false;
        }
        // cout<<cur<<" "<<i<<" "<<sell<<endl;
    }
    if(flag == true)
    {
        cur += sell*v[n-1];
    }
    cout<<cur;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  if (a[0] == 0) {
    cout << 0 << endl;
  } else {
    ll res = 1;
    rep(i,n) {
      if (res == -1) continue;
      else if (res > 1000000000000000000 / a[i]) res = -1;
      else res *= a[i];
    }
    cout << res << endl;
  }

  return 0;
}



Measured memory_bytes: 4048
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll d, t, s;

int main() {
	cin >> d >> t >> s;
	if ((d + s - 1) / s <= t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
int main()
{
	std::string str;
	std::cin >> str;
	int i;
	for (i = 2 - str.length() % 2; str.substr(0, (str.length() - i) / 2) != str.substr((str.length() - i) / 2, (str.length() - i) / 2); i += 2);
	std::cout << str.length() - i << std::endl;
	return 0;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l=[LI() for _ in range(3)]
  n=I()
  ans=[[0]*3 for _ in range(3)]

  for i in range(n):
    a=I()
    for j in range(3):
      for k in range(3):
        if l[j][k]==a:
          ans[j][k]=1

  for i in range(3):
    if ans[i][0]==1 and ans[i][1]==1 and ans[i][2]==1:
      return 'Yes'

  for i in range(3):
    if ans[0][i]==1 and ans[1][i]==1 and ans[2][i]==1:
      return 'Yes'

  if ans[0][0]==1 and ans[1][1]==1 and ans[2][2]==1:
    return 'Yes'

  if ans[0][2]==1 and ans[1][1]==1 and ans[0][2]==1:
    return 'Yes'

  return 'No'

# main()
print(main())


Measured memory_bytes: 5800
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int d[101] = { 0 }, a, m = 0;
	while (cin >> a){
		d[a]++;
		m = max(m, d[a]);
	}
	for (int i = 1; i <= 100; i++){
		if (m == d[i])cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import math
r = int(input())
p = math.pi
print(2*r*p)



Measured memory_bytes: 9152