akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

// 空白区切り、1行の数式を取得する
std::vector<std::string> GetInputFormula()
{
    std::vector<std::string> vecstr;

    std::string r, s;
    std::getline(std::cin, r);
    std::stringstream ss;
    ss << r;
    while (getline(ss, s, ' '))
    {
        vecstr.push_back(s);
    }
    return vecstr;
}

// 逆ポーランド記法の数式を
// std::stackを用いて計算する
void CalcRPNbyStack(std::vector<std::string> vecstr)
{
    std::stack<int> results;
    for (std::string v : vecstr)
    {
        try
        {
            int num = std::stoi(v);
            results.push(num);
        }
        catch (const std::invalid_argument &e)
        {
            int num1 = results.top();
            results.pop();
            int num2 = results.top();
            results.pop();
            if (v == "+")
            {
                int res = num2 + num1;
                results.push(res);
            }
            else if (v == "-")
            {
                int res = num2 - num1;
                results.push(res);
            }
            else if (v == "*")
            {
                int res = num2 * num1;
                results.push(res);
            }
            // 今回は割り算は対象ではないが一応
            else if (v == "/")
            {
                int res = num2 / num1;
                results.push(res);
            }
        }
    }
    std::cout << results.top() << std::endl;
}

int main()
{
    static const int MAX = 1000000;
    int n, R[MAX];
    std::string r, s;
    std::vector<std::string> vecstr = GetInputFormula();

    CalcRPNbyStack(vecstr);

    return 0;
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MAX = 1e5;
const int MOD = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main()
{
    COMinit();
    ll n, k; cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        cout << COM(n - k + 1, i) % (ll)(1e9+7) * COM(k - 1, i - 1) % (ll)(1e9+7) << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

long long int cube(int a) {
	return (long long int)a * a * a;
}

int l(int a, int b) {
	return a / b;
}

int main() {
	int n, k, flg;
	long long int x, y;
	scanf("%d%d", &n, &k);
	flg = (k % 2 == 0);
	x = cube(n / k);
	y = flg ? cube(l(n,l(k,2)) - l(n,k)) : 0;
	printf("%lld", x + y);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int N,A[100100];

int main()
{
	scanf ("%d",&N);
	for (int i=0;i<N;i++){
		scanf ("%d",&A[i]);
	}

	long long mn = 2, mx = 2;
	for (int i=N-1;i>=0;i--){
		if (mn % A[i]){
			mn -= mn % A[i];
			mn += A[i];
		}
		mx -= mx % A[i];
		if (mn > mx){
			puts("-1");
			return 0;
		}
		mx += A[i]-1;
	}

	printf ("%lld %lld\n",mn,mx);
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
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;
}

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

    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    REP(i, H) cin >> s[i];

    REP(i, H) {
        std::cout << s[i] << '\n';
        std::cout << s[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
list1=[list(map(int,input().split())) for i in range(N)]

dp=[float('inf')]*100001 # dpリストを作る。
# dp[i]は、価値の総和がiになる時の質量の総和の最小。
dp[0]=0

for i in range(N): # １つ１つの商品について
    for j in range(100000,list1[i][1]-1,-1):
        dp[j]=min(dp[j],dp[j-list1[i][1]]+list1[i][0])

for i in range(100000,-1,-1):
    if dp[i]<=W:
        print(i)
        break

Measured memory_bytes: 92620
#include<stdio.h>
int main()
{
    int ara[51],count=0;
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&ara[i]);
    }

    if(ara[n-1]==1&&ara[0]==n&&ara[1]==2){
            printf("YES\n");
        }
        else if(ara[0]==1&&ara[1]==2&&ara[n-1]==n){
            printf("YES\n");
        }
        else{
    for(i=0;i<n;i++){
        if(ara[i]-ara[i+1]==1 && ara[i]+1==ara[i+2]&&(ara[0]==1||ara[n-1]==n)){
            count++;
        }
        else if(ara[i]==1&&ara[n-1]==n&&ara[0]==i+1){
            count++;
        }
        else if(ara[i]==n&&ara[n-1]==i+1&&ara[0]==1){
            count++;
        }
        }
       if(count==1)
            printf("YES\n");
       else
        printf("NO\n");
}

return 0;
}


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

int main(){
  int ans[4];
  int N;

  //入力
  cin >> N;

  string arr[N+1];
  for(int i=1;i<=N;i++) cin >> arr[i];
  ans[0]=ans[1]=ans[2]=ans[3]=0;
  for(int i=1;i<=N;i++){
    if(arr[i]=="AC"){
      ans[0]+=1;
    }else if(arr[i]=="WA"){
      ans[1]+=1;
    }else if(arr[i]=="TLE"){
      ans[2]+=1;
    }else{
      ans[3]+=1;
    }
  }
  cout << "AC x ";
  cout << ans[0] << endl;
  cout << "WA x ";
  cout << ans[1] << endl;
  cout << "TLE x ";
  cout << ans[2] << endl;
  cout << "RE x ";
  cout << ans[3] << endl;

}


Measured memory_bytes: 6752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(a<=9 && b<=9) System.out.println(a*b);
		else System.out.println(-1);
	}
}


Measured memory_bytes: 22612
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.next()
    val s = n.toCharArray()
    if(s[0].equals('7') || s[1].equals('7') || s[2].equals('7')) println("Yes") else println("No")
}

fun abc000a(n:Int, a:List<Int>, q:Int, m:List<Int>) {

}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



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

int a, b, c, d;

int main(void){
    // Here your code !
    scanf("%d %d %d %d", &a, &b, &c, &d);

    if ((a + b) == (c + d)) printf("Balanced\n");
    else if ((a + b) < (c + d)) printf("Right\n");
    else printf("Left\n");

    return 0;
}


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

using namespace std;

template<typename tp> inline void read(tp &x) {
	x = 0; register char c = getchar(); register bool f = 0;
	for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}

int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    if(a > 9 || b > 9) {
        puts("-1");
        }else{
            printf("%d",a * b);
        }
    return 0;
}

Measured memory_bytes: 256
import fractions
a,b = map(int,input().split())
x = fractions.gcd(a,b)

def so(n):
    a = []
    while n%2==0:
        a.append(2)
        n//=2
    f = 3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n!=1:
        a.append(n)
    return a
y = set(so(x))
print(len(y)+1)


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

int main() {
    string S;
    cin >> S;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if (p and q and r) {
        cout << 3 << endl;
    } else if ((p and q) or (q and r)) {
        cout << 2 << endl;
    } else if (p or q or r) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
#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 ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;


int n,k ;

bool check(int m, vi &a){
  int cnt=0;
  REP(i,a.size()){
    cnt += (a[i]-1)/m;
  }
  return cnt <= k;
}

int main(){
  cin >> n >> k;
  vi a(n);

  int l=1;
  int r=0;
  REP(i,n){
    cin >> a[i];
    chmax(r,a[i]);
  }

  //  checkの戻り値が FFFTTT で一番左のTを見つけたい場合
  while(l<r){
    ll m = (l+r)/2;
    //cout << l << " " << r << " " << m << endl;
    if(check(m,a)){
      r=m;
    }else{
      l=m+1;
    }
  }
  cout << l << endl;
}



Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
bool dfs(int p, const vector<vector<int>> &w, vector<int> &path,
         vector<int> &visited) {
  // if (visited[p]) return false;
  visited[p] = 1;
  path.push_back(p);
  auto &pnode = w[p];
  bool hasNext = false;
  for(auto pp: pnode) {
    if (!visited[pp]) {
      dfs(pp, w, path, visited);
      hasNext = true;
      break;
    }
  }
  // path.pop_back(p);
  // visited[p] = 0;
  return hasNext;
}
int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> edges(N + 1);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  vector<int> path1;
  vector<int> path2;
  vector<int> visited(N + 1, 0);
  dfs(1, edges, path1, visited);
  visited[1] = 0;
  dfs(1, edges, path2, visited);

  reverse(path1.begin(), path1.end());
  path1.pop_back();


  for(auto p: path2) path1.push_back(p);

  cout << path1.size() << '\n';
  cout << path1[0];
  for(int i = 1; i < path1.size(); ++i) {
    cout << ' ' << path1[i];
  }
}

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

int main()
{
	int64_t a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	printf("%lld\n", std::max({a * c, b * d, a * d, b * c}));

	return 0;
}

Measured memory_bytes: 3780
#include <stdio.h>

int main(void)
{
	double v, y;
	int n;
	
	while (scanf("%lf", &v) != EOF){
		y = (v * v / 19.6);
		n = 0;
		while (5.0 * n <= y){
			n++;
		}
		printf("%d\n", n + 1);
	}
	return (0);
}

Measured memory_bytes: 628
#include <iostream>
using namespace std;
void printA(int A[], int n){
    for (int k = 0; k < n; k++){
        if (k != n - 1){
            cout << A[k] << " ";
        }else{
            cout << A[n - 1] << endl;
        }
    }
}
int main(void){
    int n;
    cin >> n;
    int A[n];
    // A???????????????
    for (int i = 0; i < n; i++){
        int item;
        cin >> item;
        A[i] = item;
    }
    printA(A, n);
    // insertion sort
    for (int i = 1; i < n; i++){
        int key;
        key = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > key){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = key;
        printA(A, n);
    }
}

Measured memory_bytes: 1164
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	int n, p;

	while (true)
	{
		cin >> n >> p;

		if (n == 0 && p == 0) { break; }

		int c = 0, r = p;

		vector<int> d(n, 0);

		while (true)
		{
			if (p != 0)
			{
				d[c]++; p--;
			}
			else
			{
				p = d[c]; d[c] = 0;
			}

			bool ok = false;

			if (p == 0)
			{
				ok = true;

				for (int i = 0; i < n; i++)
				{
					if (i != c && d[i] != 0)
					{
						ok = false;
					}
				}
			}

			if (ok)
			{
				break;
			}

			c = (c + 1) % n;
		}

		cout << c << endl;
	}
}

Measured memory_bytes: 2996
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**9)
    from collections import deque
    mod = 10**9+7
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N-1):
        x, y = map(int, input().split())
        G[x-1].append(y-1)
        G[y-1].append(x-1)
    que = deque([0])
    children = [[] for _ in range(N)]
    while que:
        v = que.pop()
        for nv in G[v]:
            if children[nv]:
                continue
            children[v].append(nv)
            que.append(nv)   
    memo = [[-1]*2 for _ in range(N)]
    def dp(i, c):
        if memo[i][c] >=0:
            return memo[i][c]
        if c == 1:
            res = 1
            for j in children[i]:
                res*=dp(j, 0)
                res%=mod
            memo[i][c] = res
        else:
            res = 1
            for j in children[i]:
                res*=(dp(j, 0)+dp(j, 1))
                res%=mod
            memo[i][c]= res
        return memo[i][c]
    print((dp(0, 0)+dp(0, 1))%mod)
main()


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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n,m,c;cin >> n >> m >> c;

    int b[20];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }

    int res=0;
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<m;j++){
            int a;cin >> a;
            sum += a*b[j];
        }
        if(sum+c>0) res++;
    }
    p(res)
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int H=0, R=0;
	scanf("%d", &H);
	scanf("%d", &R);
	if (H < 0) {
		if (R == -H) {
			printf("0\n");
		}
		else {
			printf("-1\n");
		}
	}
	else {
		printf("1\n");
	}
	return 0;
}


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

int main() {

  int a,b;
  bool kai = false;

  while(true) {

    cin >> a >> b;
    if ( a == 0 && b == 0 ) break;

    if ( kai ) cout << endl;
    kai = true;

    bool flag = true;

    for ( int i = a; i <= b; i++ ) {

      bool f = false;
      if ( i % 4 == 0 ) f = true;
      if ( i % 100 == 0 ) f = false;
      if ( i % 400 == 0 ) f = true;

      if ( f ) {
	cout << i << endl;
	flag = false;
      }

    }

    if ( flag ) cout << "NA" << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
/*input
8
10 9 8 7 6 5 4 3
*/

// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}


const ll LOG = 45;

ll get(ll val, ll bit) {
	return val & (1ll << bit);
}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	ll n, r = 0; cin >> n;
	vector<ll> a(n);
	for(ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(ll i = 2; i < n; i++) {
		r ^= a[i];
	}
	ll dot = a[0] + a[1] - r;
	if(dot & 1) {
		cout << "-1" << endl;
		return 0;
	}
	dot >>= 1;
	ll a1 = 0, a2 = 0;
	for(int i = LOG - 1; i >= 0; i--) {
		if(get(dot, i)) {
			a1 += (1ll << i);
			a2 += (1ll << i);
			if(a1 > a[0]) {
				for(int j = i + 1; j < LOG; j++) {
					if(get(a1, j) && !get(a2, j)) {
						a1 -= (1ll << j);
						a2 += (1ll << j);
						break;
					}
				}
			}
			if(a1 > a[0]) {
				cout << "-1" << endl;
				return 0;
			}
		}
		else {
			if(get(r, i)) {
				a1 += (1ll << i);
				if(a1 > a[0]) {
					a1 -= (1ll << i);
					a2 += (1ll << i);
				}
			}
		}
	}
	if((a1 + a2 != a[0] + a[1]) || ((a1 ^ a2) != r) || (a1 < 1 || a1 > a[0])) {
		cout << "-1" << endl;
	}
	else {
		cout << a[0] - a1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define ll long long
const int N = 2e6 + 15;
int main(){
	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(n, k-n) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int N = 2e6 + 239;
const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int f[N];
int rf[N];

int C(int n, int k) {
	return mul(f[n], mul(rf[n - k], rf[k]));
}

int calc(int r, int c) {
	int ans = 0;
	for (int l = 1; l <= r + 1; l++) {
		ans = add(ans, C(l + c, c));
	}
	return ans;
}

void init() {
	f[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = mul(i, f[i - 1]);
	}
	for (int i = 0; i < N; i++) {
		rf[i] = binpow(f[i], MOD - 2);
	}
}

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

	init();

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	int kek =  calc(r2, c2) - calc(r1 - 1, c2) - calc(r2, c1 - 1) + calc(r1 - 1, c1 - 1);
	kek %= MOD;
	kek += MOD;
	cout << kek % MOD << endl;
}


Measured memory_bytes: 31488
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            double D = double.Parse(str[0]);
            double N = double.Parse(str[1]);
            
            if(N%100 == 0) N++;
            double ans = Math.Pow(100,D)*N;
            
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
int a,b,c,d;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(a),read(b),read(c),read(d);
	if(a!=c)
		puts("1");
	else
		puts("0");
	return 0;
}

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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

vector<ll> DecToBinary(ll num,ll trailing_zero, ll nbits)
{
    vector<ll> bits;
    while(num > 0)
    {
        bits.push_back(num%2);
        num /= 2;
    }

    if(trailing_zero == 1)
    {
        while(bits.size() < nbits)
        {
            bits.push_back(0);
        }
    }

    return bits;
}

long long int BinaryToDec(vector<ll> bits)
{
    ll number = 0;
    ll i;
    for(i=bits.size()-1;i>=0;i--)
    {
        number += (bits[i] * (long long)pow((ll)2 , i));
    }
    return number;
}

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        // ll n,i,j;
        // cin >> n;
        // ll arr[n];

        // for(i=0;i<n;i++)
        // {
        //     cin >> arr[i];
        // }

        char inp;
        cin >> inp;
        if(inp >= 'A' && inp <='Z')
        {
            cout << 'A' << '\n';
        }
        else
        {
            cout << 'a' << '\n';
        }
        
    }
    
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;

int main(){
    int N,sa=10000,sum;
    cin>>N;
    int w[101];
    cin>>w[0];
    sum = w[0];
    for(int i=1;i<N;i++){
        int tmp;
        cin >> tmp;
        w[i] = w[i-1]+tmp;
        sum += tmp;
    }
    for(int i=0;i<N;i++){
        int tmp = sum - w[i];
        sa = min(sa,abs(w[i]-tmp));
    }
    cout<<sa<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int PMAX = 2000000;

const function<int(int, int)> minQ = [](int l, int r) { return min(l, r); };

template <typename T>
struct node {
	T val;
	node *l, *r;
	node() {}
	node(T val) : val(val), l(nullptr), r(nullptr) {}
	void init(T v, node *left, node *right) {
		val = v;
		l = left;
		r = right;
	}
};

node<int> pool[PMAX];

template <typename T>
class PersistentSegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id;
	func_t merge;
	int it;
	vector<node<T>*> root;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(int val = 0, node<T> *l = nullptr, node<T> *r = nullptr) {
		pool[it].init(val, l, r);
		return &pool[it++];
	}
	node<T> *fix(node<T> *x, int p, T val, int lb, int ub) {
		if (p < lb || ub <= p) return x;
		if (lb + 1 == ub) return new_node(val);
		int c = (lb + ub) / 2;
		auto nl = fix(x->l, p, val, lb, c);
		auto nr = fix(x->r, p, val, c, ub);
		return new_node(merge(nl->val, nr->val), nl, nr);
	}
	T sub(node<T> *x, int l, int r, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return x->val;
		int c = (lb + ub) / 2;
		return merge(sub(x->l, l, r, lb, c), sub(x->r, l, r, c, ub));
	}
public:
	PersistentSegmentTree(int n_, T id_, func_t merge_) : n(size(n_)), id(id_), merge(merge_) {
		for (int i = 1; i < n * 2; i++) {
			pool[i - 1].init(id, i < n ? &(pool[i * 2 - 1]) : nullptr, i < n ? &(pool[i * 2]) : nullptr);
		}
		it = n * 2 - 1;
		root.push_back(&pool[0]);
	}
	void update(int p, T val, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		root.push_back(fix(root[rt], p, val, 0, n));
	}
	T find(int l, int r, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		return sub(root[rt], l, r + 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	PersistentSegmentTree<int> st(n, INT_MAX, minQ);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			st.update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 30932
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String str = s.next();
        char[] ch = str.toCharArray();
        int i = 0;
        int maxcount = 0;
        while(i < ch.length) {
            if(ch[i] != 'R') {
                i++;
                continue;
            }
            int count= 0;
            while ( i < ch.length && ch[i] == 'R') {
                count++;
                i++;
            }

            maxcount = Math.max(maxcount, count);
            i++;
        }

        System.out.println(maxcount);
    }

}


Measured memory_bytes: 26992
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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


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

fn main() {
    input! {
        d: usize,
        g: i64,
        pc: [(i64, i64); d],
    }
    let mut min = std::i64::MAX;
    for i in 0..1 << d {
        let mut cnt = 0;
        let mut pnt = 0;
        for j in 0..d {
            if i & (1 << j) != 0 {
                cnt += pc[j].0;
                pnt += pc[j].0 * (j + 1) as i64 * 100 + pc[j].1;
            }
        }
        if pnt < g {
            for j in (0..d).rev() {
                if i & (1 << j) == 0 {
                    let last_cnt = std::cmp::min((g - pnt) / ((j + 1) as i64 * 100), pc[j].0 - 1);
                    pnt += last_cnt * (j + 1) as i64 * 100;
                    cnt += last_cnt;
                }
            }
        }
        if pnt >= g {
            min = std::cmp::min(min, cnt);
        }
    }
    println!("{}", min);
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t N, X, M;
  cin >> N >> X >> M;
  int64_t res = 0;
  set<int64_t> st;
  auto f = [](int64_t x, int64_t m) { return x % m; };
  while (N > 0 && st.find(X) == st.end()) {
    res += f(X, M);
    st.insert(X);
    X *= X;
    X %= M;
    N--;
  }
  if (N == 0) {
    cout << res << '\n';
    return 0;
  }
  int64_t loop = 0;
  set<int64_t> tt;
  while (tt.find(X) == tt.end()) {
    loop += f(X, M);
    tt.insert(X);
    X *= X;
    X %= M;
  }
  res += loop * (N / (int)tt.size());
  N %= (int)tt.size();
  while (N > 0) {
    res += f(X, M);
    X *= X;
    X %= M;
    N--;
  }
  // int idx = 0;
  // int64_t tsum = 0;
  // for (int i = 0; i < (int)XS.size(); i++) {
  //   if (XS[i] == X) {
  //     idx = i;
  //     break;
  //   }
  // }
  // for (int i = idx; i < (int)XS.size(); i++) {
  //   tsum += XS[i];
  // }
  // res *= (N / ((int)XS.size() - idx));
  // N %= (int)XS.size() - idx;
  // while (N > 0) {
  //   res += f(X, M);
  //   X *= X;
  //   X %= M;
  //   N--;
  // }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 8248
A, B = map(int, input().split())
# https://www.iandprogram.net/entry/2015/03/18/003511
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)
# https://qiita.com/kageyasai2/items/48ef81f39b4e31c6d396
def factorize(n):
    factor = []
    for num in range(2, int(n**0.5+1)):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n != 1:
        factor.append(n)
    return set(factor)
    
g = gcd(A, B)
f = factorize(g)
print(len(f) + 1)

Measured memory_bytes: 3064
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e5 + 10;
pair<double, double> a[maxn];
double dx[maxn], dy[maxn], ans, lb = 0, lbb, rbb, rb = 2e8;

int n;

char c;

double calc(double t) {
	double u, d, l, r;
	l = r = a[0].first + t * dx[0], u = d = a[0].second + t * dy[0];
	for (int i = 1; i < n; i++) {
		l = min(l, a[i].first + t * dx[i]);
		r = max(r, a[i].first + t * dx[i]);
		u = max(u, a[i].second + t * dy[i]);
		d = min(d, a[i].second + t * dy[i]);
	}
	return (u - d) * (r - l);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second >> c;
		if (c == 'U')
			dx[i] = 0, dy[i] = 1;
		else if (c == 'D')
			dx[i] = 0, dy[i] = -1;
		else if (c == 'R')
			dx[i] = 1, dy[i] = 0;
		else
			dx[i] = -1, dy[i] = 0;
	}
	ans = calc(0);
	for (int i = 0; i < 1000; i++) {
		lbb = (2 * lb + rb) / 3;
		rbb = (lb + 2 * rb) / 3;
		if (calc(lbb) < calc(rbb))
			rb = rbb;
		else
			lb = lbb;
	}
	cout << setprecision(10) << fixed << calc(lb) << '\n';
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
  char a[100],b[100],c[100];
  int n,count=0,i;
  scanf("%d %s %s %s",&n,a,b,c);
  for(i=0;i<n;i++){
    if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i]) count+=2;
    else if(a[i]!=b[i]||b[i]!=c[i]||a[i]!=c[i]) count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}
int main(){
	int N;
	cin >> N;

	// 最上位ビット以外を0nにする
	// cout << bitset<7>(N).to_string() << endl;
	int cntr = 0;
	string str = bitset<7>(N).to_string();
	while(str[cntr] == '0') cntr++;
	// cout << 6-cntr << endl;
	cout << pow(2,6-cntr) << endl;
}



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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	int cnt;
	int i1,i2,i3,i4;
	int temp1,temp2,temp3,temp4;

	while(1){
		cin>>n;
		if(n==0) break;

		cnt=0;
		for(i1=floor(sqrt(n));i1>0;i1--){
			temp1=n-i1*i1;
			if(temp1==0){cnt++;continue;}
			for(i2=i1;i2>0;i2--){
				temp2=temp1-i2*i2;
				if(temp2==0) {cnt++; continue;}
				else if(temp2<0) continue;
				for(i3=i2;i3>0;i3--){
					temp3=temp2-i3*i3;
					if(temp3==0) {cnt++; continue;}
					else if(temp3<0) continue;
					for(i4=i3;i4>0;i4--){
						temp4=temp3-i4*i4;
						if(temp4==0) {cnt++; break;}
					}
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=2005;
vector<int>v[N];
int n,m,a,b,dist[N][N];//dist[i][j]=k点i到点j的最短路径为k 
inline bool cmp(vector<int>x,vector<int>y){return x.size()>y.size();}
void bfs()
{
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i][j]=1e9;
	queue<int>q;
	for(int i=0;i<n;i++)
	{
		q.push(0);
		q.push(i);
		q.push(i);
	}
	while(!q.empty())
	{
		int move=q.front();q.pop();
		int org=q.front();q.pop();
		int now=q.front();q.pop();
		if(dist[org][now]<=move)continue;
		dist[org][now]=move;
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i];
			q.push(move+1);
			q.push(org);
			q.push(to);
		}
	}
	
}
void solve()
{
	bfs();
	int pnt=0,ans=0;
	vector<int>e[N];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(dist[i][j]>m)
				e[i].pb(j),pnt++;
	for(int i=0;i<n;i++)sort(e[i].begin(),e[i].end());
	while(pnt)
	{
		int MAX=0,num=-1;//就是这一行 
		for(int i=0;i<n;i++)
		{
			if(MAX<e[i].size())
			{
				num=i;
				MAX=e[i].size();
			}
		}
		for(int i=0;i<e[num].size();i++)
		{
			int to=e[num][i];
			e[to].erase(lower_bound(e[to].begin(),e[to].end(),num));
		}
		ans++;
		pnt-=e[num].size()*2;
		e[num].clear();
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n-1;i++)
	{
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	solve();
	return 0;
}
/*
*/

Measured memory_bytes: 67332
#include<stdio.h>

int main(){
	
	int a[3];
	int o, j;

	a[0] = a[1] = a[2] = -1;
	
	for(j = 0; j < 10; j++){
		
		scanf("%d",&o);
		
		if(a[0] <= o){
			
			a[2] = a[1];
			a[1] = a[0];
			a[0] = o;
			
		}else if(a[1] <= o){
			
			a[2] = a[1];
			a[1] = o;
			
		}else if(a[2] <= o){
			
			a[2] = o;
			
		}
		
	}
	
	printf("%d\n", a[0]);
	printf("%d\n", a[1]);
	printf("%d\n", a[2]);
	
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int x,y;
/*
a+2b=x
2a+b=y
a=(-x+2y)/3
b=(2x-y)/3
*/
ll f[1010101], invf[1010101];
ll inv(ll x) {
    ll res = 1;
    ll k = inf - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % inf;
        y = (y * y) % inf;
        k >>= 1;
    }
    return res;
}

void init() {
    f[0] = 1;
    rep(i, 1, 1010101) f[i] = (f[i - 1] * i) % inf;
    rep(i, 0, 1010101) invf[i] = inv(f[i]);
}

ll comb(int n, int k) {
    ll a = f[n];
    ll b = invf[n-k];
    ll c = invf[k];
    ll bc = (b * c) % inf;
    return (a * bc) % inf;
}

int main(){cout<<fixed<<setprecision(10);
           cin >> x >> y;
           ll a=( - x + 2 * y ),b=( 2 * x - y );
           if( a % 3 != 0 || b % 3 != 0 || a < 0 || b < 0 ) {
            cout << 0 << endl;
             return 0;
           }
           a/=3;b/=3;
           init();
           cout << comb (a+b , a ) << endl;
           //cout << a << " " << b << endl;
}

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


int main(){
    string a;
    cin>>a;
    int len = a.length();
    string b = "s";
    string c = "es";
    if(a[len-1] == 's')a = a+c;
    else a = a+b;
    cout<<a;
   // system("PAUSE");
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        int max = 0;
        for(int i = 0;i < n;i++){
            int x = sc.nextInt();
            a.add(x);
            max = Math.max(max,x);
        }
        int cnt = 0;
        
        int color = max+1;
        for(int i = 0;i < n-1;i++){
            if(a.get(i) != a.get(i+1)){
                continue;
            }
            a.set(i+1,color);
            color++;
            cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
using namespace std;
int W,H,w,h,sum,ans[510][510],v;
int main(){
    scanf("%d%d%d%d",&H,&W,&h,&w);
    if(H%h==0&&W%w==0){puts("No");return 0;}
    v=500*500/(w*h-1);
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++){
            if(i%h==0&&j%w==0)ans[i][j]=-(w*h-1)*v-1;
            else ans[i][j]=v;
            sum+=ans[i][j];
        }
    if(sum>0){
        puts("Yes");
        for(int i=1;i<=H;i++,puts(""))
            for(int j=1;j<=W;j++)
                printf("%d ",ans[i][j]);
    }
    else puts("No");
}


Measured memory_bytes: 2944
#include<cstdio>
#include<cstring>
int a[100100];
int sum[100100];
int inv(int x)
{
    long long ans=1,m=x;
    int y=1000000005;
    while(y)
    {
        if(y&1)
            ans=ans*m%1000000007;
        m=m*m%1000000007;
        y>>=1;
    }
    return ans;
}
int main()
{
    int ans=0;
    int n;
    long long fact=1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;++i)
    {
        sum[i]=(sum[i-1]+inv(i))%1000000007;
        fact=fact*i%1000000007;
    }

    for(int i=1;i<=n;++i)
        ans=(ans+(long long)a[i]*(sum[i]+sum[n-i+1]-1)%1000000007)%1000000007;
    printf("%lld\n",fact*ans%1000000007);
    return 0;
}


Measured memory_bytes: 896
import sys
sys.setrecursionlimit(pow(10, 7))


# vをcに塗る。pはvの親
def dfs(v, p, c):
    res[v] = c
    for e in G[v]:
        if e[0] == p:
            continue
        if e[1] & 1:
            dfs(e[0], v, 1-c)
        else:
            dfs(e[0], v, c)


N = int(input())

G = [[] for _ in range(N)]
res = [0] * N
for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append([v-1, w])
    G[v-1].append([u-1, w])
dfs(0, -1, 1)
print('\n'.join(map(str, res)))


Measured memory_bytes: 85208
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    char a[n][n];
    char b[m][m];
    for(int i=0;i<n;i++){
        scanf("%s",a[i]);
    }   
    for(int i=0;i<m;i++){
        scanf("%s",b[i]);
    }
    int flag=0;
    for(int i=0;i<n&&flag==0;i++){
        for(int j=0;j<n&&flag==0;j++){
            int ia=i,ja=j;
            int ib=0,jb=0;
            while(a[ia][ja]==b[ib][jb]){
                if(ib==m-1&&jb==m-1){
                    flag=1;
                    break;
                }
                if(jb==m-1){
                    jb=0;
                    ib++;
                    ja=j;
                    ia++;
                }else if(jb<m-1){
                    jb++;
                    ja++;
                }
            }

        }
    }
 if(flag==1) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 }

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	vector <ll> v(n+1);

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

	for(int i=2; i<=n; i++){
		for(int j=i; j<=n; j+=i){
			v[j]++;
		}
	}

	ll m=0;
	for(ll i=1; i<=n; i++){
		m += i*v[i];
	}

	cout << m;



	
	

	return 0;
}

Measured memory_bytes: 81336
s = input()

ans = False
if s.startswith('A'):
    if s.count('C') == 1:
        if 2 <= s.find('C') <= len(s) - 2:
            s = s.replace('A', 'a', 1)
            s = s.replace('C', 'c', 1)
            if s.lower() == s:
                ans = True
print('AC' if ans else 'WA')



Measured memory_bytes: 9104
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int w = nextInt();
			if (w == 0) {
				break;
			}

			int h = nextInt();
			int[][] map = new int[h][w];
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					map[i][j] = nextInt();
				}
			}

			int island = 0;
			Deque<Integer[]> deque = new ArrayDeque<Integer[]>();
			for (int i = 0; i < map.length; i++) {
				for (int j = 0; j < map[i].length; j++) {
					if (map[i][j] == 1) {
						island++;
						Integer[] land = { i, j };
						deque.addFirst(land);
						map[i][j] = 0;
						while (deque.size() > 0) {
							Integer[] pop = deque.pollFirst();
							for (int k = -1; k <= 1; k++) {
								for (int l = -1; l <= 1; l++) {
									if (pop[0] + k >= 0
											&& pop[0] + k < map.length
											&& pop[1] + l >= 0
											&& pop[1] + l < map[0].length
											&& map[pop[0] + k][pop[1] + l] == 1) {
										Integer[] push = { pop[0] + k,
												pop[1] + l };
										deque.addFirst(push);
										map[pop[0] + k][pop[1] + l] = 0;
									}
								}
							}
						}
					}
				}
			}
			System.out.println(island);
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 24708
import numpy as np
n=int(input())
A=np.array(list(map(int,input().split())),dtype='int64')
dp=A.copy()
for i in range(1,n):
    if i%2==0:
        dp=np.maximum(dp[1:]+A[:n-i],dp[:-1]+A[i:])
    else:
        dp=np.minimum(dp[1:]-A[:n-i],dp[:-1]-A[i:])
print(dp[0]*(n%2*2-1))

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

int main() {
  
  string s;
  cin >> s;
  
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

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

#define pb push_back
#define ff first
#define ss second

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

ll a, b, c, k, ans;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c >> k;
	if (k & 1)
		ans = - a + b;
	else
		ans = a - b;
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	for (auto i = 0; i < tx - sx; ++i)
	{
		cout << 'R';
	}

	for (auto i = 0; i < ty - sy; ++i)
	{
		cout << 'U';
	}

	for (auto i = 0; i < tx - sx; ++i)
	{
		cout << 'L';
	}

	for (auto i = 0; i < ty - sy; ++i)
	{
		cout << 'D';
	}

	cout << 'D';
	for (auto i = 0; i < tx - sx + 1; ++i)
	{
		cout << 'R';
	}

	for (auto i = 0; i < ty - sy + 1; ++i)
	{
		cout << 'U';
	}

	cout << 'L';
	cout << 'U';

	for (auto i = 0; i < tx - sx + 1; ++i)
	{
		cout << 'L';
	}

	for (auto i = 0; i < ty - sy + 1; ++i)
	{
		cout << 'D';
	}
	cout << 'R' << endl;

	return 0;
}

Measured memory_bytes: 256