akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cstring>
#include <iomanip>
#include <queue>
#include <deque>
#include <cmath>
using namespace std;
#define inf 280201280201280201
#define mn 200005
#define FLN "test"
#define int long long
typedef pair<int, int> ii;
//constance

//common data structures and templates
template<typename T>
struct SegmentTree{
};
//gb
int n;
int s[mn];
//functions here
void input(){
}
vector<ii> solve(int left, int right){
  vector<ii> ans;
  int l = left, r = right-1, lower=left;
  while(l<= r){
    int mid = (l+r)>>1;
    if(s[mid]-s[left-1] <= s[right]-s[mid]){
      lower = mid;
      l = mid+1;
    }
    else r = mid-1;
  }
  ans.push_back({s[lower]-s[left-1], s[right]-s[lower]});
  l = left, r = right-1; 
  int higher=left;
  while(l<= r){
    int mid = (l+r)>>1;
    if(s[mid]-s[left-1] >= s[right]-s[mid]){
      higher = mid;
      r = mid-1;
    }
    else l = mid+1;
  }
  ans.push_back({s[higher]-s[left-1], s[right]-s[higher]});
  return ans;
}

//#define LOCAL 1

signed main(signed argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifdef LOCAL
	   freopen(FLN".inp", "r", stdin);
	   freopen(FLN".out", "w", stdout);
#endif
  cin >> n;
  for(int i=1; i<= n; ++i){
    cin >> s[i];
    s[i] += s[i-1];
  }
  //1- >i && i+1 -> n
  vector<ii> p, q;
  int ans= inf;
  for(int i=2; i<n ; ++i){
    //1->i
    p = solve(1, i);
    q = solve(i+1,n);
    for(ii x : p)
      for(ii y : q){
        int mi = min(min(x.first, x.second), min(y.first, y.second));
        int ma = max(max(x.first, x.second), max(y.first, y.second));
        ans = min(ans, ma - mi);
      }
  }
  cout << ans;
	return 0;
}


Measured memory_bytes: 1792
//
// Created by Harshit on 20-08-2020.
//
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector <vector <int>> arr(n,vector <int> (3));
    vector <vector <int>> res(n,vector <int> (3,INT_MIN));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            cin>>arr[i][j];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            if(i==0)
                res[i][j]=arr[i][j];
            else{
                for(int k=0;k<3;k++){
                    if(j!=k)
                    res[i][j]=max(res[i-1][k]+arr[i][j],res[i][j]);
                }
            }
        }
    }
    cout<<max(res[n-1][0],max(res[n-1][1],res[n-1][2]))<<endl;

}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) {
        is >> x;
    }
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;

    vector<int> v(s.size(), 0);
    int c = 0;
    int irl = 0;
    REP(i, s.size() - 1) {
        c++;
        if (s[i] == 'R' and s[i + 1] == 'L') {
            v[i] += (c - c / 2);
            v[i + 1] += c / 2;
            irl = i + 1;
            c = 0;
        } else if (s[i] == 'L' and s[i + 1] == 'R') {
            v[irl] += (c - c / 2);
            v[irl - 1] += c / 2;
            c = 0;
        }
    }

    if (c == 0) {
        v.back()++;
    } else {
        c++;
        v[irl] += (c - c / 2);
        v[irl - 1] += c / 2;
    }

    REP(i, v.size()) { cout << v[i] << " "; }
    cout << endl;

    return 0;
}


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

H,W=map(int,input().split())
S=[input().strip() for i in range(H)]
from collections import deque

def bfs(x,y):
    if S[x][y]=="#":
        return 0
    
    Q=deque()
    Q.append((x,y))
    count=[[-1]*W for i in range(H)]
    count[x][y]=0

    while Q:
        x,y=Q.pop()
        for z,w in [(x+1,y),(x-1,y),(x,y-1),(x,y+1)]:
            if 0<=z<H and 0<=w<W and count[z][w]==-1 and S[z][w]==".":
                count[z][w]=count[x][y]+1
                Q.appendleft((z,w))

    #print(x,y)
    #for c in count:
    #    print(c)

    return max([max(c) for c in count])

ANS=0

for i in range(H):
    for j in range(W):
        ANS=max(ANS,bfs(i,j))

print(ANS)
        
        

    
    


Measured memory_bytes: 3316
#include <iostream>

int main(int argc, char const *argv[]) {

    std::string s;
    std::cin >> s;

    std::string head = s.substr(0,1);
    std::string tail = s.substr(s.length()-1,1);

    std::cout << head << s.length()-2 << tail << '\n';

    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#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 repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
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; }

int main()
{
	int m1, d1, m2, d2;
	bool flag = false;

	cin >> m1 >> d1;
	cin >> m2 >> d2;

	if (m2 - 1 == m1 || (m2 == 1 && m1 == 12))
	{
		if (d2 == 1)
		{
			if (m1 == 1 || m1 == 3 || m1 == 5 || m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12) {
				if (d1 == 31)
					flag = true;
			}
			else if (m1 == 2) {
				if(d1 == 28)
					flag = true;
			}
			else {
				if(d1 == 30)
					flag = true;
			}
		}
	}

	if (flag)
		cout << "1" << endl;
	else
		cout << "0" << endl;


	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<unordered_map>

using namespace std;

int d, c[100], s[400][100];
int sat;
unordered_map<int, int> last;

int main() {
  scanf("%d", &d);
  for (int i = 1; i <= 26; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 1; i <= d; i++) {
    for (int j = 1; j <= 26; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 1; i <= d; i++) {
    int t;
    scanf("%d", &t);
    sat += s[i][t];
    last[t] = i;
    for (int j = 1; j <= 26; j++) {
      sat -= c[j] * (i - last[j]);
    }
    printf("%d\n", sat);
  }
}


Measured memory_bytes: 3368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

// Napsack problem
int main()
{
  int N, W;
  cin >> N >> W;
  vii items;
  ll ans = 0;
  ll dp[N + 1][W + 1];
  items.push_back(make_pair(0, 0));
  rep(i, N)
  {
    int n, w;
    cin >> n >> w;
    items.push_back(make_pair(n, w));
  }

  for (int i = 0; i <= W; i++)
    dp[0][i] = 0;

  for (int i = 1; i <= N; i++)
  {
    dp[i][0] = 0;
    for (int j = 1; j <= W; j++)
    {
      if (items[i].first > j)
      {
        dp[i][j] = dp[i - 1][j];
        ans = max(ans, dp[i][j]);
      }
      else
      {
        dp[i][j] = max(dp[i - 1][j], items[i].second + dp[i - 1][j - items[i].first]);
        ans = max(ans, dp[i][j]);
      }
    }
  }

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

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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            if(K < S.Length)
            {
                Console.WriteLine(S.Substring(0, K) + "...");
            }
            else
            {
                Console.WriteLine(S);
            }
        }
    }
}


//文字配列の取得
//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: 27524
#include <bits/stdc++.h>
using namespace std;

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

struct Combination {
  int mod; // e.g. 1000000007
  vector<int> fact; // factorial
  vector<int> invf; // inverse factorial
  vector<vector<int> > part; // partition number

  /*
    constructor : O(sz+log(mod))   
    make factorial table (fact) and inverse factorial table (invf)
  */
  Combination(int sz, int mod) : fact(sz+1), invf(sz+1), mod(mod) {
    fact[0] = 1;
    for ( int i = 1; i < (int)fact.size(); i++ ) {
      fact[i] = fact[i-1]*i%mod;
    }
    invf[sz] = inv(fact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      invf[i] = invf[i+1]*(i+1)%mod;
    }
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return ret;
  }

  int inv(int x) const {
    return pow(x, mod - 2);
  }

  /*
    permutation
  */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return fact[n]*invf[n-r]%mod;    
  }

  /*
    combination
  */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return fact[n]*invf[r]%mod*invf[n-r]%mod;    
  }  

  /*
    combination with repetition
  */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
  */
  int S(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      int add = C(r, i)*pow(i, n)%mod;      
      if ( (r-i)&1 ) ret += mod-add;
      else ret += add;
      ret %= mod;      
    }
    (ret *= invf[r]) %= mod;
    return ret;
  }

  /*
    bell number
  */
  int B(int n, int r) const {
    int ret = 0;
    for ( int i = 1; i <= r; i++ ) {
      (ret += S(n, i)) %= mod;      
    }
    return ret;
  }

  /*
    calc partition number
    return and make partition number table (part)
  */
  vector<vector<int> > built_part(int n, int r) {
    part = vector<vector<int> >(n+1, vector<int>(r+1, 0));
    part[0][0] = 1;
    for ( int i = 0; i <= n; i++ ) {
      for ( int j = 1; j <= r; j++ ) {
	if ( i-j >= 0 ) {
	  (part[i][j] = part[i][j-1]+part[i-j][j]) %= mod;	  
	} else {
	  part[i][j] = part[i][j-1];
	}
      }
    }
    return part;    
  }

  /*
    TODO 
    make built_part() that make only part[i][i]
    https://twitter.com/kirika_comp/status/953482654787149824
    http://d.hatena.ne.jp/DEGwer/20170829
    http://mathworld.wolfram.com/BellNumber.html
  }    
  */
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  const int MOD = 1e9+7;
  Combination comb(3000000, MOD);
  int ans = 0;
  for ( int r = r1; r <= r2; r++ ) {
    ans += comb.C(r+c2+1, c2);    
    ans -= comb.C(r+c1, c1-1);
    // cout << comb.C(r+c2+1, c2) << " " << comb.C(r+c1, c1) << endl;
    ans += MOD;
    ans %= MOD;    
  }

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


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

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

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

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

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

int main()
{
    int n,k,x,y;
    cin >> n >> k >> x >>y;
    int sum = 0;

    if(n <= k){
            for(int i = 0;i<n;++i)
    {
        sum = sum + x;
    }
        cout << sum;
    }
    else
    {
      for(int i = 0;i<k;++i)
    {
        sum = sum + x;
    }
    int p = n-k;
    while(p--)
        sum = sum + y;
    cout << sum;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Rev(a) reverse(a.begin(), a.end())
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  int n, a;
  cin >> n;
  vector<int> M(n);
  rep(i, n-1){
    cin >> a;
    if(M[a-1]!=0) M[a-1]+=1;
    else M[a-1]=1;
  }
  rep(i, n) cout << M[i] << endl;
}



Measured memory_bytes: 4048
n = int(input())

result = [0 for i in range(n+1)]

for i in range(1, n+1):
    for j in range(2, i+1):
        while i%j == 0:
            result[j] += 1
            i //= j
        if i == 1:
            break
r = 1
for i in range(n+1):
    r *= result[i]+1
    r %= 10**9 + 7
print(r)

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

using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int kol = 0;
    ll sum = 0;
    for(int  i = 0 ; i < s.size(); ++i){
        if(s[i] =='B'){
            ++kol;
            sum += i;
        }
    }
    ll a1 = s.size() - kol;
    ll an = s.size() - 1;
    ll sum1 = kol*(a1 + an)/2;
    cout<<sum1 - sum;
    return 0;
}


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

int main(){
    long long L,R;
    cin>>L>>R;
    long long ans=2019;
    long long l=(L-1)/2019, r=R/2019;
    if(r>l) ans=0;
    else{
        long long Lm=L%2019, Rm=R%2019;
        for(int i=Lm;i<Rm;i++){
            for(int j=i+1;j<=Rm;j++){
                if(i*j%2019<ans) ans=i*j%2019;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 3660
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, x := nextInt(), nextInt()

	if x <= 1 || x >= 2*n-1 {
		fmt.Println("No")
		return
	}

	values := make([]int, 0)
	for v := 2; v < 2*n-1; v++ {
		if v != x {
			values = append(values, v)
		}
	}

	fmt.Println("Yes")
	for i := 0; i < 2*n-1; i++ {
		switch {
		case i == n-2:
			fmt.Println(x)
		case i == n-1:
			switch {
			case x < n:
				fmt.Println(1)
			default:
				fmt.Println(2*n - 1)
			}
		case i == n:
			switch {
			case x < n:
				fmt.Println(2*n - 1)
			default:
				fmt.Println(1)
			}
		default:
			fmt.Println(values[0])
			values = values[1:]
		}
	}
}


Measured memory_bytes: 8704
#include <iostream>

using namespace std;

int main(){
  string S;
  cin >> S;
  if (S == "RRR")
    cout << "3" << endl;
  else if (S == "SRR" || S == "RRS")
    cout << "2" << endl;
  else if (S == "RSR"|| S == "SSR" || S == "RSS" || S == "SRS")
    cout << "1" << endl;
  else
    cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define umap unordered_map
#define flush fflush(stdout)
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define ln "\n"
#define all(v) v.begin(),v.end()
#define MAX 1000000009
#define MOD 1000000007
#define mid (start + end) / 2
#define R(ii) (ii + ii + 1)
#define L(ii) (ii + ii)
#define N 100005
using namespace std;
typedef pair<ll,ll> pp;
typedef vector<ll> vi;
ll n, q, k, t, x, y, a, b, c;
int main(){
    #ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    map <ll,ll> m;
    cin >> a >> b >> c;
    m[a]++;
    m[b]++;
    m[c]++;
    if(m[a] == 2 || m[b] == 2 | m[c] == 2){
        cout << "Yes";
        return 0;
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N,a,b;
  cin>>N;
  a=N/10;
  b=N/100;
  
  bool ans=false;
  if(N%10==7) {
    ans=true;
  }
  if(a%10==7) {
    ans=true;
  }
  if(b%10==7) {
    ans=true;
  }
  if(ans)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

template <class T> using vec_alias = ::std::vector<T>;
template <template <class> class Container> class union_find {
  protected:
    class node_type;

  public:
    using container_type = Container<node_type>;
    using size_type = typename container_type::size_type;

  protected:
    class node_type {
      public:
        typename union_find::size_type parent;
        typename union_find::size_type size;
    };

    container_type tree;

  public:
    union_find() : tree() {}
    explicit union_find(const size_type size) : tree(size, {0, 1}) {
        for(size_type i = 0; i < size; ++i)
            tree[i].parent = i;
    }

    bool empty() const { return tree.empty(); }
    size_type size() const { return tree.size(); }

    size_type find(size_type x) {
        assert(x < size());
        while(tree[x].parent != x)
            x = tree[x].parent = tree[tree[x].parent].parent;
        return x;
    }
    bool same(const size_type x, const size_type y) {
        assert(x < size());
        assert(y < size());
        return find(x) == find(y);
    }
    size_type size(const size_type x) {
        assert(x < size());
        return tree[find(x)].size;
    }

    ::std::pair<size_type, size_type> unite(size_type x, size_type y) {
        assert(x < size());
        assert(y < size());
        x = find(x);
        y = find(y);
        if(x != y) {
            if(tree[x].size < tree[y].size) ::std::swap(x, y);
            tree[x].size += tree[y].size;
            tree[y].parent = x;
        }
        return {x, y};
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    union_find<vec_alias> uf(N + 1);
    int a, b;
    rep(i, M) {
        cin >> a >> b;
        uf.unite(a, b);
    }

    int max = 0;
    rep(i, N) { chmax(max, int(uf.size(i))); }
    cout << max << endl;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  string a, b, c; 
  cin >> a >> b >> c;

  int cnt = 0;
  REP(i, n){
    if(a[i] == b[i]){
      if(b[i] == c[i]){
        
      } else {
        cnt++;
      }
    } else{
      if(b[i] == c[i]){
        cnt++;
      } else{
        if(a[i] == c[i]){
          cnt++;
        } else {
          cnt += 2;
        }
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	string O,E; cin>>O>>E;
	if(O.size() == E.size()){
	  for(int i = 0; i < O.size(); i++){
			cout<<O[i];
			cout<<E[i];
	  }
  }
	else if(O.size() > E.size()){
		rep(q , E.size()){
			cout<<O[q];
			cout<<E[q];
		}
		cout<<O[O.size() - 1];
	}
	/*else{
		rep(t , O.size()){
			cout<<O[t];
			cout<<E[t];
		}
		cout<<E[E.size() - 1];
	}*/
}


Measured memory_bytes: 256
N = int(input())
S = input()

cntE = [0] * N
cntW = [0] * N

if S[0] == 'E' :
    cntE[0] = 1
if S[N-1] == 'W' :
    cntW[N-1] = 1

for i in range(1, N) :
    cntE[i] = cntE[i-1]
    if S[i] == 'E' :
        cntE[i] += 1

for i in range(N-1)[::-1] :
    cntW[i] = cntW[i+1]
    if S[i] == 'W' :
        cntW[i] += 1

#print(cntE)
#print(cntW)
cntSum = list(map(sum, zip(cntE, cntW)))
#print(cntSum)
print(N - max(cntSum))


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

struct data{
  int key;
  struct data *right,*left,*parent;
};

struct data *root,*NIL;

struct data * find(struct data *u, int k){
  while(u != NIL && k != u -> key){
    if(k < u -> key){
      u = u -> left;
    }
    else{
      u = u -> right;
    }
  }
  return u;
}

void insert(int k){
  struct data *y = NIL;
  struct data *x = root;
  struct data *z;

  z = (struct data *)malloc(sizeof(struct data));
z -> key = k;
z -> left = NIL;
z -> right = NIL;

while(x != NIL){
  y = x;
  if(z -> key < x -> key){
    x = x -> left;
  }
  else{
    x = x -> right;
  }
}

z -> parent = y;
if(y == NIL){
  root = z;
}
else{
  if(z -> key < y -> key){
    y -> left = z;
  }
  else{
    y -> right = z;
  }
}
}

void inorder(struct data *cin){
  if(cin == NIL){
    return;
  }
  inorder(cin -> left);
  printf(" %d",cin -> key);
  inorder(cin -> right);
}

void preorder(struct data *cin){
  if(cin == NIL){
    return;
  }
  printf(" %d",cin -> key);
  preorder(cin -> left);
  preorder(cin -> right);
}

int main(){
  int num,i,x;
  char mozi[1000];

scanf("%d",&num);
for(i = 0;i < num;i++){
  scanf("%s",mozi);
  if(mozi[0] == 'f'){
    scanf("%d",&x);
    struct data *t = find(root,x);
    if(t != NIL){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  else if(strcmp(mozi,"insert") == 0){
    scanf("%d",&x);
    insert(x);
  }
  else if(strcmp(mozi,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
    return 0;
}



Measured memory_bytes: 20476
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;

using namespace std;

int n;
int a[100100];
int dp[100100];
void solve(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		dp[i] = inf;
		if(a[i] != i) dp[i] = dp[i-1] ;
		if(i > 1){
			int x = a[i-1];
			int y = a[i];
			if(x != i && y != i-1) dp[i] = min(dp[i-2] + 1, dp[i]);
		}
		if(i > 2){
			dp[i] = min(dp[i-3] + 2, dp[i]);
		}
	}
	printf("%d\n", dp[n]);
}


int main () {
    //cout << "Hello world\n";
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int h,w,a,b;
ll f[200010];
ll finv[200010];

ll c(ll n,ll m) {
    ll ret=f[n];
    ret=(ret*finv[n-m])%MOD;
    ret=(ret*finv[m])%MOD;
    return ret;
}

ll calc(ll i,ll j) {
    return c(i+j-2,i-1);
}

ll qp(ll x,ll n) {
    ll ret=1;
    while (n) {
        if (n&1) ret=(ret*x)%MOD;
        n=n>>1;
        x=(x*x)%MOD;
    }
    return ret;
}

int main() {
    scanf("%d%d%d%d",&h,&w,&a,&b);
    memset(f,0,sizeof(f));
    memset(finv,0,sizeof(finv));
    f[0]=finv[0]=1;
    for (int i=1;i<=200000;i++) {
        f[i]=(f[i-1]*i)%MOD;
        finv[i]=qp(f[i],MOD-2);
    }
    ll ans=0;
    for (int i=1;i<=w-b;i++) {
        ans=(ans+(calc(a,i)*calc(h-a,w-i+1))%MOD)%MOD;
        ans=(ans+MOD)%MOD;
    }
    printf("%lld\n",ans);
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


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


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int K, U, P, C;
	int ans = 10000;

	K = U = P = C = 0;

	do {
		switch(getchar()) {
			case 'K':
				K++;
				break;
			case 'U':
				U++;
				break;
			case 'P':
				P++;
				break;
			case 'C':
				C++;
				break;
			case '\n':
				goto END;
		}
	} while(1);

END:
	if(ans > K)
		ans = K;
	if(ans > U)
		ans = U;
	if(ans > P)
		ans = P;
	if(ans > C)
		ans = C;

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

	return 0;
}

Measured memory_bytes: 524
h,w = map(int,input().split())
ma = [list(map(int,input().split())) for _ in range(10)]
for i in range(10):
    for j in range(10):
        for k in range(10):
            ma[j][k] = min(ma[j][k], ma[j][i]+ma[i][k])
li = [list(map(int,input().split())) for _ in range(h)]
ans = 0
for each_li in li:
    for l in each_li:
        if l!=-1:
            ans += ma[l][1]
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int main(void)
{
    sync;
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for(int i=0;i<m;++i)
    {
        ll t;
        cin>>t;
        sum+=t;
    }
    n-=sum;
    cout<<(n>=0?n:-1)<<endl;
    return 0;
}

Measured memory_bytes: 3652
mark = ['S','H','C','D']
number = [str(x) for x in range(1,14)]
all_card = []
for m in mark:
    for n in number:
        c = m + ' ' + n
        all_card.append(c)
missing = all_card.copy()
for _ in range(int(input())):
    e_card = input()
    missing.remove(e_card)
for _ in missing:
    print(_)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int num[10][10];
int main()
{
	int x,y,i,j,n,sum=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		x=i%10; //末尾 
		y=i;  //首位 
		while(y>=10)
		{
			y=y/10;
		}
		num[y][x]+=1;
	}
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			int m=num[i][j]*num[j][i];
            sum+=m;
		}
	}
	cout<<sum;
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n;
int _pow26[12];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	_pow26[0] = 1;
	for(int i=1; i<12; i++) _pow26[i] = _pow26[i-1] * 26;
	for(int i=1; i<12; i++) {
		if (n > _pow26[i]) {
			n -= _pow26[i];
		} else {
			n -= 1;
			vector<int> ans(i);
			for(int j=0; j<i; j++) {
				ans[i-1-j] = n % 26;
				n /= 26;
			}
			for(int j=0; j<i; j++) cout << char(ans[j] + 'a');
			cout << endl;
			return 0;
		}
	}	

	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
vector<tuple<string, int, int>> sps;

map<string, vector<pair<int, int>>> mp;

bool cmp(const tuple<string, int, int> &a, const tuple<string, int, int> &b) {
  string str_a = get<0>(a);
  string str_b = get<0>(b);

  int pnt_a = get<1>(a);
  int pnt_b = get<1>(b);

  if (str_a == str_b) {
    return get<1>(a) > get<1>(b);
  }
  else {
    return get<0>(a) < get<0>(b);
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    string s;
    int p;

    cin >> s;
    scanf("%d", &p);

    mp[s].push_back(make_pair(p, i));
    sps.push_back(make_tuple(s, p, i));
  }

  for (auto &e: mp) {
    sort(e.second.begin(), e.second.end(), greater<pair<int, int>>());
  }

  // for (auto &e: mp) {
  //   for (auto &pr: e.second) {
  //     printf("%d\n", pr.second);
  //   }
  // }

  sort(sps.begin(), sps.end(), cmp);

  for (auto &e: sps) {
    printf("%d\n", get<2>(e));
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(tuple(map(int, input().split())))
F = np.array(tuple(map(int, input().split())))

if sum(A) <= K:
    print(0)
else:
    def solve(N, K, A, F):
        A = np.sort(A)
        F = np.sort(F)[::-1]
        l = -1
        r = 10**12
        while (r - l) > 1:
            mid = (r + l) // 2
            # 成績がmidだったとして、修行しなければならない回数を算出
            fmid = (np.fmax([0]*N, A - (mid // F))).sum()
            if fmid <= K:
                r = mid
            else:
                l = mid
        return(r)
    print(solve(N, K, A, F))

Measured memory_bytes: 37240
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    g[a-1].append([b-1,i])
    g[b-1].append([a-1,i])
from collections import deque
d = deque([(0,-1)])
ans = [0 for i in range(n-1)]
while d:
    a,noc = d.popleft()
    c = 1 if noc != 1 else 2
    for b,i in g[a]:
        if ans[i] == 0:
            ans[i] = c
            d.append((b,c))
        else:
            continue
        c += 1 if c+1 != noc else 2
print(max(ans))
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 84256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    cin>>s;
   // cout<<s.substr(0,n/2);
    if(n&1)cout<<"No";
    else
    {
        if(s.substr(0,n/2)==s.substr(n/2,n/2))cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 5;
ll n, m, t, a[MAXN];
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> n)
	{
		for (ll i = 1; i <= 9; ++i)
			for (ll j = 1; j <= 9; ++j)
				if (i*j == n)
				{
					cout << "Yes" << endl;
					return 0;
				}
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
st = [input() for _ in range(n)]
x = input()
s = [''] * n 
t = [0] * n
for i in range(n):
  s[i], t[i] = st[i].split()
  t[i] = int(t[i])
index_a = s.index(x)
result=0
for j in range(index_a+1, n):
  result += t[j]
print(result)

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

int main()
{
	long long int a,b,c,sum;
	cin >> a >> b >> c >> sum;

	int ans = 0;
	if(a >= sum){
        ans += sum;
	}
	else{
        ans += a;
	}
	sum = sum - a;
	if(sum <= 0){
        cout << ans << endl;
        return 0;
	}

	sum = sum - b;
	if(sum <= 0){
        cout << ans << endl;
        return 0;
	}

	if(c >= sum){
        ans -= sum;
	}
	else{
        ans -= c;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#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;

void solve()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(c >= a && c <= b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int main(){cin.tie(0);ios_base::sync_with_stdio(false);solve();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  vector<pair<int,int>> vec(n) ;
  REP(i,n){
    int a ;
    cin >> a ;
    vec.at(i) = MP(a,i+1) ;
  }
  
  sort(ALL(vec)) ;
  
  REP(i,n){
    cout << vec.at(i).SE <<" " ;
  }


  return 0 ;
}



Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p 998244353

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(MOD(a * a), N / 2);
	}
	else{
		return MOD(a * power(a, N - 1));
	}
}

signed main(){
	int N, i, ans;
	char *S = (char *)malloc(sizeof(char) * 200001);
	scanf("%s", S);
	for(i = 0; S[i] != '\0'; i++){}
	N = i;
	if(N == 2){
		if(S[0] == S[1]){
			ans = 1;
		}
		else{
			ans = 2;
		}
	}
	else if(N == 3){
		if(S[0] == S[1] && S[1] == S[2]){
			ans = 1;
		}
		else if(S[0] == S[1] || S[1] == S[2]){
			ans = 6;
		}
		else if(S[0] == S[2]){
			ans = 7;
		}
		else{
			ans = 3;
		}
	}
	else{
		int f1 = 1, f2 = 1;
		for(i = 1; i < N; i++){
			if(S[i - 1] != S[i]){
				f1 = 0;
			}
			else{
				f2 = 0;
			}
		}
		if(f1 == 1){
			ans = 1;
		}
		else{
			int sum = 0;
			for(i = 0; i < N; i++){
				sum += (int)S[i] - (int)'a';
			}
			sum %= 3;
			int j, k, l, m;
			int ***dp = (int ***)malloc(sizeof(int **) * N);
			for(i = 0; i < N; i++){
				dp[i] = (int **)malloc(sizeof(int *) * 3);
				for(j = 0; j < 3; j++){
					dp[i][j] = (int *)malloc(sizeof(int) * 3);
					for(k = 0; k < 3; k++){
						dp[i][j][k] = 0;
					}
				}
			}
			for(j = 0; j < 3; j++){
				for(k = 0; k < 3; k++){
					if(j == k){
						dp[0][j][k] = 1;
					}
					else{
						dp[0][j][k] = 0;
					}
				}
			}
			for(i = 1; i < N; i++){
				for(j = 0; j < 3; j++){
					for(k = 0; k < 3; k++){
						for(l = 0; l < 3; l++){
							for(m = 0; m < 3; m++){
								if(j != l && (k + l) % 3 == m){
									dp[i][l][m] = MOD(dp[i][l][m] + dp[i - 1][j][k]);
								}
							}
						}
					}
				}
			}
			ans = MOD(f2 + power(3, N - 1) - (dp[N - 1][0][sum] + dp[N - 1][1][sum] + dp[N - 1][2][sum]));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 26880
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)

typedef long long ll;

using namespace std;
int INF = 1000000000;

bool a[200005];
bool k[200005];



int main(){
  int n;
  vector<int> ans;


  cin >> n;

  rep1(i,n) cin >> a[i];

  repr1(i,n){
    if (a[i] == k[i]) continue;
    ans.push_back(i);
    for(int j=1 ; j*j<=i ; ++j){
      if(i%j == 0){
        k[j] ^= true;
        if (j!=1 && j*j!=i){
          k[i/j] ^= true;
        }
      }
    }
  }
  int s = ans.size();
  cout << s << endl;
  if (s != 0){
  rep(i,s-1){
    cout << ans[i] << ' ';
  }
  cout << ans[s-1] << endl;  
  }


  return 0;

}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    int n = stoi(s), tmp = 0;
    rep(i, s.size()) tmp += s[i] - '0';
    if (n % tmp) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

type Edge struct {
	to, w int
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	E := make([][]Edge, N)
	for i := 0; i < N-1; i++ {
		u, v, w := sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()
		E[u] = append(E[u], Edge{v, w})
		E[v] = append(E[v], Edge{u, w})
	}
	C := make([]int, N)
	C[0] = 0
	done := make([]bool, N)
	var search func(cur int)
	search = func(cur int) {
		done[cur] = true
		for i := 0; i < len(E[cur]); i++ {
			next, w := E[cur][i].to, E[cur][i].w
			if done[next] {
				continue
			}
			if w%2 == 0 {
				C[next] = C[cur]
			} else {
				C[next] = C[cur] ^ 1
			}
			search(next)
		}
	}

	for i := 0; i < N; i++ {
		if !done[i] {
			search(i)
		}
	}
	for i := 0; i < N; i++ {
		fmt.Fprintln(wtr, C[i])
	}
	wtr.Flush()
}


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a > 8 || b > 8) {
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }



    }

}

Measured memory_bytes: 22740
/**
 * @author torith
 * @date 2018-10-09
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

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

    int N;
    cin >> N;
    int a[10000];
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        while (a[i] % 2 == 0){
            ans++;
            a[i] >>= 1;
        }
    }
    cout << ans << "\n";
}


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

#define N 10000
#define INF 1000000000

typedef struct{
  int go; //go 前に進む
  int back; //back 後ろに戻る
  int c; //cost コスト
}Date;

int n, d[N];
Date A[500000+5];

void Root(int);

int main(){
  int i, j;
  int k, u;
	int count = 0;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k);
    for(j = 0 ; j < k ; j++){
      A[count].back = u;
      scanf("%d%d",&A[count].go,&A[count].c);
      count++;
    }
  }
  Root(count);

  for(i = 0 ; i < n ; i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

void Root(int x){
  int i;
	int flag = 1;

  for(i = 0 ; i < n ; i++) d[i] = INF;
  d[0] = 0;

  while(flag != 0){
    flag = 0;
    for(i = 0 ; i < x ; i++){
      if(A[i].c + d[A[i].back] < d[A[i].go]){
	d[A[i].go] = A[i].c + d[A[i].back];
	flag = 1;
      }
    }
  }
}



Measured memory_bytes: 7556
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int a,b,c;
    int x,y,z;
    cin >> x >> y >> z;
    a = x;
    b = y;
    c = z;
    int tmp;
    tmp = b;
    b = a;
    a = tmp;
    tmp = c;
    c = a;
    a = tmp;

    cout << a << " " << b << " " << c << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int P, N[6];
int solve(int x) {
	int ret = 0;
	ret += x / 500; x %= 500;
	ret += x / 100; x %= 100;
	ret += x / 50; x %= 50;
	ret += x / 10; x %= 10;
	ret += x / 5; x %= 5;
	return ret + x;
}
int main() {
	while (~scanf("%d", &P)) {
		if (P == 0) break;
		for (int i = 0; i < 6; i++) scanf("%d", &N[i]);
		int ret = 999999999;
		for (int i = 0; i < 500; i++) {
			int r = i + P, s = 0;
			s += min(r / 500, N[5]); r -= 500 * min(r / 500, N[5]);
			s += min(r / 100, N[4]); r -= 100 * min(r / 100, N[4]);
			s += min(r / 50, N[3]); r -= 50 * min(r / 50, N[3]);
			s += min(r / 10, N[2]); r -= 10 * min(r / 10, N[2]);
			s += min(r / 5, N[1]); r -= 5 * min(r / 5, N[1]);
			s += min(r, N[0]); r -= 1 * min(r, N[0]);
			if (r != 0) break;
			ret = min(ret, solve(i) + s);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2716