akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9+7;

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

  for (int i= 0; i < a+b+1; i++) {
    if (i < a) if (s[i] == '-') {
        printf("No\n");
        return 0;
      }
    if (i == a) if (s[i] != '-') {
        printf("No\n");
        return 0;
      }
    if (i < a+b && i > a) if (s[i] == '-') {
        printf("No\n");
        return 0;
      }
  }
  printf("Yes\n");
  
  
  return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int x1,Y1,x2,y2;
signed main() {
    cin>>x1>>Y1>>x2>>y2;
    int xsa=x1-x2,ysa=Y1-y2;
    int x3=x2+ysa,y3=y2-xsa;
    int x4=x1+ysa,y4=Y1-xsa;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


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

using namespace std;


int N;
string S;

int find(int tgt, int begin);

int main()
{

	cin >> N;
	cin >> S;

	int ans = 0;


	for (int i = 0; i < 10; i++) {
		int f = find(i,0);
		if (f == -1) { continue; }
		for (int j = 0; j < 10; j++) {
			int s = find(j, f + 1);
			if (s == -1) { continue; }
			for (int k = 0; k < 10; k++) {
				int t = find(k, s + 1);
				if (t != -1) { ans++; }

			}
		}
	}

	cout << ans << endl;

	return 0;


}

int find(int tgt, int begin)
{
	int ret = -1;
	for (int i = begin; i < N && ret == -1; i++) {
		if (S[i] == tgt + '0') { ret = i; }
	}

	return ret;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<bitset>
#define nl n<<1
#define nr (n<<1)|1
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const ll mod=100000073;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' | ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0' && ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(ll aa)
{
    if(aa>9)
        Out(aa/10);
    putchar(aa%10+'0');
}
int main()
{
    int n=read();
    if(n/100==n%10)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

int main() {
    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) cout << i << endl; 
    }

    return 0;
}


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

int main( void ) {
	int h, w, d, ini;

	for ( ; scanf( "%d %d", &h, &w ), h; printf( "%d %d\n", h, w ) ) {
		for ( d = ini = h * h + w * w; ; d++ )
			for ( h = d == ini ? h + 1 : 1; h * h * 2 < d; h++ ) {
				w = sqrt( d - h * h );

				if ( w * w == d - h * h )
					goto contin;
			}

		contin: ;
	}

	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
main(){
  char str1[10000],str2[10000],str3[10000];
  int i,j,k,l1,l2,n,sign;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  start:
    scanf("%s",str1);
    scanf("%s",str2);
    l1=strlen(str1);
    l2=strlen(str2);
    if(l1>80||l2>80){
    exit:
      printf("overflow\n");
    exit2:
      i++;
      if(i==n)return 0;
      goto start;
    } else if(str1[0]=='0'&&str2[0]=='0'){
      printf("0\n");
      goto exit2;
    }
     else{
      for(j=l1;j<=100;j++)str3[j]='0';
      for(j=l1-1,k=0;j>=0;j--,k++)str3[k]=str1[j];
      for(j=0;j<=100;j++)str1[j]='0';
      for(j=l2-1,k=0;j>=0;j--,k++)str1[k]=str2[j];
      for(j=0,sign=0;j<=99;j++){
    str3[j]+=(str1[j]-'0')+sign;
    sign=0;
    if(str3[j]>'9'){
      str3[j+1]+=1;
    }
      }
    }
    for(j=80;j<100;j++){
      if(str3[j]!='0'){
    goto exit;
      }
    }
    for(sign=0,j=79;j>=0;j--){
      if(str3[j]!='0'){
    sign++;
      }
      if(sign!=0){
    if(str3[j]>='0'&&str3[j]<='9'){
      printf("%c",str3[j]);
    }else{
      printf("%c",str3[j]-10);
    }
      }
    }
     puts("");
  }
  return 0;
}


Measured memory_bytes: 2036
use proconio::input;

fn main() {
  input! {
    n: usize,
    m: usize,
    h: [usize; n],
    a: [(usize, usize); m]
  }
  
  let mut t: Vec<bool> = Vec::new();
  t.resize(n, true);
  
  for (a, b) in a {
    if h[a-1] == h[b-1] {
      t[a-1] = false;
      t[b-1] = false;
    } else if h[a-1] > h[b-1] {
      t[b-1] = false;
    } else {
      t[a-1] = false;
    }
  }
  
  let mut ans = 0;
  for t in t {
    if t {
      ans += 1;
    }
  }
  
  println!("{}", ans);
}

Measured memory_bytes: 6680
def main():
    # k,a,b:a以上b以下にkの倍数が含まれるか
    k = int(input())
    a,b = map(int, input().split())

    x = a%k
    if x==0:
        print("OK")
    else:
        if (a-x+k)<=b: print("OK")
        else: print("NG") 

main()

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

int main() {
  int n;
  cin >> n;
  int m=0;
  int o=1;
  for(int i=1;i<n+1;i++){
    for(int j=1;j<n+1;j++){
      for(int k=1;k<n+1;k++){
        for(int l=1;l<min(i,min(j,k))+1;l++){
          if(i%l==0 && j%l==0 && k%l==0){
          o=l;
          }
        }
      m+=o;
      o=1;  
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef struct magic{
  int mp, damage;
}magic;
int dp_all[2][100000 + 1],
  dp_single[2][100000 + 1];

int main(int argc, char *argv[]){
  int n, m;
  while(std::cin >> n, n){
    int hp[n];
    int max_hp = 0;
    for (int i = 0; i < n; i++) {
      std::cin >> hp[i];
      max_hp = max(max_hp, hp[i]);
    }
    std::cin >> m;
    string s;
    vector<magic> single, all;
    for (int i = 0; i < m; i++) {
      int mp, damage;
      std::cin >> s >> mp >> s >> damage;
      if(damage == 0)continue;
      if(s == "All"){
        all.push_back(magic{mp, damage});
      }else{
        single.push_back(magic{mp, damage});
      }
    }
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j <= max_hp; j++) {
        dp_all[i][j] = 1e9;
      }
    }
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j <= max_hp; j++) {
        dp_single[i][j] = 1e9;
      }
    }
    for (int i = 0; i < 2; i++) {
      dp_all[i][0] = 0;
    }
    for (int i = 0; i < 2; i++) {
      dp_single[i][0] = 0;      
    }
    for (int i = 0; i < all.size(); i++) {
      int &mp = all[i].mp, &damage = all[i].damage;
      for (int j = 0; j <= max_hp; j++) {
        if(j < damage){
          dp_all[((i + 1)&1)][j] = min(mp, dp_all[(i&1)][j]);
        }else{
          dp_all[((i + 1)&1)][j] =
            min(dp_all[(i&1)][j],
                dp_all[((i + 1)&1)][j - damage] + mp);
        }
      }
    }
    for (int i = 0; i < single.size(); i++) {
      int &mp = single[i].mp, &damage = single[i].damage;
      for (int j = 0; j <= max_hp; j++) {
        if(j < damage){
          dp_single[((i + 1)&1)][j] =
            min(mp, dp_single[(i&1)][j]);
        }else{
          dp_single[((i + 1)&1)][j] =
            min(dp_single[(i&1)][j],
                dp_single[(i + 1)&1][j - damage] + mp);
                
        }
      }
    }
    long long int ans = 1e10;
    int size_all = all.size(), size_single = single.size();
    for (int i = 0; i <= max_hp; i++) {
      long long int sum = dp_all[size_all&1][i];
      for (int j = 0; j < n; j++) {
        if(hp[j] - i <= 0)continue;
        sum += dp_single[size_single&1][hp[j] - i];
      }
      ans = min(ans, sum);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2796
from bisect import bisect

k = int(input())
A = list(range(10))

if k <= 9:
    print(A[k])
    exit()


def is_1_keta(i):
    return len(str(i)) == 1


kouho = list(map(str, range(1, 10)))
kouho2 = list(map(str, range(1, 10)))
while True:
    ll = []
    for i in kouho:
        su = list(filter(is_1_keta, [int(i[-1]) - 1, int(i[-1]), int(i[-1]) + 1]))
        l = [str(i) + str(x) for x in su]
        A.extend(l)
        ll.extend(l)
    kouho = ll
    kouho2.extend(ll)
    if len(kouho2) > k:
        break

print(sorted(list(map(int, kouho2)))[k - 1])


Measured memory_bytes: 94448
N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
#print(M)
for x in M:
    st = str(x[0]).zfill(6)
    st += str(x[3]+1).zfill(6)
    print(st)


Measured memory_bytes: 78552
#include <iostream>
#include <string>
#include <vector>
#include <set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  for (int i = N; i <= 999; i++)
  {
    int n = i;
    std::set<int> s;
    while (n > 0)
    {
      s.insert(n % 10);
      n /= 10;
    }

    if (s.size() == 1)
    {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


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

int main(void){
    int v[3];
    rep(i,3){
        cin>>v[i];
    }
    sort(v,v+3);
    v[2] *= 10;
    cout<<accumulate(v,v+3,0)<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
K2 = 2 * K
m = Array.new(K2 + 1){Array.new(K2 + 1, 0)}
readlines.map(&:split).each do |x, y, c|
  x = x.to_i % K2
  y = (y.to_i + (c == 'W' ? K : 0)) % K2
  m[x + 1][y + 1] += 1
  m[(x + K) % K2 + 1][(y + K) % K2 + 1] += 1
end
(1 .. K2).each do |i|
  (1 .. K2).each do |j|
    m[i][j] += m[i - 1][j] + m[i][j - 1] - m[i - 1][j - 1]
  end
end
ans = 0
(1 .. K).each do |i|
  (1 .. K).each do |j|
    c = m[i + K][j + K] - m[i][j + K] - m[i + K][j] + m[i][j]
    ans = c if c > ans
    c = N - c
    ans = c if c > ans
  end
end
puts ans

Measured memory_bytes: 59924
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        char c = scanner.nextLine().charAt(0);
        if (Character.isLowerCase(c))
            System.out.println('a');
        else 
            System.out.println('A');


    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
//#include <iostream>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    string s;
    cin >> n >> s;
    vector <vector <int> > data(n);
    int r = 0, g = 0, b = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'R') ++r;
        else if (s[i] == 'G') ++g;
        else ++b;
        data[i] = {r, g, b};
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < (n - 1); ++j) {
            if (s[i] == s[j]) continue;
            int cnt = 0;
            if ('R' + 'G' + 'B' - s[i] - s[j] == 'R') cnt += data[j + 1][0];
            else if ('R' + 'G' + 'B' - s[i] - s[j] == 'G') cnt += data[j + 1][1];
            else cnt += data[j + 1][2];
            if (j + (j - i) < n) {
                int new_ind = j + (j - i);
                if ('R' + 'G' + 'B' - s[i] - s[j] - s[new_ind] == 0) --cnt;
            }
            ans += cnt;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    FOR(i,1,n){
        FOR(j,i+1,n+1){
            int t=2;
            int cnt=1;
            while(i%t==j%t){
                t*=2;
                cnt++;
            }
            cout << cnt << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {

    int n;

    while(cin >> n, n) {
        vector< pair< double, string > > ans;
        for(int i = 0; i < n; i++) {
            string str;
            int p, a, b, c, d, e, f, s, m;
            cin >> str >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            int t = a + b + c + (d + e) * m;
            int cnt = f * m;
            ans.push_back(make_pair(-(cnt * s - p) / (double)t, str));
        }

        sort(ans.begin(), ans.end());
        for(int i = 0; i < n; i++) {
            cout << ans[i].second << endl;
        } cout << "#" << endl;
    }
}



Measured memory_bytes: 3040
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if (i == 0 || a[i-1] < a[i]) a[i]--;
        else if (a[i-1] > a[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


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

double degToRad(double deg){
	return M_PI * deg / 180;
}

int main() {
	int n, m;
	int angle;
	int v;
	double area1, area2;
	double E = 0.0000000000001f;
	
	while(cin >> n, n){
		area1 = area2 = 0;
		
		angle = 0;
		for(int i = 0; i < n - 1; ++i){
			cin >> v;
			area1 += sin(degToRad(v));
			angle += v;
		}
		area1 += sin(degToRad(360 - angle));
		
		cin >> m;
		
		angle = 0;
		for(int i = 0; i < m - 1; ++i){
			cin >> v;
			area2 += sin(degToRad(v));
			angle += v;
		}
		area2 += sin(degToRad(360 - angle));
		
		//cout << area1 << " " << area2 << " ";
		
		if(fabs(area1 - area2) < E){
			cout << 0 << endl;
		}else if(area1 > area2){
			cout << 1 << endl;
		}else{
			cout << 2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout << #x << ":\t" << x << endl
#define _ << " " <<

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const int N = 21;
const ll M = 1e9 + 7;

int n, a[N][N];
ll dp[1 << N];

int main() {
//	mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//	freopen("in", "r", stdin)
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) cin >> a[i][j];
	}
	
	dp[0] = 1;
	for (int i = 1; i < (1 << n); ++i) {
		int cnt = __builtin_popcount(i) - 1;
		for (int j = 0; j < n; ++j) {
			if (a[cnt][j] && (i & (1 << j))) {
				dp[i] += dp[i ^ (1 << j)];
				if (dp[i] >= M) dp[i] -= M;
			}
		}
	}
	cout << dp[-1 + (1 << n)];
	
	return 0;
}


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

using namespace std;

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

  int N,K;
  cin>>N>>K;
  vector<int> P(N);
  for (auto& p : P) cin>>p;

  vector<int> par(N-K+1);
  iota(par.begin(), par.end(), 0);
  auto root = [f=[&](auto g, int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = g(g, par[x]);
  }](int x) {
    return f(f, x);
  };
  auto unite = [&](int x, int y) {
    par[root(y)] = root(x);
  };

  {
    int f = 0;
    int l = 1;
    int rooti = -1;
    for (int i = 1; i < N; i++) {
      if (P[i] > P[i - 1]) {
        if (++l == K) {
          if (rooti == -1) {
            rooti = f;
          } else {
            unite(rooti, f);
          }
        }
      } else {
        f = i;
        l = 1;
      }
    }
  }

  {
    set<int> in_window;
    for (int i = 0; i < K; i++)
      in_window.insert(P[i]);
    for (int i = 0; i < N - K; i++) {
      in_window.insert(P[i + K]);
      if (P[i + K] == *(--in_window.end()) and
          P[i] == *in_window.begin()) {
        unite(i, i + 1);
      }
      in_window.erase(P[i]);
    }
  }

  unordered_set<int> graph;
  for (int i = 0; i < par.size(); i++) {
    graph.insert(root(i));
  }
  cout << graph.size() << endl;

  return 0;
}


Measured memory_bytes: 10368
main::IO()
main = do 
    [a,b,c] <- getLine
    print $ raindays a b c
    
raindays a b c
    |(a=='R')&&(b=='R')&&(c=='R') = 3
    |((a=='R')&&(b=='R'))||((b=='R')&&(c=='R')) = 2
    |(a=='R')||(b=='R')||(c=='R') = 1
    |otherwise = 0

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

int main()
{
    int a,b,ans;

    while(scanf("%d %d",&a,&b)!=EOF)
    {
        if(b<10)
            ans=10*a+b;
        else if(b<100)
            ans=100*a+b;
        else
            ans=1000*a+b;

        int x=ceil(sqrt(1.0*ans))-floor(sqrt(1.0*ans));

        if(x)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

bool equation(char *str, int &p);
bool formula(char *str, int &p);

bool c[11];

bool equation(char *str, int &p)
{
    return formula(str, p) == formula(str, ++p);
}

bool formula(char *str, int &p)
{
    //printf("  %d\n", p);
    bool a;
    if (str[p] == 'T') {
        a = true;
        ++p;
    } else if (str[p] == 'F') {
        a = false;
        ++p;
    } else if ('a' <= str[p] && str[p] <= 'k') {
        a = c[str[p] - 'a'];
        ++p;
    } else if (str[p] == '-' && str[p + 1] != '>') {
        ++p;
        a = !formula(str, p);
    } else {
        ++p;
        bool l = formula(str, p);
        if (str[p] == '*') {
            ++p;
            bool r = formula(str, p);
            a = l && r;
        } else if (str[p] == '+') {
            ++p;
            bool r = formula(str, p);
            a = l || r;
        } else if (str[p] == '-' && str[p + 1] == '>') {
            p += 2;
            bool r = formula(str, p);
            a = !l || r;
        }
        ++p;
    }
    return a;
}

int main()
{
    for (;;) {
        char str[1001];

        gets(str);
        if (str[0] == '#')
            break;

        bool f = true;
        for (int j = 0; j < 2048; ++j) {
            c[0] = j & 0x01;
            c[1] = j & 0x02;
            c[2] = j & 0x04;
            c[3] = j & 0x08;
            c[4] = j & 0x10;
            c[5] = j & 0x20;
            c[6] = j & 0x40;
            c[7] = j & 0x80;
            c[8] = j & 0x100;
            c[9] = j & 0x200;
            c[10] = j & 0x400;
            //printf("%4d: %d%d%d%d%d%d%d%d%d%d%d\n", j, c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8], c[9], c[10]);

            int i = 0;
            f = f && equation(str, i);
            if (!f)
                break;
        }

        puts(f ? "YES" : "NO");
    }

    return 0;
}

Measured memory_bytes: 960
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> yakusu(int n){//約数の全列挙
    vector<int> ret(0);
    for(int i=1;i*i<=n;i ++){
        if(n%i==0){
            ret.emplace_back(i);
            if(i*i<n) ret.emplace_back(n/i);
        }
    }
    return ret;
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
 int n;
 cin>>n;
 int cnt=0;
 for(int i=1;i<=n;i+=2){
     auto a=yakusu(i);
     if(a.size()==8) cnt ++;
 }
 cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x;i <= y; ++ i)
#define repd(i,x,y) for(register int i = x;i >= y; -- i)
using namespace std;
typedef long long ll;
template<typename T>inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = -1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}

const int N = 2e5 + 50;
int head[N],to[N << 1],nxt[N << 1],tot;
inline void add(int x,int y)
{
	to[tot] = y;
	nxt[tot] = head[x];
	head[x] = tot ++;
}

char s[N];
int l[N],r[N],mx[N],se[N],sz[N],n;

void dfs1(int x,int fa)
{
	for(register int i = head[x];~i;i=nxt[i])
		if(to[i] != fa)
		{
			dfs1(to[i],x);
			sz[x] += sz[to[i]];
			if(mx[x] < mx[to[i]] + 1)	
				se[x] = mx[x],mx[x] = mx[to[i]] + 1;
			else if(se[x] < mx[to[i]] + 1)
				se[x] = mx[to[i]] + 1;
			if(sz[to[i]]) l[x] = min(l[x],mx[to[i]] + 1);
		}
}

ll ans;

void dfs2(int x,int fa)
{
	r[x] = min(se[x] + 1,mx[x] - 1);
	if(l[x] <= r[x]) ans += r[x] - l[x] + 1;
	for(register int i = head[x];~i;i=nxt[i])
		if(to[i] != fa)
		{
			int k = mx[to[i]]+1==mx[x]?se[x]+1:mx[x]+1;
			if(k > mx[to[i]]) se[to[i]] = mx[to[i]],mx[to[i]] = k;
			else if(k > se[to[i]]) se[to[i]] = k;
			if(sz[1] - sz[to[i]]) l[to[i]] = min(l[to[i]],k);
			dfs2(to[i],x);
		}
}
int main()
{
	memset(head,-1,sizeof head);
	read(n);
	rep(i,2,n)
	{
		int u,v;
		read(u); read(v);
		add(u,v); add(v,u);
	}
	scanf("%s",s + 1);
	rep(i,1,n)
		if(s[i] == '1') l[i] = 0,sz[i] = 1;
		else l[i] = n + 1;

	dfs1(1,1); 
	dfs2(1,1);

	cout << ans + 1<< endl;

	return 0;
}

Measured memory_bytes: 15360
#include <iostream>
#include <array>
#include <algorithm>
#include <stack>
#include <queue>

const int nmax = 105;
const int NIL = -1;
int n;
// state of vertex
// 0: not visited
// 1: visited
// 2: complete search from the vertex
std::array<int, nmax> color, d;

std::array<std::array<int, nmax>, nmax> adj;

void bfs(int v)
{
  std::queue<int> q;
  q.push(v);
  d[v] = 0;

  while (!q.empty())
    {
      v = q.front();
      for (int i=0; i<n; ++i)
        {
          if (adj[v][i] == 1 && d[i] == NIL)
            {
              q.push(i);
              d[i] = d[v] + 1;
            }
        }
      q.pop();

    }
}
int main ()
{
  std::cin >> n;

  color.fill(0);
  std::for_each(adj.begin(), adj.end(), [](auto x){x.fill(0);});
  for (int i=0; i<n; ++i)
    {
      int u, k;
      std::cin >> u >> k;
      for (int j=0; j<k; ++j)
        {
          int v;
          std::cin >> v;
          adj[u-1][v-1] = 1;
        }
    }

  d.fill(NIL);
  bfs(0);

  for (int i=0; i<n; ++i)
    {
      std::cout << i+1 << ' ' << d[i] << std::endl;
    }
}




Measured memory_bytes: 3124
#include <stdio.h>

int main(){
  int count=0;
  char data[4];
  char data2[4];
  scanf("%s",data);
  scanf("%s",data2);
  for(int i=0;i<3;i++){
    if(data[i]==data2[i]){
      count++;
    }
  }
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int,int> pii;
typedef priority_queue<int,vector<int>,greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n,m;
vector<int>v[60];
ll path[60];
void dfs(int x,int fa,ll num){
    path[x]=num;
    for(auto vv:v[x]){
        if(vv==fa)continue;
        dfs(vv,x,num|(1ll<<vv));
    }
}
ll info[60];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int x,y;scanf("%d%d",&x,&y);
        v[x].push_back(y);v[y].push_back(x);
    }
    dfs(1,0,0ll);
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int x,y;scanf("%d%d",&x,&y);
        info[i]=(path[x]^path[y]);
    }
    ll maxstate=(1ll<<m)-1;
    ll ans=0ll;
    for(int i=0;i<=maxstate;i++)
    {
        ll num=0ll;
        int cnt=0;
        for(int j=0;j<=m-1;j++)
        {
            if(i&(1<<j))
            {
                cnt++;
                num|=info[j];
            }
        }
        int free=n-1-__builtin_popcountll(num);
        ans+=(1ll<<free) * (cnt & 1 ? -1ll : 1ll);//这边奇为减，是因为直接计算合法的总数，2^ n-1  --
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> x(N);
  vector<int> y(N);
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
    v[i] = i;
  }

  double distance = 0.0;
  int count = 0;

  // 1,2,3 の順列を生成し、出力する
  do {
    count++;
    double d = 0.0;
    for(int i = 0; i < N - 1; i++) {
      int dx = x[v[i]] - x[v[i + 1]];
      int dy = y[v[i]] - y[v[i + 1]];
      d += pow(dx * dx + dy * dy, 0.5);
    }
    distance += d;
  } while (next_permutation(v.begin(), v.end()));

  cout << setprecision(14) << distance / count << endl;

  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int count = 0;
    for(int i = 0; i < N - 1; i++){
      if(array[i] != array[i + 1]){
        count++;
      }
    }

    System.out.println(count + 1);
  }
}

Measured memory_bytes: 25896
#include <vector>
#include <iostream>
#include <iomanip>
using namespace std;

template <typename T>
using V = vector<T>;

int main() {
    long long n, a; cin >> n >> a;
    V<long long> ns(n); for (auto &x: ns) cin >> x;

    V<V<V<long long>>> memo(n+1, V<V<long long>>(n+1, V<long long>(n*50+1, 0)));
    // [nsのindex][使用する枚数][数] = 何組作れるか
    for (int i=0; i<n+1; i++)
        for (int j=0; j<n+1; j++)
            for (int k=0; k<n*50+1; k++)
                if (i==0 && j==0 && k==0)
                    memo[i][j][k] = 1;
                else if (i>0 && j>0 && k-ns[i-1]>=0)
                    memo[i][j][k] = memo[i-1][j][k] + memo[i-1][j-1][k-ns[i-1]];
                else if (i>0)
                    memo[i][j][k] = memo[i-1][j][k];
                else
                    memo[i][j][k] = 0;

    long long cnt = 0;
    for (int j=1; j<n+1; j++)
        for (int k=0; k<n*50+1; k++)
            if (k%j==0 && k/j==a)
                cnt += memo[n][j][k];
    cout << cnt << endl;
}

Measured memory_bytes: 52224
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N; cin >> N;
    for(int i=0; i<N; i++){
        int a, b, c;
        cin >> a >> b >> c;
        if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }   
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL __int128

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

void write(LL x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}

LL a,b;
char s[10];

int main()
{
	a=read();
	scanf("%s",s+1);
	for(int i=1;i<=strlen(s+1);++i)
		if(s[i]!='.')
			b=b*10+s[i]-'0';
	a=a*b;
	a/=100;
	write(a);
	printf("\n");
	return 0;
}


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

#define DEBUG(x) cout << x << endl;

int N;
int v[100005][3];
int dp[100005][3];

int solve() {
    dp[0][0] = v[0][0];
    dp[0][1] = v[0][1];
    dp[0][2] = v[0][2];
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + v[i][j]);
                }
            }
        }
    }
    return max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2]);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> v[i][0] >> v[i][1] >> v[i][2];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

const long long LLINF = 1LL << 60;

int main(void) {
	string s;
	cin >> s;
	while (s != "-") {
		int m;
		cin >> m;
		rep(i, m) {
			int h;
			cin >> h;
			string tmp = s.substr(0,h);
			s.erase(s.begin(), s.begin() + h);
			s.append(tmp);
		}
		cout << s << endl;
		cin >> s;
	}
}


Measured memory_bytes: 3220
s=input()
n=len(s)
x=[ord(c)-ord('a') for c in s]

for i in range(1,n):
    if x[i]==x[i-1]:
        print('{} {}'.format(i,i+1))
        exit(0)
    if i>1 and x[i-2]==x[i]:
        print('{} {}'.format(i-1,i+1))
        exit(0)

print('-1 -1')

Measured memory_bytes: 75292
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>


using namespace std;

int a[100005];
int d[100005];

void oku(){
  int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d", a + i);

	memset(d,0,sizeof d);

	for(int i=0;i<n;i++) 
	{
		if(a[i] > 0)
		   d[a[i]-1]++;
		d[a[i]]++;
		d[a[i]+1]++;
	}

	int ans = 0;

	for(int i=0;i<100005;i++)
		ans = max(ans, d[i]);

	cout<<ans;
}

int main(){

oku();
return 0;}

Measured memory_bytes: 1024
from Queue import * # Queue, LifoQueue, PriorityQueue
from bisect import * #bisect, insort
from collections import * #deque, Counter,OrderedDict,defaultdict
#set([]) 
import math
import copy
import itertools
import string
import sys
myread = lambda : map(int,raw_input().split())
def solver():
    memo = defaultdict(int)
    S = raw_input()
    for c in S:
        memo[c] += 1

    for v in memo.values():
        if v % 2 == 1:
            print 'No'
            return
    print 'Yes'



if __name__ == "__main__":
    solver()
    


Measured memory_bytes: 3292
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

vector<long long> calc(long long N){
    long long i;
    vector<long long> yakusuu;
    for(i=1;i<=sqrt(N);i++){
        if(N%i==0){
            if(i!=1){
                yakusuu.push_back(i);
            }
            if(i!=sqrt(N)){
                yakusuu.push_back(N/i);
            }
        }
    }
    
    
    
    
    
    
    
    return yakusuu;
}
int main(){

    long long N; cin >> N;
    
    long long cnt=0;
    vector<long long> yakusuu_N_1 = calc(N-1);
    vector<long long> yakusuu_N = calc(N);
    
    long long N_temp = N;
    for(long long k : yakusuu_N){
        N = N_temp;
        while(1){
            N = N/k;
            if(N==1){
                cnt++;
                break;
            }
            if(N%k==0) continue;
            if(N%k==1){
                cnt++;
            }
            break;
        }
    }
    
    cout << cnt + yakusuu_N_1.size()<< endl;
    
    
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
	int S;
	int h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-(3600*h))/60;
	s=(S-(3600*h))%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 2708
input()
seq = [int(x) for x in input().split()]
ans = 0
streak = 0
cur_val = seq[0]
for i, val in enumerate(seq[1:]):
    if val <= cur_val:
      streak += 1
    else:
      ans = max(ans, streak)
      streak = 0
    cur_val = val
ans = max(ans, streak)
print(ans)

Measured memory_bytes: 14252
mod=1e9+7
mod=int(mod)
def pow(a,b):
    # if a>b:
    #     a,b=b,a
    if(b==0):
        return 1
    temp=pow(a,b//2)%mod
    temp=(temp**2)%mod
    if b%2==0:
        return temp%mod
    else:
        return (temp*a)%mod

a,b=map(int,input().split())
print(pow(a,b)%mod)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a; cin >> a;
	string str; cin >> str;
	int cnt1[a + 50][15];
	memset(cnt1, 0, sizeof(cnt1));
	for(int i=0; i<a; i++)
	{
		if(i)
		{
			for(int j=0; j<10; j++)
				cnt1[i][j] = cnt1[i - 1][j];
		}
		cnt1[i][str[i] - '0'] = true;
	}
	int cnt2[a + 50][105] = {0};
	for(int i=1; i<a; i++)
	{
		if(i)
		{
			for(int j=0; j<100; j++)
				cnt2[i][j] = cnt2[i - 1][j];
		}
		for(int j=0; j<10; j++)
		{
			int temp = j * 10 + str[i] - '0';
			if(cnt1[i - 1][j]) cnt2[i][temp] = true;
		}
	}
	int cnt3[a + 50][1005] = {0};
	int ans = 0;
	for(int i=2; i<a; i++)
	{
		if(i)
		{
			for(int j=0; j<1000; j++)
				cnt3[i][j] = cnt3[i - 1][j];
		}
		for(int j=0; j<100; j++)
		{
			int temp = j * 10 + str[i] - '0';
			if(cnt2[i - 1][j])
			{
				if(!cnt3[i][temp]) ans ++;
				cnt3[i][temp] = true;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 132352
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

static int n;

double calc(int day, int win)
{
	static const int cut = 10;
	static double memo[100001][cut];
	
	if(day == 0)
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < cut; ++j)
				memo[i][j] = -1;
	
	double ret = 0;
	double per = 1.0 / (1 << win);
	
	if(n == day || win >= cut)
		return 0;
		
	if(memo[day][win] != -1)
		return memo[day][win];
	
	ret += (calc(day + 1, win + 1) + 1) * per;
	ret += calc(day + 1, 0) * (1 - per);
	
	return memo[day][win] = ret;
}

int main()
{
	while(true) {
		
		scanf("%d", &n);
		
		if(n == 0)
			break;
		
		printf("%f\n", calc(0, 0));
	}
	
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}

const ll MOD = (ll)(1e9+7);
ll f[100000 + 10];

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int M = nextInt();
  if (N > M) swap(N, M);
  if (N + 1 < M) {
    cout << 0 << endl;
    return 0;
  }

  f[0] = 1;
  for (int i = 1; i < N+2; i++) f[i] = (f[i-1] * i) % MOD;
  
  ll ans = f[N] * f[M] % MOD;
  if (N == M) ans = (ans * 2) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 1024
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}

template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

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

  ll n,m,l;
  std::cin>>n>>m>>l;

  std::vector<std::vector<P>> graph(n);

  std::vector<std::vector<ll>> dp(n,std::vector<ll>(n,MOD));

  rep(i,0,m){
    ll a,b,c;
    std::cin>>a>>b>>c;
    a--;b--;
    if(c<=l){
      graph[a].push_back({b,c});
      graph[b].push_back({a,c});
    }
  }

  rep(i,0,n){
    std::stack<P> que;
    que.push({i,l});
    std::vector<ll> used(n,-1);
    used[i]=l;

    while(!que.empty()){
      P now=que.top();que.pop();
      dp[i][now.first]=1;

      for(P next:graph[now.first]){
        if(chmax(used[next.first],now.second-next.second)){
          que.push({next.first,now.second-next.second});
        }
      }
    }
  }

  rep(i,0,n)dp[i][i]=0;

  rep(k,0,n){
    rep(i,0,n){
      rep(j,0,n){
        dp[i][j]=std::min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }

  ll q;
  std::cin>>q;

  rep(_,0,q){
    ll s,t;
    std::cin>>s>>t;
    s--;t--;
    if(dp[s][t]==MOD)std::cout<<-1<<"\n";
    else std::cout<<std::max(dp[s][t]-1,0ll)<<"\n";
  }
 
  return 0;
}

Measured memory_bytes: 3584
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut ans = 0;
    for i in 0..n{
        let line = read_as_vec::<u32>();
        ans += (line[1] -line[0]+1);
    }
    println!("{}", ans);
}


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

int main(void){
    string s;
    cin>>s;
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi" ){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  for(int i = 0; i < 100000; ++i){
    if (a%2 != 0 || b%2 != 0 || c%2 != 0){
      cout << i << endl;
      return 0;
    }
    int na = b/2 + c/2;
    int nb = a/2 + c/2;
    int nc = a/2 + b/2;
    a = na;
    b = nb;
    c = nc;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a1 = sc.nextInt();
    int a2 = sc.nextInt();
    int a3 = sc.nextInt();

    if(a1 + a2 + a3 >= 22){
        System.out.println("bust");
    }else{
        System.out.println("win");
    }
    
    
	}
}

Measured memory_bytes: 35688
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	priority_queue<ll> q;
	for(int i = 0; i < n; ++i) {
		ll a;
		cin >> a;
		if( a % 2 == 0 ) { 
			q.push(a);
		}
	}
	
	if( q.empty() ) { 
		cout << 0 << endl;
		return 0;
	}
	
	int cnt = 0;
	while( !q.empty() ) {
		ll tmp = q.top();
		q.pop();
		
		if( tmp % 2 == 0 )  {
			q.push(tmp / 2);
			cnt++;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 512
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
vector<pii> g[100005];
int cnt[3],c[100005];
bool flag;
int sz=0,sz_m;
inline void dfs(int x){
	cnt[c[x]]++;sz++;
	for(int i=0;i<g[x].size();i++){
		int y=g[x][i].fi,z=g[x][i].se;
		sz_m++;
		if(!(~c[y])){
			c[y]=(c[x]+z)%3;
			dfs(y);
		}
		else if(c[y]!=(c[x]+z)%3)	flag=1;
	}
}
signed main(){
	fz(i,1,m){
		int x=read(),y=read();
		g[x].push_back({y,1});
		g[y].push_back({x,2});
	}
	int ans=0;
	fill1(c);
	fz(i,1,n){
		if(c[i]==-1){
			c[i]=0;fill0(cnt);flag=0;sz=sz_m=0;
			dfs(i);
			if(flag){
				ans+=sz*sz;
			}
			else{
				if(cnt[0]&&cnt[1]&&cnt[2])
					ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
				else
					ans+=sz_m>>1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10624
#include<iostream>
#include<ios>
#include<algorithm>
using namespace std;
int dp[111][111];
int a[111];
main()
{
	int i=0,last=0;
	while(1)
	{
		int t=0;
		char c;
		while(scanf("%d%c",a+t++,&c),c==',');
		if(last==0)
		{
			dp[i+1][0]=a[0];
			last=t;
		}
		else if(last<t)
		{
			for(int j=0;j<last;j++)
			{
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]+a[j]);
				dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+a[j+1]);
			}
			last=t;
		}
		else
		{
			for(int j=0;j<t;j++)
			{
				dp[i+1][j]=max(dp[i][j],dp[i][j+1])+a[j];
			}
			last=t;
			if(t==1)
			{
				cout<<dp[i+1][0]<<endl;
				return 0;
			}
		}
		i++;
	}
}


Measured memory_bytes: 3168
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int n;
  cin >> n;
  if(n >= 3) cout << n/3 << endl;
  else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
     
    using namespace std; 
    // using namespace arma;
     
    #define ll long long
    #define ld long double
    // int ans(vector < vector<int > > xx)
    // {
    //  return 0;
    // }
    int main()
    {
        ll h,w,k;
        cin >> h >> w >> k;
        char arr[h][w];
        ll bk=0;
        for(ll i=0;i<h;i++)
        {
            for(ll j=0;j<w;j++)
            {
                cin >> arr[i][j];
                if(arr[i][j]=='#')
                    bk+=1;
            }
        } 
        ll ans=0;
        for(ll i=0;i<(1<<h);i++)
        {
            for(ll j=0;j<(1<<w);j++)
            {
                ll ct=0; 
                for(ll a=0;a<h;a++)
                {
                    for(ll b=0;b<w;b++)
                    {
                        if((i&(1<<a)) || (j&(1<<b)))
                        {
                            if(arr[a][b]=='#')
                                ct++;
                            //cout << a << " " << b << "\n";
                        }
                    }
                }
                ll dif = bk-ct;
               //cout << dif << "\n";
                if(dif==k)
                {
                  ans+=1;
                  //cout << i << " " << j << "\n";
                }
            }
        }
        //if(bk==k)
          //ans=1;
        cout << ans << "\n";
    }

Measured memory_bytes: 3568