akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  std::string s;
  std::cin >> s;
  std::string S;
  for (long long i = 0; i < s.length(); ++i) {
    if (s[i] == 'A') {
      S.push_back('A');
      continue;
    } else if (i < s.length() - 1 and s[i] == 'B' and s[i + 1] == 'C') {
      S.push_back('X');
      ++i;
      continue;
    } else {
      S.push_back(s[i]);
      continue;
    }
  }
  // std::cout << r << std::endl;
  long long N = S.length();

  long long res = 0;
  for (long long l = 0; l < N; ++l) {
    if (S[l] == 'B' or S[l] == 'C')
      continue;
    long long r = l;
    while (r < N and (S[r] == 'A' or S[r] == 'X'))
      ++r;

    // メイン処理
    long long numA = 0;
    for (long long k = l; k < r; ++k) {
      if (S[k] == 'A') {
        ++numA;
      } else {
        assert(S[k] == 'X');
        res += numA;
      }
    }

    // 後処理
    l = r;
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
#define MAX 2000000000
#define MOD 1000000009
typedef long long ll;

ll n, h[200001],a[200001];
set<pair<ll,ll>> s;


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

    s.insert({0,0});

    for(int i=1;i<=n;i++)
    {
        auto it=s.lower_bound({h[i],0});
        it--;
        ll val=it->second+a[i];
        s.insert({h[i],it->second+a[i]});
        
        it=s.lower_bound({h[i]+1,0});

        while(it!=s.end()&&val>=it->second)
        {
            auto tmp=it;
            tmp++;

            s.erase(it);
            it=tmp;
        }
    }

    auto it=s.end();
    it--;

    cout<<it->second;


	return 0;
}

Measured memory_bytes: 19168
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

main(){
  priority_queue<pair<int, int> > q;
  int N, R, L, S[1000001], T[1000001], d, t, x;
  
  scanf("%d %d %d", &N, &R, &L);
  q.push(make_pair(0, -1));

  for ( int i = 0; i <= N; i++ ) S[i] = T[i] = 0;
  int pret = 0, pred = 1;

  for(int i = 0; i < R; i++){
    scanf("%d %d %d", &d, &t, &x);
    S[d] += x;
    q.push(make_pair(S[d], -d));
    while(1){
      pair<int, int> p = q.top();
      if(p.first == S[-p.second]){
	T[pred] += t - pret;
	pred = -p.second;
	pret = t;
        break;
      }
      q.pop();
    }
  }
  T[pred] += L - pret;

  int maxv = -2000000000, ans = -1;
  for ( int i = 1; i <= N; i++ ){
    if ( maxv < T[i] ){
      maxv = T[i];
      ans = i;
    }
  }

  printf("%d\n",  ans);
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int h, w, dp[1009][1009];

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

    cin >> h >> w;
    FOR(i, 1, h + 1) FOR(j, 1, w + 1) {
        char c;
        cin >> c;
        if(i + j == 2)
            dp[i][j] = 1;
        else if(c == '.') {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            if(dp[i][j] > mod) dp[i][j] -= mod;
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;
    int n=s.length();
    if(n==2 && s[0]==s[1]){
        cout << "1 2";
        return 0;
    }
    for(int i=0;i<n-2;i++){
        if(s[i]==s[i+1] || s[i]==s[i+2]){
            cout << i+1  << " " << i+3 << endl;
            return 0;
        }
    }
    if(s[n-1]==s[n-2]){
        cout << n-1 << " " << n;
        return 0;
    }   
    cout << "-1 -1";

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define S 100

int main(){
  int i,j,n,x,y;
  int r[S+1],m[S+1][S+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&r[i-1],&r[i]);
  }
  for(i=0;i<=n;i++){
    m[i][i]=0;
  }

  for(x=2;x<=n;x++){
    for(i=0;i<=n-x+1;i++){
      j=i+x-1;
      m[i][j]=(1<<21);
      for(y=i;y<=j-1;y++) if(m[i][j]>m[i][y]+m[y+1][j]+r[i-1]*r[y]*r[j]) m[i][j]=m[i][j]=m[i][y]+m[y+1][j]+r[i-1]*r[y]*r[j];
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2052
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] s = S.toCharArray();
        
        Arrays.sort(s);
      
        for(int i = 0; i < s.length; i++){
          int count = 0;
          for(int j = i; j < s.length; j++){
            if(s[i] == s[j]){
              count++;
            }
          }
         
          if(count % 2 != 0){
            System.out.println("No");
            return;
          }else{
            i += count-1;
            continue;
          }
        }
                  
          System.out.println("Yes");
        
	}
}

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

int main(){
  string t;
  int r,s,p,k,n;
  cin >> n >> k >> r >> s >> p >> t;
  int ans=0;
  queue<char>ng;
  for(int i=0;i<k;i++)
    ng.push('/');
  for(int i=0;i<n;i++){
    if(ng.front()==t.at(i)){
      ng.push('/');
    }else{
      switch(t.at(i)){
        case 's':
          ans+=r;
          break;
        case 'r':
          ans+=p;
          break;
        case 'p':
          ans+=s;
          break;
      }
      ng.push(t.at(i));
    }
    ng.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3836
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

ra=[p,q,r]

x=p[1]-p[0]
y=p[2]-p[0]



ans=[]

for n in range(1,3):
    if ra[n][1]-ra[n][0] == x and ra[n][2]-ra[n][0] == y:
        ans.append(True)
    else:
        ans.append(False)

if ans[0] and ans[1]:
    print('Yes')
else:
    print('No')



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

#define MOD 1000000007

using namespace std;

int n;
vector<int> matching;

vector<vector<long long>> memo;

long long no_of_combinations(int idx, int free) {
    if(idx == n)
        return 1;
    if( free == 0)
        return 0;
    
    if(memo[idx][free] != -1)
        return memo[idx][free];
    memo[idx][free] = 0;
    for(int i = n - 1; i >= 0; i--) {
        if((matching[idx] & (1 << i) ) > 0 && (free & (1 << i) ) > 0) {
            memo[idx][free] += no_of_combinations( idx + 1, free ^ (1 << i)) % MOD;
        }
    }
    return memo[idx][free] % MOD;
}

int main() {

    cin >> n;
    
    memo = vector<vector<long long>>( n, vector<long long>( 1 << n , -1));

    for(int i = 0; i < n; i++) {
        int num = 0;
        char v;
        for(int j = n - 1; j >= 0; j--) {
            cin >> v;
            num = v == '1' ? num | ( 1 << j) : num;
        }
        matching.push_back(num);
    }

    cout << no_of_combinations( 0, (1<<n) - 1) << endl;    

    return 0;
}

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

using namespace std;

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

int main(){
    long long n,s=0;
    cin >> n;
    vector<long long> a(n);
    rep(i,n){
        cin >> a[i];
        s += a[i];
    }

    int min = *min_element(a.begin(), a.end());
    int max = *max_element(a.begin(), a.end());

    printf("%d %d %lld\n", min, max, s);
    return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <map>
#include <utility>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;


int main()
{
    ll a;
    double b;
    cin >> a >> b;
    int c = round(b*100);
    cout << a*c/100 << endl;
}

Measured memory_bytes: 3732
#include<cstdio>

int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	while(a || b){
		if(a > b){
			printf("%d %d\n", b, a);
		}else{
			printf("%d %d\n", a, b);
		}
		scanf("%d %d", &a, &b);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

typedef long long ll;

inline void update(int &x,ll y) {
  x=(x+y)%MOD;
}

int f[2][305][305];
int num[605],kind[605];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=2*n;i++) scanf("%d",&num[i]);
  int cnt=0;
  for(int i=1;i<=n;i++)
    if (num[2*i-1]==-1||num[2*i]==-1) {
    	if (num[2*i-1]!=-1) kind[num[2*i-1]]=1;
    	if (num[2*i]!=-1) kind[num[2*i]]=1;
    	if (num[2*i-1]==-1&&num[2*i]==-1) cnt++;
	}
	else kind[num[2*i-1]]=kind[num[2*i]]=-1;
  int cur=0;
  f[cur][0][0]=1;
  int s1=0,s2=0;
  for(int i=2*n;i>0;i--)
    if (kind[i]!=-1) {
    	cur^=1;
    	memset(f[cur],0,sizeof(f[cur]));
    	for(int j=0;j<=min(s1,n);j++)
    	  for(int k=0;k<=min(s2,n);k++)
    	    if (f[cur^1][j][k]) {
    	    	if (kind[i]) {
    	    		if (j<n) update(f[cur][j+1][k],f[cur^1][j][k]);
    	    		if (k) update(f[cur][j][k-1],f[cur^1][j][k]);
				}
				else {
					if (k<n) update(f[cur][j][k+1],f[cur^1][j][k]);
					if (j) update(f[cur][j-1][k],(ll)j*f[cur^1][j][k]);
					if (k) update(f[cur][j][k-1],(ll)(cnt-((s2-s1+j-k)>>1))*f[cur^1][j][k]);
				}
			}
		if (kind[i]) s1++; else s2++;
	}
  printf("%d\n",f[cur][0][0]);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;
}


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

int main() {
    int H, W; cin >> H >> W;
    int c[10][10];
    rep(i, 10) rep(j, 10) cin >> c[i][j];

    rep(via, 10) rep(from, 10) rep(to, 10) {
        if(c[from][via] + c[via][to] < c[from][to]) c[from][to] = c[from][via] + c[via][to];
    }

    int ans = 0;
    rep(y, H) {
        rep(x, W) {
            int a; cin >> a;
            if(a == -1) continue;
            ans += c[a][1];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  map<int, int> mp;
  mp[0] = 1;
  int ms = 0;
  rep(i, n){
    ms += a.at(i);
    ms %= m;
    mp[ms]++;
  }
  ll ans = 0;
  for(auto p : mp){
    ans += (ll)p.second * (p.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6684
A,B,K = [int(i) for i in input().split()]

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
GCD = gcd(A,B)
count=0
for i in range(GCD,0,-1):
    if GCD // i == GCD/i:
        count +=1
        if count == K:
            ans = i
            break
print(ans)

Measured memory_bytes: 3064
import java.util.*;

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

        for (int i=0; i<N; i++) {
            w[i] = sc.nextInt();
        }

        int l = 0;
        int r = 0;
        int lsum = 0;
        int rsum = 0;

        for (int i=0; i<N; i++) {
            if (lsum >= rsum) {
                rsum += w[N-1-r];
                r++;
                continue;
            }
            if (rsum > lsum) {
                lsum += w[l];
                l++;
                continue;
            }
        }
        System.out.println(Math.abs(rsum - lsum));
    }
}



Measured memory_bytes: 21972
List = list(map(int, input().split()))
A = list(map(int, input().split()))

D = []
for i in range(1,List[1]):
    D.append(List[0]-(A[i]-A[i-1]))

D.append(List[0]-(A[0]+List[0]-A[List[1]-1]))

print(min(D))

Measured memory_bytes: 26444
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for i in range(H):
    for j in range(W):
        if grid[i][j]=="#":
            dist[i][j]=0
            black_cells.append((i,j))

d = 0
while black_cells:
    # キューとして使うのでpop()ではなくpopleft()
    h, w = black_cells.popleft()
    d = dist[h][w]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_h = h + dy
        new_w = w + dx
        if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
            continue
        if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
            dist[new_h][new_w] = d+1
            black_cells.append((new_h, new_w))
print(d)

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vs s(h);
  rep(i,h) cin >> s[i];
  int ans = inf;
  rep(bit,1<<(h-1)) {
    int g = 0;
    vi div(h);
    rep(i,h) {
      div[i] = g;
      if(bit>>i&1) g++;
    }
    int cur = g;
    g++;
    vi now(g);
    auto add = [&](int j) {
      rep(i,h) {
        if(s[i][j] == '1') now[div[i]]++;
        if(now[div[i]] > k) return false;
      }
      return true;
    };
    rep(j,w) {
      if(!add(j)) {
        rep(i,h) now[div[i]] = 0;
        cur++;
        if(!add(j)) {
          cur = inf;
          break;
        }
      }
    }
    chmin(ans, cur);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y 

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

#define INF 1e9
#define pi 3.141592653589
#define e 2.718281828459
#define phi 1.618033988749
#define MOD 1000000007
#define printarr(arr,n){for(int i=0;i<(n);i++){cout<<arr[i]<<" ";}cout<<endl;}
#define foreach(it , l) for(auto it = l.begin(); it != l.end(); ++it)
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define rev_sort(a) sort(a.rbegin(),a.rend());

struct Timer
{
    chrono::time_point<chrono::high_resolution_clock> start , end;
    chrono:: duration<float> dur;
    Timer()
    {
        start = chrono::high_resolution_clock::now();
    }
    ~Timer()
    {
        end = chrono::high_resolution_clock::now();
        dur = end - start;
        cout<<"\nTime Elapsed : " <<dur.count() << " s\n";
    }
};

ll sum() {return 0;}
template<typename T, typename... Args>
T sum(T a , Args... args)   {return a + sum(args...); }

//76149
template<int D, typename T> 
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};

struct Graph
{
    int n;
    vector<vector<int> > adj;
    Graph(int n)
    {
        this->n = n;
        adj.resize(n + 1);
    }
    void add_edge(int u , int v)
    {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    void solve()
    {
        queue<int> q;
        vector<int> dist(n+ 1, INF) , parent(n +1, -1);
        vector<bool> visited(n + 1, false);
        q.push(1) , dist[1] = 0 , visited[1] = true;
        while (!q.empty())
        {
            int u = q.front();q.pop();
            for(auto v :adj[u])
            {
                if(!visited[v])
                {
                    dist[v] = dist[u] + 1;
                    parent[v] = u;
                    visited[v] = true;
                    q.push(v);
                }
            }
        }
        cout<<"Yes\n";
        for(int i = 2; i<= n;i++)
            cout<<parent[i]<<"\n";
        
    }
};

int main()
{
    xlr8;
    int testCases  = 1;
    //cin>>testCases;
    while (testCases--)
    {
        int n,m;
        cin>>n>>m;
        Graph g(n);
        for(int i = 0 ; i< m ; i++)
        {
            int u , v;
            cin>>u>>v;
            g.add_edge(u ,v);
        }
        g.solve();
    }
    
    

    

}


Measured memory_bytes: 10632
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let mut a = split.next().unwrap().parse::<u64>().unwrap();
    let mut b = split.next().unwrap().parse::<u64>().unwrap();
    let mut c = split.next().unwrap().parse::<u64>().unwrap();
    let mut result = 0;
    while a % 2 == 0 && b % 2 == 0 && c % 2 == 0 {
        result += 1;
        let new_a = (b + c) / 2;
        let new_b = (a + c) / 2;
        let new_c = (a + b) / 2;
        a = new_a;
        b = new_b;
        c = new_c;
        if a == b && b == c && c == a {
            result = -1;
            break;
        }
    }
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("4 12 20\n", "3\n");
    }
    #[test]
    fn case2() {
        test("14 14 14\n", "-1\n");
    }
    #[test]
    fn case3() {
        test("454 414 444\n", "1\n");
    }
}



Measured memory_bytes: 4352
n = int( raw_input() )
d = [ 100 for i in range(n) ]
G = [ 0 for i in range(n) ]
v = [ [ 0 for i in range(n) ] for j in range(n) ]
  
def BFS(s):
    for e in range(n):
        if v[ s ][ e ] == 1:
            if d[ e ] > d[ s ] + 1:
                d[ e ] = d[ s ] + 1
                BFS(e)
  
for i in range(n):
    G = map( int , raw_input().split() )
 
    for j in range( G[1] ):
        v[ G[0] -1 ][ G[ 2+j ] -1 ] = 1
 
d[0] = 0
  
for i in range(n):
    BFS(i)
 
for i in range(n):
    if d[ i ] == 100:
        d[ i ] = -1
 
for i in range(n):
    print i+1 , d[ i ]

Measured memory_bytes: 6476
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/
ll ma=1e9+7;

ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll dp[n+1];
    dp[0]=1;
    for(int i=1;i<=n;i++){
        dp[i]=0;
        for(int j=3;i-j>=0;j++){
            dp[i]=(dp[i]+dp[i-j])%ma;
        }

    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 3656
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    state = [list(input()) for _ in range(N)]

    ans = 0
    for i in range(N):
        ok = True
        for x in range(N):
            for y in range(N):
                if state[(x+i)%N][y] != state[(i+y)%N][x]:
                    ok = False
                    break
        if ok:
            ans += N
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43504
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;
#define int long long

signed main(){
    ios();
    int n;
    cin >> n;
    
    vector<int> a(n), b(n);
    for(int& i : a) cin >> i;
    for(int& i : b) cin >> i;

    int ans = 0;

    RREP(i, 30){
        int k = 1 << i;
        for(int& j : b) j %= (k << 1);
        sort(all(b));
        int cnt = 0;
        REP(j, n){
            int r = a[j] % (k << 1);
            int c1 = lower_bound(all(b), 2*k - r) - lower_bound(all(b), k - r);
            int c2 =  lower_bound(all(b), 4*k - r) - lower_bound(all(b), 3*k - r);
            cnt += c1 + c2;
        }
        ans ^= (cnt % 2) << i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;

int main()
{
    int r = 0, g = 0, b = 0, N = 0;
    long total = 0;

    cin >> r >> g >> b >> N;

    for(int i = 0; i <= N/r; i++)
    {
       if(i*r > N)
         break;
       for(int j = 0; j <= N/g; j++)
       {
         if((i*r + j*g) > N)
            break;
         if((N - i * r - j * g) % b == 0)
         {
            total++;
         }
       }
    }

    cout << total;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
    const double PI = acos(-1);
    int a, b, C;
    scanf("%d %d %d", &a, &b, &C);
    double C_rad = PI * C / 180;
    double S = 0.5 * a * b * sin(C_rad);
    double c = sqrt(a * a + b * b - 2 * a * b * cos(C_rad));
    double L = a + b + c;
    double h = 2 * S / a;
    printf("%f\n%f\n%f\n", S, L, h);
    return 0;
}


Measured memory_bytes: 2972
#include<stdio.h>
#include<string.h>


int main(){
	char in[10],out[10];
	int n,i,mcxi,j,k;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		mcxi=0;
		for(k=0;k<2;k++){
			scanf(" %s ",in);
			for(j=0;;j++){
				if(in[j]=='\0')break;
				if(in[j]=='m'){
					if(j-1==-1 || in[j-1]>'9'){
						mcxi+=1000;
					}else{
						mcxi+=1000*(in[j-1]-'0');
					}
				}
				
				if(in[j]=='c'){
					if(j-1==-1 || in[j-1]>'9'){
						mcxi+=100;
					}else{
						mcxi+=100*(in[j-1]-'0');
					}
				}
				
				if(in[j]=='x'){
					if(j-1==-1 || in[j-1]>'9'){
						mcxi+=10;
					}else{
						mcxi+=10*(in[j-1]-'0');
					}
				}
				
				if(in[j]=='i'){
					if(j-1==-1 || in[j-1]>'9'){
						mcxi+=1;
					}else{
						mcxi+=in[j-1]-'0';
					}
				}
			}
		}
		
		j=0;
		if(mcxi/1000==1){
			out[j]='m';
			++j;
		}else if(mcxi/1000>1){
			out[j]=mcxi/1000+'0';
			++j;
			out[j]='m';
			++j;
		}
		mcxi%=1000;
		
		if(mcxi/100==1){
			out[j]='c';
			++j;
		}else if(mcxi/100>1){
			out[j]=mcxi/100+'0';
			++j;
			out[j]='c';
			++j;
		}
		mcxi%=100;
		
		if(mcxi/10==1){
			out[j]='x';
			++j;
		}else if(mcxi/10>1){
			out[j]=mcxi/10+'0';
			++j;
			out[j]='x';
			++j;
		}
		mcxi%=10;
		
		if(mcxi==1){
			out[j]='i';
			++j;
		}else if(mcxi>1){
			out[j]=mcxi+'0';
			++j;
			out[j]='i';
			++j;
		}
		out[j]='\0';
		printf("%s\n",out);
	}
	return 0;
}

Measured memory_bytes: 0
from heapq import heappop,heappush
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    a,b,c = map(int, input().split())
    G[a-1].append({"to":b-1, "cost":c})
    G[b-1].append({"to":a-1, "cost":c})
Q,K = map(int, input().split())
K -= 1

dist = [float("inf")] * N
dist[K] = 0
que = [(0, K)]

while que:
    d,v = heappop(que)
    if dist[v] < d: continue
    for e in G[v]:
        if dist[e["to"]] > d + e["cost"]:
            dist[e["to"]] = d + e["cost"]
            heappush(que, (dist[e["to"]], e["to"]))

for _ in range(Q):
    x,y = map(int, input().split())
    x -= 1; y -= 1
    print(dist[x] + dist[y])

Measured memory_bytes: 93112
k = int(input())
a, b = list(map(int, input().split()))

ans = k
flag = True
while True:
    if (ans < a):
        ans += k
        continue
    if (ans <= b):
        break
    else:
        flag = False
        break

if (flag):
    print("OK")
else:
    print("NG")


Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	if ((a + b) >= c) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	long long int a[100][100], b[100][100], c[100][100] = { 0 };
	int n, m, l, i, j, k;
	cin >> n >> m >> l;
	for (i = 0; i < n; i++){
		for (j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (i = 0; i < m; i++){
		for (j = 0; j < l; j++){
			cin >> b[i][j];
		}
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < l; j++){
			for (k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for (i = 0; i < n; i++){
		for (j = 0; j < l; j++){
			if (j == 0) { printf("%ld", c[i][j]); }
			else		{ printf(" %ld", c[i][j]); }
		}
		printf("\n");
	}
}

Measured memory_bytes: 1400
//package hoge; のようなパッケージ宣言は提出前に除く
//インポート文など
import java.util.Scanner;
import java.math.BigDecimal;
public class Main { //クラス名はMain
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
      	String a = in.next();
        String b = in.next();
      	BigDecimal c = new BigDecimal(a);
        BigDecimal d = new BigDecimal(b);
        BigDecimal e = c.multiply(d);
        BigDecimal f = e.setScale(0, BigDecimal.ROUND_DOWN);
        System.out.println(f);      	
    }
}

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


int main(){
  string s;
  cin >> s;
  int i;
  if(s[0] == s[s.length() - 1])
    i = 1;
  else 
    i = 0;
  if((s.length() + i) % 2 == 0)
    cout << "Second" << endl;
  else
    cout << "First" << endl;
  return 0;


}


Measured memory_bytes: 512
N = int(input())
sum = 0
 
for i in range(1,N+1):
        if i % 3 == 0 and i % 5 == 0:
            i = ["FizzBuzz"]
        elif i % 3 == 0:
            i = ["Fizz"]
        elif i % 5 == 0:
            i = ["Buzz"]
    # if i % 3 == 0 and i % 5 == 0:
        else:
            sum += i
print(sum)

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

int main() {
  int x;
  cin>>x;
  string s=to_string(x);
  int n=s.size();
  int fx=0;
  for(int i=0;i<n;i++) fx+=s[i]-'0';
  if(x%fx==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		out.println((a+b-1)/b*c);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 25440
#include<bits/stdc++.h>
using namespace std;
struct List{int x;List*prev,*next;};

List*cursor;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int q; cin>>q;
	List first,last;
	first.x=0,first.prev=nullptr,first.next=&last;
	last.x=0,last.prev=&first,last.next=nullptr;
	cursor=&last;
	for(int i=0;i<q;++i){
		int que; cin>>que;
		if(que==2){
			if(cursor==&last)continue;
			cursor->prev->next=cursor->next;
			cursor->next->prev=cursor->prev;
			List*res=cursor->next;
			delete cursor;
			cursor=res;
		}
		else{
			int y; cin>>y;
			if(que==0){
				List*node=new List;
				node->x=y,node->next=cursor->prev->next;
				node->prev=cursor->prev,node->prev->next=node;
				cursor->prev=node;
				cursor=node;
			}
			else{
				if(y>0)for(int j=0;j<y;++j){
					cursor=cursor->next;
				}else for(int j=0;j>y;--j){
					cursor=cursor->prev;
				}
			};
		}
	}
	cursor=&first; cursor=cursor->next;
	while(cursor->next!=nullptr){
		cout<<cursor->x<<"\n"s;
		cursor=cursor->next;
		delete cursor->prev;
	}
}


Measured memory_bytes: 18684
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    BufferedReader t=new BufferedReader(new InputStreamReader(System.in));
    String a=t.readLine();
    String[] s=a.split(" ");
    
    int l=Integer.parseInt(s[0]);
    int h=Integer.parseInt(s[1]);
    
    System.out.println(l*h+" "+(l+h)*2);
    
    
    }
}

Measured memory_bytes: 24208
def divisor(n):
    ret = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ret.append(i)
            if i*i != n:
                ret.append(n//i)
    return ret
def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
def extgcd(a, b):
    x0, x1, y0, y1 = 0,1,1,0
    while a:
        g,b,a = b//a, a, b%a
        y0,y1 = y1, y0-g*y1
        x0,x1 = x1, x0-g*x1
    return x0, y0, b

def get_t(A,y):
    ta = int(-A/y) + 1
    if -A < 0 and A%y != 0:
        ta = int(-A/y)
    return ta

n = int(input())
if n == 2:
    k = 3
elif is_prime(n):
    k = n-1
else:
    k = float("inf")
    n = 2*n
    div = divisor(n)
    for x in div:
        y = n//x
        A, B, g = extgcd(x, -y)
        if g == 1:
            ta = get_t(A, y)
            tb = get_t(B, y)
            t = max(ta, tb)
            a = A + y*t
            b = B + x*t
            ax = a*x
            by = b*y
            k = min(k, by)

print(k)



Measured memory_bytes: 69624
#include<iostream>
using namespace std;
#include<vector>
#include<set>

int main(){
    int n,l;
    cin>>n>>l;
    multiset<string> s;
    for(int i = 0;i<n;i++){
        string a;
        cin>>a;
        s.insert(a);
    }
    
    for(auto x : s){
        cout<< x;
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
S = list(input())
if (S.count(S[0]) == 4):
    print("No")
else:
    if (S == S[::-1]):
        print("Yes")
    else:
        if (S[0] == S[1] and S[2] == S[3]) or (S[0] == S[2] and S[1] == S[3]):
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n,cnt,q,mx,mn,x,y,z;
bitset<N> isprime;
bool prime(int l){
    if(l<=1) return 0;
    for(int i=2;i<l;++i)
        if(l%i==0) return 0;
    return 1;
}
void sieve(){
    isprime[0]=isprime[1]=0;
for(int p=2;p<N;++p)
    if(isprime[p])
    for(int m=2*p;m<N;m+=p)
        isprime[m]=0;
}

int main(){
    isprime.set();
    sieve();
    for(int i=1;i<N;++i){
     A[i]=(isprime[i]&&isprime[(i+1)/2]);
     A[i]+=A[i-1];
    }
    //for(int i=0;i<55;++i)
      //  cout<<i<<":"<<A[i]<<endl;
    scanf("%d",&q);
    while(q--){
        scanf("%d %d",&x,&y);
        printf("%d\n",A[y]-A[x-1]);
    }
    return 0;
}


Measured memory_bytes: 1024
def sum_of_digits(n)
    sum = 0
    loop do
        sum += n % 10
        n /= 10
        break if n < 1
    end
    sum
end

n , min, max = gets.split(' ').map(&:to_i)

res = 0
for n in (1..n) do
    sum = sum_of_digits(n)
    res += n if sum >= min && sum <= max
end

puts res


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    rep(i,n){
        cin>>d[i];
    }
    int sum=0;
    rep(i,n-1){
        re(j,i+1,n){
            sum+=(d[i]*d[j]);
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

int main(){
  int n,k;cin >> n >> k;
  int cnt=0;
  bool ans=true;
  for(int i=0;ans;i++){
    if(n>=k){
      cnt++;
      n/=k;
    }else{
      ans=false;
    }
  }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
    cin >> n >> k;
    long long sum = 1;
    int i = 0;
    for(i = 0; ; ++i) {
        sum *= k;
        if(sum > n) break;
    }

    cout << i+1 << endl;
}

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

int main(){
	int N;
	cin >> N;
	int A[N], ans = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		int cnt = 0;
		while(A[i] % 2 == 0){
			A[i] /= 2;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll N; cin >> N;
	ll a[10010], b[10010];
	ll asum, bsum;
	asum = 0; bsum = 0;
	REP(i, N) {
		cin >> a[i];
		asum += a[i];
	}
	REP(i, N) {
		cin >> b[i];
		bsum += b[i];
	}
	if (asum > bsum) {
		cout << "No" << endl;
		return 0;
	}
	ll diff = bsum - asum;//操作回数
	ll cnt = 0;
	REP(i, N) {
		if (b[i] > a[i]) {
			cnt += (b[i] - a[i] + 1) / 2;
		}
	}
	if (cnt > diff) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

int F,C;			//変数の用意

int main(){
cin>>F;		 	//変数の読み込み
C = ( F -30 ) / 2;		//華氏温度（F）を摂氏温度（C）に変換
cout<< C << endl; 	//摂氏温度（C）を出力

return 0;
}



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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int n;
ll arr[ MAXN ];

ll solve( int s ) {
  ll r = 0, sum = 0;
  for( int i = 0; i < n; ++i, s = -s ) {
    sum += arr[ i ];
    if( s*sum <= 0 ) {
      r += abs(sum)+1;
      sum = s;
    }
  }
  return r;
}

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n ) {
    for( int i = 0; i < n; ++i ) {
      cin >> arr[ i ];
    }
    cout << min( solve(1), solve(-1) ) << '\n';
  }

  return 0;
}


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

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

  int A,B;
  A = s/100;
  B = s%100;

  bool YYMM =false;
  bool MMYY =false;

  if(0<A && A<13)MMYY = true;
  if(0<B && B<13)YYMM = true;

  if(YYMM ==true && MMYY == true)cout<<"AMBIGUOUS"<<endl;
  if(YYMM ==true && MMYY == false)cout<<"YYMM"<<endl;
  if(YYMM ==false && MMYY == true)cout<<"MMYY"<<endl;
  if(YYMM ==false && MMYY == false)cout<<"NA"<<endl;

return 0;

}


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

int main() {
    int N, Q; cin >> N >> Q;
    string str; cin >> str;

    // 累積和
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    // クエリ
    for (int q = 0; q < Q; ++q) {
        int l, r; cin >> l >> r;
        --l, --r; // 0-indexed にする
        cout << s[r] - s[l] << endl;
    }
} 

Measured memory_bytes: 1408
# https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_A


class WeightedUnionFind:
    """
    重み付きUnionFind

    """
    root_position = 0

    def __init__(self, size: int):
        self.size = size
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.parent = [-1] * size
        self.weight = [WeightedUnionFind.root_position] * size

    def find(self, x: int) -> (int, int):
        """
        xを含む集合の代表とxの代表からの位置を求める
        """
        if self.parent[x] < 0:
            return x, self.weight[x]
        # 集合の代表にリンクを繋ぎ変える
        same_group_items = []
        y = x
        while self.parent[y] >= 0:
            same_group_items.append(y)
            y = self.parent[y]
        w = 0
        while same_group_items:
            child = same_group_items.pop()
            w += self.weight[child]
            self.weight[child] = w
            self.parent[child] = y
        return y, self.weight[x]

    def unite(self, x: int, y: int, weight: int) -> bool:
        """
        xを含む集合とyを含む集合を併合する
        `weight[x] + weight = weight[y]`になるように辺に重みをもたせる。
        xとyがすでに同じ集合に含まれている場合Falseを返す。
        """
        root_x, weight_x = self.find(x)
        root_y, weight_y = self.find(y)

        if root_x == root_y:
            return False

        if self.parent[root_x] >= self.parent[root_y]:
            self.parent[root_x] += self.parent[root_y]
            self.parent[root_y] = root_x
            self.weight[root_y] = weight_x + weight - weight_y
        else:
            self.parent[root_y] += self.parent[root_x]
            self.parent[root_x] = root_y
            self.weight[root_x] = weight_y - weight - weight_x

        return True


def solve():
    n, q = map(int, input().split())
    uf = WeightedUnionFind(n)
    for _ in range(q):
        query = list(map(int, input().split()))
        if query[0] == 0:
            _, x, y, z = query
            uf.unite(x, y, z)
        else:
            _, x, y = query
            root_x, pos_x = uf.find(x)
            root_y, pos_y = uf.find(y)
            if root_x == root_y:
                print(pos_y - pos_x)
            else:
                print('?')


if __name__ == "__main__":
    solve()



Measured memory_bytes: 12368
#include <cstdio>
inline int gcd(int x, int y)
{
	while (y)
	{
		int r = x % y;
		x = y;
		y = r;
	}
	return x;
}
const char ans[][15] = {"First", "Second"};
int arr[100005];
int main()
{
	// freopen("AGC010-D.in", "r", stdin);
	int n, rev = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	while (true)
	{
		int cnt = 0;
		for (int i = 0; i < n; i++)
			cnt += arr[i] & 1 ^ 1;
		if (cnt & 1)
		{
			puts(ans[rev]);
			return 0;
		}
		if (n - cnt >= 2)
		{
			puts(ans[!rev]);
			return 0;
		}
		int g = 0;
		for (int i = 0; i < n; i++)
		{
			if (arr[i] == 1)
			{
				puts(ans[!rev]);
				return 0;
			}
			if (arr[i] & 1)
				arr[i]--;
			g = gcd(g, arr[i]);
		}
		for (int i = 0; i < n; i++)
			arr[i] /= g;
		rev ^= 1;
	}
	return 0;
}


Measured memory_bytes: 512
'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const N = tmp[0][0], W = tmp[0][1];
  const Vmax = N * 1000;
  const dp = [Array(Vmax+1).fill(Infinity)];
  dp[0][0] = 0;
  for ( let i = 0; i < N; i++ ) {
    let w = tmp[i+1][0];
    let v = tmp[i+1][1];
    dp.push(Array(Vmax+1).fill(Infinity));
    for ( let j = 0; j <= Vmax; j++ ) {
      if ( j >= v ) dp[i+1][j] = Math.min( dp[i][j], dp[i][j-v] + w );
      else dp[i+1][j] = dp[i][j];
    }
  }
  for ( let i = Vmax; i > 0; i-- ) if ( dp[N][i] <= W ) return i;
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 115588