akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) ((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int main(){
  int x; cin >>x;
  print(360/gcd(360,x));
}





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

int N;
unsigned long int mod = 1000000007;

int solve()
{
	unsigned long int p = 1;
	for (int i = 1; i <= N; ++i)
	{
		p = (p * i) % mod; 
	}
	return p;
}

int main(int argc, char **argv)
{
	cin >> N;
	std::cout << solve()<< std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<queue>
#include<ctime>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,x,y,sum,vis[1000005];
priority_queue<pair<int,long long>/**/> pq;
int main()
{
	cin>>n;
	x=n;
	while (x)
	{
		m+=x%10;
		x/=10;
	}
	pq.push(make_pair(-1,1));
	while ((!pq.empty()))
	{
		x=pq.top().second;
		y=-pq.top().first;
		pq.pop();
		if (vis[x]) continue;
		vis[x]=1;
		if (y>=m)
		{
			cout<<m;
			return 0;
		}
		if (!(x%n))
		{
			cout<<y;
			return 0;
		}
		if (!vis[(x+1)%n]) pq.push(make_pair(-y-1,(x+1)%n));
		if (!vis[(x*10)%n]) pq.push(make_pair(-y,(x*10)%n));
	}
	cout<<m;
	return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;

int main(void){
	long n;
	int a;
	while(scanf("%d", &n) != EOF){
		vector<bool>p;
		for(int i = 0; i <= n; i++) p.push_back(true);
		p[0] = false;
		p[1] = false;
		for(int i = 2; i < sqrt(n)+1; i++){
			if(p[i]){
				for(int j = 0; i*(j+2) <= n; j++){
					p[i*(j+2)] = false;
				}
			}
		}
		int count = 0;
		for(int i = 2; i <= n; i++){
			if(p[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

long long n, a[1001][1001], f[1001];

void Process()
{
    int vis[1001], cou = 0, sinn = 0;
    for (int i=1; i<=n; i++) f[i] = 1;

    while (sinn == 0)
    {
        memset(vis, 0, sizeof(vis));    sinn = 1;

        for (int i=1; i<=n; i++)
        {
            if (i == a[a[i][f[i]]][f[a[i][f[i]]]] &&
                vis[i] == 0 && vis[a[i][f[i]]] == 0)
            {
                //cout << i << " " << a[i][f[i]] << " " << vis[i] << " " << vis[a[i][f[i]]] << endl;
                vis[i] = 1; vis[a[i][f[i]]] = 1;
                f[a[i][f[i]]]++;    f[i]++;
                sinn = 0;
            }
        }

        cou++;

//        for (int i=1; i<=n; i++) cout << f[i] << " ";
//        cout << endl << endl;
    }

    for (int i=1; i<=n; i++)
        if (f[i] != n) sinn = 0;

    if (sinn == 0) cout << -1;
        else cout << cou - 1;
}

void Input()
{
    ios_base::sync_with_stdio(0);   cin.tie(0);

    //freopen("abc.txt", "r", stdin);

    cin >> n;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=n-1; j++)
            cin >> a[i][j];
}

int main()
{
    Input();
    Process();
    return 0;
}


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

int main(){
  int sx, sy, tx, ty;
  string res = "";
  cin >> sx >> sy >> tx >> ty;
  for(int i = 0; i < ty - sy; i++) res += "U";
  for(int i = 0; i < tx - sx; i++) res += "R";
  for(int i = 0; i < ty - sy; i++) res += "D";
  for(int i = 0; i < tx - sx + 1; i++) res += "L";
  for(int i = 0; i < ty - sy + 1; i++) res += "U";
  for(int i = 0; i < tx - sx + 1; i++) res += "R";
  res += "DR";
  for(int i = 0; i < ty - sy + 1; i++) res += "D";
  for(int i = 0; i < tx - sx + 1; i++) res += "L";
  res += 'U';
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,p,d[100001];

int get_d(int a,int b){return (n+b-a)%n;}

int main(){
  cin>>n>>m>>p;
  d[m]=p;
  for(int i=0;i<m;i++)cin>>d[i];
  sort(d,++m+d);
  int st=0;
  while(d[st]!=p) st++;

  int ans=min(get_d(p,d[(m+st-1)%m]),get_d(d[(st+1)%m],p));
  for(int i=1;i<m;i++){
    int rl=(st+i)%m,lr=(m+st-i)%m;
    ans=min(ans,2*get_d(p,d[rl])+get_d(d[(rl+1)%m],p));
    ans=min(ans,2*get_d(d[lr],p)+get_d(p,d[(m+lr-1)%m]));
  }
  cout <<ans*100<<endl;
  return 0;
}

Measured memory_bytes: 1220
# B問題
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(input())
for i in range(H+2):
    if i == 0 or i == H+1:
        print('#'*(W+2))
    else:
        tmp = ''
        tmp = '#' + a[i-1]  + '#'
        print(tmp)


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

const int P = 998244353;
int cnt[100005];
pair<int, int> d[100005];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++) cin >> d[i].first, d[i].second = i;
	if(d[0].first != 0){
		cout << 0 << '\n';
		return 0;
	}
	sort(d, d + n);
	cnt[0] = 1;
	int ans = 1;
	for(int i = 1; i < n; i ++){
		if(d[i].first == 0) {
			ans = 0;
			break;
		}
		ans = 1LL * ans * cnt[d[i].first - 1] % P;
		cnt[d[i].first] ++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
sh = sorted(h, key=lambda x: x[2], reverse=True)

ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansB = True
        ansh = sh[0][2] + abs(sh[0][0] - i) + abs(sh[0][1] - j)
        for k in range(N):

            tmp = max(ansh - abs(sh[k][0] - i) - abs(sh[k][1] - j), 0)

            if tmp != sh[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
int N;
string S;
cin >> N;
cin >> S;

vector<int> W(N + 1, 0), E(N + 1, 0);

REP(i, N){
    int a = 0;
    if(S[i] == 'W') a = 1;
    W[i + 1] = W[i] + a;

    int b = 0;
    if(S[i] == 'E') b = 1;
    E[i + 1] = E[i] + b;
}

int ans = MOD;
REP(i, N){
    if(i == 0){
        ans = min(ans, E[N] - E[i + 1]);
    }else if(i == N - 1){
        ans = min(ans, W[i] - W[0]);
    }else{
        ans = min(ans, (W[i] - W[0]) + (E[N] - E[i + 1]));
    }
}

print(ans);
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll N;
void func(ll i,int check,ll &count){
   if(i>N)return ;
   if(check==0b111)count++;
   func(i*10+7,check|0b100,count);
   func(i*10+5,check|0b010,count);
   func(i*10+3,check|0b001,count);
}

int main(){
   cin>>N;
   ll res=0;
   func(0,0,res);
   cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << "  " << y << endl
#define dbg3(x, y, z) cout << x << "  " << y << "  " << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    int  n, m;
    cin >> n >> m;
    int arr[n];
    int sum = 0;
    f(i, 0, n){
        cin >> arr[i];
        sum += arr[i];
    }
    int limit= sum /(4*m);
    if(sum % (4*m) != 0){
        limit++;
    }
    sort(arr, arr+n);
    if(arr[n-m] >= limit){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n, a[101] ;
  scanf("%d", &n) ;

  int i, j ;
  for( i = 0 ; i < n ; i++ ){
    scanf("%d", &a[i]) ;
  }

  int tmp, cnt ;
  cnt = 0 ;
  for( j = 1 ; j < n ; ++j ){
    for( i = n-1 ; i >= j ; i-- ){
      //tmp = a[i] ;
      if( a[i-1] > a[i] ){
        tmp = a[i] ;
        a[i] = a[i-1] ;
        a[i-1] = tmp ;
        cnt += 1 ;
      }
    }
  }

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


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi d(n);
    rep(i,n) cin >> d[i];
    vi t(13);
    rep(i,n) t[d[i]]++;

    vi res = {0, 24};
    vi cand;
    rep(i,13){
        if(t[i] >= 3){
            cout << 0 << endl;
            return 0;
        }else if(t[i] == 2){
            res.push_back(i);
            res.push_back(24-i);
        }else if(t[i] == 1){
            if(i == 0 or i == 12){
                res.push_back(i);
            }else{
                cand.push_back(i);
            }
        }
    }

    int ans = 0;
    int len = cand.size();
    rep(i,1<<len){
        vi tmp = vi(res);
        rep(j,len){
            if(i>>j & 1) tmp.push_back(cand[j]);
            else tmp.push_back(24-cand[j]);
        }
        sort(all(tmp));
        int d = 24;
        rep(k,tmp.size()-1){
            d = min(d, tmp[k+1]-tmp[k]);
        }
        ans = max(ans, d);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0; i<n; ++i){
    int x;
    cin >> x;
    if(i%2) continue;
    if(x%2) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: f64,
    }
    let mut m = 100_f64;
    for i in 1.. {
        m = (m * 1.01).floor();
        if m >= x {
            println!("{}", i);
            return;
        }
    }
}


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

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; i < 10; i++ {
		for j := 1; j < 10; j++ {
			if i*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::cout << (n - 1) / 2 << std::endl;
}

Measured memory_bytes: 888
string = input()
flg = True
if len(string)  == 0:
  flg = False
if len(string) % 2 != 0:
  flg = False
for i in range(len(string)//2):
  if string[i*2:i*2+2] != 'hi':
    flg = False
    break
    
if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

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

int main() {
    string s;
    cin >> s;
    int ww = count(s.begin(), s.end(), 'W');
    long long ans = 0;
    for (int i = 0; i < (int) s.size(); ++i) {
        if (s[i] == 'B') {
            ans += ww++ - i;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{

    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            string str2 = Console.ReadLine();
            bool isOk = false;
            int j = 0;
            //syveryea
            //easy
            for (int i = 0; i < str1.Length; i++)
            {
                while (true)
                {
                    if (i + j < str1.Length)
                    {
                        if (str1[i + j] == str2[j])
                        {
                            j++;
                            if (j == str2.Length)
                            {
                                j = 0;
                                isOk = true;
                                break;
                            }
                        }
                        else
                        {
                            j = 0;
                            break;
                        }
                    }
                    else
                    {
                        if (str1[i + j - str1.Length] == str2[j])
                        {
                            j++;
                            if (j == str2.Length)
                            {
                                j = 0;
                                isOk = true;
                                break;
                            }
                        }
                        else
                        {
                            j = 0;
                            break;
                        }
                    }
                }
            }
            if (isOk)
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 8908
# 雑に考えたら前半と後半も回文になってるってことなので判定して終了
s = input()
if s != "".join(reversed(list(s))):
    print("No")
    exit()
pre = s[:len(s) // 2]
epi = s[len(s) // 2 + 1:]

if pre == "".join(reversed(pre)) and epi == "".join(reversed(epi)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
a=input()
if a=='SUN':
  print(7)
elif a=='MON':
  print(6)
elif a=='TUE':
  print(5)
elif a=='WED':
  print(4)
elif a=='THU':
  print(3)
elif a=='FRI':
  print(2)
else:
  print(1)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll N;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	ll countOdd;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if(a % 2 != 0) countOdd++;
	}

	if(countOdd % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int h, w; cin >> h >> w;
    vector<string> s(h); cin >> s;
    int dy[] = { -1,-1,-1,0,0,1,1,1 };
    int dx[] = { -1,0,1,-1,1,-1,0,1 };
    FOR(y, 0, h)FOR(x, 0, w) {
        if (s[y][x] == '#')continue;
        int cnt = 0;
        FOR(k, 0, 8) {
            int ny = y + dy[k], nx = x + dx[k];
            if (out(ny, nx))continue;
            if (s[ny][nx] == '#')++cnt;
        }
        s[y][x] = char('0' + cnt);
    }
    FOR(i, 0, h)cout << s[i] << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    int a,b,c;
    vector<int> gcd_list;
    for(a = K;a >= 1;a--){
        for(b = a;b >= 1;b--){
            for(c = b;c >= 1;c--){
                auto gcd_number= gcd(gcd(a,b),c);
                if(!(a == b && b == c)){
                    if(a != b && a != c && b != c){
                        gcd_number *= 6;
                    }else{
                        gcd_number *= 3;
                    }
                }
                gcd_list.push_back(gcd_number);
            }
        }
    }
    cout << accumulate(gcd_list.begin(),gcd_list.end(),0) << endl;
}

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

using namespace std;

int main()
{
	string ans;

	while (true)
	{
		string s;
		cin >> s;

		if (s == "0")
			break;

		int sum = 0;
		for (int i = 0; i < s.size(); ++i)
			sum += (s[i] - '0');

		ans += to_string(sum) + "\n";
	}

	cout << ans;

	return 0;
}

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

double dp[60][60];
int v[60];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",v+i);
	sort(v,v+n);
	for(int i=0;i<n;i++)
		dp[i][i]=v[i];
	for(int i=1;i<n;i++)
		for(int j=0;j+i<n;j++)
			for(int k=0;k<i;k++)
				dp[j][j+i]=max(dp[j][j+i],(dp[j][j+k]+dp[j+k+1][j+i])/2);
	printf("%.6lf",dp[0][n-1]);
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  string T;
  rep(i, N) {
    if (i >= 1 && S[i - 1] != S[i]) T += S[i];
  }
  cout << T.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	string a, s, b;
	cin >> a >> s >> b;
	cout << a[0] << s[0] << b[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		for (int i = 1; i <= N; i++) {
			x[i] = sc.nextInt();
		}
		long[][][] dp = new long[N + 1][N + 1][N * A + 1];
		dp[0][0][0] = 1;

		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N; j++) {
				for (int k = 0; k <= N * A; k++) {
					if (i != 0) {
						dp[i][j][k] = dp[i - 1][j][k];
					}
					if (i > 0 && j > 0 && k >= x[i]) {
						dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
					}
				}
			}
		}
		long ans = 0;

		for (int i = 1; i <= N; i++) {
			ans += dp[N][i][i * A];
		}

		System.out.println(ans);
	}

}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        string cmd;
        cin >> cmd;
        int a, b;
        string p;
        if (cmd == "print") {
            cin >> a >> b;
            cout << s.substr(a, b - a + 1) << endl;
        } else if (cmd == "reverse") {
            cin >> a >> b;
            reverse(s.begin() + a, s.begin() + b + 1);
        } else if (cmd == "replace") {
            cin >> a >> b >> p;
            int cnt = 0;
            for (int i = a; i <= b; i++) {
                s[i] = p[cnt++];
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,q,i;
  cin >> n;
  vector<int> a(n);
  for(i = 0; i < n; ++i) cin >> a[i];
  cin >> q;
  while(q--) {
    int b, m, e;
    cin >> b >> m >> e;
    rotate(a.begin()+b, a.begin()+m, a.begin()+e);
  }
  for(i = 0; i < n; ++i) cout << a[i] << " \n"[i==n-1];
}


Measured memory_bytes: 3164
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        String b = scanner.next();
        int c = scanner.nextInt();

        if(b.equals("+") == true){
            System.out.println(a + c);
        }else
            System.out.println(a - c);


    }





}




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

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 500010, inf = 1e9;
int p[N], a[N];
struct node {
	int to, nxt;
} g[N << 1];
int lst[N], gl, d[N], n, k;
void add(int x, int y) { g[++gl] = (node) {y, lst[x]}; lst[x] = gl; d[y]++; }
int t[N << 2];
#define lson (o << 1)
#define rson (o << 1 | 1)
void build(int o, int l, int r) {
	t[o] = inf; if (l == r) return ;
	int mid = (l + r) >> 1;
	build(lson, l, mid); build(rson, mid + 1, r);
}
void Modify(int o, int l, int r, int p, int k) {
	t[o] = k; if (l == r) return ;
	int mid = (l + r) >> 1;
	if (p <= mid) Modify(lson, l, mid, p, k);
	else Modify(rson, mid + 1, r, p, k);
}
int Query(int o, int l, int r, int L, int R) {
	if (R < l || L > r || L > R) return inf;
	if (L <= l && r <= R) return t[o];
	int mid = (l + r) >> 1, res = inf;
	if (L <= mid) res = Query(lson, l, mid, L, R);
	if (R > mid) res = min(res, Query(rson, mid + 1, r, L, R));
	return res;
}
struct cmp { bool operator () (int x, int y) { return a[x] > a[y]; } };
priority_queue<int, vector<int>, cmp> q;
int main() {
	read(n), read(k);
	for (int i = 1; i <= n; i++) read(p[i]);
	for (int i = 1; i <= n; i++) a[p[i]] = i;
	build(1, 1, n);
	for (int i = n, p; i >= 1; i--) {
		p = Query(1, 1, n, a[i] + 1, a[i] + k - 1);
		if (p != inf) add(i, p);
		p = Query(1, 1, n, a[i] - k + 1, a[i] - 1);
		if (p != inf) add(i, p);
		Modify(1, 1, n, a[i], i);
	}
	for (int i = 1; i <= n; i++)
		if (!d[i]) q.push(i);
	n = 0;
	while (!q.empty()) {
		int u = q.top(); q.pop();
		p[++n] = a[u];
		for (int i = lst[u]; i; i = g[i].nxt) {
			int v = g[i].to;
			if (!(--d[v])) q.push(v);
		}
	}
	for (int i = 1; i <= n; i++) a[p[i]] = i;
	for (int i = 1; i <= n; i++)
		printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 27512
import math

n, w = map(int, input().split())
weights = []
costs = []
for i in range(n):
    a,b = map(int, input().split())
    weights.append(a)
    costs.append(b)
dp = [[0 for i in range(w+1)] for i in range(n)]
for i in range(w+1):
    if(i>= weights[0]):
        dp[0][i] = costs[0]

for i in range(1, n):
    for j in range(w+1):
        if(j >= weights[i]):
            val = max(dp[i-1][j], costs[i]+dp[i-1][j-weights[i]])
            dp[i][j] = val
        else:
            dp[i][j] =max(dp[i][j], dp[i-1][j])
print(dp[-1][-1])

Measured memory_bytes: 218640
#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;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  int ans = x;
  rep(i, n){
    if(s.at(i) == 'I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<long long> A(N),sum(100009);
  for(int i=0;i<N;i++){cin >> A[i];}
  sort(A.begin(),A.end());
  for(int i=0;i<N;i++){sum[i]=0;}
  sum[0]=A[0];
  for(int i=1;i<N;i++){sum[i]=sum[i-1]+A[i];}
  int j;
  for(j=N-2;j>=0;j--){
    if(A[j+1]>sum[j]*2){break;}
  }
  cout << N-j-1 << endl;
}

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

int lcs_number(string a1, string a2){
	int n1=a1.size()+1, n2=a2.size()+1;	
	vector <vector <int> > A(n1, vector <int> (n2));

	for (int i1=0; i1<n1; i1++)
		for (int i2=0; i2<n2; i2++)
			if (i1==0 || i2==0) A[i1][i2]=0;
			else if (a1[i1-1]==a2[i2-1])
				A[i1][i2]=A[i1-1][i2-1]+1;
			else if (A[i1-1][i2]>A[i1][i2-1])
				A[i1][i2]=A[i1-1][i2];
			else
				A[i1][i2]=A[i1][i2-1];
	return A[n1-1][n2-1];
}

int main(void){
	int n;
	string text1, text2;
	cin>>n;

	for (int i=0; i<n; i++){
		cin>>text1;
		cin>>text2;
		cout<<lcs_number(text1, text2)<<endl;
	}

	return 0;
} 

Measured memory_bytes: 5040
N = int(input())
A,B = map(int,input().split())

lis = [0,0,0]

P = list(map(int,input().split()))

for i in P:
  if i <= A:
    lis[0] += 1
  elif i <= B:
    lis[1] += 1
  else:
    lis[2] += 1
    
print (min(lis))

Measured memory_bytes: 3064
nnk = list(map(lambda x: int(x), input().split(" ")))
n = nnk[0]
k = nnk[1]

hs = [int(input()) for l in range(n)]
hs.sort()

num = n - k + 1

hmmm = []
for l in range(num):
    hmmm.append(hs[k+l-1] - hs[l])

hmmm.sort()
print(hmmm[0])

Measured memory_bytes: 11292
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string a,b;
        cin>>a>>b;
        int al=a.length();
        int bl=b.length();
        int dp[1005][1005];
        memset(dp,0,sizeof(dp));
       // for(int i=0;i<=al;i++)
           // dp[i][0]=0;
       // for(int i=0;i<=bl;i++)
            //dp[0][i]=0;
        for(int i=1;i<=al;i++)
            for(int j=1;j<=bl;j++)
            {
                if(a[i-1]==b[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
                else
                    dp[i][j]=std::max(dp[i-1][j],dp[i][j-1]);
                    
            }
        cout<<dp[al][bl]<<endl;
    }
    return 0;
}



Measured memory_bytes: 7100
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int N = s.size();
  int ans = 0;
  for(int i = 0; i < N; i++){
    ans += (int)(s[i] - '0');
  }

  if(ans == 1){
    cout << 10 << endl;
  }
  else{
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, c;
vector<P> st[30], st2;
 
int main(int argc, char **argv) {
	cin >> n >> c;
	REP(i, n) {
		ll ts, tt, tc;
		cin >> ts >> tt >> tc;
		--tc;
		st[tc].push_back(P{ts, tt});
	}
	REP(i, c) sort(ALL(st[i]));
	REP(i, c) {
		if (st[i].size() == 0) continue;
		ll l = st[i][0].F;
		REP(j, st[i].size()-1) if (st[i][j].S < st[i][j+1].F) {
			st2.push_back(P(l, -1));
			st2.push_back(P(st[i][j].S, 1));
			l = st[i][j+1].F;
		}
		st2.push_back(P{l, -1});
		st2.push_back(P{st[i][st[i].size()-1].S, 1});
	}
	sort(ALL(st2));
	ll res = 0, cnt = 0;
	REP(i, st2.size()) {
		cnt -= st2[i].S;
		res = max(res, cnt);
	}
	cout << res << endl;
	return 0;
}
 

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

# 1から始まるNまでの連続数を生成して配列に入れる
L = []
for i in range(N):
    L.append(i + 1)

cntArray = []
maxNum = 0
i_when_max = 0
for i in range(len(L)):
    cnt = 0
    while L[i] % 2 == 0:
        cnt += 1
        L[i] = L[i] / 2
    cntArray.append(cnt)
    if cntArray[i] > maxNum:
        maxNum = cntArray[i]
        i_when_max = i

L = []
for i in range(N):
    L.append(i + 1)
print(L[i_when_max])
    

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#define MAX_H 10
#define MAX_W 10

int h, w, c, cnt, ans;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

using namespace std;

int in_map(int x, int y)
{
  return (0 <= x && x < w && 0 <= y && y < h);
}

void connection(vector< vector<int> > &map, int x, int y, int color, int sc)
{
  int xx, yy;

  map[y][x] = color;

  for(int i = 0; i < 4; i++)
    {
      xx = x + dx[i];
      yy = y + dy[i];
      if(in_map(xx, yy) && map[yy][xx] == sc && map[yy][xx] != color)
	connection(map, xx, yy, color, sc);
     }
  return ;
}

void count(vector< vector<int> > &map, int x, int y)
{
  map[y][x] = -1;
  int xx, yy;
  cnt++;
  for(int i = 0; i < 4; i++)
    {
      xx = x + dx[i];
      yy = y + dy[i];
      if(in_map(xx, yy) && map[yy][xx] == c)
	count(map, xx, yy);
    }
}

void dfs(vector< vector<int> > map, int depth)
{
  if(depth >= 4)
    {
      connection(map, 0, 0, c, map[0][0]);
      for(int  i = 0; i < h; i++)
	for(int j = 0; j < w; j++)
	  {
	    if(map[i][j] == c)
	      {
		count(map, j, i);
		ans = (cnt > ans)? cnt: ans;
		cnt = 0;
	      }
	  }
    }
  else
    {
      for(int i = 1; i <= 6; i++)
	{
	  vector < vector <int> > map_bk = map;
	  connection(map_bk, 0, 0, i, map_bk[0][0]);
	  dfs(map_bk, depth + 1);
	}
    }
}

int main(void)
{
  vector< vector<int> > map;
  
  while(1)
    {
      cin >> h;
      cin >> w;
      cin >> c;

      if(h == 0 && w == 0)
	break;

      map.resize(h);
      for(int i = 0; i < h; i++)
	map[i].resize(w);

      for(int i = 0; i < h; i++)
	for(int j = 0; j < w; j++)
	  cin >> map[i][j];

      dfs(map, 0);

      cout << ans << endl;

      ans = 0;
    }
  return 0;
}

Measured memory_bytes: 1236
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9+7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

vector<pair<int,ii>> e;
int l[N],r[N];
// End Times of Movies People Are Watching Means When They Are Free.
multiset<int> pq;

void solve () {
    string s;cin>>s;
    string t;cin>>t;
    int n = s.length();
    bool ok = true;
    for (int i=0;i<n;i++) {
        if (s[i] != t[i]) {
            ok = false;
            break;
        }
    }
    if (sz(t) != n+1) ok = false;
    if (ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,T;
  cin>>N>>T;
  int ans=T,memo;
  cin>>memo;
  rep(i,1,N){
    int X;
    cin>>X;
    ans+=min(T,X-memo);
    memo=X;
  }
  cout<<ans<<endl;
  }



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


int main() {
  string s;
  cin>>s;
  ll mod=1e9+7,a=1,amari=0;
  ll n=s.size();
  ll dp[100100][13];
  dp[0][0]=1;
  rep(i,12) dp[0][i+1]=0;
  
  for(ll i=0; i<n; i++){
    int c=0;
    if(s[i]=='?'){
      c=-1;
    }else{
      c=s[i]-'0';
    }
    for(int j=0; j<10; j++){
      ll num=0;
      if(c!=-1&&c!=j)
        continue;
      for(int k=0; k<13; k++){
        num=(k*10+j)%13;
        dp[i+1][num]+=dp[i][k];
      }
      rep(k,13)
        dp[i+1][k]%=mod;
    }
  }
      
  cout<<dp[n][5]<<endl;   
  
}

Measured memory_bytes: 10624
#include <iostream>

#define INF 100000000

using namespace std;

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

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

	for(int i = 0; i < n - 1; i++) {
		int tmp;
		cin >> tmp;
		
		arr[i] = min(arr[i], tmp);
		arr[i + 1] = min(arr[i + 1], tmp);
	}

	long long total = 0;

	for(int i = 0; i < n; i++) total += arr[i];

	cout << total << endl;

	return 0;
}

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

int main() {
    int h,w;
    char c[52][52] = {{'.'}};
    cin>>h>>w;
    for(int i =0; i<w;i++)
        cin>>c[i];
    for(int i =0;i<h;i++){
        for(int j = 0;j<w;j++){
            if((c[i][j]=='#')&&(c[i][j+1]=='.')&&(c[i][j-1]=='.')&&(c[i+1][j]=='.')&&(c[i-1][j]=='.')){
                cout<<"No\n";
                return 0;
            }
        }
    }
    cout <<"Yes\n";
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
//#define S set<int>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  SCIN(s);
  ll cou = 1LL+1LL * s.size() * (s.size()-1) / 2;
  M m;
  REP(i,s.size())
    m[s[i]]++;
  FOREACH(xx,m){
    cou -= 1LL*xx.second * (xx.second-1) / 2;
  }
  COUT(cou);
  return 0;
}


Measured memory_bytes: 640
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, a[maxN], b[maxN], xorSum, cntCyc, cntVtx;
map<int, int> id;
bool haveSum, visited[maxN];
vector<int> g[maxN];

void DFS(int u) {
    ++cntVtx;
    visited[u] = true;
    if (u == id[xorSum]) haveSum = true;
    for(int v: g[u]) {
        if (!visited[v]) DFS(v);
    }
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);
    fto(i, 1, n) scanf("%d", &b[i]);

    multiset<int> s;
    fto(i, 1, n) {
        s.insert(a[i]);
        xorSum ^= a[i];
    }
    s.insert(xorSum);

    for(int x: s) {
        if (!id[x]) id[x] = sz(id);
    }

    bool ok = true;
    fto(i, 1, n) {
        if (s.find(b[i]) == s.end()) {
            ok = false;
            break;
        }
        s.erase(s.find(b[i]));
    }

    if (!ok) {
        puts("-1");
        return 0;
    }

    int ans = 0;
    fto(i, 1, n) {
        if (b[i] != a[i]) {
            ++ans;
            g[id[b[i]]].pb(id[a[i]]);
        }
    }

    //forit(it, id) printf("%d %d\n", it->ff, it->ss);
    DFS(id[xorSum]);
    fto(u, 1, sz(id)) {
        if (!visited[u]) {
            cntVtx = 0;
            haveSum = false;
            DFS(u);
            //printf("%d %d %d\n", u, cntVtx, haveSum);
            if (cntVtx > 1 && !haveSum) ++ans;
        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 19200
#include<stdio.h>

long long count(long long int c){
    int n=0;
    while(c!=1){
        if(c%2==0)c/=2;
        else c=3*c+1;
        n++;
    }
    return n;
}

int main()
{

    long long int aa,bb,a,b,t,i,max;

    while(~scanf("%lld",&aa) && aa){
        printf("%lld\n",count(aa));
    }
    return 0;
}

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

int main() {
  int N;
  string moji;
  cin >> N;
  cin >> moji;
  int count = 0;
  for(int i = 0 ; i < N-2 ; i++){
  	if( moji.at(i) == 'A' && moji.at(i+1) == 'B' && moji.at(i+2) == 'C'){
    	count++;
    }      
  }
  cout << count << endl;
}

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    void solve(){
        int n;
        cin>>n;
        int k;
        cin>>k;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=k;i<n;i++){
            if(a[i]>a[i-k])
                cout<<"Yes"<<"\n";
            else
                cout<<"No"<<"\n";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("alchemy_input.txt", "r", stdin);
//        freopen("alchemy_output.txt", "w", stdout);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int a[100002][4];
long long int dp[100002][4][3];
long long int solve(long long int index,long long int activity,long long int count)
{
    if(index==n)
    return 0;
    if(dp[index][activity][count]!=-1)
    return dp[index][activity][count];
    long long int ans=0;
    for(int i=0;i<=2;i++)
    {
        if(count==0)
        {
            ans=max(ans,solve(index+1,i,1)+a[index][i]);
        }
        else if(count==1)
        {
            if(activity==i)
            continue;
            ans=max(ans,solve(index+1,i,1)+a[index][i]);
        }
    }
    return dp[index][activity][count]=ans;
}
int main()
{
    long long int i,j,k,x,y,z;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
    for(i=0;i<=100000;i++)for(j=0;j<=3;j++)for(k=0;k<=2;k++)dp[i][j][k]=-1;
    cout<<solve(0,0,0);
    return 0;
}


Measured memory_bytes: 20608
function main()
  h, w, k = parse.(Int, split(readline()))
  
  c = String[]
  for i in 1:h
    push!(c, readline())
  end
  
  ans = 0
  for i in 0:2^(h+w)-1
    cnt = 0
    for x in 1:h
      for y in 1:w
#        println(i >> (x-1), i >> (y+h-1))
        if (i >> (x-1) ) % 2 == 0 || (i >> (y+h-1)) % 2 == 0
          continue
        elseif c[x][y] == '#'
          cnt += 1
        end
      end
    end
    
    if k == cnt
      ans += 1
    end
  end
  
  println(ans)
end

main()

Measured memory_bytes: 175608
#include <cstdio>
using namespace std;

int main() {
	int n, t[101] = {}, v[101] = {}, i;
	long area, speed = 0, distance4x = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &t[i]);
	}
	for (i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	for (i = n - 1; i >= 0; i--) {
		if (v[i] - v[i + 1] > t[i]) {
			v[i] = v[i + 1] + t[i];
		}
	}
	for (area = 0; area < n; area++) {
		for (i = 1; i <= t[area]; i++) {
			if (speed > v[area + 1] + (t[area] - i)) {
				speed--;
				distance4x += 2 + 4 * speed;
			}
			else if ((speed + 1 > v[area + 1] + (t[area] - i)) && speed < v[area]) {
				distance4x += 1 + 4 * speed;
			}
			else if (v[area] == speed) {
				distance4x += 4 * speed;
			}
			else {
				speed++;
				distance4x += 4 * speed - 2;
			}
		}
	}
	printf("%f", (double)distance4x / 4.0);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[200000]={},num1=0,num2=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    if(num1<a[i]) {
      num2=num1;
      num1=a[i];
    }
    else if(num2<a[i]) {
      num2=a[i];
    }
  }
  for(int i=0; i<n; i++) {
    if(a[i]!=num1) {
      cout << num1 << endl;
    }
    else {
      cout << num2 << endl;
    }
  }
}

Measured memory_bytes: 2432