akhauriyash/Code-Regression huggingface dataset:
/* include */
#include <bits/stdc++.h>

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

#define space cout << endl;
#define test_data(data) cout << data << endl;
#define test_comp(var1, var2) cout << var1 << " " << var2 << endl;

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int data;    // input

  int i;    // subscript

  int bit;
  vector<int>  num(4);
  vector< vector<char> > op( (1<<3), vector<char>(3));

  int  sum; 
  int  ans_bit;


  /* Input, Array_Proclamation */
  cin >> data;


  /* Initialize */
  ans_bit = -1;
  
  for(i=0; i<4; i++)
  {
    num.at(i) = data % 10;
    data /= 10;
  }
  reverse( all(num) );


  /* Calculation */


  for(bit = 0;  bit < (1<<3);  bit++)
  {

    sum = num.at(0);

    for(i=0; i<3; i++)
    {
      ( bit & (1<<i) )?             op.at(bit).at(i) = '+':  op.at(bit).at(i) = '-';
      ( op.at(bit).at(i) == '+' )?  sum += num.at(i+1):      sum -= num.at(i+1);
    }

    if(sum == 7)
    {
      ans_bit = bit;
      break;
    }

  }
  
  


  /* Output */
  cout << num.at(0);
  rep(i, 3)
  {
    cout << op.at(ans_bit).at(i);
    cout << num.at(i+1);
  }
  cout << "=7" << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)
//__builtin_popcountll()



int main(){

    fast;
    int n,i,j;
    cin>>n;
    int x,y;
    vector<int>v1,v2;
    for(i=0;i<n;i++)
    {
    	cin>>x>>y;
    	v1.pb(x+y);
    	v2.pb(x-y);
	}
	sort(all(v1));
	sort(all(v2));
	cout<<max(abs(v1[n-1]-v1[0]),abs(v2[n-1]-v2[0]));

    

}

Measured memory_bytes: 5108
ns=[]

for i in range(4):
  ns.append(input())

n=[]

for j in range(4):
  n.append(int(ns[j]))

if n[0]<=n[1]:
  print(n[2]*n[0])
else:
  print(n[2]*n[1]+n[3]*(n[0]-n[1]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;cin >> n >> m;
    string ans(n,'0');
    map<char,char>mp;
    bool ok = 1;
    for(int i = '0';i<='9';i++) mp[i] = 'a';
    for(int i = 0;i<m;i++){
        char a,b;cin >> a >> b;
        if(a=='1'&&b=='0'&&n>1){ok = 0;}
        if(mp[a]=='a') mp[a] = b;
        else if(mp[a]!=b) {ok = 0;}
        else continue;
        ans[a-'0'-1] = b;
        //cout << ans[a-'0'-1]<<endl;
    }
    if(ans[0] == '0'&&n>1) ans[0] = '1';
    if(!ok) cout << -1;
    else cout << ans;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,x;
    cin>>n>>x;
    vector<int> m(n,0);
    int ans=n;
    for(int i=0;i<n;i++){
        cin>>m[i];
        x-=m[i];
    }
    sort(m.begin(),m.end());
    ans+=x/m[0];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); 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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vl P(N);
    rep(i, N) cin >> P[i];

    vc<ld> A(N);
    rep(i,N){
        A[i] = (ld)(P[i] + 1) / 2.0 ;
    }

    ld ans = 0, tmp=0;
    rep(i, K) tmp += A[i];
    ans = tmp;

    repe(i,K,N){
        tmp += A[i] - A[i - K];
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import sys
import numpy as np
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    l=np.array([(1/2)**(-(-np.log2(K/i if K/i > 1 else 1)//1)) for i in range(1,N+1)])
    print(np.sum(l)/N)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 16988
#include <stdio.h>
int main(){
  char o[51], e[51];
  scanf("%s%s", o, e);
  char c = o[0];
  int cnt = 1;
  int idx = 0;
  while(c != '\0' && c != '\n'){
    putchar(c);
    cnt = 1 - cnt;
    if(cnt == 1){
      idx++;
      c = o[idx];
    }else{
      c = e[idx];
    }
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int main()
{
  fastio;
  int n;
  cin>>n;
  vector<int> h(n);
  vector<int> d(n);
  for(int i=0;i<n;i++)
    cin>>h[i];
  d[0]=0;d[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
    d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) );
  cout<<d[n-1];
}
 


Measured memory_bytes: 1024
hp = gets.to_i

if hp == 1
  puts hp
else
  i = 0
  count = 0
  while hp > 0
    hp = (hp / 2.to_f).floor
    if i == 0
      count += 1
    else
      count += 2**i
    end
    i += 1
  end
  puts count
end




Measured memory_bytes: 1788
S = input()
flag = 1
if S[0] != 'A':
    flag = 0
if not 'C' in S[2:-1]:
    flag = 0
cnt = 0
for i in S:
    if i in [chr(i) for i in range(65, 65+26)]:
        cnt += 1
if cnt != 2:
    flag = 0
if flag:
    print('AC')
else:
    print('WA')

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

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

    while (1) {
        int N, M, r, q;
        cin >> N >> M;
        if (!N & !M) break;
        vector<vector<int>> imosu(M, vector<int>(1000, 0));
        vector<vector<int>> question;
        cin >> r;
        for (int i = 0; i < r; i++) {
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if (s)
                imosu[m - 1][t - 540] += 1;
            else
                imosu[m - 1][t - 540] -= 1;
        }
        for (int i = 0; i < imosu.size(); i++) {
            for (int j = 1; j < imosu[i].size(); j++) {
                imosu[i][j] = imosu[i][j] + imosu[i][j - 1];
            }
        }

        cin >> q;
        for (int i = 0; i < q; i++) {
            int Ts, Te, m;
            cin >> Ts >> Te >> m;
            int ans = 0;
            for (int j = Ts - 540; j < Te - 540; j++) {
                if (imosu[m - 1][j] > 0) ans++;
            }
            cout << ans << endl;
        }
    }
}



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

int main(){
  int a,b,c,d,ans=0;
  cin >> a >> b >> c >> d;
  
  vector<bool> x;
  x.resize(max(b,d));
  
  for(int i = a; i < b; i++) x[i] = true;
  for(int j = c; j < d; j++) if(x[j] == true) ans++;
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h;
	cin>>h;
	ll cnt2=1,sum=0;
	while(h>0){
		h/=2;
		sum+=cnt2;
		cnt2*=2;
	}
	cout << sum;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
fn read_number() -> Result<usize, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = try!(line.trim().parse::<usize>().map_err(|err| err.to_string()));
    Ok(n)
}

fn read_number_each_line(n: usize) -> Result<Vec<i32>, String> {
    (0..n)
        .map(|_| read_number().map(|x| x as i32))
        .collect::<Result<Vec<i32>, String>>()
}

fn read_numbers() -> Result<Vec<i32>, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let numbers = line.split_whitespace()
        .map(|x| x.parse::<i32>().ok().unwrap())
        .collect();
    Ok(numbers)
}

fn generate_adjacency(inputs: Vec<Vec<i32>>) -> () {
    let n_nodes = inputs.len();
    let mut matrix = vec![vec![0; n_nodes]; n_nodes];

    for line in inputs {
        // println!("{:?}", line);
        let i_node = line[0];
        let n_out = line[1];

        for i_out in 0..n_out {
            // println!("{} {}", (i_node - 1) as usize, (i_out - 1) as usize);
            matrix[(i_node - 1) as usize][(line[2 + i_out as usize] - 1) as usize] = 1;
        }
    }

    for row in matrix {
        for (i_col, e) in row.iter().enumerate() {
            print!("{}", e);
            if i_col < row.len() - 1 {
                print!(" ");
            }
        }
        println!("");
    }
}

fn main() {
    let n = match read_number() {
        Ok(num) => num,
        Err(err) => panic!("{:?}", err),
    };

    let numbers = (0..n)
        .map(|_i| read_numbers())
        .collect::<Result<Vec<Vec<i32>>, String>>();

    match numbers {
        Ok(x) => generate_adjacency(x),
        Err(err) => panic!("{:?}", err),
    }
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll gcd(ll a, ll b) 
{ 
    if (a == 0ll) 
        return b; 
   	
    return gcd(b % a, a); 
 }
int main()
{
    chutiyaap;
    ll k;cin>>k;
    ll res=0;
    for(ll i=1;i<=k;i++)for(ll j=1;j<=k;j++)for(ll x=1;x<=k;x++)res+=gcd(gcd(i,j),x);
    cout<<res;
return 0;
}

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

public class Main {
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();

    String S = fs.next(), ans = "Yes";

    for (int i = 0; i < S.length(); i++) {
      if (i % 2 == 1 && S.charAt(i) == 'R') ans = "No";
      if (i % 2 == 0 && S.charAt(i) == 'L') ans = "No";
    }

    System.out.println(ans);
  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
    return buffer[ptr++];
    else
    return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
    ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
    throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
    throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
      throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
    throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

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

int main(void) {
    int m = 0;
    int f = 0;
    int r = 0;
    
    while(cin >> m >> f >> r){
        
        // End of Data
        if(m == -1 && f == -1 && r == -1)
            break;

        int total = m + f;
        
        if(m == -1 || f == -1){
            cout << "F\n";
        }else if(total >= 80){
            cout << "A\n";
        }else if(total >= 65 && total < 80){
            cout << "B\n";
        }else if(total >= 50 && total < 65){
            cout << "C\n";
        }else if(total >= 30 && total < 50 && r >= 50){
            cout << "C\n";
        }else if(total >= 30 && total < 50){
            cout << "D\n";
        }else if(total < 30){
            cout << "F\n";
        }
        
        // cout << m_point << " " << f_point << " " << r_point << "\n";
    }
    
    return 0;
}



Measured memory_bytes: 3060
N,M = map(int,input().split())
li = []
ans = 0
for i in range(N):
    AB = list(map(int,input().split()))	
    li.append(AB)
li.sort()
i=0
while M > 0:
    M -= li[i][1]
    ans += li[i][0]*li[i][1]
    if M < 0:
        ans -= -M*li[i][0]
    i+=1
print(ans)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int hea[maxn],nxt[maxn<<1],to[maxn<<1],tot;
void add(int a,int b) {
	nxt[++tot]=hea[a];
	hea[a]=tot;
	to[tot]=b;
}
int dfs(int x,int f) {
	int s=1;
	for(int i=hea[x];i;i=nxt[i])
		if(to[i]!=f)s+=dfs(to[i],x);
	if(s>2)puts("First"),exit(0);
	if(s==2)return 0;
	return 1;
}
int main() {
	int n,a,b;
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		scanf("%d%d",&a,&b);
		add(a,b);
		add(b,a);
	}
	puts(dfs(1,0)?"First":"Second");
	return 0;
}

Measured memory_bytes: 5676
#include<stdio.h>
int main() {
    long long x;
    scanf("%lld", &x);
    long long year = 0;
    long long amount = 100;
    while (amount < x)
    {
        amount = amount + amount / 100;
        year = year + 1;
    }
    printf("%lld\n", year);



    return 0;
}

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


public class Main {
        public static void main(String[] args) {
            MyScanner sc = new MyScanner();
            //out = new PrintWriter(new java.io.BufferedOutputStream(System.out));
            String s = sc.next();
            String t = sc.next();
            if (t.substring(0, t.length() - 1).equals(s)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }



        }


       // public static PrintWriter out;

        public static class MyScanner {
            BufferedReader br;
            StringTokenizer st;

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

            String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

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

            long nextLong() {
                return Long.parseLong(next());
            }

            double nextDouble() {
                return Double.parseDouble(next());
            }

            String nextLine(){
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }

        }
    }

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

int main() {
  int a;
  cin >> a;
  int b = a / 100;
  int c = (a - 100 * b) / 10;
  int d = (a - 100 * b - 10 * c);
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
def two(n,m):
  if n<=0:
    return -1
  elif n%2==0:
    return two(n//2,m+1)
  else:
    return m

N=int(input())
A=list(map(lambda x: two(int(x),0),input().split()))
#print(A)

print(min(A))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, ans = 0; cin >> n;
    map<ll, ll> small;
    map<ll, ll> tall;
    repf(i, n){
        ll a; cin >> a;
        small[i+a]++;
        tall[i-a]++;
    }
    for(auto p: small) ans += p.second*tall[p.first];
    cout << ans << endl;
}

Measured memory_bytes: 37856
import java.io.*;

class Main{

    public static void main(String[] args)throws IOException{

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String strInput = br.readLine();
	String[] input = strInput.split(" ");
	int a = Integer.parseInt(input[0]);
	int b = Integer.parseInt(input[1]);

	int d = a / b;
	int r = a % b;
	double f = (double) a / b;

	String rd = String.valueOf(d);
	String rr = String.valueOf(r);
	String rf = String.valueOf(f);

	System.out.printf("%d %d %f\n", d, r, f);

    }

}

Measured memory_bytes: 17072
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int W = scan.nextInt();

			int[][]dp = new int[N+1][100010];

			//dp[0][0] = 0;

			int[]w = new int[N+1];
			int[]v = new int[N+1];
			int sum = 0;

			for(int i = 1;i<=N;i++) {
				w[i] = scan.nextInt();
				v[i] = scan.nextInt();
				sum+=v[i];
			}


				for(int j = 1;j<=sum;j++) {
					dp[0][j] = 1000000000;
				}





				for(int j = 1;j<=N;j++) {
					for(int i = 0;i<=sum;i++) {
					if(i-v[j]>=0) {
						dp[j][i] = Math.min(dp[j-1][i-v[j]]+w[j], dp[j-1][i]);
					}else {
						dp[j][i] = dp[j-1][i];
					}
				}
			}


			for(int i = sum;i>=0;i--) {
				//System.out.println(dp[N][i]);

				if(dp[N][i]<=W) {
					System.out.println(i);
					break;
				}
			}

		}


	}


}


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

int main() {
  long long n;
  int c = 0;
  cin >> n;
  long long f = n;
  while(f > 0){
    c += f % 10;
    f /= 10;
  }
  if(n % c == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += (n / i) * max(i - k, 0) + max(n % i - k + 1, 0);
    }
    if (k == 0)
        OP(ans - n);
    else
        OP(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N, X;
  cin >> N >> X;
  vector<int> L(N); REP(i, N) cin >> L[i];
  
  int D = 0, ans = 1;
  REP(i, N) {
    D += L[i];
    if (D <= X) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int main(int argc, const char * argv[]) {
    double xp1, yp1, xp2, yp2;
    int q;
    double xp, yp;
    
    cin >> xp1 >> yp1 >> xp2 >> yp2;
    cin >> q;
    
    double dist = sqrt((xp1 - xp2) * (xp1 - xp2) + (yp1 - yp2) * (yp1 -yp2));
    double nx, ny; //unit vector along the line
    nx = (xp2 - xp1) / dist;
    ny = (yp2 - yp1) / dist;
    
    for (int i = 0; i < q; ++i) {
        cin >> xp >> yp;
        double t = nx * (xp - xp1) + ny * (yp - yp1);
        printf("%.10lf %.10lf\n", 2 * (xp1 + nx * t) - xp, 2 * (yp1 + ny * t) - yp);
    }
    
    return 0;
}



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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9



int main(){

    string str =  "MARCH";
    int N; cin >> N;

    map<char, ll> mp;

    for(int i = 0; i < N; i++){
        string name; cin >> name;
        for(int j = 0; j < 5; j++){
            if(name[0] == str[j]){
                mp[name[0]]++;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 4; j++){
            for(int k = j+1; k < 5; k++){
                ans += mp[str[i]] * mp[str[j]] * mp[str[k]];
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,ans="Yes";
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
        ans="No";
        break;
      }
    }
    else{
      if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
        ans="No";
       break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
      
    


Measured memory_bytes: 256
char s[102];
A(){
	char a[101],b[101],t,t2;
	return sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,&t2)==3&&t=='~'&&strlen(a)==strlen(b);
}
B(){
	short*q;
	char*p=s,l=0;
	if(*(q=p++)=='^>'){
		for(;*(q=++p)=='=Q';p++)l++;
		if(l>0&&*(q=p++)=='~~'&&*++p==0)
			return 1;
	}
	return 0;
}
main(){
	scanf("%*d\n");
	for(;~scanf("%[^\n]\n",s);){
		if(A())
			puts("A");
		else if(B())
			puts("B");
		else
			puts("NA");
	}
}

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

#define ran 101101

int n, k;
char s[ran];
int ans[ran], la;

int main() {
	scanf("%d%d", &n, &k);
	scanf("%s", s);
	
	la = 0;
	int it = n, cnt = 0;
	while(it>0) {
		int last = it;
		it=max(0, it-k);
		while(s[it]=='1') it++;
		if(it>=last) {
			puts("-1");
			return 0;
		}
		ans[la++] = last - it;
	}
	for(int i=la-1;i>=0;i--)
		printf("%d%c", ans[i], i>0 ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int X, dp[100002];
int arr[] = {0, 100, 101, 102, 103, 104, 105};
int main(){
    memset(dp, 0x3f3f3f3f, sizeof dp);
    scanf("%d", &X);
    if(X<100) {printf("0\n"); return 0;}
    dp[0] = 1;
    for (int i = 1; i <= 6; i++) {
        for (int j = 100; j <= X; j++) {
            if(arr[i]>j) continue;
            if(dp[j-arr[i]] !=0x3f3f3f3f)
                dp[j] = min(dp[j], dp[j-arr[i]]+1);
        }
    }
    if(dp[X]!=0x3f3f3f3f){printf("1\n");}
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF (1ll<<60)
typedef long long ll;
using namespace std;

int a, b;
int n;

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

    if ((b - a) % 2 == 0){
        cout << "Alice" << endl;
    }  else {
        cout << "Borys" << endl;
    }
}

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

int main() {

    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int day = 0;day  < n;++day){
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i = 0;i < 3;++i) scanf("%d",&c[i]);
        for(int i = 0;i < 3;++i){
            for(int j = 0;j < 3;++j){
                if(i != j){
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  lint A[N],B[N];
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  if(accumulate(A,A+N,0LL)<accumulate(B,B+N,0LL)) cout << "-1" << endl;
  else{
    lint C[N],ans=0,minus=0,p=0;
    rep(i,N) C[i]=A[i]-B[i];
    sort(C,C+N,greater<lint>());
    rep(i,N) if(C[i]<0) minus-=C[i],ans++;
    while(minus>0){
      ans++,minus-=C[p];
      p++;
    }
    cout << ans << endl;
  }
}

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

int kiriage (int m) {
	if (m % 1000 == 0) return m;
	else {
		return (m / 1000 + 1) * 1000;
	}
}

int main() {
	int n;
	cin >> n;
	int money = 100000;
	for (int i = 0; i < n; i++) {
		money *= 1.05;
		money = kiriage(money);
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)
__gcd(a,b)は最大公約数を取ってくれる、aとb
の大きい方をNとしたとき、計算量は log(N);
*/
const int mod = 1e9 + 7;

//ここから書き始める
int main(){
	int n ;// nは整数
	cin >> n; // 毎回入力するのをテンプレートに
	vector<int> v(n); //使うならrepで入力すること
	
	string s; 
	cin >> s;
	ll ans = 1;
	rep(i,n-1){
		if(s[i]!=s[i+1]){
			ans ++;
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 896
N,M=map(int, raw_input().split())
#print N,M
A=[]
B=[]
for i in xrange(N):
    A.append(list(raw_input()))
#print A

for i in xrange(M):
    B.append(list(raw_input()))
#print B

diff=N-M+1
#print diff

found=False
for i in xrange(diff):
    for j in xrange(diff):
        wrong=False
        for k1 in xrange(M):
            for k2 in xrange(M):
                if A[i+k1][j+k2] != B[k1][k2]:
                    wrong=True
                    break
            if wrong:
                break
        if wrong==False:
            found=True
            break
    if found==True:
        break
if found:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 2692
#include <stdio.h>

int main(){
    long    N, A[200+1] = {0};
    int     flag=1, cnt=0;

    scanf("%ld", &N);

    for(int i=0; i<N; i++){
        scanf("%ld", &A[i]);
    }

    while( flag==1 ){
        for(int i=0; i<N; i++){
            if( A[i] % 2 == 0 ){ A[i] /= 2;        }
            else               { flag  = 0; break; }
        }
        if( flag==1 ){ cnt++; }
    }
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 acs[110000] = {0};
int was[110000] = {0};
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<int> ps(M);
    vector<string> S(M);
    REP(i, M) { cin >> ps.at(i) >> S.at(i); }
    int ac = 0;
    set<int> se;
    REP(i, M) {
        if (acs[ps[i]] == 0) {
            if (S[i] == "WA") {
                was[ps[i]]++;
            } else if (S[i] == "AC") {
                se.insert(ps[i]);
                acs[ps[i]] = 1;
                ac++;
            }
        }
    }
    int wa = 0;
    for (auto i : se) {
        wa += was[i];
    }

    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>

using namespace std;
typedef long long ll;

ll n,ans=0;
inline ll jud(ll num)
{
	ll cnt=0;
	for(ll i=1; i<=num; i++)
		if(num%i==0)cnt++;
	return cnt;
}
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
		if(i%2==0)continue;
		else if(jud(i)==8)ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, m;
int p[111111], y[111111];

vector<int> data[111111];

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

  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> p[i] >> y[i];
    data[p[i]].push_back(y[i]);
  }

  for(int i=1;i<=n;i++){
    sort(data[i].begin(), data[i].end());
  }

  for(int i=0;i<m;i++){
    int ans = lower_bound(data[p[i]].begin(), data[p[i]].end(), y[i]) - data[p[i]].begin();
    ans++;
    printf("%06d%06d\n", p[i], ans);
  }

  return 0;
}



Measured memory_bytes: 8064
from collections import deque
n = int(input())
edges = [[]*n for _ in range(n)]
for _ in range(n-1):
    a, b, c = map(int, input().split())
    edges[a-1].append([b-1, c])
    edges[b-1].append([a-1, c])

q, k = map(int, input().split())
k -= 1
d = deque([k])
visited = [False]*n
visited[k] = True
distance_from_k = [0]*n
while d:
    p = d.popleft()
    for child, c in edges[p]:
        if visited[child]:
            continue
        visited[child] = True
        d.append(child)
        distance_from_k[child] += distance_from_k[p] + c
#print(distance_from_k)

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




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

using namespace std;

typedef long long int ll;

ll n,w;
ll weights[100005];
ll values[100005];
ll memo[101][100005];
ll dp(ll pos, ll weight)
{
	if(weight>w)
		return INT_MIN;//consider '0'
	 if(pos==n)
	 	return 0;
	if(memo[pos][weight]!=-1)
		return memo[pos][weight];
	ll ans = INT_MIN;
	ans = max(dp(pos+1, weight+weights[pos])+values[pos], dp(pos+1, weight));//try omitting 'ans' in 'max' function's argument. 
	return memo[pos][weight] = ans;
} 
int main()
{
	cin>>n>>w;
	for(ll i = 0 ; i < n; i++)
		cin>>weights[i]>>values[i];
	memset(memo, -1, sizeof memo);
	cout<<dp(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 80128
N=gets.chomp.to_i
P=gets.chomp.split.map(&:to_i)
c=0

(N-2).times do |i|
  if ((P[i] < P[i+1]) && (P[i+1]< P[i+2])) || ((P[i] > P[i+1]) && (P[i+1]> P[i+2])) then
    c+=1
  end
end

puts c


Measured memory_bytes: 1788
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

static const long long MOD = 1000000007;
static const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}

void solve(int N) {
	modll ans = modll::modpow(10, N);
	ans -= modll::modpow(9, N);
	ans -= modll::modpow(9, N);
	ans += modll::modpow(8, N);
	cout << ans << endl;
}

int main() {
	int N;
	std::cin >> N;
	solve(N);
	return 0;
}


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define MAX_COMMAND_LENGTH 12

struct Node {
  Node *prev, *next;
  int key;
};

Node *guard_node;

void init_list() {
  guard_node = (Node *)malloc(sizeof(Node));
  guard_node->prev = guard_node;
  guard_node->next = guard_node;
}

void insert_node(int new_key) {
  Node *new_node = (Node *)malloc(sizeof(Node));
  new_node->key = new_key;
  new_node->prev = guard_node;
  new_node->next = guard_node->next;

  new_node->prev->next = new_node;
  new_node->next->prev = new_node;
}

void delete_node(Node *deleted_node) {
  if(deleted_node == guard_node) {
    return;
  }

  deleted_node->prev->next = deleted_node->next;
  deleted_node->next->prev = deleted_node->prev;
  free(deleted_node);
}

void delete_node_by_key(int key) {
  Node* current_node = guard_node->next;

  while(true) {
    if(current_node == guard_node) {
      break;
    }

    if(current_node->key == key) {
      break;
    }

    current_node = current_node->next;
  }

  // Find
  if(current_node != guard_node) {
    delete_node(current_node);
  }
}

void delete_first_node() {
  delete_node(guard_node->next);
}

void delete_last_node() {
  delete_node(guard_node->prev);
}

void print_node() {
  Node *current_node = guard_node->next;

  while(true) {
    if(current_node == guard_node) {
      break;
    }

    // Last print
    if (current_node->next == guard_node) {
      printf("%d", current_node->key);
    } else {
      printf("%d ", current_node->key);
    }

    current_node = current_node->next;
  }

  printf("\n");
}


int main() {
  int command_number, command_arg;
  char command[MAX_COMMAND_LENGTH];

  init_list();

  scanf("%d", &command_number);

  for(int i = 0; i < command_number; i++) {
    scanf("%s", command);

    if(strncmp(command, "insert", 5) == 0) {
      scanf("%d", &command_arg);
      insert_node(command_arg);
    } else if(strncmp(command, "delete", 5) == 0) {
      if(strncmp(command, "deleteFirst", 11) == 0) {
        delete_first_node();
      } else if(strncmp(command, "deleteLast", 10) == 0) {
        delete_last_node();
      } else {
        scanf("%d", &command_arg);
        delete_node_by_key(command_arg);
      }
    }
  }

  print_node();
}



Measured memory_bytes: 33964
n, x, y = map(int, input().split())
if x > y: x, y = y, x
ans_lst = [0] * (n)
for i in range(n-1):
    for j in range(i+1, n):
        tmp = j-i
        tmp = min(tmp, abs(i-(x-1)) + abs(j-(y-1)) + 1)
        ans_lst[tmp] += 1
        # print(i, j, tmp)
for i in range(1, len(ans_lst)):
    print(ans_lst[i])

Measured memory_bytes: 47676
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    if (n==22) {
      System.out.println("Christmas Eve Eve Eve");
    }
    if (n==23) {
      System.out.println("Christmas Eve Eve");
    }
    if (n==24) {
      System.out.println("Christmas Eve");
    }
    if (n==25) {
      System.out.println("Christmas");
    }
  }
}

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

int main() {
    string s;
    cin >> s;
    int l = s.length();
    
    for (int i = 0; i < l; i++) {
        if (s[i] == ',') {
            s[i] = ' ';
        }
    }
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

$p = array_fill(0, 1000000, true);
$p[0] = $p[1] = false;

for($i = 2; $i * $i < 1000000; $i++){
    if(!$p[$i]) continue;
    for($j = $i * $i; $j < 1000000; $j += $i){
        $p[$j] = false;
    }
}

$sum = array_fill(0, 1000000, 0);

for($i = 1; $i < 1000000; $i++){
    $sum[$i] += $sum[$i - 1];
    if($p[$i]) $sum[$i]++;
}

while(fscanf(STDIN, "%d", $n)){
    echo $sum[$n] . "\n";
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int H, W;
int N;
int a[10004];
int main() {
    cin >> H >> W;
    cin >> N;
    rep(i, N) cin >> a[i];
    vector<vector<int>> ans(H);

    int idx = 0;
    rep(i, N) {
        while (a[i]--) {
            // cout << idx << endl;
            ans[idx / W].push_back(i + 1);
            idx++;
        }
    }
    rep(i, H) {
        if (i % 2 == 1) reverse(all(ans[i]));
        rep(j, W) cout << ans[i][j] << " ";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll res = 1;
    REP(i, n){
        if(i && s[i] != s[i - 1]) res++;
    }
    cout << res << endl;
    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll a[MAX],ac[MAX];
 
int main(){
	fastio;
	ll n,ans = 0;
	cin >> n;
	f(i,1,n+1) cin >> a[i],ac[i] = (ac[i-1]+a[i])%mod;
	f(i,1,n+1) (ans += (a[i] * ac[i-1])%mod )%=mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6772
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		int i, j, n;
		ArrayList<Article> list = new ArrayList<Article>();
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			for(i = 0; i < n; i++) {
				Article article = new Article(sc.nextInt(),sc.nextInt(),sc.next(),sc.nextLong(),sc.next());
				list.add(article);
			}
			Comparator<Article> comparator =
					Comparator.comparing(Article::getValue)
					.thenComparing(Article::getHeight)
					.thenComparing(Article::gettype)
					.thenComparing(Article::getDate)
					.thenComparing(Article::getName);
			list.stream().sorted(comparator)
			.forEach(a ->
			System.out.println(a.getValue() + " " + a.getHeight() + " " + a.gettype()
			+ " " + a.getDate() + " " + a.getName()));
		}
	}
}
class Article {
	private int value;
	private int height;
	private String type;
	private long date;
	private String name;
	public Article(int value, int height, String type, long date, String name) {
		this.value = value;
		this.height = height;
		this.type = type;
		this.date = date;
		this.name = name;
	}
	public int getValue() {
		return this.value;
	}
	public int getHeight() {
		return this.height;
	}
	public String gettype() {
		return this.type;
	}
	public long getDate() {
		return this.date;
	}
	public String getName() {
		return this.name;
	}
}


Measured memory_bytes: 202552
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int C = scan.nextInt();

    if (A == B && B == C) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21332
N,M = map(int, input().split())
S = [list(map(int,input().split())) for _ in range(N)]
C = [list(map(int,input().split())) for _ in range(M)]
for a, b in S:
    distance = 1001001001
    ans = 0
    for i in range(len(C)):
        c, d = C[i][0], C[i][1]
        if abs(a - c) + abs(b - d) < distance:
            distance = abs(a - c) + abs(b - d)
            ans = i + 1
    print(ans)


Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll N, T;
	cin >> N >> T;
	vector<ll> t(N);
	rep(i, N) {
		cin >> t[i];
	}

	ll ans = min(T, t[0]);

	rep1(i, N) {
		ans += min(T, t[i] - t[i - 1]);
	}

	ans += T;

	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n,k;
    cin>>n>>k;
    set<int>s;
    for(int i=1;i<=k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int tp;
            cin>>tp;
            s.insert(tp);
        }
    }
    cout<<n-s.size()<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>
 
int d(int a){
  a *= a;
  return a;
}
 
int main(void){
  int a, b;
  double c,S,h,k,L,A;
 
  scanf("%d %d %lf",&a,&b,&c);
  c = c / 180 * M_PI;
  S = a * b * sin(c) / 2;
  h = 2 * S / a;
  k = d(a) + d(b) - 2 * a * b * cos(c);
  A = sqrt(k);
 
  L = a + b + A;
 
 
  printf("%f\n%f\n%f\n",S,L,h);
 
  return 0;
}

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

int eat_num(int Ai, int D) {
    if (D % Ai == 0) {
        return D / Ai;
    }
    return D / Ai + 1;
}

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int eat = 0;

    rep(i, N) {
        eat += eat_num(A.at(i), D);
    }

    cout << eat + X << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int a, b, c;

	scanf("%d %d %d",&a,&b,&c);

	if (a + c == b||a+b==c||b+c==a) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

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

int main(){
  string s; cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      cout<<i+1<<' '<<i+2<<endl;
      return 0;
    }else if(s[i]==s[i+2] && i+2!=s.size()){
      cout<<i+1<<' '<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<' '<<-1<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int k, s, cnt=0;
  cin>>k>>s;
  for(int i=0;i<=k;i++){for(int j=0;j<=k;j++){if(s-i-j<=k&&s-i-j>=0)cnt++;}}
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
io = STDIN
s=io.gets.chomp
k=io.gets.chomp.to_i
hash= ("a".."z").zip([0]+(1..25).to_a.reverse).to_h
s.size.times do |i|
  ss = s[i]
  j = hash[s[i]]
  if s.size-1 == i
    if j <= (k%26)
      ss="a"
      (k%26-j).times{ss.succ!}
    else
      (k%26).times{ss.succ!}
    end
    s[i]=ss[0]
    k=0
  else
    if j <= k
      j.times{ss.succ!}
      s[i] = ss[0]
      k-=j
    end
  end
  break if k<=0
end
puts s

Measured memory_bytes: 2044