akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

class Dice {
public:
  int label[100][6] = {};
  string rotation = "EEENEEENEEESEEESEEENEEEN";

  void E(int label[]) {
    int rotate = label[0];
    label[0] = label[3];
    label[3] = label[5];
    label[5] = label[2];
    label[2] = rotate;
  }
  void N(int label[]) {
    int rotate = label[0];
    label[0] = label[1];
    label[1] = label[5];
    label[5] = label[4];
    label[4] = rotate;
  }
  void S(int label[]) {
    int rotate = label[0];
    label[0] = label[4];
    label[4] = label[5];
    label[5] = label[1];
    label[1] = rotate;
  }
  void W(int label[]) {
    int rotate = label[0];
    label[0] = label[2];
    label[2] = label[5];
    label[5] = label[3];
    label[3] = rotate;
  }

  bool comp(int label1[], int label2[]) {
    if (label1[0] == label2[0] &&
        label1[1] == label2[1] &&
        label1[2] == label2[2] &&
        label1[3] == label2[3] &&
        label1[4] == label2[4] &&
        label1[5] == label2[5]) return true;
    else return false;
  }
};

int main() {
  Dice dice;
  int n;
  {
    cin >> n;
    for (int i = 0; i < n; i++) for (int j = 0; j < 6; j++) cin >> dice.label[i][j];
  }

  bool is_different = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) break;

      if (dice.comp(dice.label[i], dice.label[j])) {
        cout << "No" << endl;
        return 0;
      }

      for (int k = 0; k < dice.rotation.size(); k++) {
        if (dice.rotation[k] == 'E') dice.E(dice.label[j]);
        else if (dice.rotation[k] == 'N') dice.N(dice.label[j]);
        else if (dice.rotation[k] == 'S') dice.S(dice.label[j]);
        else if (dice.rotation[k] == 'W') dice.W(dice.label[j]);

        if (dice.comp(dice.label[i], dice.label[j])) {
          is_different = false;
          break;
        } else is_different = true;
      }

      if (!is_different) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int lim;
vector<vector<int>> A;

LL solve(int num){
    LL ans = 0;
    int tmp = 0;
    bool ok = true;
    rep(i,lim){
        ans += A[tmp][i];
        if(i == num)tmp++;
        if(tmp == 1 && ok){
            ans += A[tmp][i];
            ok = false;
        }
    }
    return ans;
}

int main() {
    int N;cin >> N;
    A.resize(2,vector<int>(N));
    rep(i,2)rep(j,N)cin >> A[i][j];
    lim = N;

    LL ans = 0;
    rep(i,N){
        ans = max(ans,solve(i));
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
typedef long long ll;
ll N,M;
int main(){
	cin>>N>>M;
	ll ans=1;
	for(ll i=1;i*i<=M;i++){
		if (M%i==0){
			if (M/i>=N){
				ans=max(ans,i);
			}
			if (i>=N){
				ans=max(ans,M/i);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long N;
    cin>> N;
    N=N-1;
    int a = (int)'a';
    vector<long long> div;
    while(N>=0){
        long long tmp = N%26;
        div.push_back(tmp);
        
        if(N==0){
            break;
        }
        N=(N-tmp)/26-1;
    }

    string ans="";

    for(long long k :div){
        ans=  (char)(k+a)+ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <random>
#include <stack>
#include <ctime>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    string s;
    cin >> s;
    
    string a, b;
    for (auto c: s) {
        if (c != 'x') {
            a.push_back(c);
        }
    }
    b = string(a);
    reverse(a.begin(), a.end());
    if (a != b) {
        cout << -1 << endl;
        return 0;
    }
    
    VI interval;
    long cnt = 0;
    REP(i,s.size()) {
        if (s[i] != 'x') {
            interval.push_back(cnt);
            cnt = 0;
        } else {
            cnt++;
        }
    }
    interval.push_back(cnt);
    assert(interval.size() == a.size() + 1);
    long ans = 0;
    REP(i,interval.size()) {
        ans += abs(interval[i] - interval[interval.size() - 1 - i]);
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1656
import java.util.*;

public class Main{
	public static void main(String[]args){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for(int i=0; i<n; i++){
			int[] a = new int[3];
			a[0] = s.nextInt();
			a[1] = s.nextInt();
			a[2] = s.nextInt();
			Arrays.sort(a);
			if(a[2]*a[2] == a[0]*a[0] + a[1]*a[1]){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}


Measured memory_bytes: 33548
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string s, t;
  cin >> s >> t;
  ll n = SZ(s);
  ll m = SZ(t);
  ll ans = INF;
  rep(i, n-m+1){
    ll tmp = 0;
    rep(j, m){
      tmp += s[i+j]!=t[j];
    }
    chmin(ans, tmp);
  }
  print(ans);
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  REP(i, n) {
    int a; cin >> a;
    if (a % 2 == 1) {
      cout << "first" << '\n';
      return 0;
    }
  }
  cout << "second" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  double a,b,h,m; cin >> a >> b >> h >> m;
  double wa,wb;
  wb = 360*(m/60);
  wa = 360*(h/12)+30*(m/60);
  double w = wb-wa;
  if(w < 0) w = -1*w;
  double pi = 3.14159265358979;
  cout << fixed << setprecision(20);
  cout << pow(b*b+a*a-2*a*b*cos(w/360*2*pi),0.5) << endl;
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n;cin >> n;
    cout << (n-1)*n/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define lowbit(x) ((x)&(-(x)))
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline 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;
}

const int MAXN=300005;
int n,m,a[MAXN],b[105][105],c[MAXN];
int main(){
	n=read(); m=read();
	memset(a,0,sizeof(a));
	FOR(i,1,n) {
		FOR(j,1,m) {
			char ch=getchar();
			a[ch-'a']++;
		}
		getchar();
	}
	memset(b,0,sizeof(b));
	c[1]=c[2]=c[4]=0;
	FOR(i,1,n)
		FOR(j,1,m)
		if (!b[i][j]) {
			b[i][j]=1; int tot=1;
			if (!b[n+1-i][j]) b[n+1-i][j]=1,tot++;
			if (!b[i][m+1-j]) b[i][m+1-j]=1,tot++;
			if (!b[n+1-i][m+1-j]) b[n+1-i][m+1-j]=1,tot++;
			c[tot]++;
		}
	while (c[1]--) {
		int flag=0;
		FOR(i,0,25) if (a[i]%2==1) { flag=1; a[i]--; break; }
		if (!flag) {
			if (c[1]==0) { printf("No\n"); goto stop; }
			else {
				c[1]--;
				FOR(i,0,25) if (a[i]) { a[i]-=2; break; }
			}
		}
	}
	FOR(i,0,25) if (a[i]%2==1) { printf("No\n"); goto stop; }
	while (c[2]--) {
		int flag=0;
		FOR(i,0,25) if (a[i]%4==2) { flag=1; a[i]-=2; break; }
		if (!flag) {
			if (c[2]==0) { printf("No\n"); goto stop; }
			else {
				c[2]--;
				FOR(i,0,25) if (a[i]) { a[i]-=4; break; }
			}
		}
	}
	FOR(i,0,25) if (a[i]%4==2) { printf("No\n"); goto stop; }
	printf("Yes\n");
	stop:
    return 0;
}

/*
*/


Measured memory_bytes: 1408
#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <sstream>
 #include <string>
using namespace std;

void print(vector<int> &v) {
    int n = (int)v.size();

    for (int i = 0; i < n; ++i)
    {
        cout << v[i];
        if(i < n - 1) {
            cout << " ";
        }
    }
    cout <<endl;
}


void CountingSort(vector<int> &A, vector<int> &B, int k) {
    //各数値の出現数を記録するための配列
    vector<int> C(k + 1, 0); //数値"0～k"の出現数を記録するので、要素数は"k+1"必要

    //各数値の出現数を記録する
    for (int i = 0; i < (int)A.size(); ++i)
    {
        C[A[i]]++; //ex. "2"はC[2]に、"5"はC[5]に保存
    }

    //C[i]に、i以下の数値の出現数を記録する
    for (int i = 1; i < (int)C.size(); ++i)
    {
        C[i] += C[i-1]; //ex C[3]には3以下の出現回数、C[5]には5以下の出現回数を記録
    }

    // print(C);


    for (int i = (int)A.size()-1; i >= 0; --i)
    {
        // cout << " ------" << endl;
        B[C[A[i]]-1] = A[i];
        C[A[i]]--;
        // print(C);
        // print(B);
    }
}


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

    vector<int> A(n);
    int maximun = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> A[i];
        maximun = max(maximun, A[i]);
    }

    vector<int> ans(n, 0);
    CountingSort(A, ans, maximun);

    print(ans);

    return 0;
}



Measured memory_bytes: 18400
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 100010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
char s[maxn];
int cnt[26];
int n;
int main()
{
	n=read();
	scanf("%s",s);
	for(int i=0;i<n;i++)
		++cnt[s[i]-'a'];
	ll ans=1;
	for(int i=0;i<26;i++)
		ans=ans*(cnt[i]+1)%mod;
	writeln((ans+mod-1)%mod);
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def bfs(s):
    from collections import deque
    check = [-1] * (n + 1)
    check[s] = 0
    q = deque([s])
    while q:
        now = q.popleft()
        for next in graph[now]:
            if check[next] == -1:
                check[next] = now
                q.append(next)
    return check


n, m = map(int, readline().split())
graph = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)
print('Yes')
for v in bfs(1)[2:]:
    print(v)


Measured memory_bytes: 34436
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long a = scanner.nextLong();
    long b = scanner.nextLong();
    long x = scanner.nextLong();
    System.out.println(b / x - (a == 0L ? -1L : (a - 1L) / x));
  }
}


Measured memory_bytes: 35672
#include <iostream>
#include <vector>
//#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

const int MOD = 998244353;

int main() {
  int n, tmp;
  cin >> n;
  
  vector<int> a;
  for (int i=0; i<n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  int sum = accumulate(a.begin(), a.end(), 0);

  // DP1
  //long long dp[n+1][sum+1];
  vector<vector<long long>> dp(n+1, vector<long long>(sum+1, 0));
  dp[0][0] = 1;
  for (int r=1; r<sum+1; r++) {
    dp[0][r] = 0;
  }
  
  for (int t=0; t<n; t++) {
    for (int r=0; r<sum+1; r++) {
      if(r>=a[t]) dp[t+1][r] = dp[t][r-a[t]] + (2*dp[t][r] % MOD);
      else dp[t+1][r] = 2*dp[t][r];
      dp[t+1][r] %= MOD;
    }
  }
  
  long long ans1 = 0;
  for (int r=(sum+1)/2; r<sum+1; r++) {
    ans1 += dp[n][r];
    ans1 %= MOD;
  }
  long long temp = ans1*2;
  temp %= MOD;
  ans1 += temp;
  ans1 %= MOD;
  
  // DP2
  //long long dq[n+1][sum+1];
  vector<vector<long long>> dq(n+1, vector<long long>(sum+1, 0));
  dq[0][0] = 1;
  for (int r=1; r<sum+1; r++) {
    dq[0][r] = 0;
  }
  
  for (int t=0; t<n; t++) {
    for (int r=0; r<sum+1; r++) {
      if(r>=a[t]) dq[t+1][r] = dq[t][r-a[t]] + dq[t][r]; // R or G
      else dq[t+1][r] = dq[t][r];
      dq[t+1][r] %= MOD;
    }
  }
  long long ans2 = 0;
  if (sum%2==0) {
    ans2 = dq[n][sum/2];
    ans2 %= MOD;
  }
  temp = ans2*2;
  temp %= MOD;
  ans2 += temp;
  ans2 %= MOD;
  
  // ans
  long long ans = 1LL;
  for(int i=0; i<n; i++) ans = ans*3%MOD;
  ans = (ans + ans2) % MOD;
  ans = (ans + MOD - ans1) % MOD;
  
  cout << ans << endl;
  //cout << ans << ' ' << ans1 << ' ' << ans2 << endl;
  
  return 0;
}

Measured memory_bytes: 423872
#include <bits/stdc++.h>
    using namespace std;
    const int N=2e3+20;
    typedef long long ll;
    int n,m,q;
    int f[N][N],h[N][N],g[N][N]; 
    char s[N][N];
    int main()
    {
    	while(cin>>n>>m>>q)
    	{
    		for(int i=1;i<=n;i++)
    			scanf("%s",s[i]+1);
    		memset(f,0,sizeof(f));
    		memset(h,0,sizeof(h));
    		for(int i=1;i<=n;i++)
    		{
    			for(int j=1;j<=m;j++)
    			{  
    				f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(s[i][j]-'0');
    				int cnt=0,res=0;
    				if(s[i][j]=='1')
    				{
    					if(s[i-1][j]=='1')
    						res++;
    					if(s[i][j-1]=='1')
    						cnt++;
    				}
    				h[i][j]=h[i-1][j]+h[i][j-1]-h[i-1][j-1]+cnt;
    				g[i][j]=g[i-1][j]+g[i][j-1]-g[i-1][j-1]+res;
    			//	cout<<g[i][j]<<' ';
    			}
    		}
    		int x1,y1,x2,y2;
    		while(q--)
    		{
    			scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    			int ans=f[x2][y2]-f[x2][y1-1]-f[x1-1][y2]+f[x1-1][y1-1];
    			int cnt=h[x2][y2]-h[x2][y1]-h[x1-1][y2]+h[x1-1][y1];
    			int res=g[x2][y2]-g[x1][y2]-g[x2][y1-1]+g[x1][y1-1];	
    			ans-=cnt+res;
    			printf("%d\n",ans);
    		}
    	}
    	return 0;
    }

Measured memory_bytes: 53632
#include<stdio.h>
int main(void){
	int n,m,d,i,j,y,z=0;
	char a[102][102];
	scanf("%d%d%d",&n,&m,&d);
	for(i=0;i<n;i++)scanf("%s",a[i]);
	for(i=0;i<n;i++){
		for(j=0;j<m-d+1;j++){
			if(a[i][j]=='#')continue;
			else {
				for(y=j;y<d+j;y++){
					if(a[i][y]=='#')break;
					else if(y==d+j-1)++z;
				}
			}
		}
	}
	for(j=0;j<m;j++){
		for(i=0;i<n-d+1;i++){
			if(a[i][j]=='#')continue;
			else {
				for(y=i;y<d+i;y++){
					if(a[y][j]=='#')break;
					else if(y==d+i-1)++z;
				}
			}
		}
	}
	printf("%d\n",z);
	return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  string board[60];
  const int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
  const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

  for(int i = 1; i < H+1; ++i){
    cin >> board[i];
  } 

  for(int i = 1; i < H + 1; ++i){
    for(int j = 0; j < W +1; ++j){
      if(board[i][j] == '#') continue;
      int sum = 0;
      for(int d = 0; d < 8; ++d){
        if( board[i+dx[d]][j+dy[d]] == '#') ++sum;
      }
      board[i][j] = char( sum + '0');
    }
  }
  for(int i =1; i < H + 1; ++i){
    cout << board[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define f(i,a,b) for(lli i=a;i<b;i++)
const long long mod=1e9+7;
using namespace std;

int main()
{
    lli n,m;
    cin>>n>>m;
    vector<lli> a(m,0),my(n+1,0);my[0]=1;
    vector<bool> t(n+1,1);
    f(i,0,m)cin>>a[i];
    f(i,0,m)
    {
     t[a[i]]=0;
    }
    f(i,1,n+1)
    {
     if(t[i]==0)
     continue;
     else
        {
          if(i==1)my[i]=1;
          else
          {
           my[i]=my[i-1]%mod+my[i-2]%mod;
          }
        }
    }
    cout<<my[n]%mod;
    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */


int main(){
    int n, m; cin >> n >> m;
    vector<int> a(m); rep(i, m) cin >> a[i];
    int sum = 0; rep(i, m) sum += a[i];
    if(sum > n) out(-1);
    else out(n - sum);
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(){
  int i=1;
  long x,y;
  scanf("%ld %ld",&x,&y);
  if(x%y==0)  printf("-1\n");
  else{
    do{
      if((x*i)%y!=0){
        printf("%ld\n",x*i);
        break;
        }
      i++;
    }while(i<100000);
  }
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Cutting Down Water Bills
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0216

"""
import sys


def solve(w):
    ans = 1150
    if w > 10:
        ans += 125 * min(10, (w-10))
    if w > 20:
        ans += 140 * min(10, (w-20))
    if w > 30:
        ans += 160 * (w-30)
    return 4280 - ans


def main(args):
    while True:
        w = int(input())
        if w == -1:
            break
        ans = solve(w)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5612
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			if (n == 0)
				return;
			strs = new String[n];
			for (int i = 0; i < n; i++) {
				strs[i] = scanner.next();
			}
			System.out.println(solve() ? "OK" : "NG");
		}
	}

	private boolean solve() {
		int[] in = new int[26], out = new int[26];
		UnionFind unionFind = new UnionFind(26);
		for (int i = 0; i < n; i++) {
			int from = (int) (strs[i].charAt(0) - 'a');
			int to = (int) (strs[i].charAt(strs[i].length() - 1) - 'a');
			in[from]++;
			out[to]++;
			unionFind.merge(to, from);
		}
		for (int i = 0; i < 26; i++) {
			if (in[i] != out[i]) {
				return false;
			}
		}
		int index = -1;
		boolean flag = false;
		for (int i = 0; i < 26; i++) {
			if (in[i] == 0)
				continue;
			if (in[i] != 0 && !flag) {
				index = i;
				flag = true;
				continue;
			}
			if (!unionFind.isSame(index, i))
				return false;

		}

		return true;
	}

	int n;
	String[] strs;

	class UnionFind {
		int[] pars;
		int[] rank;

		@Override
		public String toString() {
			return "UnionFind [pars=" + Arrays.toString(pars) + ", rank="
					+ Arrays.toString(rank) + "]";
		}

		UnionFind(int size) {
			pars = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++)
				pars[i] = i;
		}

		int root(int x) {
			if (x == pars[x])
				return x;
			return pars[x] = root(pars[x]);
		}

		boolean isSame(int x, int y) {
			return root(x) == root(y);
		}

		void merge(int x, int y) {
			x = root(x);
			y = root(y);
			if (x == y)
				return;
			if (rank[x] > rank[y])
				pars[y] = x;
			else {
				pars[x] = y;
				if (rank[x] == rank[y])
					rank[y]++;
			}
		}
	}
}

Measured memory_bytes: 45096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BeginnerCont143
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var o = 0;
            var past = ' ';
            foreach(var ss in s)
            {
                if (ss != past)
                {
                    o++;
                }
                past = ss;
            }

            Console.WriteLine(o.ToString());
        }
    }
}


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

using namespace std;

const long long mx = 1e18;

int main() {
  int n;
  long long ans = 1;
  bool ng = false;
  cin >> n;
  rep(i, n){
    long long a;
    cin >> a;
    if(a == 0){
      cout << 0 << endl;
      return 0;
    }
 
    if(ng || a > (mx / ans)){
      ng = true;
    }
    ans *= a;
  }
  
  if(ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 3612
#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  char s[5];
  cin >> s[0] >> s[1] >> s[2];

  if (s[0] == s[1] && s[1] == s[2]) {
    cout << "No";
  } else {
    cout << "Yes";
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    while queue:
      #queueには訪れた地点が入っている。そこから、4方向に移動できるか考え、queueから消す。
        y, x = queue.popleft()#queueに入っていたものを消す。
        if [y, x] == [gy, gx]:#もしゴールについていたならば、そのときの手数を出す。
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
          p = 0
          l = 1
          while p == 0:
              new_y, new_x = y + j * l, x + k * l 
              if (0 <= new_y < H) and (0 <= new_x < W): 
                if maze[new_y][new_x] == "@":
                  p = 1
                elif visited[new_y][new_x] == -1:#まだ来たことない点だったという条件
                  visited[new_y][new_x] = visited[y][x] + 1
                  queue.append([new_y, new_x])#新しい点を足す。
                elif visited[new_y][new_x] < visited[y][x] + 1:
                  p = 1
              else:
                p = 1
              l += 1
              if l == K + 1:
                p = 1

H, W, K = map(int, input().split())
#K = min(K, max(H, W))
x1, y1, x2, y2 = map(int, input().split())
x1, y1, x2, y2 = x1-1, y1-1, x2-1, y2-1
C = [0] * H
for i in range(H):
  C[i] = str(input())
visited = [[-1] * W for i in range(H)]
bfs(C, visited, x1, y1, x2, y2)
#print(visited)
print(visited[x2][y2])
  




Measured memory_bytes: 36548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

struct union_find {//1-origin
	vector<int> rnk, par;
	union_find(int n) {
		rnk.resize(n+1);
		par.resize(n+1);
		for(int i = 1; i <= n; i++){
			par[i] = i;
			rnk[i] = 0;
		}
	}
	
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
 
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rnk[x] < rnk[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rnk[x] == rnk[y])rnk[x]++;
		}
	}
	
	bool same(int x, int y) {
		return (find(x) == find(y));
	}
};

ll n, m;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	vector<P> edge;
	rep(j, 1, m){
		ll a, b;
		cin >> a >> b;
		edge.push_back(P(a, b));
	}
	
	ll ans = 0;
	rep(j, 1, m){
		union_find u(n);
		rep(k, 1, m){
			if(k != j){
				u.unite(edge[k-1].first, edge[k-1].second);
			}
		}

		rep(i, 1, n){
			if(!u.same(i, 1)){
				ans++;
				break;
			}
		}
	}
	
	print(ans)
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int n, k;
long long dp[100005][3];
int h[100005][3];
const long long INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
    cin >> n;
    for(int i=0;i<n;i++) for (int j=0;j<3;j++) cin >> h[i][j];

    for (int i = 0; i < 100005; ++i) for (int j=0;j<3;j++) dp[i][j]=0;

    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j != k) chmax(dp[i][k], dp[i-1][j]+h[i-1][k]);
            }
        }
    }

    // cout << dp[n-1] << endl;
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[n][j]);
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007

int main(){
    int N,K;
    cin >> N >> K;
    pair<int,int> E[2001];
    vector<int> edge[2001];
    for(int i=0;i<N-1;i++){
        int A,B;
        cin >> A >> B;
        edge[A].push_back(B);
        edge[B].push_back(A);
        E[i]=make_pair(A,B);
    }

    int best=2001;
    if(K%2==0){
        for(int v=1;v<=N;v++){
            int cnt=0;
            bool checked[2001];
            for(int i=1;i<=N;i++) checked[i]=false;
            queue<pair<int,int>> Q;
            Q.push(make_pair(v,0));
            checked[v]=true;
            while(!Q.empty()){
                auto t=Q.front();
                Q.pop();
                if(t.second>K/2) cnt++;
                for(auto e:edge[t.first]){
                    if(!checked[e]){
                        checked[e]=true;
                        Q.push(make_pair(e,t.second+1));
                    }
                }
            }
            best=min(best,cnt);
        }
    }else{
        for(int e=0;e<N-1;e++){
            int cnt=0;
            bool checked[2001];
            for(int i=1;i<=N;i++) checked[i]=false;
            queue<pair<int,int>> Q;
            Q.push(make_pair(E[e].first,0));
            Q.push(make_pair(E[e].second,0));
            checked[E[e].first]=true;            
            checked[E[e].second]=true;
            while(!Q.empty()){
                auto t=Q.front();
                Q.pop();
                if(t.second>K/2) cnt++;
                for(auto ed:edge[t.first]){
                    if(!checked[ed]){
                        checked[ed]=true;
                        Q.push(make_pair(ed,t.second+1));
                    }
                }
            }
            best=min(best,cnt);
        }
    }
    cout << best << endl;

    return 0;
}

Measured memory_bytes: 384
//#include<bist_stdc++.h>
#include <iostream>
#include <vector>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int m, f, r;
    while(true) {
        char grade;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) {
            break;
        }
        if(m == -1 || f == -1) {
            grade = 'F';
        } else if(m + f >= 80) {
            grade = 'A';
        } else if(m + f >= 65) {
            grade = 'B';
        } else if(m + f >= 50) {
            grade = 'C';
        } else if(m + f >= 30) {
            if(r >= 50) {
                grade = 'C';
            } else {
                grade = 'D';
            }
        } else {
            grade = 'F';
        }
        cout << grade << endl;
    }
}



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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  
  string s;
  for(int i=0; i<n; i++) s += v[i];
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
 
string s;
int p;
 
ll A[200][300];
int idx;
 
ll bnf();
 
ll get_num(){
 
  if(s[p]=='('){
     
    p++;
 
    ll res=bnf();
     
    p++;
 
    return res;
  }
   
  if('a'<=s[p]&&s[p]<='z') return A[idx][s[p++]];
   
  ll num=0;
   
  while('0'<=s[p]&&s[p]<='9') num=num*10+s[p]-'0', p++;
 
  return num;
   
}
 
ll bnf3(){
 
  ll res=get_num();
   
  while(p<s.size()){
 
    if(s[p]=='^'){
 
      p++;
 
      ll r=get_num();
 
      ll tmp=1;
 
      for(int i=0;i<r;i++) tmp*=res;
 
      res=tmp;
       
    }else break;
     
  }
   
  return res;
}
 
ll bnf2(){
 
  ll res=bnf3();
 
  while(p<s.size()){
 
    if(s[p]=='*'){
 
      p++;
 
      ll r=bnf3();
       
      res*=r;
       
    }else break;
     
  }
   
  return res;
}
 
ll bnf(){
 
  ll res=bnf2();
   
  while(p<s.size()){
     
    if(s[p]=='+'){
 
      p++;
       
      ll r=bnf2();
       
      res+=r;
       
    }
    else if(s[p]=='-'){
 
      p++;
 
      ll r=bnf2();
 
      res-=r;
       
    }else break;
     
  }
   
  return res;
}
 
void change(){
   
  for(int i=0;i<s.size();i++)
    if((s[i]==')'||('a'<=s[i]&&s[i]<='z')||('0'<=s[i]&&s[i]<='9')))
      if((s[i+1]=='('||('a'<=s[i+1]&&s[i+1]<='z')||('0'<=s[i+1]&&s[i+1]<='9')))
    if(!('0'<=s[i]&&s[i]<='9'&&'0'<=s[i+1]&&s[i+1]<='9'))
      s=s.substr(0,i+1)+'*'+s.substr(i+1);
 
   
  for(int i=0;i<s.size();i++)
     
    if(s[i]==' ')
       
      while(s[i]==' '&&i+1<s.size()&&s[i+1]==' ') s.erase(s.begin()+i);
   
 
  if(s[0]==' ') s.erase(s.begin());
   
  if(s[s.size()-1]==' ') s.erase(s.begin()+s.size()-1);
 
  for(int i=0;i<s.size();i++)
    if(s[i]==' ')
      if((s[i-1]==')'||('a'<=s[i-1]&&s[i-1]<='z')||('0'<=s[i-1]&&s[i-1]<='9')))
    if((s[i+1]=='('||('a'<=s[i+1]&&s[i+1]<='z')||('0'<=s[i+1]&&s[i+1]<='9'))) s[i]='*';
 
  for(int i=0;i<s.size();i++)
     
    if(s[i]==' ') s.erase(s.begin()+i), i--;
   
   
}
 
int main(){
   
  for(int T=0;T<200;T++)
     
    for(int i=0;i<300;i++) A[T][i]=rand();
   
  while(1){
 
    string tmp=s;
     
    getline(cin,s);
     
    if(s==".") break;
     
    change();
     
    ll base[200];
 
    for(int T=0;T<200;T++){
      idx=T;
      p=0;
      base[T]=bnf();
    }
     
    while(1){
       
      getline(cin,s);
       
      if(s=="."){
    cout<<"."<<endl;
    break;
      }
       
      change();
       
      bool ans=true;
       
      for(int T=0;T<200;T++){
           
    idx=T;  
    p=0;
       
    ll r=bnf();
     
    if(base[T]!=r) ans=false;
     
      }
       
      if(ans) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
       
    }
     
  }
   
  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(){
	char S[3];
	
	scanf("%s",S);
	
	for(int i=0;i<2;i++){
		if(S[i] == 'A'){
			if(S[i+1] == 'B'){
				printf("Yes\n");
				return 0;
			}
		}else if(S[i] == 'B'){
			if(S[i+1] == 'A'){
				printf("Yes\n");
				return 0;
			}
		}
	}
	
	printf("No\n");
		
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 2;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int N;
  cin >> N;
  vector<int> t(N+1);
  vector<int> x(N+1);
  vector<int> y(N+1);
  t[0] = 0; x[0] = 0; y[0] = 0;
  rep(i, 1, N+1) {
    cin >> t[i] >> x[i] >> y[i];
  }

  rep(i, 1, N+1) {
    int dist = x[i]-x[i-1] + y[i]-y[i-1];
    int time = t[i]-t[i-1];
    if (time < dist || (time - dist)%2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,x,y;
  cin >> n >> x >> y;
  map<ll,ll> cnt;
  for(ll i=1;i<=n;i++) {
    for(ll j=i+1;j<=n;j++) {
      ll dis=min({abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j)});
      cnt[dis]++;
    }
  }
  for(ll i=1;i<n;i++) {
    cout << cnt[i] << endl;
  }
}

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

int main () {
  string s;
  cin >>s;
  if(s =="Sunny") cout<<"Cloudy"<<endl;
  if(s =="Cloudy") cout<<"Rainy"<<endl;
  if(s =="Rainy") cout<<"Sunny"<<endl;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))

summation = [0] * 1001
expected = [0] * 1001
for i in range(1000):
    summation[i + 1] = summation[i] + (i + 1)

for i in range(1, 1001):
    expected[i] = summation[i] / i

S = [0] * (N + 1)
for i in range(N):
    S[i + 1] = S[i] + expected[P[i]]

ans = 0
for i in range(0, N - K + 1):
    tmp = S[i + K] - S[i]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 71792
#include <stdio.h>
#define N 10
void sort(int *data,int size);
int main(){
	int a[N],i;
	for(i=0;i<N;i++)scanf("%d",&a[i]);
	sort(a,N);
	for(i=0;i<3;i++)printf("%d\n",a[i]);
	return 0;
}
void sort(int *data,int size){
	int i,j,swap;
	for(i=0;i<size;i++){
		for(j=i+1;j<size;j++){
			if(data[i]<data[j]){
				swap=data[i];
				data[i]=data[j];
				data[j]=swap;
			}
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll a[N+100];
	ll ans = 0;
	for (ll i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (ll i = 1; i <= N; i++) {
		if (a[i] == i){
          	swap(a[i],a[i+1]);
			ans++;
        }
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#import<atcoder/all>
using namespace std;int o(int a,int b){return a<b?b:a;}int e(){return 0;}int K,A,T=3<<17;main(){atcoder::segtree<int,o,e>P(T);for(cin>>K>>K;cin>>A;)P.set(A,P.prod(o(0,A-K),min(T,A+K+1))+1);cout<<P.prod(0,T);}

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    vector<string> cards(3);
    rep(i, 0, 3) cin >> cards[i];

    vector<int> index(3);
    rep(i, 0, 3) index[i] = 0;
    
    int now = 0;

    while(true) {
        char top = cards[now][index[now]];
        index[now] += 1;
        if (index[now] > cards[now].size()) {
            switch (now) {
                case 0: cout << "A" << endl; return 0;
                case 1: cout << "B" << endl; return 0;
                case 2: cout << "C" << endl; return 0;
            }
        }

        switch (top) {
            case 'a': now = 0; break;
            case 'b': now = 1; break;
            case 'c': now = 2; break;
        }
    }
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
using namespace std;
bool prime(int a){
  for(int i=2;i<=sqrt(a);i++){
    if(a%i==0)return false;
  }
  return true;
}

int main(){
  int n,count;
  while(cin>>n,n){
    count=0;
    for(int i=1;i<=n;i++){
      if(prime(i+n))count++;
    }
    cout<<count<<endl;
  }
}
    

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

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

	if (a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  ll h,w;
  cin >> h >> w;
  ll m;
  m = h*w;
  if( h == 1 || w == 1) cout << 1 << endl;
  else if(m%2 == 0)cout << m/2 << endl ;
  else if(m%2 == 1)cout << (m+1)/2 << endl ;
  return 0;
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        //110110011
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        int n=sc.nextInt();
        int c=2*100000+1;
        
        long e[]=new long[c];
        int pre=-1;
        long ans=1;
        for (int i = 0; i < n; i++) {
			int x=sc.nextInt()-1;
			if(pre==x) {
				continue;
			}
			e[x]=e[x]+ans;
			e[x]%=mod;
			ans=e[x];
			pre=x;
//			db(pre,x,ans);
		}


        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 43952
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,k;
  cin>>n>>k;
  vector<int> l;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    l.push_back(tmp);
  }
  sort(l.begin(),l.end(),greater<int>());
  cout<<accumulate(l.begin(),l.begin()+k,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Convert.ToInt32(Console.ReadLine());
            int output=1;
            for (int i = 0; i < 3; i++)
            {
                output = output * input;
            }
            Console.WriteLine(output.ToString());
        }
    }
}



Measured memory_bytes: 15944
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();

    let mut ans = 0;
    for i in 0..k {
        ans += a[i];
    }
    println!("{}", ans);
}


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

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 f(ll x, int c, int d) {
    ll res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}

int main(){
    ll a,b;
    int c,d;
    cin >> a >> b >> c >> d;
    ll ans = f(b,c,d) - f(a-1,c,d);
    cout << ans << endl;
}

Measured memory_bytes: 256
#B

A = []

for _ in range(3):
  A += [list(map(int, input().split()))]

import copy

B = copy.deepcopy(A)

for i in range(3):
  B += [[A[0][i], A[1][i], A[2][i]]]
B += [[A[0][0], A[1][1], A[2][2]]]
B += [[A[0][2], A[1][1], A[2][0]]]

B = [set(b) for b in B]

N = int(input())

bs = []

for _ in range(N):
  bs += [int(input())]

bs = set(bs)

flag = "No"

for b in B:
  if b.issubset(bs):
    flag = "Yes"

print(flag)

Measured memory_bytes: 3444
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
using namespace std;

int main()
{
   
    int a, b;
    cin>>a>>b;
    cout <<"a " <<(a<b?"<":(a>b?">":"==")) << " b" << endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int right[100002], left[100002];
    int r, l;
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'L') r = i;
        left[i] = r;
    }
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') l = i;
        right[i] = l;
    }
    int ans[100002] {0};
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            if((left[i] - i) % 2 == 0) ans[left[i]]++;
            else ans[left[i] - 1]++;
        }
        else{
            if((i - right[i]) % 2 == 0) ans[right[i]]++;
            else ans[right[i] + 1]++;
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
}

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

int main(){
  int n; cin>>n;
  map<string, long long> dic;
  
  string s;
  for (int i=0; i<n; i++){
    cin>>s;
    sort(s.begin(), s.end());
    if (dic.count(s)) dic[s]+=1;
    else dic[s]=1;
  }
  
  long long ans=0;
  for (auto p : dic){
    long long v=p.second;
    ans+=v*(v-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136