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

const int M=1e9+7;
int h, w, bd[1001][1001];
char c;

int main() {
	cin >> h >> w;
	for (int i=0; i<1001; i++) {
		bd[0][i] = 0;
		bd[i][0] = 0;
	}
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			cin >> c;
			if (c=='#') 
				bd[i][j] = 0;
			else bd[i][j] = (bd[i-1][j]+bd[i][j-1])%M;
			bd[1][1] = 1;
		}
	}
	cout << bd[h][w] << "\n";
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int in0, in1, in2, sa10, sa20;
    int f = 0;
    rep(i, 3){
        cin >> in0 >> in1 >> in2;
        if(i != 0){
            if(sa10 != in1 - in0 || sa20 != in2 - in0) f = 1;
        }
        sa10 = in1 - in0;
        sa20 = in2 - in0;
    }
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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 << ' ';
        }
    }
}

template <class T> long long mod_factorial(T N, const int mod) {
    long long ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= (i + 1);
        ans %= mod;
    }
    return ans;
}

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

    int N;
    cin >> N;
    auto ans = mod_factorial(N, MOD7);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> P;
int H,W,h,w;
int a[505][505];
int main(){
    cin >> H >> W >> h >> w;
    if(H%h == 0 && W%w == 0){
        puts("No");
        return 0;
    }
    puts("Yes");
    a[0][0] = 1e8;
    a[h-1][w-1] = -1e8-1;
    rep(i,H){
        rep(j,W-1){
            cout << a[i%h][j%w] << " ";
        }
        cout << a[i%h][(W-1)%w] << endl;
    }
    
}

Measured memory_bytes: 2816
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define PI 3.14159265359
#define INF 1001001001
typedef long long ll;
char t[200001];
bool isq[200001];
int main() {
	scanf("%s", t);
	int len = strlen(t);
	for (int i = len - 1; i >= 0; i--) {
		if (t[i] == '?') {
			isq[i] = true;
			if (i == len - 1) {
				t[i] = 'D';
			} else if (t[i + 1] == 'D') {
				t[i] = 'P';
			} else {
				t[i] = 'D';
			}
		}
	}
	for (int i = 0; i < len - 1; i++) {
		if (isq[i + 1] && t[i] == 'P' && t[i + 1] == 'P') {
			t[i + 1] = 'D';
		}
	}
	printf("%s\n", t);
	return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{
	string s; cin >> s;
	int m=sz(s);
	string ans;
	rep(i,m)ans+="x";
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
import math

N=int(input())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()
cnt=0
for i in range(N):
    A[i]+=cnt
    tmp=math.ceil(A[i]/B[i])*B[i]-A[i]
    cnt+=tmp
print(cnt)

Measured memory_bytes: 15080
using System;

namespace Watch
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int input = int.Parse(line);

            int hour, min, sec;
            sec = input % 60;
            min = (input / 60) % 60;
            hour = input / 3600;

            Console.WriteLine("{0}:{1}:{2}", hour, min, sec);

        }
    }
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

ll arr[100010];

int main() {
  int N, M;
  cin >> N >> M;
  int l[M], r[M];
  for (int i = 0; i < M; i++) cin >> l[i] >> r[i];

  for (int i = 0; i < M; i++) {
    arr[l[i]]++;
    arr[r[i]+1]--;
  }

  for (int i = 1; i < 100010; i++) {
    arr[i] += arr[i-1];
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) if (arr[i] == M) {
    ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    int S = A[0] + A[1];
    int X = 0; FOR(i, 2, N) X ^= A[i];
    int C = (S - X) / 2;

    if(S < X || (S - X) % 2 != 0 || (X & C) != 0){
        Out(-1);
        return 0;
    }
    //debug(S); debug(X); debug(C);

    int ans = -1, t = 0;
    IREP(i, 60){
        if(((C >> i) & 1) == 1) t += bit(i);
        else if(((X >> i) & 1) == 1){
            if((t >> i) < (A[0] >> i)){
                int t0 = t;
                REP(j, i) if(((C >> j) & 1) || ((X >> j) & 1)) t0 += bit(j);
                if(t0 > 0 && t0 <= A[0]) chmax(ans, t0);
            }

            if((t >> i) < (A[0] >> i)) t += bit(i);
            else if((t >> i) > (A[0] >> i)) break;
        }
    }
    if(t > 0 && t <= A[0]) chmax(ans, t);
    chOut(ans >= 0, A[0] - ans, ans);

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define int long double
using namespace std;

int n,tmp,sumv=0.00;

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>tmp;
		sumv=(sumv+1.00/tmp);
	}
	cout<<fixed<<setprecision(15)<<1.00/sumv<<endl;
	
	return 0;
}

Measured memory_bytes: 256
main = do
  [h, w] <- fmap (map read . words) getLine :: IO [Int]
  if [h, w] == [0, 0] then
    return ()
  else do
    mapM_ putStrLn [[ if y `mod` 2 == x `mod` 2 then
                        '#' else '.' | x <- [1..w]] | y <- [1..h]]
    putStrLn ""
    main

Measured memory_bytes: 3948
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;


int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a.at(i);
	sort(a.begin(), a.end());
	if(a.at(0) + a.at(1) == a.at(2)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lMax = 0
rMin = n
for i in range(m):
    l, r = map(int, input().split())
    if l > lMax:
        lMax = l
    if r < rMin:
        rMin = r
print(rMin - lMax + 1 if rMin >= lMax else 0)


Measured memory_bytes: 3060
from collections import deque
s=deque(input())
q=int(input())
flag=0
for _ in range(q):
  query=input().split()
  if len(query)==1:
    flag=(flag+1)%2
  else:
    if (int(query[1])+flag)%2:
      s.appendleft(query[2])
    else:
      s.append(query[2])
print(''.join(s) if flag==0 else ''.join(reversed(s)))

Measured memory_bytes: 8436
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll k;
vector<int> a;
//約数列挙オーダー√n
vector<ll> divisor(ll n)
{
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
                res.push_back(n / i);
        }
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k;
    vector<ll> b=divisor(k);
    vector<ll> c = divisor(k-1);
    ll ans=c.size()-1;
    rep(i,b.size()){
        ll t=k;
        if(b[i]==1)continue;
        while(t%b[i]==0){
            t/=b[i];
        }
        if(t%b[i]==1)ans++;
    }
    cout<<ans<<"\n";
}


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

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
using hll = __int128;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}


#define solvsh
//#define multi

#ifdef solvsh

//const int MAXN = 1e2 + 2;

#define uint ll

uint ml(uint a, uint b){
    return (a*1ll * b);
}

uint add(uint a, uint b){
    return (a*1ll + b);
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


const int MAXN = 81;
const int MAXSUM = 81 * 200;

ll dp[MAXN];

void solve() {

    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int curr;
        cin >> curr;
        v.push_back(curr);
    }
    dp[0] = 1000;
    for (int i = 1; i <= n; ++ i) {
        ll maxx = dp[i - 1];
        for (int j = 1; j < i; ++j) {
            if (v[j - 1] < v[i - 1]) {
                ll cnt = dp[j] / v[ j   - 1];
                ll curr = dp[j] - cnt * v[j - 1] + cnt * v[i - 1];

                maxx = max(maxx, curr);
            }
        }

        dp[i] = maxx;
    }

    ll maxx = dp[n];

    cout << maxx;
}

#else

void solve() {

}


#endif


void multisolve() {
//    prec();
    int t;
    cin >> t;

//    scanf("%d", &t);

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ":\n";
        solve();
//        cout << "\n";
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif


}

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

int main(){
  string S;
  cin >> S;
  char a[4];
  if (S[0]==S[1]){
    if(S[2]==S[3] && S[0]!=S[2]){
      cout << "Yes";
    }
    else{
      cout <<"No";
    }
  }
    else if(S[0]==S[2]){
      if(S[1]==S[3] && S[0]!=S[1]){
        cout << "Yes";
      }
      else{
        cout << "No";
      }
    }
    else if(S[0]==S[3] ){
      if (S[1]==S[2] && S[0]!=S[1]){
        cout << "Yes";
      }
      else{
        cout << "No";
      }
    }
    else{
      cout << "No";
    }
  }
  
  

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        long ans = 1;
        long A = cin.nextLong();
        long B = cin.nextLong();

        for (long i = 2; i * i <= Math.Max(A, B); i++)
        {
            if (A % i == 0 || B % i == 0)
            {
                int acount = 0;
                int bcount = 0;
                while (A % i == 0) { acount++; A /= i; }
                while (B % i == 0) { bcount++; B /= i; }
                if (acount >= 1 && bcount >= 1) ans++;
            }
        }
        if(A != 1 && B != 1 && A == B)
        {
            ans++;
        }

        Console.WriteLine(ans);
    }
    
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 13140
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int D = Integer.parseInt(sc.next());
    int N = Integer.parseInt(sc.next());
    
    int n = (int)Math.pow(100, D);
    
    System.out.println(N==100 ? n*(N+1) : n*N);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
	double r;
    double menseki, ensyuu;

    cin >> r;
    
    menseki = M_PI * (r*r);
    ensyuu = M_PI * r * 2;


    cout << fixed << setprecision(6) << menseki << " " << fixed << setprecision(6) <<  ensyuu << " " << endl;

    return 0;


}


Measured memory_bytes: 3276
#include<stdio.h>

int main(){
  
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);

  for(int i=0;; i++){

    c = c-b;
        if( c <= 0){
        printf("Yes");
        return 0;
      }
    a = a-d;
      if( a <= 0){
        printf("No");
        return 0;
      }      
  }
  

  return 0;
}

Measured memory_bytes: 1728
# ABC121C - Energy Drink Collector
def main():
    N, M, *AB = map(int, open(0).read().split())
    AB = list(zip(*[iter(AB)] * 2))
    AB.sort()
    ans = 0
    for a, b in AB:
        while b > 0 and M > 0:
            ans += a
            b -= 1
            M -= 1
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> A(N);
  for(int i=0; i<N ;i++){
    cin >> A.at(i);
  }
  
  for(int i=0; i<N-K ;i++){
    if(A.at(K+i)>A.at(i)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  
}

Measured memory_bytes: 4052
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

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


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline", "no-stack-protector", "unroll-loops")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#include <bits/stdc++.h> 
using namespace std;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55];
	int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	template <class I>
	inline void gi (I &x) {
		for (c = gc(); c < '0' || c > '9'; c = gc());
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x<<1)+(x<<3) + (c & 15);
	}
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0');
		if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	struct Flusher_ {
		~Flusher_() {
			flush();
		}
	} io_flusher_;
}
using io :: gi;
using io :: putc;
using io :: print;
const int N=2e5+5,Mod=1e9+7;
int Head[N],Next[N],Adj[N],tot=0;
void addedge(int u,int v){
	Next[++tot]=Head[u],Head[u]=tot,Adj[tot]=v;
}
bool foot[N];
int a[N],p[N],deg[N];
int fa[N],num[N],siz[N],counter[N],cnt;
int getrt(int x){
	return fa[x]==x?x:fa[x]=getrt(fa[x]);
}
bool vis[N],onc[N];
void dfs(int x){
	vis[x]=true,p[++cnt]=x;
	if (!vis[a[x]]) dfs(a[x]);
	else{
		int i;
		for (i=cnt;i>=1;i--)
			if (p[i]==a[x]) break;
		if (i>=1){
			int fst=0,lst=0,st=i;
			while (i<=cnt){
				if (deg[p[i]]>1){
					if (!fst) fst=i;
					siz[p[i]]=i-lst,lst=i;
				}
				onc[p[i]]=true,i++;
			}
			siz[p[fst]]=fst-st+1+cnt-lst;
		}
	}
}
int getsz(int x){
	int sz=1;
	for (int e=Head[x];e;e=Next[e])
		if (!onc[Adj[e]]) sz+=getsz(Adj[e]);
	return sz;
}
int f[N],sz[N];
void gg(){puts("0");exit(0);}
int main(){
	int n,ans=1;gi(n);
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=n;i++){
		gi(a[i]);
		addedge(a[i],i);
		++deg[a[i]];
		if (deg[a[i]]>2) gg();
		if (getrt(i)!=getrt(a[i])) fa[getrt(i)]=getrt(a[i]);
	}
	for (int i=1;i<=n;i++){
		counter[getrt(i)]++;
		if (!vis[i]) cnt=0,dfs(i);
	}
	for (int i=1;i<=n;i++)
		if (!onc[i]&&deg[i]>1) gg();
	for (int i=1;i<=n;i++)
		if (deg[i]>1) {
			foot[getrt(i)]=true;
			sz[i]=getsz(i)-1;
		}
	for (int i=1;i<=n;i++)
		if (deg[i]>1){
			if (sz[i]<siz[i]) ans=ans*2%Mod;
			else if (sz[i]>siz[i]) gg();
		}
	for (int i=1;i<=n;i++)
		if (getrt(i)==i&&(!foot[i]))
			++num[counter[i]];
	for (int i=1,t;i<=n;i++)
		if (num[i]){
			if (i==1) t=1;
			else t=(i&1)+1;
			f[0]=1,f[1]=t;
			for (int j=2;j<=num[i];j++)
				f[j]=(1ll*f[j-1]*t+1ll*(j-1)*f[j-2]%Mod*i)%Mod;
			ans=1ll*ans*f[num[i]]%Mod;
		}
	print(ans);
	return 0;
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define MOD 998244353
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
 
int power(int x,int y,int mod) 
{ 
 	int ret = 1;
 	x = x % mod;
 	while (y){
 		if(y&1) ret = (ret*x)%mod;
 		y = y>>1;
 		x = (x*x)%mod;
    } 
    return ret%mod; 
}

int isprime(int x)
{
	for (int i=2;i*i<=x;i++)
		if (x%i==0) return 0;
	return 1;
}

void solve()
{	
	int n;
	cin>>n;
	vector<vector<int>> inp(n,vector<int>(3));
	vector<vector<int>> dp(n,vector<int>(3));

	for (auto &x:inp){
		for (auto &y:x){
			cin>>y;
		}
	}
	dp[0] = inp[0];
	for (int i=1;i<n;i++){
		for (int j=0;j<3;j++){
			for (int k=0;k<3;k++){
				if (k!=j){
					dp[i][j] = max(dp[i][j],dp[i-1][k] + inp[i][j]);
				}
			}
		}
	}
	cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;


}
 
 
signed main(){
	// int t;
	// cin>>t;
	// while (t--)	
	solve();	
 
}
	

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll N = 200010;
map<ll, ll> mp;
ll a[N];
ll n;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];

	ll res = 0;
	for (int i = 1; i <= n; i++) {
		res += mp[a[i] - i];
		mp[-(a[i] + i)]++;
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 27932
package main

import (
	"fmt"
	"strings"
)

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)

	dx, dy := tx-sx, ty-sy

	// s -> t
	fmt.Print(strings.Repeat("U", dy))
	fmt.Print(strings.Repeat("R", dx))

	// t -> s
	fmt.Print(strings.Repeat("D", dy))
	fmt.Print(strings.Repeat("L", dx))

	// s -> t
	fmt.Print("L")
	fmt.Print(strings.Repeat("U", dy+1))
	fmt.Print(strings.Repeat("R", dx+1))
	fmt.Print("D")

	// t -> s
	fmt.Print("R")
	fmt.Print(strings.Repeat("D", dy+1))
	fmt.Print(strings.Repeat("L", dx+1))
	fmt.Print("U")

	fmt.Println()
}


Measured memory_bytes: 640
from pprint import pprint

__BASE     = 1000000007
__MOD      = (2**64)
__INV      = 13499267949257065399

def main():
    s,t = input(),input()
    x = len(t)
    mp = {}
    hashv = 0
    for i in range(len(s)):
        if i - x >= 0:
            hashv = hashv - ord(s[i-x]) * ( __BASE ** (x-1) )
        hashv *= __BASE
        hashv %= __MOD
        hashv += ord(s[i])
        hashv %= __MOD
        if i >= x-1:
            if hashv in mp:
                mp[hashv].append(i)
            else:
                mp[hashv] = [i]
    hashv = 0
    for c in t:
        hashv *= __BASE
        hashv %= __MOD
        hashv += ord(c)
    if hashv in mp:
        for pos in mp[hashv]:
            print(pos-(x-1))

if __name__ == "__main__":
    main()


Measured memory_bytes: 6716
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define INF 10000000000

int main() {
	long long int n, l;
	cin >> n >> l;
	vector<long long int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	vector<long long int> t(n, INF);
	while (true) {
		bool h = true;
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				if (d[i] > d[i+1]) {
					t[i] = (l-d[i]);
				} else {
					t[i] = (l-d[i])+t[i+1];
				}
			} else if (i == n-1) {
				if (d[i] > d[i-1]) {
					t[i] = (l-d[i]);
				} else {
					t[i] = (l-d[i])+t[i-1];
				}
			} else {
				if (d[i] > d[i+1] && d[i] > d[i-1]) {
					t[i] = (l-d[i]);
				} else if (d[i] > d[i+1]) {
					t[i] = (l-d[i])+t[i-1];
				} else if (d[i] > d[i-1]) {
					t[i] = (l-d[i])+t[i+1];
				} else {
					t[i] = (l-d[i])+max(t[i+1],t[i-1]);
				}
			}
			if (t[i] >= INF) {
				h = false;
			}
		}
		if (h) {
			long long int tt = 0;
			for (int i = 0; i < n; i++) {
				tt = max(tt, t[i]);
			}
			cout << tt << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2592
N = int(input())
A = list(map(int, input().split(' ')))

B = []
for a in A:
  if a%2 == 0:
    B.append(a)

cnt = 0
for b in B:
  if b%3 == 0 or b%5 == 0:
    cnt += 1
if cnt == len(B):
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
def merge(A,left,mid,right):
    global count

    L=A[left:mid]+[1000000001]
    R=A[mid:right]+[1000000001]

    i=0
    j=0

    for k in range(left,right):
        if L[i] <=R[j]:

            A[k]=L[i]
            i=i+1

        else:
            A[k]=R[j]
            j=j+1

    count+=right-left


def merge_sort(A,left,right):
    if left+1<right:
        mid=(left+right)//2

        merge_sort(A,left,mid)
        merge_sort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
A=list(map(int,input().split()))
count=0
merge_sort(A,0,n)
print(*A)
print(count)
        
    



Measured memory_bytes: 61652
S_A = [i for i in input()+'A']
S_B = [i for i in input()+'B']
S_C = [i for i in input()+'C']
T = S_A
l = T.__len__()
while(l > 1):
    t = T.pop(0)
    if t == 'a':
        T = S_A
    elif t == 'b':
        T = S_B
    elif t == 'c':
        T = S_C
    l = T.__len__()
print(T[0])


Measured memory_bytes: 3060
N = int(input())
A_n = list(map(int, input().split(' ')))

count = 0
last_i = 0
temp = 1
t = 0

if 1 not in set(A_n):
    print('-1')
else:
    for a in A_n:
        if a == temp:
            temp += 1
        else:
            count += 1
    print(count)

Measured memory_bytes: 32276
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 20 == 19) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

ll gcd(ll a, ll b)
{
  while (b > 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  bool is_exist[(ll)1e5 + 1];
  for (ll i = 0; i <= 1e5; ++i) {
    is_exist[i] = false;
  }

  ll N, K;
  std::cin >> N >> K;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    is_exist[va[i]];
  }

  ll max_val = *std::max_element(va.begin(), va.end());
  ll x = va[0];
  for (ll i = 1; i < (ll)va.size(); ++i) {
    x = gcd(va[i], x);
  }

  std::string judge = "POSSIBLE";
  if (K > max_val) {
    judge = "IMPOSSIBLE";
  } else if (K % x != 0) {
    judge = "IMPOSSIBLE";
  }

  print(judge);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int n;
	int a;
	int maxN = 100010;
	cin >> n;
	vector<int> v(maxN,0);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a > 0) v[a - 1] ++;
		v[a]++;
		v[a + 1]++;
	}
	int maxval = 0;
	for (auto val : v) {
		maxval = max(maxval, val);
	}
	cout << maxval << endl;
	return 0;
}

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


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

int a,b,sum;
b = 1000;
sum = 0;
for (int i = 0; i < n; i++)
{
    cin >> a;
    sum += a;
    if (b > a)
    {
        b = a;
    }

}

cout << n + (x - sum) / b << endl;




}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int lenght(char* str){
  int i=0;
  while(str[i]){
     i++;
  }
  return i;
}

int main(){
  char S[200005], T[200005] ;
  int N, ans = 0, check = 0, len ;
  cin >> S >> T ;
  len = lenght(S) ;
  for(int i=0;i<len;i++){
    if(S[i] != T[i]){
      ans++ ;
    }
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 4028
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = []
for i, g in enumerate(grid):
    r = ''
    for j, s in enumerate(g):
        if s == '#':
            r += s
        else:
            r += str(sum([temp[max(j-1, 0): min(j+1, W)+1].count('#') for temp in grid[max(i-1, 0): min(i+1, H)+1]]))
    ans.append(r)
print(*ans, sep='\n')

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);

	std::ios_base::sync_with_stdio(false), cin.tie(0);

	ll n, k, a, ans = 0;
	cin >> n >> k;
	for(int kk = k ; (kk >> 1) <= n ; kk += k){
		if(kk & 1) continue;
		a = (kk >> 1);
		ans += (((n + a) / k) - (a / k)) * (((n + a) / k) - (a / k));

	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
const int N=55;
typedef std::pair<int,int> P;
int n,k;P a[N];
int main() {
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&a[i].first),a[i].second=i;
    std::vector<int> ans;
    ++k;std::sort(a+1,a+1+n,std::greater<P>());
    ans.push_back(a[1].second);a[1].first--;
    while(k--) {
        std::sort(a+2,a+1+n,std::greater<P>());
        for(int i=2;i<=n;i++) {
            if(!a[i].first) return !printf("-1");
            else ans.push_back(a[i].second),a[i].first--;
        }
        std::swap(a[1],a[n]);
    }
    printf("%d\n",int(ans.size()));
    for(int v:ans) printf("%d ",v);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <list>
#include <algorithm>
using namespace std;
int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    int min = p + q;
    if(q+r < min)
        min = q+r;
    
    if(r+p < min)
        min = r+p;

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3632
#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 FOR(i, m, n) for (ll i = m; i < n; 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;


int main()
{
    string s; cin >> s;
    string s1(ALL(s));
    string s2(ALL(s));
    reverse(ALL(s2));

    ll s1count = 0;
    FOR(i, 1,  s.size()) {
        if (s1[i] == s1[i-1]) {
            s1count++;
            if (s1[i] == '0') s1[i] = '1';
            else s1[i] = '0';
        }
    }

    ll s2count = 0;
    FOR(i, 1,  s.size()) {
        if (s2[i] == s2[i-1]) {
            s2count++;
            if (s2[i] == '0') s2[i] = '1';
            else s2[i] = '0';
        }
    }
    cout << min(s1count, s2count) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
 
typedef struct{
  double x;
  double y;
} Point;
 
void Koch(int n,Point a,Point b){
  if(n==0) return;
  Point s,t,u;
  double th=M_PI*60.0/180.0;
 
  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
 
  Koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  Koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  Koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  Koch(n-1,t,b);
}
 
int main(){
  Point a,b;
  int n;
  scanf("%d",&n);
  a.x=a.y=b.y=0;
  b.x=100;
  printf("%.8f %.8f\n",a.x,a.y);
  Koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N,K; cin >> N >> K;
    vector<ll> a(N+1,0);
    vector<ll> b(N+1,0);
    int i,j;
    ll x;
    ll ans=1;
    int y=0,z=0;

    rep(i,N){
        cin >> x;
        if(x<0){
            x = x*(-1);
            b[z]=x;
            z++;
        }
        else {
            a[y]=x;
            y++;
        }
    }

    if(N == K){
            rep(i,y) ans = ans * a[i]%MOD;
            rep(i,z) ans = ans * b[i]%MOD;
            if(z%2==1){
                ans *= -1;
                ans = (ans + MOD) % MOD;
            }
            AA(ans);
            return 0;
        }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    if(y == 0){
        if(K%2==1){
            rep(i,K) ans = ans * b[N+1-z+i]%MOD;
            ans = (ans*(-1) + MOD)%MOD;
            AA(ans);
            return 0;
        }
    }

    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    y=0,z=0;
    for(i=0;i<K;i++){
        if(a[y]*a[y+1]>b[z]*b[z+1]){
            ans = ans * a[y] % MOD;
            y++;
        }
        else if(y+z < K-1){
            i++;
            ans = (ans * b[z] % MOD) * b[z+1] % MOD;
            z+=2;
        }
        else {
            ans = ans * a[y] % MOD;
            y++;
        }
    }
    AA(ans);
    return 0;
}

Measured memory_bytes: 6268
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <algorithm>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; scanf("%d", &___T); for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 3050;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int mod = 1e9+7;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
int n , dp[maxn][maxn], ans;
char c[maxn];
//dp[i][j]  安排完前i个数第i个数是j的方案
int main()
{
    cin >> n;
    scanf("%s",c+1);
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++){
        if(c[i-1] == '<'){
            for(int j = 2; j <= i; j++){
                dp[i][j] = (dp[i][j-1]+dp[i-1][j-1]) % mod;
            }
        }else {
            for(int j = i-1; j ; j--){
                dp[i][j] = (dp[i][j+1]+dp[i-1][j]) % mod;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        //add(ans, dp[n][i]);
      ans=(ans+dp[n][i])%mod;
    }
    cout << ans << endl;
}

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

using namespace std;
const int maxn = 3005;
const int base = 998244353;
int n, s;
int a[maxn];
long long f[maxn][maxn + maxn];
// long long calc(int i, int s) {
//     if (s < 0) return 
// }
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    f[0][0] = 1;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < a[i]; ++j)
            f[i][j] = f[i - 1][j] * 2 % base;
        for (int j = 0; j <= sum; ++j) 
            f[i][j + a[i]] = (f[i - 1][j] + f[i - 1][j + a[i]] * 2) % base; //classic
        sum += a[i];
        sum = min(sum, s);
    }
    cout << f[n][s];
    return 0;
}

Measured memory_bytes: 97588
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		
		Map<Character, Integer> counter = new HashMap<>();
		for (char c : w.toCharArray()) {
			int count = counter.getOrDefault(c, 0);
			counter.put(c, count + 1);
		}
		
		boolean isBeautiful = counter.values().stream().allMatch(i -> i % 2 == 0);
		String result = isBeautiful? "Yes" : "No";
		System.out.println(result);
	}

}


Measured memory_bytes: 15436
N, M = map(int, raw_input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, raw_input().split())
  E[a-1] += [b-1]
  E[b-1] += [a-1]

ok = True
for e in E:
  if len(e)%2!=0:
    ok = False
if not ok:
  print "No"
  exit(0)

ok = False
for e in E:
  if len(e)>=6:
    ok = True
if ok:
  print "Yes"
  exit(0)

c = 0
for e in E:
  if len(e)==4:
    c += 1
if c>=3:
  print "Yes"
  exit(0)
if c<=1:
  print "No"
  exit(0)

for i in range(len(E)):
  if len(E[i])==4:
    c = 0
    for v in E[i]:
      p = i
      while len(E[v])==2:
        if E[v][0]==p:
          p = v
          v = E[v][1]
        else:
          p = v
          v = E[v][0]
      if v==i:
        c += 1
    if c==2:
      print "Yes"
      exit(0)
    else:
      print "No"
      exit(0)


Measured memory_bytes: 23144
// problem: "https://atcoder.jp/contests/abc141/tasks/abc141_b"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;

    int i;
    for(i=0;i!=s.size();i++)
    {
        if(i%2)
        {
            if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
            {
                cout<<"No";
                exit(0);
            }
        }

        else
        {
            if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
            {
                cout<<"No";
                exit(0);
            }
        }
    }

    cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    char c; cin>>c;
    if(c>='a' && c<='z'){
        cout<<'a';
    }
    else{
        cout<<'A';
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3684
N = int(input())
src = [int(input()) for i in range(N)]
if src[0]:
    print(-1)
    exit()

ans = prev = 0
for a in reversed(src):
    if prev > 0:
        if a == prev - 1:
            prev = a
            continue
        elif a < prev:
            print(-1)
            exit()
    ans += a
    prev = a
print(ans)


Measured memory_bytes: 11052
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int H, W, N;
int a[100000];

signed main(){
    cin >> H >> W >> N;
    rep(i, N) cin >> a[i];
    int k = 0;
    rep(i, H){
        vector<int> ans;
        rep(j, W){
            ans.pb(k+1);
            a[k]--;
            if(a[k] == 0) k++;
        }
        if(i%2) reverse(all(ans));
        rep(j, W){
            if(j != 0) cout << " ";
            cout << ans[j];
        }
        cout << endl;
    }
}

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

int main()
{
	int N, Q;
	while (cin >> N >> Q && N != 0 || Q != 0)
	{
		string names[1000];
		long eraBased[1000];
		long yearStart[1000];
		long western[1000];

		for (int i = 0; i < N; i++)
		{
			cin >> names[i] >> eraBased[i] >> western[i];
			yearStart[i] = western[i] - eraBased[i];
		}

		for (int i = 0; i < Q; i++)
		{
			long year;
			cin >> year;
			string yearName = "";
			int diff = -1;
			for (int j = 0; j < N; j++)
			{
				if (yearStart[j] < year && western[j] >= year)
				{
					yearName = names[j];
					diff = (year - yearStart[j]);
					break;
				}
			}

			if (diff != -1)
			{
				cout << yearName << " " << diff << endl;
			}
			else
			{
				cout << "Unknown" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1300