akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
// ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main(){                fastIO
  // input_from_file
  ll n,w;cin>>n>>w;ll vec[n],cost[n];
  for(int i=0;i<n;i++) cin>>vec[i]>>cost[i];
  vector<ll> dp(1e5+1,1e12);
  dp[0]=0;ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=1e5;j>=0 && j-cost[i]>=0;j--){
      if(j-cost[i]!=1e12) dp[j]=min(dp[j],dp[j-cost[i]]+vec[i]);
    }
  } 
  for(ll i=0;i<=1e5;i++) {
    if(w-dp[i]>=0) ans=max(ans,i);
  }
  cout<<ans;
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<vector<li>> v = {
    {0, 1, 2},
    {3, 4, 5},
    {6, 7, 8},
    {0, 3, 6},
    {1, 4, 7},
    {2, 5, 8},
    {0, 4, 8},
    {2, 4, 6}
};

li a[9];
li n;


int main() {
    rep(i, 9) {
        cin >> a[i];
    }
    cin >> n;
    set<li> b;
    rin{
        li x;
        cin >> x;
        b.insert(x);
    }

    for (auto && vv : v) {
        bool ok = true;
        for (auto && vvv : vv) {
            if (b.count(a[vvv]) == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
#define MAX_INT INT_MAX
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int h,w;
char s[51][51];
int t[51][51];
int main(){
    cin>>h>>w;
    int c=-1;
    rep(i,h)rep(j,w){
        cin>>s[i][j];
        if(s[i][j]=='.')c++;
    }
    memset(t,-1,sizeof(t));
    t[0][0]=0;
    queue<P>q;
    q.push(P(0,0));
    while(q.size()){
        P v=q.front();q.pop();
        if(v.fi==h-1&&v.se==w-1)break;
        rep(i,4){
            P u=P(v.fi+dy[i],v.se+dx[i]);
            if(s[u.fi][u.se]=='.'&&t[u.fi][u.se]==-1){
                q.push(u);
                t[u.fi][u.se]=t[v.fi][v.se]+1;
            }
        }
    }
    if(t[h-1][w-1]!=-1)cout<<c-t[h-1][w-1]<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<Integer, Integer>();
        
        for (int i = 0; i < n; i++) {
            a.put(sc.nextInt(),i);
        }
        sc.close();
        for (int i = 0; i < n; i++) {
            System.out.print(a.get(i+1) + 1);
            System.out.print(" ");
        }
    }
}


Measured memory_bytes: 71532
#include <iostream>
#include <string>
#include <set>
using namespace std;

set<char> s;
string str;

int main(){
  cin >> str;
  
  for(int i = 0; i < str.length(); i++){
    s.insert(str[i]);
  }
  
  if(s.size() == str.length()){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
}


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

typedef long long ll;
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007
using namespace std;
ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) {return m / gcd(n, m) * n;}

int main(void) {
	ll p, c, m;
	cin >> p >> m >> c;
	cout << p + m + c << endl;
	return 0;
}


Measured memory_bytes: 3092
S = input()
a = int(S[:2])
b = int(S[2:])
if a <= 12 and a >= 1:
    if b <= 12 and b >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if b <= 12 and b >= 1:
        print("YYMM")
    else:
        print("NA")



Measured memory_bytes: 2940
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (h, w): (usize, usize) = parse!(it, 2);
    let mut a = vec![];
    let mut b = vec![];
    for _ in 0..h {
        let ai: Vec<usize> = parse!(it, w);
        a.push(ai)
    }
    for _ in 0..h {
        let ai: Vec<usize> = parse!(it, w);
        b.push(ai)
    }

    let M = 15000;
    let mut dp = vec![vec![vec![false; M]; w]; h];
    let diff = |x, y| if x > y { x - y } else { y - x };
    dp[0][0][diff(a[0][0], b[0][0])] = true;
    for i in 0..h {
        for j in 0..w {
            for k in 0..M {
                if !dp[i][j][k] {
                    continue;
                }
                if i < h - 1 {
                    let d = diff(a[i + 1][j], b[i + 1][j]);
                    let dm = diff(k, d);
                    dp[i + 1][j][dm] = true;
                    let dk = k + d;
                    if dk < M {
                        dp[i + 1][j][dk] = true;
                    }
                }
                if j < w - 1 {
                    let d = diff(a[i][j + 1], b[i][j + 1]);
                    let dm = diff(k, d);
                    dp[i][j + 1][dm] = true;
                    let dk = k + d;
                    if dk < M {
                        dp[i][j + 1][dk] = true;
                    }
                }
            }
        }
    }
    for i in 0..M {
        if dp[h - 1][w - 1][i] {
            println!("{}", i);
            return;
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        2 2
1 2
3 4
3 4
2 1
        ";
        solve(s);
        // assert!(solve(s) == ());
    }
}


Measured memory_bytes: 135420
import java.io.*;
import java.util.*;
import java.util.function.IntPredicate;
 
public class Main{
	
	int N, M;
	int[] X, Y;
	final long MOD = 1000000007;
	public void solve(){
		N = nextInt();
		M = nextInt();
		X = new int[N];
		Y = new int[M];
		for(int i = 0; i < N; i++){
			X[i] = nextInt();
		}
		for(int i = 0; i < M; i++){
			Y[i] = nextInt();
		}
		Arrays.sort(X);
		long sum = 0;
		long prev = 0;
		for(int i = 1; i < N; i++){
			long d = X[i] - X[i - 1];
			prev = ((d * i) % MOD + prev) % MOD;
			sum = (sum + prev) % MOD;
		}
		Arrays.sort(Y);
		long sum2 = 0;
		prev = 0;
		for(int i = 1; i < M; i++){
			long d = Y[i] - Y[i - 1];
			prev = ((d * i) % MOD + prev) % MOD;
			sum2 = (sum2 + prev) % MOD;
		}
		out.println((sum * sum2) % MOD);
	}
	
	public int[] count(String str){
		int[] cnt = new int[256];
		for(int i = 0; i < str.length(); i++){
			cnt[str.charAt(i)]++;
		}
		return cnt;
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

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

int main() {
  int K, A, B;
  cin >> K;
  cin >> A >> B;

  bool ans = false;
  for(int i = A; i <= B; i++) {
    if(i % K == 0) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	bool can = 1;
  	for(int i = 0; i < n; i++){
    	int temp;
      	cin>>temp;
      	if(temp%2 == 0){
        	if(temp % 3 == 0){
            	continue;
            }
          	else if(temp % 5 ==0){
            	continue;
            }
          	else{
            	can = 0;
            }
        }
    }	
	if(can)cout<<"APPROVED\n";
  	else cout<<"DENIED\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;

ll dist[110][110];
const ll INF = 100000000;
int N, K;


void update(int a, int b) {
	for (int k =0 ; k <N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j <N;j++) {
				dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
}

int main()
{
	while (1) {
		cin >> N >> K;
		if (N == 0 && K == 0)break;

		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				dist[i][j] = INF;

		for (int i = 0; i < K; i++) {
			ll a, b, c, d;
			cin >> a;
			if (a == 1) {
				cin >> b >> c >> d;
				b--, c--;
				if (dist[b][c] > d) {
					dist[b][c] = dist[c][b] = d;
					update(b, c);
				}
			}
			else if (a == 0) {
				cin >> b >> c;
				b--, c--;
				if (dist[b][c] != INF)
					cout << dist[b][c] << endl;
				else
					cout << -1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3112
using System;

public class Program
{
	public static void Main()
	{
		var S = new string[3];
		for (int i = 0; i < 3; i++)
		{
			S[i] = Console.ReadLine();
		}
		var idx = new[] { 0, 0, 0 };
		int target = 0;
		while (idx[target] < S[target].Length)
		{
			target = S[target][idx[target]++] - 'a';
		}
		Console.WriteLine((char)('A' + target));
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    rep(i,N) cin >> S[i];
    UNIQUE(S);
    pr(S.size());
}

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

using namespace std;
long long gcd(long long a,long long b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}

int main(void){
    long long A,B,C,D;
    cin>>A>>B>>C>>D;
    long long num_c=B/C-(A-1)/C;
    long long num_d=B/D-(A-1)/D;
    long long com=C*D/gcd(C,D);
    long long num_com=B/com-(A-1)/com;
    long long ans=(B-A+1)-(num_c+num_d-num_com);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long m=sc.nextLong();
		long ans=0;

  		long[][] ab=new long[n][2];
		for(int c=0;c<n;c++){
    		ab[c][0]=sc.nextLong();
          	ab[c][1]=sc.nextLong();
    	}
  
        Arrays.sort(ab,(a, b) -> Long.compare(a[0], b[0]));
        long count=0;
        int c=0;
 		while(count<m){
        if(ab[c][1]>0){
        ans+=ab[c][0];
        ab[c][1]--;
        }else{
        ans+=ab[c+1][0];
        ab[c+1][1]--;
        c++;
        }
        count++;
        }

    	System.out.println(ans);
    }
}

Measured memory_bytes: 62808
program interval_game
  implicit none
  integer :: n, l(100001), r(100001), i
  integer(8) :: k
  l = 0
  r = 0
  k = 0_8
  read(*,*) n
  do i = 1, n
    read(*,*) l(i), r(i)
  end do
  call bitonic_sort(l(1:n+1),.false.)
  call bitonic_sort(r(1:n+1),.true.)
  do i = 1, n+1
    k = k+2_8*max(0_8,int(l(i)-r(i),8))
  end do
  write(*,'(i0)') k
  stop
contains
  recursive subroutine bitonic_sort(a,ascend)
    implicit none
    integer, intent(inout) :: a(:)
    logical, intent(in) :: ascend
    integer :: n
    n = size(a)
    if (n.eq.1) return
    call bitonic_sort(a(1:n/2),.not.ascend)
    call bitonic_sort(a(n/2+1:n),ascend)
    call bitonic_merge(a,ascend)
    return
  end subroutine bitonic_sort
  recursive subroutine bitonic_merge(a,ascend)
    implicit none
    integer, intent(inout) :: a(:)
    logical, intent(in) :: ascend
    integer :: n, m, i, b
    n = size(a)
    if (n.eq.1) return
    m = 1
    do while (2*m.lt.n)
      m = 2*m
    end do
    do i = 1, n-m
      if ((a(i).gt.a(i+m)).eqv.ascend) then
        b = a(i)
        a(i) = a(i+m)
        a(i+m) = b
      end if
    end do
    call bitonic_merge(a(1:m),ascend)
    call bitonic_merge(a(m+1:n),ascend)
    return
  end subroutine bitonic_merge
end program interval_game

Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;

char str[10];

int main()
{
	scanf("%s",str);
	for(register int i=0;i<3;++i)
	{
		if(str[i]=='9')
			str[i]='1';
		else if(str[i]=='1')
			str[i]='9';
	}
	printf("%s",str);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <iomanip>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

// #define X first
// #define Y second

const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = 3.1415926535897932;
const int _N = 2e5;
const int _M = 270000;
int n;
map<int, bool> m;
int main() {
  omajinai;
  cin>>n;
  int ans=0;
  REP(i,n){
      int x;
      cin>>x;
      if(m.find(x)==m.end()){
          m[x]=true;
          ans++;
      }else{
          ans += m[x] ? -1 : 1;
          m[x]=!m[x];
      }
  }
  cout << ans << endl;
  return 0;
}



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


int main() {
  string S;
  cin >> S;
  int cnt = 0;
  char pre = '0';
  int i=0, lng = 0;
  
  while (i < S.size()){
    if(pre == S[i] && lng == 1){
      if(i+1 == S.size()){
        break;
      }
      else{
        pre = S[i+1];
        i += 2;
        cnt++;
        lng = 2;
      }
    }
    else{
      pre = S[i];
      i++;
      cnt++;
      lng = 1;
    }
  }
  
         
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n,p[110];
  cin>>n;
  std::vector<tuple<string,int,int>>v;

  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    v.push_back(tie(s,p,i));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    cout<<get<2>(v[i])<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<3;i++)for(int j=i+1;j<3;j++)if(a[i]>a[j]){
		int temp = a[i]; a[i] = a[j];a[j]=temp;
	}
	printf("%d",a[2] - a[0]);
}


Measured memory_bytes: 128
n, m = map(int, input().split())
M1 = []
M2 = []
for i in range(n):
 M1.append(list(map(int, input().split())))

for i in range(m):
 M2.append(int(input()))

for i in range(n):
 c = 0
 for s in range(m):
  c += M1[i][s] * M2[s]
 print(c)

Measured memory_bytes: 7940
#include <stdio.h>

int main()
{
	int i, N;
	char S[10001];
	scanf("%d", &N);
	scanf("%s", S);
	for (i = 0; S[i] != 0; i++) S[i] = 'A' + (S[i] - 'A' + N) % 26;
	printf("%s\n", S);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
#define deb(x)   cout<<"> "<<#x<<" : "<<x<<endl;
#define deb2(x,y)cout<<"> "<<#x<<"->"<<x<<"  "<<#y<<"->"<<y<<endl;
#define LINE   cout << "--- LINE NO : " << __LINE__ <<"  ---"<< endl;
#define pnr(a)   for(auto x:a){cout<<x<<" ";}cout<<endl;
#define pnr2(a)  for(auto x:a){cout<<x.first<<" "<<x.second<<endl;}
#define   pi       2*acos(0.0)
#define   inf      (int)1e18
const int mod =    1e9 + 7,
          mxn =    2e5 + 5;

#define   vt       vector
#define   ff       first
#define   ss       second
#define   int      long long
#define   db       long double
#define   umap     unordered_map
#define   pii      pair<int,int>
#define   Maxpq(x) priority_queue<x>
#define   Minpq(x) priority_queue<x,vt<x>,greater<x>>

#define   endl     "\n"
#define   pb       push_back
#define   si(x)    (int)x.size()
#define   all(x)   x.begin(),x.end()
#define   rall(x)  x.rbegin() ,x.rend()
#define   mem(a,x) memset(a,x,sizeof(a))
#define   forr(i,n) for(int i=0;i<n;i++)
#define   FOR(a)   for(auto& x :  a )

set<string> st;

void recur( string s , int idx)
{
	if (idx == si(s))
	{
		s.insert(idx , "+");
		st.insert(s);
		return ;
	}
	recur(s , idx + 1);

	s.insert(idx , "+");
	recur(s , idx + 2);
	return ;

}
int mainx() {
	string s;
	cin >> s;
	recur(s , 1);
	// for (int i = 0 ;)
	// pnr(st);
	int ans = 0;
	FOR(st)
	{
		string t = x , a;
		FOR(t)
		{
			if (x == '+')
			{
				ans += stoll(a);
				a.clear();
			}
			a += x;

		}


	}
	cout << ans << endl;


	return 0;
}


bool cmp(pii &a , pii &b) {
	if (a.ff < b.ff)return true;
	if (a.ff == b.ff )return a.ss < b.ss;
	return false;
}
inline void INCLUDE() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
}
int32_t main() {

	//INCLUDE();

	ios::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	//cout << fixed << setprecision(20);

	int tt = 1;
	//cin>>tt;
	for (int t = 1 ; t <= tt ; t++ )
	{
		// cout<<"Case #"<<t<<": ";
		mainx();
	}
	return 0 ;
}



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

int main(void)
{
    int N, L;
    cin >> N >> L;
    auto taste_min = L, taste_max = L + N -1;
    auto total_taste = ((taste_max+taste_min)*N)/2;

    if(taste_min > 0) {
        cout << total_taste - taste_min << endl;
    } else if(taste_max < 0) {
        cout << total_taste - taste_max << endl;
    } else {
        cout << total_taste << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  string sij;
  set<string> sl{};
  for (int i=1;i<k+1;i++){
    for (int j=0;j<s.size();j++){
      sij = s.substr(j,i);
      sl.insert(sij);
    }
  }
  //sort(sl.begin(),sl.end());
  auto itr = sl.begin();
  for(int i=1;i<k;i++) itr++;
  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, a + k - 1); i++) cout << i << endl;
	for (int i = max(b - k + 1, a + k); i <= b; i++) cout << i << endl;
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,sum=0,r=1,i=0;
    cin >> N;

    if(N==0){
        cout << 0 << endl;
        return;
    }

    string ans;
    while(sum!=N){
        if((N-sum)%(r*2)!=0){
            ans+="1";
            sum+=(i%2==0?1:-1)*r;
        }else{
            ans+="0";
        }

        r*=2;
        ++i;
    }

    reverse(begin(ans),end(ans));
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 26
 
typedef struct node{
  int p;
  int l;
  int r;
} Tree;
 
int Height(int);
 
int n;
Tree T[MAX];
 
int main(){
  int i,j,id,left,right;
  int s[MAX],deg[MAX],dep[MAX],h[MAX];
 
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
    s[i]=-1;
    deg[i]=0;
    dep[i]=0;
    h[i]=0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
 
    if(left!=-1){
      T[left].p=id;
      deg[id]++;
    }
 
    if(right!=-1){
      T[right].p=id;
      deg[id]++;
    }
 
    T[id].l=left;
    T[id].r=right;
    s[left]=right;
    s[right]=left;
  }
 
  for(i=0;i<n;i++){
    j=i;
     
    while(T[j].p!=-1){
      j=T[j].p;
      dep[i]++;
    }  
 
    h[i]=Height(i);
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
       ,i,T[i].p,s[i],deg[i],dep[i],h[i]);
 
    if(T[i].p==-1){
      printf("root\n");
    }else if(T[i].l==-1 && T[i].r==-1){
      printf("leaf\n");
    }else{
      printf("internal node\n");
    }
  }
 
  return 0;
}
 
int Height(int i){
  int j,count=0,max=0;
 
  for(j=0;j<n;j++){
    if(T[j].p==i){
      count=Height(j)+1;
 
      if(count>max){
    max=count;
      }
    }
  }
 
  return max;
}

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

int main()
{
  int n;

  ll sum = 0;

  cin >> n;

  vector<int> a(n);
  rep(i, n) cin >> a.at(i);

  rep(i,n){
    while(a.at(i) %2 == 0){
      a.at(i) /= 2;
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3480
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

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

	int *dp = new int[N + 1];
	dp[0] = 0;

	for (int i = 1; i <= N; i++) {
		dp[i] = 10e10;
		
		int p = 6;
		while (p <= i) {
			dp[i] = min(dp[i], dp[i - p] + 1);
			p *= 6;
		}

		p = 9;
		while (p <= i) {
			dp[i] = min(dp[i], dp[i - p] + 1);
			p *= 9;
		}

		p = 1;
		dp[i] = min(dp[i], dp[i - p] + 1);
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 640
double P[102][101];
char L[101],B[101];
main(){
	int N,T,l,b,x,t,n,k;
	for(;scanf("%d%d%d%d",&N,&T,&l,&b),N;){
		memset(P,0,sizeof(P));
		memset(L,0,sizeof(L));
		memset(B,0,sizeof(B));
		for(;l--;)scanf("%d",&x),L[x]=1;
		for(;b--;)scanf("%d",&x),B[x]=1;
		P[0][0]=1;
		for(t=0;t<T;t++)for(n=0;n<=N;n++){
			if(n==N){
				P[t+1][N]+=P[t][N];
			}else{
				for(k=1;k<=6;k++){
					x=n+k;
					if(x>N)x=2*N-x;
					double d=P[t][n]/6;
					if(L[x])P[t+2][x]+=d;
					else if(B[x])P[t+1][0]+=d;
					else P[t+1][x]+=d;
				}
			}
		}
		printf("%f\n",P[T][N]);
	}
exit(0);}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for(int i = (l); i < (r); ++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 303030;
int n;
char s[N];
int e[N], w[N];
int main() {
	scanf("%d%s", &n, s);
	rep(i, 0, n) {
		e[i + 1] = e[i] + (s[i] == 'E');
		w[i + 1] = w[i] + (s[i] == 'W');
	}
	int ans = 1e9;
	rep(i, 1, n + 1) {
		ans = min(ans, w[i - 1] + e[n] - e[i]);
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2944
package main

import (
	"fmt"
)

func main() {
	var n, q int
	var s string
	fmt.Scan(&n, &q, &s)
	ar := make([]int, n)
	bk := 'T'
	sum := 0
	for i, v := range s {
		if bk == 'A' && v == 'C' {
			sum++
		}
		ar[i] = sum
		bk = v
	}
	ls := make([]int, q)
	rs := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scan(&ls[i], &rs[i])
	}
	for i := 0; i < q; i++ {
		fmt.Println(ar[rs[i]-1] - ar[ls[i]-1])
	}
}


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

int main(){
  vector<int>a(3);
  for(int i=0;i<3;i++){
      cin >> a.at(i);
  }
  int ans =0;
  while(a.at(0)!=a.at(1)||a.at(1)!=a.at(2)||a.at(0)!=a.at(2)){
      sort(a.begin(),a.end());
      if(a.at(2)==a.at(1))a.at(0)+=2;
      else {
          a.at(0)++;
          a.at(1)++;
      }
      ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
N = int(input())
lst = list()
cnt = 0
for _ in range(N):
    a = int(input())
    if a == 0:
        lst.append(cnt)
        cnt = a
    else:
        cnt += a
lst.append(cnt)

ans = 0
for cnt in lst:
    ans += cnt // 2
print(ans)


Measured memory_bytes: 49240
/*
      author : nishi5451
      created: 11.08.2020 20:52:53
*/

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


int main(){
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#define A 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n , m[A][A];

int color[A] , d[A] , f[A] , tt;

void dfs(int u)
{
	int v ;
	color[u] = GRAY;
	d[u] = ++tt;
	for(v = 0; v < n; v++)
	{
		if(m[u][v] == 0)
		{
			continue;
		}
		if(color[v] == WHITE)
		{
			dfs(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void df()
{
	int u;
	for(u = 0; u < n; u++)
	{
		color[u] = WHITE;
		
	}
	tt = 0; 
	for( u = 0; u < n; u++)
	{
		if(color[u] == WHITE)
		{
			dfs(u);
		}
	}
	for(u = 0; u < n; u++)
	{
		printf("%d %d %d\n",u+1,d[u],f[u]);
	}
}

int main(void)
{
	int u, v , k, i,j;
	scanf("%d",&n);
	
	for(i = 0; i < n; i++)
	{
		for(j = 0; j < n; j++)
		{
			m[i][j] = 0;
		}
	}
	for(i = 0; i < n; i++)
	{
		scanf("%d %d",&u,&k);
		u--;
		for(j = 0; j < k; j++)
		{
			scanf("%d",&v);
			v--;
			m[u][v] = 1;
		}
	}
	df();
	return 0;
}


Measured memory_bytes: 2084
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<vector>
#include<set>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int maxn = (int)2e6 + 5;
using namespace std;

int a[200005], b[200005];

int find(int a[], int low, int high, int key)  
{  
    int mid = low + (high - low) / 2;  
    if(low > high)  
        return -1;  
    else{  
        if(a[mid] == key)  
            return mid;  
        else if(a[mid] > key)  
            return find(a, low, mid - 1, key);  
        else  
            return find(a, mid +1, high, key);  
    }  
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a, a + n);
	int x = n / 2;
	for(int i = 0; i < n; i++){
		int y = find(a, 0, n, b[i]);
		if(x > y) cout << a[x] << endl;
		else if(x <= y) cout << a[x-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    
    int main(){
        string x;
        cin >> x;
        ll s = 0 , t = 0;
        
        for(ll i = 0 ; i < x.length() ; i++ ){
            if(x[i] == 'S'){
              s += 1;  
            }else{
                if(s > 0){
                    s -= 1;
                }else{
                    t += 1;
                }
            }
        }
        
        cout << s + t << endl;
        
        return 0;
        
    }

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> Qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> Qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n;
  cin >> n;
  string s;
  map<string,int> m;
  REP(i,n) {
    cin >> s;
    m[s]++;
  }
  cout << m.size() << endl;
  return 0;
}


Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x));
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> n >> s;
    if(n%2==0){
        REP(i,n/2){
            if(s[i]!=s[i+n/2]){
                cout << "No" << endl;
              return 0;
            }
        }
    }else{
        cout << "No" << endl;
      return 0;
    }
    cout << "Yes" <<endl;
}


Measured memory_bytes: 3520
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;

int main()
{
  ll N;
  std::string S;
  std::cin >> N >> S;

  std::string ans;
  for (auto& c : S) {
    char x = c + N;
    if (x > 'Z') x -= 26;
    std::cout << x;
  }

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


Measured memory_bytes: 256
require "prime"
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

def division(x)
  ret=[]
  1.upto((x**0.5)+1) do|i|
      if (x%i).zero?
        ret.push(i)
        ret.push(x/i) if i!=x/i   
      end
  end
  return ret
end
N,M=get_i
div=division(M)
#p div
ans=1
div.sort{|x,y| y<=>x}.each do|v|
    if M/N>=v
        ans=v
        break
    end
end
puts ans

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

#define N 1000

int max( int a , int b ){
	
		if( a >= b ){
			return a;
		}else{
			return b;
		}
}

int lcs( char x[] , char y[] ){
	
	int c[N+1][N+1];
	int m = strlen(x);
	int n = strlen(y);
	int maxl = 0;
	
	char x2[m+1] , y2[n+1];
	
	x2[0] = ' ';
	for( int i = 1; i <= m; i++ ){
		x2[i]=x[i-1];
	}
	y2[0] = ' ';
	for( int i = 1; i <= n; i++ ){
		y2[i]=y[i-1];
	}
	
	for( int i = 0; i <= m; i++ ){
		c[i][0] = 0;
	}
	for( int j = 1; j <= n; j++ ){
		c[0][j] = 0;
	}
	
	for( int i = 1; i <= m; i++ ){
		for( int j = 1; j <= n; j++ ){
			if( x2[i] == y2[j] ){
				c[i][j] = c[i-1][j-1] + 1;
			}else{
				c[i][j] = max( c[i-1][j] , c[i][j-1] );
			}
			maxl = max( maxl , c[i][j] );
		}
	}
	return maxl;
}

int main( void ){
	
	char s1[N] , s2[N];
	
	int n;
	
	scanf( "%d" , &n );
	
	for( int i = 0; i < n; i++ ){
		scanf( "%s" , s1 );
		scanf( "%s" , s2 );
		printf( "%d\n" , lcs(s1 , s2) );
	}
	
	return 0;
}
	


Measured memory_bytes: 5632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

std::vector<int> parent;
std::vector<int> rnk;

void init(int n){
    parent.clear();
    rnk.clear();
    for(int i=0; i<n; i++){
        parent.push_back(i);
        rnk.push_back(0);
    }
}

int find(int x){
    if(x == parent[x]){
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rnk[x] < rnk[y]){
        parent[x] = y;
    } else {
        parent[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

struct edge{
    int from, to, cost;
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int v, e;
    cin >> v >> e;

    vector<edge> es(e);
    for(int i=0; i<e; i++) {
        edge ed;
        cin >> ed.from >> ed.to >> ed.cost;
        ed.from; ed.to;
        es[i] = ed;
    }

    sort(es.begin(), es.end(), comp);
    init(v);
    int ret = 0;
    for(int i=0; i<e; i++){
        edge e = es[i];
        if(!same(e.from, e.to)){
            ret += e.cost;
            unite(e.from, e.to);
        }
    }
    cout << ret << "\n";
}

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

int main(){
		int a, b, c; cin >> a >> b >> c;
		vector<int> v(10);
		v[a]++;
		v[b]++;
		v[c]++;
		if(v[5] == 2 && v[7] == 1){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}

		return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#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 <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007
#define INF (1e9)
#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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B;
    cin >> A >> B;
    if (A <= 8 & B <= 8) print("Yay!");
    else print(":(");
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
S = input()
T = input()

used = [False]*26
d = defaultdict(str)

flg = True
for i in range(len(S)):
    if S[i] in d:
        if d[S[i]] != T[i]:
            flg = False

    else:
        d[S[i]] = T[i]
        if used[ord(T[i])-ord('a')] is True:
            flg = False
        used[ord(T[i])-ord('a')] = True

if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 41932
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);

  int count[MAX] = {0};
  rep(i, 1, n+1) {
    rep(j ,i, n+1) {
      int l = min(min(j-i, abs(x-i)+abs(y-j)+1), abs(y-i)+abs(x-j)+1);
      count[l]++;
    }
  }
  rep(i, 1, n) {
    printf("%d\n", count[i]);
  }
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(cin>>m>>f>>r&&(m!=-1||f!=-1||r!=-1)){
        if(m==-1||f==-1){
            cout<<'F'<<"\n";
        }else{
            if(m+f>=80)cout<<'A'<<"\n";
            else if(m+f>=65)cout<<'B'<<"\n";
            else if((m+f>=50)||(m+f>=30&&r>=50))cout<<'C'<<"\n";                                                              
            else if(m+f>=30)cout<<'D'<<"\n";
            else cout<<'F'<<"\n";
        }
    }
}


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

int a[100010];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int minans = 1000001, maxans = -1000001;
	long long int sumans = 0;
	for(int i = 0; i < n; i++){
		minans = min(minans, a[i]);
		maxans = max(maxans, a[i]);
		sumans += a[i];
	}
	cout << minans << " " << maxans << " " << sumans << endl;
}



Measured memory_bytes: 3124
#include <stdio.h>

#define MAX_H 110
#define MAX_W 110

char field[MAX_H][MAX_W];


void dfs(int y, int x)
{
	char c = field[y][x];
	field[y][x] = 0;
	
	if (c == field[y][x + 1]){
		dfs(y, x + 1);
	}
	if (c == field[y][x - 1]){
		dfs(y, x - 1);
	}
	if (c == field[y + 1][x]){
		dfs(y + 1, x);
	}
	if (c == field[y - 1][x]){
		dfs(y - 1, x);
	}
}
	

int main(void)
{
	int i, j;
	int w, h;
	int count;
	
	while (1){
		count = 0;
		scanf("%d %d", &h, &w);
		
		if (h == 0 && w == 0){
			break;
		}
		
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				scanf(" %c", &field[i][j]);
			}
		}
		
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if (field[i][j] != 0){
					dfs(i, j);
					count++;
				}
			}
		}
		
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 1820
board = [[False]*1000001]*1000001
while True:
    m = int(input())
    if m == 0: break
    star = list({tuple(map(int, input().split())) for i in range(m)})
    sx, sy = star[0]
    
    n = int(input())
    starlist = list({tuple(map(int, input().split())) for i in range(n)})
    for i in range(len(starlist)):
        board[starlist[i][0]][starlist[i][1]] = True
    for i in range(n):
        flag = True
        for j in range(len(star)-1):
            dx = starlist[i][0] + star[j+1][0] - sx
            dy = starlist[i][1] + star[j+1][1] - sy
            if dx < 0 or 1000000 < dx or dy < 0 or 1000000 < dy or board[dx][dy] == False:
                flag = False
                break

        if flag == True:
            print("{} {}".format(starlist[i][0] - sx, starlist[i][1] -sy))
            break
    

Measured memory_bytes: 22692
import java.util.Arrays;
import java.util.Scanner;

class UnionFind {
    int[] parent;

    UnionFind(int n) {
        parent = new int[n];
        Arrays.fill(parent, -1);
    }

    int find(int x) {
        if (parent[x] < 0) {
            return x;
        } else {
            parent[x] = find(parent[x]);
            return parent[x];
        }
    }

    void unite(int x, int y) {
        int rootX = find(x);
        int rootY = find(y);
        if (rootX == rootY) {
            return;
        }

        if (parent[rootX] > parent[rootY]) {
            int temp = rootX;
            rootX = rootY;
            rootY = temp;
        }
        parent[rootX] += parent[rootY];
        parent[rootY] = rootX;
    }

}


public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = nextInt(scanner);
        int m = nextInt(scanner);
        UnionFind unionFind = new UnionFind(n);
        for (int i = 0; i < m; i++) {
            unionFind.unite(nextInt(scanner) - 1, nextInt(scanner) - 1);
        }
        System.out.println(Math.abs(Arrays.stream(unionFind.parent).min().orElse(0)));
    }

    private static int nextInt(Scanner scanner) {
        return Integer.parseInt(scanner.next());
    }

    private static long nextLong(Scanner scanner) {
        return Long.parseLong(scanner.next());
    }

    private static float nextFloat(Scanner scanner) {
        return Float.parseFloat(scanner.next());
    }

    private static double nextDouble(Scanner scanner) {
        return Double.parseDouble(scanner.next());
    }


}









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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, q; cin >> n >> k >> q;
  vector<int> res(n, k - q);
  for (int i = 0; i < q; i++) {
    int a; cin >> a; a--;
    res[a]++;
  }
  for (int i = 0; i < n; i++) {
    string ans = (res[i] > 0) ? "Yes" : "No";
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N, K, S;
    cin >> N >> K >> S;
    if(S == 1000000000){
        for(int i=0; i<N; i++){
        if(i < K){cout << S;}
        else{cout << 1;}
        cout << " ";
        }
    }
    else{
    for(int i=0; i<N; i++){
        if(i < K){cout << S;}
        else{cout << S+1;}
        cout << " ";
    }
    }
}

Measured memory_bytes: 1280
import qualified Data.ByteString.Char8 as BS
import Data.Ord (compare)
 
readInt :: String -> Integer
readInt = read
 
main = do
  first <- map (readInt . BS.unpack) . BS.words <$> BS.getLine
  second <- map (readInt . BS.unpack) . BS.words <$> BS.getLine
  putStrLn $ case compare first second of
    LT -> "LESS"
    EQ -> "EQUAL"
    GT -> "GREATER"

Measured memory_bytes: 508
process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    const n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .filter(x => x !== "");

    [...uniquenum] = n;
    let judge = [];
    let all = [];
    for (let y = 1; y <= 30; y++) {
        all.push(y);
    }
    const num = uniquenum.sort((a, b) => a - b)
    for (let i = 0; i < 30; i++) {
        if (num.some(item => item == all[i]) == false) {
            judge.push(all[i]);
        }
    }
    const ans = judge.sort((a, b) => a - b);
    console.log(ans[0]);
    console.log(ans[1]);
});


Measured memory_bytes: 15476
w, h, n = map(int, input().split(" "))
x_y_a = [tuple(map(int, input().split(" "))) for i in range(n)]

min_x, max_x, min_y, max_y = 0, w, 0, h
for x_y_a_i in x_y_a:
    x, y, a = x_y_a_i
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    elif a == 4:
        max_y = min(max_y, y)

print(max(0, max_x-min_x) * max(0, max_y-min_y))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

static int count_divisor(int n) {
    int cnt = 0;
    for (int i = 1; i <= floor(sqrt(n)); ++i) {
        if (n % i == 0) cnt += 2;
    }
    return cnt;
}

int main() {
    int N;
    cin >> N;
    int answer = 0;
    for (int i = 0; i <= N; ++i) {
        if (i % 2 == 1) {
            if (count_divisor(i) == 8) ++answer;
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256