akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i) = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  string s;cin>>s;
  bool ok = false;
  rep(i,s.size())ok |= s[i] == '7';
  print(ok?"Yes":"No");
  return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n, k;
    cin >> n >> k;
    cout << (n + k - 1)/k;
    return 0;
}


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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;


int main()
{

    map<string, int> mp;
    int n;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto x: mp){
        mx = max(mx, x.second);
    }
    for(auto x: mp){
        if(x.second == mx){
            cout << x.first << "\n";
        }
    }

    return 0;
}



Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int INF = 1 << 30;
 
int sum[1000];
int getSum(int left, int right){ // [left, right)
  if(left == 0) return sum[right - 1];
  return sum[right - 1] - sum[left - 1];
}
 
int main(){
  int N, c[1000], w[1000], dp1[1000][1001], dp2[1001];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> c[i] >> w[i];
    sum[i] = w[i];
    if(i > 0) sum[i] += sum[i - 1];
  }
  fill_n( *dp1, 1000 * 1001, false);
  // dp1[left][right]: [left, right)を1人にできるか
  for(int i = 0; i < N; i++){
    dp1[i][i + 1] = true;
  }
 
  for(int i = 2; i <= N; i++){ // 区間
    for(int left = 0; left + i <= N; left++){ // 左
      int right = left + i; // 右
      if(dp1[left][right - 1]){
        int weight = getSum( left, right - 1); // 持ち上がってる
        dp1[left][right] |= weight <= c[right - 1];
      }
      if(dp1[left + 1][right]){
        int weight = getSum( left + 1, right);
        dp1[left][right] |= weight <= c[left];
      }
    }
  }
 
  fill_n( dp2, 1001, INF);
  dp2[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j <= N; j++){
      if(dp1[i][j]) dp2[j] = min( dp2[j], dp2[i] + 1);
    }
  }
  cout << dp2[N] << endl;
}

Measured memory_bytes: 5084
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
 
int main()
{
  string s;
  int k;
  cin >> k;
  cin >> s;
 
	  
  if (s.length() <= k){
	cout << s << endl;
  }else{
	s = s.substr(0,k);
    cout << s  << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n; sc(n);
    ll len = 3e5, ans = 0;
    vector<ll> a(n), b(len,0);
    rep(i, 0, n) sc(a[i]);
    rep(i, 0, n){
        if (i-a[i]+1 < 0) continue;
        b[i-a[i]+1]++;
    }
    rep(i, 0, n){
        if (i+a[i]+1>len) continue;
        ans += b[i+a[i]+1];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	double a, b, c, C, S, h;

	cin >> a >> b >> C;

	C = C * PI / 180;
	S = a * b * sin(C) / 2;
	c = a * a + b * b - 2 * a * b * cos(C);
	c = sqrt(c);
	h = 2 * S / a;

	printf("%.10lf\n", S);
	printf("%.10lf\n", a + b + c);
	printf("%.10lf\n", h);


	return 0;
}



Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x,y) memset(x,y,sizeof(x))
#define STS system("pause")
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const int P=716070898,Mod=998244353;
vector<int>e[101000];
int n,m,X,Y,fac[303000],f[3][101000],sg[101000],ans;
map<int,int>mp;
I add(int &x,int y){
	(x+=y)>=Mod?x-=Mod:0;
}
int main(){
	read(n);
	fac[0]=1;
	F(i,1,n*3)fac[i]=(ll)fac[i-1]*P%Mod;
	F(c,0,2){
		read(m);
		F(i,1,n)e[i].clear(),sg[i]=0;
		F(i,1,m){
			read(X);read(Y);
			if(X>Y)swap(X,Y);
			e[X].emplace_back(Y);
		}
		FOR(i,n,1){
			mp.clear();
			for(auto d:e[i])mp[sg[d]]=1;
			sg[i]=0;
			while(mp[sg[i]])sg[i]++;
			add(f[c][sg[i]],fac[i]);
		}
	}
	F(i,0,500){
		F(j,0,500){
			add(ans,(ll)f[0][i]*f[1][j]%Mod*f[2][i^j]%Mod);
		}
	}
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 6912
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn exe(card: Vec<Vec<u32>>, b: Vec<u32>) -> bool {
    let mut a = [[false; 3]; 3];
    for i in 0..3 {
        for j in 0.. 3 {
            a[i][j] = b.contains(&card[i][j]);
        }
    }
    (a[0][0] && a[0][1] && a[0][2]) ||
    (a[1][0] && a[1][1] && a[1][2]) ||
    (a[2][0] && a[2][1] && a[2][2]) ||
    (a[0][0] && a[1][0] && a[2][0]) ||
    (a[0][1] && a[1][1] && a[2][1]) ||
    (a[0][2] && a[1][2] && a[2][2]) ||
    (a[0][0] && a[1][1] && a[2][2]) ||
    (a[0][2] && a[1][1] && a[2][0])
}

fn main() {
    input! {
        card: [[u32; 3]; 3],
        n: usize,
        b: [u32; n]
    }
    let ans = if exe(card, b) { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = gets.to_i
a = gets.split.map(&:to_i)
c = Array.new(n, nil)

j = 0
status = nil
(1..(n-1)).each do |i|
  if i == n - 1
    if status == "up"
      if a[i-1] < a[i]
        c[i] = 2
        c[j] = 2
      else
        c[i-1] = 2
      end
    elsif status == 'down'
      if a[i-1] < a[i]
        c[i-1] = 1
        c[i] = 2
      else
        c[i-1] = 2
      end
    else
      if a[i-1] < a[i]
        c[i-1] = 1
        c[i] = 2
      end
    end
  elsif a[i-1] < a[i]
    if status == "up"
    elsif status == 'down'
      status = 'up'
      j = i - 1
      c[j] = 1
      c[j-1] = 2
    else
      status = 'up'
      j = i - 1
      c[j] = 1
    end
  elsif a[i-1] > a[i]
    if status == "up"
      status = 'down'
      j = i
      c[j-1] = 2
    elsif status == 'down'
      j = i
    else
      status = 'down'
      j = i - 1
    end
  end
end
num_m = 1000
num_k = 0
c.each_with_index do |z, i|
  if z == 1
    k = num_m / a[i]
    num_m -= k * a[i]
    num_k += k
  elsif z == 2
    num_m += num_k * a[i]
    num_k = 0
  end
end
puts num_m

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

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (a + k - 1 < b - k + 1) {
    for (int i = a; i <= a + k - 1; ++i) cout << i << endl;
    for (int i = b - k + 1; i <= b; ++i) cout << i << endl;
  } else {
    for (int i = a; i <= b; ++i) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
s = input()
c = True
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] != 'U' and s[i] != 'D' and s[i] != 'L':
            c = False
    if i % 2 == 0:
        if s[i] != 'U' and s[i] != 'D' and s[i] != 'R':
            c = False

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

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

int main() {
	map<long long int, bool> mp;
	long long int N, A, count = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		mp[A] = !mp[A];
	}
	map<long long int, bool>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		if (it->second) count++;
	}
	cout << count;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int inf = int (1e9) + int (1e5);
const ll infl = ll(2e18) + ll(1e10);
const ui M = 1E9 + 7;
const double eps = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define MP make_pair

bool solve(int x0,int y0,int x,int y,int dt){
    if (x==x0 && y==y0) return false;
    int steps = abs(x-x0) + abs(y-y0);
    if ( steps > dt) return false;
    if ((steps%2==0 && dt%2!=0) || (steps%2!=0 && dt%2==0)) return false;
    return true;

}

int main() {
    int N,x0,y0,t0,x,y,t;
    cin >> N;
    x0=y0=t0=0;
    bool ret;
    while (N--){
        cin >> t >> x >> y;
        ret = solve(x0,y0,x,y,t-t0);
        if (!ret){
            cout << "No";
            break;
        }
    }
    if (ret) cout << "Yes";

    return 0;
}


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

bool prime[200000000]={};
void Eratosthenes(int n)
{
  for(int i=2;i<=(int)sqrt(n)+1;++i)
  {
    if(prime[i]==true)
    {
      for(int j=i*2; j<=n; j+=i)
      {
        prime[j]=false;
      }
    }
  }
}

int main()
{ 
  int n;
  vector<int> ans;
  while(cin>>n, n)
  {
    for(int i=2;i<=2*n;++i) prime[i]=true;
    Eratosthenes(2*n);
    int cnt=0;
    for(int i=n+1;i<=2*n;++i) if(prime[i]==true) cnt++;
    ans.push_back(cnt);
  }
  for(auto& e:ans) cout<<e<<"\n";

  return 0;
}



Measured memory_bytes: 3368
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

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


int main(void){
    char s[55][55];
    ll h,w;
    scanf("%lld%lld",&h,&w);
    // ll [n];
    rep(i,0,h){
        scanf("%s",s[i]);
    }
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='.') continue;
            ll cnt=0;
            rep(k,0,4){
                ll Y=i+dy[k],X=j+dx[k];
                if(Y<0 || X<0 || Y>=h||X>=w) continue;
                if(s[Y][X]=='#') cnt++;
            }
            if(cnt==0){
                // printf("%lld %lld ",i,j);
                NO;
                return 0;
            }
        }
    }

    YES;
    // printf("%lld\n");
    return 0;
}


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

#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;
const ll INF = 1e18;

int a[N], dp[N];

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[1] = 0;
	a[0] = inf;
	for (int i = 2; i <= n; i++) {
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n];
	return 0;       	
}                               

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
class Test{
 public static void Main(){
   var N = long.Parse(Console.ReadLine());
   string ans="";
   int a = (int)'a';
   while(N>0){
     N--;
     ans += (char)((int)a+(N%26));
     N /= 26;
   }
   Console.Write(new string(ans.Reverse().ToArray()));
 }
}

Measured memory_bytes: 28068
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)

Measured memory_bytes: 6724
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;




void main() {
    int n;
    scan(n);

    auto ss = new dchar[][](n, 0);

    foreach (i ; 0 .. n) {
        ss[i] = readln.chomp.to!(dchar[]).sort().to!(dchar[]);
    }

    ss.sort();

    debug {
        writeln(ss);
    }

    auto g = ss.group.array;

    long ans;

    foreach (gi ; g) {
        long k = gi[1];
        ans += k * (k - 1) / 2;
    }

    writeln(ans);
}


















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main(void){
  int my1,my2,op;
  bool isused[11];

  while(cin >> my1 >> my2 >> op){
    int candidate = 0;
    fill(isused, isused+11, false);
    isused[my1] = true;
    isused[my2] = true;
    isused[op]  = true;
    if(my1+my2<=10){
      cout << "YES" << endl;
    }else{
      for(int i=1;i<=10;i++){
	if(isused[i] == false && my1+my2+i <= 20){
	  candidate++;
	}
      }
      if((double)candidate / 7 > 0.5){
	cout << "YES" << endl;
      }else{
	cout << "NO" << endl;
      }
    }
  }
}

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

constexpr ll nCr(ll n, ll r, ll mod = 1e9 + 7)
{
    auto min_r = min(r, n - r);
    ll x = 1;
    for (ll i = 0; i < min_r; i++) {
        x *= n - i;
    }
    ll y = 1;
    for (ll i = 0; i < min_r; i++) {
        y *= i + 1;
    }

    return x / y;
}

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    vector<ll> As_ps;
    As_ps.reserve(N);
    partial_sum(begin(As), end(As), back_inserter(As_ps));

    map<ll, ll> As_m;
    As_m[0]++;
    for (auto aps : As_ps) {
        As_m[aps]++;
    }

    ll ans = 0;
    for (auto&& m : As_m) {
        if (m.second >= 2) {
            ans += nCr(m.second, 2);
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,ans=1;
  cin >> N;
  string S,T;
  cin >> S >> T;
  rep(i,N){
    if(i==0){
      if(S.at(i)==T.at(i)){
        ans*=3;
        ans%=MOD;
      }else{
        ans*=6;
        ans%=MOD;
        i++;
      }
    }else{
      if(S.at(i)==T.at(i)){
        if(S.at(i-1)==T.at(i-1)){
          ans*=2;
          ans%=MOD;
        }
      }else{
        if(S.at(i-1)==T.at(i-1)){
          ans*=2;
          ans%=MOD;
        }else{
          ans*=3;
          ans%=MOD;
        }
        i++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3552
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n,m = getNM()

balls = [[1,0] for i in range(n)]
balls[0] = [1,1]
for i in range(m):
    x,y = getNM()
    x -= 1
    y -= 1
    balls[y][0] += 1
    if balls[x][1] == 1:
        balls[y][1] = 1
    balls[x][0] -= 1
    if balls[x][0] == 0:
        balls[x][1] = 0

print(sum([b[1] for b in balls]))


Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
int power(int x, int n) {
  int ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return ret;
}
signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int x; cin>>x;
    int ans = 1;
    for(int i=1;i<x;i++){
        for(int j=2;j<x;j++){
            int tmp = pow(i, j);
            if(tmp <= x) {
                if(ans < tmp) ans = tmp;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String[] s = S.split("");
		
		for(int i = 0; i < s.length - 1; i++) {
			for(int j = i + 1; j < s.length; j++) {
				if(s[i].equals(s[j])) {
					System.out.println("no");
					return;
				}
			}
		}
		System.out.println("yes");
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;



int main(){
    int N;
    cin >>N;
    vi H(N);
    rep(i,N) cin >>H[i];
    vi dp(N);
    dp[0]=0;
    dp[1]= abs(H[1]-H[0]);
    rep2(i,1,N-1){
        ll step1=dp[i]+abs(H[i+1]-H[i]);
        ll step2=dp[i-1]+abs(H[i+1]-H[i-1]);
        dp[i+1] = min(step1,step2);
    }
    cout <<dp[N-1]<<endl;
}


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

using namespace std;
typedef long long ll;
const int N=1e5+9;
int n,k;
int a[N];
int dp[N];
int main(){

    while(~scanf("%d%d",&n,&k)){
        memset(dp,0x3f,sizeof dp);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        dp[0]=0;
        dp[1]=0;
        for(int i=2;i<=n;i++){
            for(int j=i-1;j>=max(i-k,1);j--)
                dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
        }
        cout<<dp[n]<<"\n";
    }

    return  0;
}





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

int main(){
	std::string Number;
	cin >> Number;
	while(Number[0] != '0' || Number.size() > 1){
		int Count = 0;
		vector<int> number;
		for(int i = 0; i < Number.size(); i++){
			if(Number[i] == '0') number.push_back(0);
			if(Number[i] == '1') number.push_back(1);
			if(Number[i] == '2') number.push_back(2);
			if(Number[i] == '3') number.push_back(3);
			if(Number[i] == '4') number.push_back(4);
			if(Number[i] == '5') number.push_back(5);
			if(Number[i] == '6') number.push_back(6);
			if(Number[i] == '7') number.push_back(7);
			if(Number[i] == '8') number.push_back(8);
			if(Number[i] == '9') number.push_back(9);
			Count += number[i];
		}
		cout << Count << endl;
		cin >> Number;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

int main(void)
{
    int N, K;
    cin >> N >> K;

    vector<int> l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for (int i = 0; i < K; i++)
    {
        ans += l[i];
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int m, f, r, p;

	while (1) {

		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1)
			break;

		p = m + f;

		if (m == -1 || f == -1) {
			printf("F");
		}

		else if (80 <= p) {
			printf("A");
		}

		else if (65 <= p && p < 80) {
			printf("B");
		}

		else if (50 <= p && p < 65) {
			printf("C");
		}

		else if (p < 30) {
			printf("F");
		}

		else if (30 <= p && p < 50 && r < 50) {
			printf("D");
		}
		
		else if (30 <= p && p < 50 && 50 <= r) {
			printf("C");
		}

		printf("\n");
	}

	return(0);

}


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

P f(int x){
  int a = x % 10;
  int b = 0;
  while (x){
    b = x;
    x /= 10;
  }
  return P(a, b);
}

int main(){
  int N; cin >> N;
  map<P, int> freq;
  for (int i = 1; i <= N; ++i){
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  for (int i = 1; i <= N; ++i){
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

var INF = (1 << 32) - 1

func main(){
	var N, K int

	fmt.Scan(&N)
	fmt.Scan(&K)

	trees := make([]int, N)

	for i:=0; i<N; i++{
		fmt.Scan(&trees[i])
	}

	sort.Ints(trees)

	minDiff := INF

	for i:=0; i+K<=N; i++{

		tmpDiff := trees[i+K-1] - trees[i]

		minDiff = min(minDiff, tmpDiff)

	}

	fmt.Println(minDiff)
}

func max(x int, y int) int{
	if x > y {
		return x
	}else{
		return y
	}
}

func min(x int, y int) int{
	if x < y {
		return x
	}else{
		return y
	}
}


Measured memory_bytes: 5504
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var x = long.Parse(Console.ReadLine());
            var a = 0;
            var b = 0;
            var a5 = Enumerable.Range(0, 10000).Select(x => new { X = (long)x, X5 = (long)Math.Pow(x, 5) }).ToArray();
            for (var i = 0; i < a5.Length; i++)
            {
                var b5 = a5[i].X5 - x;
                for (var j = 0; j < a5.Length; j++)
                {
                    if (Math.Abs(b5) == a5[j].X5)
                    {
                        a = i;
                        b = (b5 >= 0) ? j : -j;
                        break;
                    }
                }
            }
            Console.WriteLine($"{a} {b}");
        }
    }
}


Measured memory_bytes: 29228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define forr(i, n) for(int i = 0;i < n; ++i)
int main()
{
	cr7
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll sum = 0;
	while (a > 0 && k > 0) {
		sum += 1;
		a--; k--;
	} //deb(k);
	while (b > 0 && k > 0) {
		sum += 0;
		b--; k--;
	}
	while (c > 0 && k > 0) {
		sum -= 1;
		c--; k--;
	}
	cout << sum << "\n";
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(int N, S; cin >> N >> S && (N | S);) {
    int A[N + 1];
    rep(i, N) {
      cin >> A[i];
    }

    sort(A, A + N);
    A[N] = inf;

    ll sum = 0;

    rep(i, N - 1) {
      int j = upper_bound(A + i + 1, A + N + 1, S - A[i]) - A;
      sum += N - j;
    }

    cout << sum << endl;
  }

  
  return 0;
}

Measured memory_bytes: 3096
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a,b,c,d = readline() |> split |> parseMap
	s = readline() |> chomp
	s = s*"#"
	flg = 0
	oflg = 0
	if c<b
		for i in a:c-1
			if s[i]=='#' && s[i+1] == '#'
				flg = 1
				break
			end
		end
		for i in b:d-1
			if s[i]=='#' && s[i+1] == '#'
				flg = 1
				break
			end
		end
	else
		for i in a:max(c,d)-1
			if s[i]=='#' && s[i+1] == '#'
				flg = 1
				break
			end
		end
	end
	if c>d
		for i in b-1:d-1
			if s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'
				oflg = 1
				break
			end
		end
	else
		oflg = 1
	end
	println(flg==0&&oflg==1?"Yes":"No")
end

main()

Measured memory_bytes: 168860
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int map[5003][5003] = {0};

int main() {

  long long int n, m, input_x, input_y;

  cin >> n >> m;

  vector< long long int > x, y, x_s, y_s;
  x_s.push_back( -10000000000 );
  x_s.push_back(  10000000000 );
  y_s.push_back( -10000000000 );
  y_s.push_back(  10000000000 );

  for ( long long int i = 0; i < n; i++ ) {
    cin >> input_x >> input_y;
    x.push_back( input_x );
    y.push_back( input_y );
    x_s.push_back( input_x );
    y_s.push_back( input_y );
  }
  sort( x_s.begin(), x_s.end() );
  x_s.erase( unique( x_s.begin(), x_s.end() ), x_s.end() );
  sort( y_s.begin(), y_s.end() );
  y_s.erase( unique( y_s.begin(), y_s.end() ), y_s.end() );
  vector< long long int >:: iterator it;
  for ( long long int i = 0; i < n; i++ ) {
    it = lower_bound( x_s.begin(), x_s.end(), x[i] );
    x[i] = distance( x_s.begin(), it );
    it = lower_bound( y_s.begin(), y_s.end(), y[i] );
    y[i] = distance( y_s.begin(), it );
    map[ x[i] ][ y[i] ]++;
  }
  for ( long long int i = 0; i < n+2; i++ ) {
    long long int k = 0;
    for ( long long int j = 0; j < n+2; j++ ) {
      map[j][i] += k;
      k = map[j][i];
      if ( i > 0 ) {
	map[j][i] += map[j][i-1];
      }
    }
  }

  /*
  for ( long long int i = 0; i < n+2; i++ ) {
    for ( long long int j = 0; j < n+2; j++ ) {
      cout << map[j][i] << " ";
    }
    cout << endl;
  }
  */
  long long int x1, x2, y1, y2;
  for ( long long int i = 0; i < m; i++ ) {
    cin >> x1 >> y1 >> x2 >> y2;
    it = lower_bound( x_s.begin(), x_s.end(), x1 );
    x1 = distance( x_s.begin(), it ) - 1;
    it = lower_bound( y_s.begin(), y_s.end(), y1 );
    y1 = distance( y_s.begin(), it ) - 1;
    it = upper_bound( x_s.begin(), x_s.end(), x2 );
    x2 = distance( x_s.begin(), it ) - 1;
    it = upper_bound( y_s.begin(), y_s.end(), y2 );
    y2 = distance( y_s.begin(), it ) - 1;
    long long int ans = map[x2][y2];
    if ( x1 >= 0 ) ans -= map[x1][y2];
    if ( y1 >= 0 ) ans -= map[x2][y1];
    if ( x1 >= 0 && y1 >= 0 ) ans += map[x1][y1];
    //    cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    cout << ans << endl;
  }

  return 0;

}

Measured memory_bytes: 99196
import java.util.Scanner;


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

			int i;
			int j;

			int n = sc.nextInt();
			int m = sc.nextInt();

			int A[][] = new int[n][m];
			int b[] = new int[m];
			int c[] = new int[n];

			for(i = 0; i < n; i++) {
				for(j = 0; j < m; j++) {
					int a_ij = sc.nextInt();
					A[i][j] = a_ij;
				}
			}

			for(i = 0; i < m; i++) {
				int b_i = sc.nextInt();
				b[i] = b_i;
			}

			for(i = 0; i < n; i++) {
				for(j = 0; j < m; j++) {
					c[i] = c[i] + A[i][j] * b[j];
				}
				System.out.println(c[i]);
			}

	}
}

Measured memory_bytes: 40620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}


int main() {
    int h,w,kabe_cnt = 0;
    cin >> h >> w;
    vector<string> maze(h);
    for (int i = 0; i < h; ++i) {
        cin >> maze[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(maze[i][j] == '#') kabe_cnt++;
        }
    }
    vector<vector<int>> dist(h,vector<int>(w,-1));
    queue<pair<int,int>> q;
    dist[0][0] = 0;
    q.push({0,0});
    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for (int i = 0; i < 4; ++i) {
            int nx = x+dx[i];
            int ny = y+dy[i];
            if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if(maze[nx][ny] == '#') continue;
            if(dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y]+1;
            q.push({nx,ny});
        }
    }
    if(dist[h-1][w-1] == -1) cout << -1 << endl;
    else cout << h*w-(dist[h-1][w-1]+kabe_cnt+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

template<typename T>
T gcd(T a, T b)
{
	if (a < b) return gcd(b, a);
	T r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int g = gcd(a, b);
  puts(c % g == 0 ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int w,h,i,j,ans;
int a[100][100];

void rec(int i,int j){
  if(a[i][j]==1){
    a[i][j]=0;
    rec(i+1,j);
    rec(i-1,j);
    rec(i,j+1);
    rec(i,j-1);
    rec(i+1,j+1);
    rec(i+1,j-1);
    rec(i-1,j+1);
    rec(i-1,j-1);
  }
}

int main(){
  while(1){
    scanf("%d %d",&w,&h);
    if(w==0&&h==0)break;
    
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        scanf("%d",&a[i][j]);
      }
    }

    ans=0;
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
        if(a[i][j]==1){
          rec(i,j);
          ans++;
        }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#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, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int n;
	cin >> n;
	vector<vector<int>> edge(n + 1);
	FOR(i, 1, n + 1) {
		int u, k;
		cin >> u >> k;
		REP(j, k) {
			int v;
			cin >> v;
			edge[u].emplace_back(v);
		}
	}
	vector<int> d(n + 1, -1);
	d[1] = 0;
	queue<int> qu;
	qu.emplace(1);
	while (!qu.empty()) {
		int i = qu.front();
		qu.pop();
		for (auto &j : edge[i]) {
			if (d[j] < 0) {
				d[j] = d[i] + 1;
				qu.emplace(j);
			}
		}
	}
	FOR(i, 1, n + 1) {
		cout << i << " " << d[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3212
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------
ld PI=acos(-1);
//--MAIN-----------------------------------
void Main() {
    ll R;
    cin>>R;
    cout<< PI*2*R <<"\n";
    
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; while(Qkai--) Main();
    Main();
}
//-----------------------------------------

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
 
  if ((n%1000)%111 == 0 || (n/10)%111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  } 
}

Measured memory_bytes: 256
s = input().split()
k=int(s[0])
n=int(s[1])
s = input().split()
rang=[]
for i in range(1,n):
    rang.append(int(s[i])-int(s[i-1]))
rang.append(k-int(s[n-1])+int(s[0]))
print(k-max(rang))

Measured memory_bytes: 20148
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

ll solve(ll a, ll b)
{
  int t = 0, k = 0;
  while(a > 0){
    t++;
    a /= 10;
  }
  while(b > 0){
    k++;
    b /= 10;
  }
  return max(k, t);
}

int main()
{
  ll n; cin >> n;
  ll ans = 1e10;
  for(ll i = 1; i*i <= n; i++){
    if(n % i == 0){
      ans = min(ans, solve(i, n/i));
    }
  }
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int n,a,b,cnt,dist[110000];vector<int>x[110000];bool used[110000];
void dfs(int pos,int depth){
	if(used[pos]==true)return;
	used[pos]=true;dist[pos]=depth;
	for(int i=0;i<x[pos].size();i++)dfs(x[pos][i],depth+(x[pos].size()==2));
}
int main(){
	cin>>n;for(int i=1;i<=n-1;i++){cin>>a>>b;x[a].push_back(b);x[b].push_back(a);}
	for(int i=1;i<=n;i++){if(x[i].size()==1)cnt++;}
	for(int i=1;i<=n;i++)used[i]=false;dfs(1,0);
	int maxn=0,maxid=0;for(int i=1;i<=n;i++){if(maxn<dist[i]){maxn=dist[i];maxid=i;}}
	for(int i=1;i<=n;i++)used[i]=false;dfs(maxid,0);
	sort(dist+1,dist+n+1);
	cout<<cnt+dist[n]<<endl;
	return 0;
}


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

int main() {
    int n, a, b;  cin >> n >> a >> b;
    if (n == 1)  cout << "Hello World" << endl;
    else  cout << a+b << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var nums = new int[3];
        for(var i = 0; i < 3; i++)
        {
            nums[i] = Convert.ToInt32(input[i]);
        }
        for(var i = 0; i < 2; i++)
        {
            if (nums[i] == nums[i + 1])
            {
                Console.WriteLine(nums[2 * (1 - i)]);
                break;
            }
            if (nums[i] == nums[i + 2])
            {
                Console.WriteLine(nums[1]);
                break;
            }
        }
    }
}



Measured memory_bytes: 11220
// Lavina Jain
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ord_set;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1000000007
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define cases int t; cin>>t; while(t--)
ll mini(ll a,ll b) { if(a<b) return a; return b; }
ll maxi(ll a,ll b) { if(a>b) return a; return b; }
ll mod(ll a) { return a % MAX ; }
ll power(ll a,ll b) { if(b==0) return 1; else if(b%2==0) return power(a*a,b/2); else return a*power(a*a,b/2); }
ll powermod(ll a,ll b) { if(b==0) return 1; else if(b%2==0) return mod(powermod(mod(a*a),b/2)); else return mod(a)*mod(powermod(mod(a*a),b/2)); }
//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int n;
ll ar[200010];
set<ll> s;

int main()
{
    fast_io;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ar[i];
    bool ans = true;
    ll count = 0;
    ll prev=0;
    ll add=0;
    if(ar[0]!=0)
        ans=false;
    for(int i=n-1;i>0;i--)
    {
        if(ar[i]==0)
        {
            continue;
        }
        if(ar[i]>ar[i-1]+1)
        {
            trace(i,ar[i],ar[i-1]);
            ans=false;
            break;
        }
        s.insert(ar[i]+add);
        if(s.find(add)!=s.end())
            s.erase(s.begin(),s.find(add));
        s.erase(add);
        count += s.size();
        add++;
        if(ar[i]!=1)
            s.insert(ar[i]-1+add);
    }
    if(!ans)
        cout<<-1<<endl;
    else
        cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 6528