akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, std::string S){
    bool ans = true;
    if (S.substr(A, 1) != "-") ans = false;

    string s1 = S.substr(0, A);
    if (!(all_of(s1.cbegin(), s1.cend(), [](char ch) { return isdigit(ch); })))
        ans = false;

    string s2 = S.substr(A + 1);
    if (!(all_of(s2.cbegin(), s2.cend(), [](char ch) { return isdigit(ch); })))
        ans = false;
    if (ans) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    cin >> A;
    long long B;
    cin >> B;
    string S;
    cin >> S;
    solve(A, B, S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
void swap(vector<int> &a,int m,int n)
{
    int t = a[m];
    a[m] = a[n];
    a[n] = t;
    return;
}
int main()
{
    vector<int> a;
    int n,m,i,j;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m;
        a.push_back(m);
    }
    m=0;
    for(i=0;i<n;i++)
        for(j=n-1;j>i;j--)
            if(a[j-1]>a[j])
            {
                swap(a,j-1,j);
                m++;
            }
    for(i=0;i<n-1;i++)
        cout<<a[i]<<' ';
    cout<<a[i]<<endl;
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
using namespace std;
int a[100];
int main()
{
  int n,alice=0,bob=0;
  cin >> n;
  for(int i=0;i<=n;i++)
    cin >> a[i];
  sort(a,a+n, greater<int>());
  for(int i=0;i<=n/2;i++)
  {
    alice+=a[2*i];
    bob+=a[2*i+1];
  }
  int s=alice-bob;
  cout << s;
}

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		int[][] dp = new int[n][k + 1];
		for (int i = 0; i < k; i++) {
			dp[0][i] = 1;
		}
		dp[0][k] = k;

		for (int i = 1; i < n; i++) {
			for (int j = 0; j < k; j++) {
				dp[i][j] = dp[i - 1][k] - dp[i - 1][j];
				dp[i][k] += dp[i][j];
			}
		}

		pr.println(dp[n - 1][k]);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 9804
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))

arr = [[0 for i in range(3)] for j in range(3)]

#print(arr)
for j in range(3):
  for i in range(3):
    if A[i][j] in b:
      #print(A[i][j])
      arr[i][j] = 1
#print(arr)
f = 0
for i in range(3):
  if sum(arr[i][:]) == 3 and f == 0:
    print("Yes")
    f = 1

  if (arr[0][i] + arr[1][i] + arr[2][i] == 3) and f == 0:
    print("Yes")
    f = 1
    
if f == 0:
  if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    print("Yes")
  elif arr[0][2] + arr[1][1] + arr[2][0] == 3:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n ,k;
    cin >> n >> k;
    vector<int>A(n);
    REP(i,n){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll cnt= 0;
    REP(i,n-k){
        cnt+= A[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
int w, a, b;
cin >> w >> a >>b;
if (a + w < b){
	cout << b - (a + w) << endl;
}else if (a > b + w){
	cout << a - (b + w) << endl;

}else{
	cout << 0 << endl;
}
return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EThisMessageWillSelfDestructIn5s {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }

      vector<ll> left(n);
      vector<ll> right(n);
      rep(i, n) {
        int f = i + a[i];
        int g = i - a[i];
        if (f < n) left[f]++;
        if (g >= 0) right[g]++;
      }

      ll ans = 0;
      rep(i, n) {
        ans += left[i]*right[i];

      }
      cout << ans << endl;


    }
};

signed main() {
  EThisMessageWillSelfDestructIn5s solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 7192
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

const ll INF = 1e18;

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

    const int NMAX = 1000;
    const int MMAX = 2000;
    int a[MMAX], b[MMAX];
    ll c[MMAX];

    FOR(i,0,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        //c[i] = -c[i];
    }

    ll dist[NMAX];
    FOR(i,0,N) dist[i] = -INF;

    dist[0] = 0;

    FOR(i,0,N-1){
        FOR(j,0,M){
            dist[b[j]] = max(dist[b[j]], dist[a[j]] + c[j]);
        }
    }
    ll ans1 = dist[N-1];

    FOR(i,0,N-1){
        FOR(j,0,M){
            dist[b[j]] = max(dist[b[j]], dist[a[j]] + c[j]);
        }
    }
    ll ans2 = dist[N-1];
    if(ans1!=ans2) cout << "inf" << endl;
    else cout << ans1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S;
    cin >> S;
    deque<char> deq;
    REP(i, S.length()) { deq.push_back(S[i]); }
    ll Q;
    cin >> Q;
    ll mode = 1;
    REP(i, Q) {
        ll T;
        cin >> T;
        if (T == 2) {
            ll F;
            char C;
            cin >> F >> C;
            if (F == 1) {
                if (mode == 1) {
                    deq.push_front(C);
                } else {
                    deq.push_back(C);
                }
            } else {  // F==2
                if (mode == 1) {
                    deq.push_back(C);
                } else {
                    deq.push_front(C);
                }
            }
        } else {  // T==1
            mode = -mode;
        }
    }

    debug(deq.size());
    debug(deq);

    ll len = deq.size();
    if (mode == -1) {
        REP(i, len) { cout << deq[len - i - 1]; }
        cout << endl;
    } else {
        REP(i, len) { cout << deq[i]; }

        cout << endl;
    }
    /*
    if (mode == -1) {
        REP(i, deq.size()) {
            cout << deq.back();
            deq.pop_back();
        }
        cout << endl;
    } else {
        REP(i, deq.size()) {
            cout << deq.front();
            deq.pop_front();
        }
        cout << endl;
    }
    */
    return 0;
}


Measured memory_bytes: 976
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
digit = H + W
sum_b = 0
for x in c:
    sum_b += x.count('#')

brack = []
for i in range(H):
    for j in range(W):
        if c[i][j] == '#':
            brack.append(int(str(10**(H+j)+10**i).zfill(digit), 2))

ans = 0
for i in range(2**digit):
    tmp = 0
    for j in brack:
        if i & j != 0: tmp += 1
    if sum_b - tmp == K: ans += 1    
print(ans)

Measured memory_bytes: 67632
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ll n, x, a[100000], ans = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		ll j = 0;
		while (a[i] + a[i - 1] > x) {
			ll eat = min(a[i+j], a[i] + a[i - 1] - x);
			a[i+j] -= eat;
			ans += eat;
			j--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
import bisect
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def main():
  n=aint()
  d=dict()
  for i in range(n):
    inp=input()
    if inp in d:
      d[inp]+=1
    else:
      d[inp]=1
  d_sorted=sorted(d.items(),key=lambda x:x[0])
  num=max(d.values())
  for cont in d_sorted:
    if cont[1]==num:
      print(cont[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 47160
// AOJ 0172: Doctor's Research Rooms
// 2018.1.24 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MOVE 0x40
#define ON   0x50
#define OFF  0x60

#define QMAX 300000
typedef struct { char rm; int light; char step, act[50]; } Q;
Q q[QMAX+2]; int top, end;

int rm[15][15], s_rm[15];
int sw[15][15], s_sw[15];
char mk[15][33000];

char *msg[7] = {0,
"You can go home in %d steps.\n",
"You can not switch off all lights.",
"Help me!",
"Move to room %d.\n",
"Switch on room %d.\n",
"Switch off room %d.\n" };

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, i, j, s, t, ans;
	int light;
	Q p, np;

	while (n = in()) {
		m = in();
		memset(s_rm, 0, sizeof(s_rm));
		memset(s_sw, 0, sizeof(s_sw));

		for (i = 0; i < m; i++){
			s = in()-1, t = in()-1;
			rm[s][s_rm[s]++] = t;
			rm[t][s_rm[t]++] = s;
		}

		light = 0; for (i = 0; i < n; i++) if (in()) light |= 1 << i;

		for (i = 0; i < n; i++) {
			j = in(); while (j--) sw[i][s_sw[i]++] = in()-1;
			qsort(sw[i], s_sw[i], sizeof(int), cmp);
        }

		memset(mk, 0, sizeof(mk));
		q[0].rm = 0, q[0].light = light, q[0].step = 0;
		top = 0, end = 1;
		ans = 3;

		while (top != end) {
			p = q[top]; if (++top == QMAX) top = 0;
			s = p.rm, t = p.light;

			if (mk[s][t]) continue;
			mk[s][t] = 1;
			if (s == n-1) {
				if (t == 1<<(n-1)) { ans = 1; break; }
				ans = 2;
			}

			for (i = 0; i < s_sw[s]; i++) if (sw[s][i] != s) {
				j = t ^ (1<<sw[s][i]);
				np = p, np.light = j;
				if (t & (1<<sw[s][i])) np.act[np.step] = OFF | sw[s][i];
				else 				   np.act[np.step] = ON  | sw[s][i];
				np.step++;
				q[end] = np; if (++end == QMAX) end = 0;
			}

			for (i = 0; i < s_rm[s]; i++) if (t & (1<<rm[s][i])) {
				np = p, np.rm = rm[s][i];
				np.act[np.step++] = MOVE | rm[s][i];
				q[end] = np; if (++end == QMAX) end = 0;
			}
		}
 
		if (ans > 1) puts(msg[ans]);
		else {
			printf(msg[ans], p.step);
			for (i = 0; i < p.step; i++) printf(msg[p.act[i] >> 4], 1+(p.act[i] & 0xf));
		}
    }
    return 0;
}


Measured memory_bytes: 12808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(min(b, d)-max(a, c), (ll)0) << endl;
}

Measured memory_bytes: 256
n = int(input())
a=list(map(int, input().split()))
count = 0
boolean = True

while boolean == True:
	for i in range(n):
		if a[i]%2 == 0 :
			a[i] = a[i]/2
			if i == (n-1):
				count += 1
		else:
			boolean = False
			break

print(count)

Measured memory_bytes: 3060
object Main {

  def main(args: Array[String]): Unit = {
    import scala.collection.immutable.Queue
    import scala.collection.mutable.ArrayBuffer
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextShort()
    val E = Array.fill(N)(ArrayBuffer[Short]())
    val Dim = new Array[Int](N)
    val visited = new Array[Boolean](N)
    (0 until N - 1) foreach { _ =>
      val _a, _b = sc.nextShort()
      val a: Short = (_a - 1).toShort
      val b: Short = (_b - 1).toShort
      E(a).append(b)
      E(b).append(a)
      Dim(a) += 1
      Dim(b) += 1
    }
    var C = Array.fill(N)(sc.nextInt()).sorted(Ordering.Int.reverse).toList
    val D = new Array[Int](N) // 最終結果
    // 入次数が小さい順に訪れて行き,

    var M = 0L
    val (_, root) = Dim.zipWithIndex.minBy(_._1) // 入次数がもっとも小さいものをルートとする
    def bfs(queue: Queue[Short]): Unit =
      if (queue.nonEmpty) {
        val (u, dequeued) = queue.dequeue
        val finded = E(u) collect { case v if !visited(v) =>
          visited(v) = true
          D(v) = C.head // 一番価値が高いものを取り出してuに入れる
          C = C.tail // 残りをCに入れて更新する
          M += D(v) // 新しく追加した辺の価値は子のほうがちいさいので蓄積
          v // さらにその子孫を探索
        }
        bfs(finded.foldLeft(dequeued)((b,n) => b.enqueue(n)))
      } else {}

    visited(root) = true
    D(root) = C.head
    C = C.tail
    bfs(Queue[Short](root.toShort))

    println(M)
    println(D.mkString(" "))
  }

}


Measured memory_bytes: 46556
import java.util.*;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        int[] x = new int[N + 1];
        for (int i = 1; i <= N; ++i) {
            x[i] = sc.nextInt();
        }

        long[][][] dp = new long[N + 1][N + 1][N * A + 1];
        for (int i = 0; i < N; ++i) {
            dp[i][0][0] = 1;
        }

        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= i; ++j) {
                for (int k = 1; k <= N * A; ++k) {
                    if (k < x[i]) {
                        dp[i][j][k] = dp[i - 1][j][k];
                    } else {
                        dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
                    }
                }
            }
        }

        long ans = 0;
        for (int j = 1; j <= N; ++j) {
            ans += dp[N][j][j * A];
        }

        System.out.println(ans);
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

int c[5][5];

bool check(deque<int> &a) {
  vector<int> b;
  rep(i,3) b.push_back(c[0][i]-a[0]);
  rep(i,3) {
    rep(j,3) {
      if( c[i][j] != ( a[i] + b[j] ) ) return false;
    }
  }
  return true;
}

bool dfs(deque<int> &a) {
  if( (int)a.size() >= 3 ) {
    return check(a);
  }
  rep(i,101) {
    a.push_back(i);
    if( dfs(a) ) return true;
    a.pop_back();
  }
  return false;
}

void compute() {

}

int main() {
  rep(i,3) rep(j,3) cin >> c[i][j];
  deque<int> deq;
  if( dfs(deq) ) puts("Yes");
  else puts("No");
  compute();
  return 0;
}


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,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=200001;
const int mod=998244353;
ll fact[MAX_N+1];
ll inv[MAX_N+1],finv[MAX_N+1];
int inv_init(ll n,ll p){
    inv[1]=1;
    FOR(i,2,n+1) inv[i]=p-(p/i)*inv[p%i]%p;
    fact[0]=finv[0]=1;
    FOR(i,1,n+1){
        fact[i]=fact[i-1]*i%p;
        finv[i]=finv[i-1]*inv[i]%p;
    }
    return 0;
}
ll comb_mod(ll n,ll k,ll p){
    if(k<0||n<k) return 0;
    return finv[k]*finv[n-k]%p*fact[n]%p;
}
int K,N;
ll p2[4096];
int main(){
    cin>>K>>N;
    inv_init(4001,mod);
    p2[0]=1;
    rep(i,4001) p2[i+1]=p2[i]*2%mod;
    FOR(i,2,K*2+1){
        int p=0,q=0;
        FOR(j,1,K+1){
            if(i-j>0&&i-j<=K) ++p;
            else ++q;
        }
        p/=2;
        ll ret=0;
        rep(j,p+1)if(N>=j){
            if(i&1){
                ret+=p2[j]*comb_mod(p,j,mod)%mod*comb_mod(N+q-1,N-j,mod)%mod;
                ret%=mod;
            }
            else{
                ret+=p2[j]*comb_mod(p,j,mod)%mod*comb_mod(N+q-2,N-j-1,mod)%mod;
                ret+=p2[j]*comb_mod(p,j,mod)%mod*comb_mod(N+q-1,N-j,mod)%mod;
                ret%=mod;
            }
        }
        cout<<ret<<endl;
    }
    return 0;
}

Measured memory_bytes: 2432
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N;
    scan(N);
    map<int, int> v;
    vector<int> a(N);
    for (size_t i = 0; i < N; i++) {
        int x;
        scan(x);
        a[i] = x;
        if (v.count(x) == 0) {
            v[x] = 1;
        } else {
            v[x]++;
        }
    }
    ll sum = 0;
    for (auto &&i : v) {
        ll x = i.second;
        sum += x * (x - 1) / 2;
    }
    for (auto &&i : a) {
        ll ans = sum - v[i] + 1;
        print(ans);
    }

    return 0;
}

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

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(ll i = first; i <= to; ++i)
#define MyDebug

#ifdef MyDebug
	#define debug(x) cout << #x << " : " << x << endl
	#define debugP(x) cout << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

const int MOD = (int)1e9 + 7;
ll facto(int n) {
	ll ans = 1;
	REP(i, 2, n) {
		ans *= i;
		ans %= MOD;
	}
	return ans;
}
	int x, y;
void solve() {
	cin >> x >> y;
	if (abs(x - y) > 1) {
		cout << 0 << endl;
		return;
	}
	ll ans = (facto(x) * facto(y)) % MOD;
	if (x == y) cout << (ans * 2 % MOD) << endl;
	else cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    string s;
    cin >> s;
    s[K-1]+='a'-'A';
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys


def solve(inp):
    (N, Y) = map(int, inp.readline().split(' '))

    for a in range(N + 1):
        for b in range(N + 1 - a):
            c = max(0, N - (a + b))
            if a * 10 + b * 5 + c * 1 == Y / 1000:
                return "{} {} {}".format(a, b, c)

    return "-1 -1 -1"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


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

typedef long long ll;

/* 2017/01/19 問題 -----  ABC050 A /Link http://abc050.contest.atcoder.jp/tasks/abc050_a */
/* -----解説等-----
問題: joisinoお姉ちゃんは、A op B という式の値を計算したいと思っています。 ここで、A,B は整数で、op は、+ または - の記号です。
あなたの仕事は、joisinoお姉ちゃんの代わりにこれを求めるプログラムを作ることです。

if文。

*/

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

    ll a, b, ans;
    string s;
    cin >> a >> s >> b;
    if (s == "+")ans = a + b;
    else ans = a - b;
        cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, y;
    cin >> n >> y;
    y /= 1000;
    for (int j = 0; j < 9; ++j) {
        int i = y - n - 4 * j;
        int k = 10 * n - y - 5 * j;
        if (i < 0 || i % 9 != 0) continue;
        if (k < 0 || k % 9 != 0) continue;

        cout << i / 9 << " " << j << " " << k / 9 << endl;
        return 0;
    }

    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

// N = 0 もあることに注意！！

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

    ll N;
    cin >> N;
    vector<ll> A(N+1);
    REP(i, N+1) cin >> A[i];
    vector<ll> S(N+1, 0);
    S[N] = A[N];
    REP(i, N) S[N-1-i] = S[N-i] + A[N-1-i];

    ll res = 0;
    ll now = 1;
    REP(i, N+1){
        if(i != 0) now *= 2;
        if(now<A[i]){
            cout << -1 << endl;
            return 0;
        }
        now = min(now, S[i]);
        res += now;
        now -= A[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4768
n = int(input())
a = [0] * (n + 1)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            c = x * x + y * y + z * z + x * y + y * z + z * x
            if c <= n:
                a[c] +=1
            else:
                break
for i in a[1:]:
    print(i)


Measured memory_bytes: 9296
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int INF = 1e9 + 7;
struct st
{
    int price;
    vector<int> skill;
}a[13];
int ans = INF;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,x;
    int tmp;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].price;
        for(int j=0;j<m;j++)
        {
            cin>>tmp;
            a[i].skill.push_back(tmp);
        }
    }
    int max_mask = (1<<n);
    for(int i=0;i<max_mask;i++)
    {
        int tmp_price = 0;
        int pass = 0;
        vector<int> val(m,0);
        for(int j=0;j<n;j++)
        {
            if( (i|(1<<j)) == i)
            {
                tmp_price += a[j].price;
                for(int p=0; p<m; p++)
                {
                    val[p]+=a[j].skill[p];
                }
            }
        }
        for(int j=0; j<m; j++)
        {
            if(val[j] >= x)
            {
                pass++;
            }
        }
        if(pass == m)
        {
            ans = min(ans,tmp_price);
        }
    }
    if(ans == INF)
    {
        cout<<-1<<endl;
    }
    else cout<<ans<<endl;
}


Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;

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

    while(true){
      int n = sc.nextInt();

      if (n==0) break;

      int score[] = new int[n];
      double m = 0;

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

      m = m/n;

      double a = 0;

      for (int i=0; i<n; i++) a += Math.pow((double)(score[i]-m), 2)/n;

      a = Math.sqrt(a);

      System.out.println(a);
    }

  }
}



Measured memory_bytes: 31544
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, K = mapint()

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(N)
blocks = set()
friends = [0]*N
possi = [0]*N
for _ in range(M):
    a, b = mapint()
    uf.union(a-1, b-1)
    friends[a-1] += 1
    friends[b-1] += 1
for _ in range(K):
    a, b = mapint()
    if uf.same(a-1, b-1):
        friends[a-1] += 1
        friends[b-1] += 1
for i in range(N):
    possi[i] = uf.size(i)-friends[i]-1
print(*possi)

Measured memory_bytes: 84540
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
struct Node{
	int x,y;
};
queue<Node> q;
int p[1010][1010];
void bfs()
{
	while(!q.empty())
	{
		Node a=q.front();
		q.pop();
		for (int dx = -1; dx <= 1; dx++)
			for (int dy = -1; dy <= 1; dy++)
				if (dx * dx + dy * dy == 1)
				{
					Node b;
					b.x=a.x+dx;
					b.y=a.y+dy;
					if(b.x>0&&b.y>0&&b.x<=n&&b.y<=m&&p[b.x][b.y]==-1)
					{
						q.push(b);
						p[b.x][b.y]=p[a.x][a.y]+1;
						//cout<<b.x<<" "<<b.y<<" "<<p[b.x][b.y]<<endl;
					}
				}
		ans=p[a.x][a.y];
	}
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m;
	string s;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		for(int j=1;j<=m;j++)
		{
			if(s[j-1]=='#')
			{
				Node xx;
				xx.x=i,xx.y=j;
				q.push(xx);
			}else{
				p[i][j]=-1;
			}
		}
	}
	bfs();
	cout<<ans<<endl;
	return 0;
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  vector<int> b(n);
  int l = 0, r = n - 1;
  for(int i = n - 1; i >= 0; --i) {
    if(i % 2 == (n - 1) % 2) {
      b[l] = a[i];
      ++l;
    }else{
      b[r] = a[i];
      --r;
    }
  }

  REP(i,n) {
    if(i) cout << " ";
    cout << b[i];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,c=0,k=1,n,h,w,m,min=100000000000,ans=1,max=0;
    string s,s2;
    VI alp(26);
    cin >> s;

    for(int i=0;i<s.size();i++){
        alp[s[i]-'a']++;
    }

    rep(i,26){
        if (alp[i] > 1){
            cout <<"no"<< endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  int x[n] = {};
  int ans = 1e+9;
  for(int i=0;i<n;i++) cin >> x[i];
  for(int i=0;i+k-1<n;i++){
    ans = min(ans, 
      ((abs(x[i]) == x[i]) == (abs(x[i+k-1]) == x[i+k-1])?
        max(abs(x[i]),abs(x[i+k-1])):
        x[i+k-1] - x[i] + min(abs(x[i]),abs(x[i+k-1]))));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

s = ins()


def solve():
    lreq = s[0] == s[-1]
    odd = len(s) % 2 == 1
    return odd ^ lreq


print("First" if solve() else "Second")


Measured memory_bytes: 3316
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, x: "List[int]"):
    ans = 0
    for i in range(N):
       ans += min(x[i], abs(K - x[i])) * 2
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long long ans; cin >> ans;
  for(int i = 1; i < n; i++){
    long long a;
    cin >> a;
    ans = lcm(ans,a);
  }
  cout << ans;
}
  

Measured memory_bytes: 3636
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
int w,h,sx,sy;
char field[32][32];
vector<pair<int,int> > t_node;
int node[16][16],visited[32][32];
int dp[1<<10][16];

int main(){
	
	while(scanf(" %d%d ",&w,&h),w|h){
		memset(node,0,sizeof(node));
		rep(i,1<<10)rep(j,16)dp[i][j]=INT_MAX;
		
		t_node.clear();
		rep(i,h){
			scanf("%s",field[i]);
			rep(j,w){
				if( field[i][j]=='o' ){
					sx = j;
					sy = i;
				}else if( field[i][j]=='*' ){
					t_node.push_back(mp(j,i));
				}
			}
		}
		if( t_node.size()==0 ){
			printf("0\n");
			continue;
		}
		t_node.push_back(mp(sx,sy));
#if DEB
		rep(i,t_node.size()){
			printf("(%d,%d)\n",t_node[i].first, t_node[i].second);
		}
#endif	
		

		// make node (bfs)
		rep(i,t_node.size()){
			memset(visited,-1,sizeof(visited));
			queue<pair<int,int> > q;
			q.push(mp(t_node[i].first, t_node[i].second));
			visited[t_node[i].second][t_node[i].first] = 0;
			while( !q.empty() ){
				int x = q.front().first;
				int y = q.front().second;
				int c = visited[y][x];
				q.pop();
				rep(k,4){
					int tx = x + dx[k];
					int ty = y + dy[k];
					if( tx<0 || ty<0 || tx>=w || ty>=h || field[ty][tx]=='x' || visited[ty][tx]!=-1 )continue;
					visited[ty][tx] = c+1;
					q.push(mp(tx,ty));
				}
			}		
			
			rep(j,t_node.size())if( i!=j ){
				node[i][j] = visited[t_node[j].second][t_node[j].first];
			}
		}

#if DEB		
		rep(i,t_node.size()){
			rep(j,t_node.size()){
				printf("%d ",node[i][j]);
			}
			puts("");
		}
		puts("");
#endif		
			

#if DEB
		rep(i,h){
			puts(field[i]);
		}puts("");
#endif

		int n = t_node.size();
		int ans = INT_MAX;
		dp[0][n-1] = 0;
		rep(i,n-1){ //kosuu
			rep(j,1<<(n-1)){ //bit dp
				rep(k,n)if( dp[j][k]!=INT_MAX ){ //now node
					rep(l,n-1)if( !((1<<l)&j) && node[k][l]>0 ){
						dp[j|(1<<l)][l] = min(dp[j|(1<<l)][l], dp[j][k]+node[k][l]);
						if( (j|(1<<l))==((1<<(n-1))-1) ){
							ans = min(ans, dp[(1<<(n-1))-1][l]);
						}
#if DEB
						printf("bit:%d  , %d --> %d  , cost:%d\n",j|(1<<l),k,l,dp[j|(1<<l)][l]);
#endif						
					}
				}
			}
		}
#if DEB
		printf("%d\n",(1<<(n-1))-1);
#endif		
		printf("%d\n",ans==INT_MAX ? -1 : ans);
	}
	return 0;
}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  int x[100],y[100];
  bool ans = false;
  for(int i=0;i<N;i++){
  	cin>>x[i];
    if(x[i]>=Y)ans=true;
  }
  for(int i=0;i<M;i++){
  	cin>>y[i];
    if(y[i]<=X)ans=true;
  }
  for(int i=0;i<N;i++){
  	for(int j=0;j<M;j++){
    	if(x[i]>=y[j])ans=true;
    }
  }
  if(ans){
  	cout<<"War"<<endl;
  }else{
  	cout<<"No War"<<endl;
  }
}

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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int [] abc = new int[3];
		
		for(int i = 0; i < abc.length; i++){
			abc[i] = scan.nextInt();
		}

		Arrays.sort(abc);
		System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);
	}
}

Measured memory_bytes: 26360
# 東西方向、南北方向の道路の本数
ew_number, sn_number = list(map(int, input().split()))

# 各交差点を最寄りとする住人の人数
people_num = []
for i in range(ew_number):
    people_num.append(list(map(int, input().split())))

# 東西方向
answer = 100 ** 10
for i in range(ew_number):
    # 南北方向
    for j in range(sn_number):
        dist = 0

        # 距離の近い方の、人数×距離を合算
        for k in range(ew_number):
            for l in range(sn_number):
                dist += min(abs(k - i), abs(l - j)) * people_num[k][l]

        answer = min(answer, dist)

print(answer)


Measured memory_bytes: 5604
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                    int x, n;
                    cin>>x>>n;
                    set<int> s;
                    for(int i = 0; i < n; i++){
                        int k;
                        cin>>k;
                        s.insert(k);
                    }
                    pair<int, int> ans = {INT_MAX, 0};
                    for(int i = 0; i < 102; i++){
                        if(s.count(i) == 0 && ans.first > abs(i-x))
                            ans = {abs(i-x), i};
                    }
                    cout<<ans.second;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 3580
#include<cstdio>
#define N 200005
#define mod 1000000007
int n;
int dp[N][2];
int head[N],nxt[N],to[N],tot;
void add(int x,int y){nxt[++tot]=head[x];head[x]=tot;to[tot]=y;}
void DP(int u,int p=0){
	dp[u][0]=dp[u][1]=1;
	for(int e=head[u];e;e=nxt[e]){
		int v=to[e];
		if(v==p)continue;
		DP(v,u);
		dp[u][0]=1LL*dp[u][0]*(dp[v][0]+dp[v][1])%mod;
		dp[u][1]=1LL*dp[u][1]*dp[v][0]%mod;
	}
//	printf("%d %d %d\n",u+1,dp[u][0],dp[u][1]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;++i){
		int u,v;scanf("%d%d",&u,&v);--u,--v;
		add(u,v);add(v,u);
	}
	DP(0);
	printf("%d\n",(dp[0][0]+dp[0][1])%mod);
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int a,b; cin>>a>>b;
   if(a%2==1&&b%2==1) cout<<"Odd"<<endl;
   else cout<<"Even"<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split(' '))

b = (n + 1)*(n**2 + 2*n + 6)
a = m*(2*m**2 - 3*m*(n + 2) + 3*n - 2)

ans = (a + b)//6+1
ans = ans % 1000000007
print(ans)

Measured memory_bytes: 61860
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,i,j,k,x,y,z;
    cin>>a>>b>>m;
    int ar1[100000],ar2[100000];
    for(i=0;i<a;i++)
        cin>>ar1[i];
    for(j=0;j<b;j++)
        cin>>ar2[j];
   long long int min1=INT_MAX;
    for(i=0;i<a;i++)
    {
        if(ar1[i]<min1)
            min1=ar1[i];
    }
    long long int min2=INT_MAX;
    for(j=0;j<b;j++)
    {
        if(ar2[j]<min2)
            min2=ar2[j];
    }
    long long int sum[100000];
    long long int min3=min1+min2;
    for(k=0;k<m;k++)
    {
        cin>>x>>y>>z;
        sum[k]=ar1[x-1]+ar2[y-1]-z;
        if(min3>sum[k])
            min3=sum[k];
    }
    cout<<min3<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    map<ll, ll> m;
    ll tmp;
    vector<ll> a;
    REP(i, N) {
        cin >> tmp;
        m[tmp]++;
        a.push_back(tmp);
    }
    ll ans = 0;
    for(auto val: a){
        ans = max(ans, m[val-1] + m[val] + m[val + 1]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 7028
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 1e5+10;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int cnt = 0, ans = 0;
	for(int i=1;i<n;i++){
		if(a[i]>=a[i+1]){
			cnt++;
			ans = max(ans,cnt);
		}else cnt = 0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
// Zero-Sum Ranges

#include <cstdio>
#include <utility>
#include <unordered_map>
using namespace std;

unordered_map<long long int, int> sum_map({});

int main()
{
    int n = 0;
    int num = 0;
    long long int cnt = 0;
    long long int sum = 0;
    scanf("%d", &n);
    sum_map.clear();
    sum_map.insert(make_pair<long long int, int>(0, 1));
    auto value = sum_map.begin();
    for (int i = 0; i<n; ++i)
    {
        scanf("%d", &num);
        sum += num;
        if ((value = sum_map.find(sum)) != sum_map.end())
        {
            cnt += value->second;
            ++value->second;
        }
        else
            sum_map.insert(make_pair<long long int, int>(move(sum), 1));
    }
    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 8520
#!python3

# input
N = int(input())
S = input()


def main():
    ans = S.count("R") * S.count("G") * S.count("B")
    
    lim = (N - 1) // 2 + 1
    for i in range(1, lim):
        lim2 = N - 2 * i
        for j in range(lim2):
            if S[j] != S[j+i] and S[j+i] != S[j+2*i] and S[j] != S[j+2*i]:
                ans -= 1
    
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    ll t;
    cin >> t;
    ll k = 1, minval = 1, cnt = 1;
    if(t == 0){
        cout << 0 << "\n";
        return 0;
    }
    for (int i = 0; i <= 30; ++i) {
        if(minval > t) continue;
        ll x = t-minval;
        ll cntt = x/k;
        x %= k;
        while(x > 0){
            cntt += x%3;
            x /= 3;
        }
        k *= 3;
        ans = min(ans, cnt+cntt);
        if(k <= 3) minval += k, cnt++;
        else minval += k/3*4, cnt += 2;


    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
using namespace std;
typedef long long int ll;
ll  p ;
ll power()  
{  
    ll res = 1;   
    ll x =  10;
    x = x % p; 
   
    if (x == 0) return 0; 
    ll y = p-2;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() {
    int n;cin>>n;
    cin>>p;
    string s;cin>>s;
    ll p10[n+1] = {0} , in = power();
    p10[0] = 1;
    for (int i=1;i<n+1;++i)p10[i] = (p10[i-1] * in)%p;
    ll sum = 0 ,ans = 0;
    ll cnt[p] = {0};cnt[0] =1;
    for (int i=0;i<n;++i){
        sum = (sum *10 + (s[i] - '0'))%p;
        ll t1 = sum;
        if (in)
        sum = (p10[i+1] *sum)%p;
        if (in == 0) {if (sum == 0){
            ans+=(i+1);
        }}else{
        ans += (cnt[sum]);
        ++cnt[sum];}
        sum = t1;
    }
    cout<<ans;
}

Measured memory_bytes: 5332
//this is a copy




#include <bits/stdc++.h>
using namespace std;

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

const long MOD = 1000000007;
long dp[100001][4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  dp[0][0] = 1;
  for (int i = 0; i < S.size(); ++i) {
    char c = S[i];
    // 0
    if (c == '?') {
      dp[i + 1][0] = dp[i][0] * 3 % MOD;
    } else {
      dp[i + 1][0] = dp[i][0] % MOD;
    }

    // 1
    if (c == '?') {
      dp[i + 1][1] = (dp[i][0] + dp[i][1] * 3) % MOD;
    } else if (c == 'A') {
      dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD;
    } else {
      dp[i + 1][1] = dp[i][1] % MOD;
    }

    // 2
    if (c == '?') {
      dp[i + 1][2] = (dp[i][1] + dp[i][2] * 3) % MOD;
    } else if (c == 'B') {
      dp[i + 1][2] = (dp[i][1] + dp[i][2]) % MOD;
    } else {
      dp[i + 1][2] = dp[i][2] % MOD;
    }

    // 3
    if (c == '?') {
      dp[i + 1][3] = (dp[i][2] + dp[i][3] * 3) % MOD;
    } else if (c == 'C') {
      dp[i + 1][3] = (dp[i][2] + dp[i][3]) % MOD;
    } else {
      dp[i + 1][3] = dp[i][3] % MOD;
    }
  }

  cout << dp[S.size()][3] << endl;
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int main(){
    int h,w;
    cin >>h >>w;
    while(h || w)
    {
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
            {
                if(j>=w-1)
                    cout<< "#"<< endl;
                else
                    cout<< "#";
            }
        cout <<endl;
        cin >>h >>w;
    }
}


Measured memory_bytes: 3100