akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string a = s.substr(0,(n-1)/2);
    string c = s.substr((n+3)/2-1);
    bool ok = true;
    string q = s;
    reverse(all(s));
    if(s!=q){
        cout << "No" << endl;
        return 0;
    }
    string b = a;
    reverse(all(a));
    if(a!=b){
        cout << "No" << endl;
        return 0;
    }
    string d = c;
    reverse(all(c));
    if(c!=d) {
        cout << "No" << endl;
        return 0;
    }
    // cout << s << ' ' << q << ' ' << a << ' ' << b << ' ' << c << ' ' << d << endl;
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
//-------------------------------------------------------------------------------

intl n;
string s;

void input_var(){
    cin >> n;
    cin >> s;
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    string t = "";
    intl cnt = 0;
    rep(i,n){
        cnt += (s[i] == '(');
        cnt -= (s[i] == ')');
        if(cnt < 0){
            t += '(';
            cnt++;
        }
    }
    t += s;
    while(cnt > 0){
        t += ')';
        cnt--;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
for i in range(1,n):
    t1 = t-h[ans]*0.006
    t2 = t-h[i]*0.006
    if abs(a-t1) > abs(a-t2):
        ans=i
        
print(ans+1)

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int N;
    while (cin >> N, N) {
        vector<set<int>> member(N+1);
        REP(i, N+1) {
            int M;
            cin >> M;
            REP(j, M) {
                int p;
                cin >> p;
                member[i].insert(p);
            }
        }

        int res = -1;
        REP(i, N) {
            bool leaked = true;
            for (int p : member[N]) {
                if (member[i].find(p) == member[i].end()) {
                    leaked = false;
                    break;
                }
            }
            if (leaked) {
                if (res == -1) {
                    res = i+1;
                } else {
                    res = -1;
                    break;
                }
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int isPrime(int x){
  int i;
  if(x == 2) return 1;
  else if(x < 2 || x%2 ==0) return 0;
  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i +2;
  }
  return 1;
}

int main(void){

  int n,x,i,count=0;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&x);
    if(isPrime(x)== 1)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
b = list(map(int, input().split()))

a = [b[0]]

ta = 0 # temporal a
for i in range(n - 2):
    ta = min(b[i], b[i + 1])
    a.append(ta)
    
ans = sum(a) + b[n - 2]

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
typedef long long int ll;

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


int main(void) {
	int N, K;
	scanf("%d%d", &N, &K);
	int A[100000];
	rep(i, N) {
		scanf("%d", &A[i]);
	}
	
	qsort(A, N, sizeof(int), cmp);


	int min = 1000000000;

	for (int i = 0; i + K - 1 < N; i++) {
		min = MIN(min, A[i + K - 1] - A[i]);
	}
	v_pri(min);


	return 0;
}

Measured memory_bytes: 892
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string out[110];
int main()
{
	int A,B;cin>>A>>B;
	rep(i,50) out[i]=string(100,'#'),out[50+i]=string(100,'.');
	rep(i,A-1){
		int x=i/49,y=i%49;
		out[x*2+1][y*2+1]='.';
	}
	rep(i,B-1){
		int x=i/49,y=i%49;
		out[x*2+51][y*2+1]='#';
	}
	cout<<"100 100"<<endl;
	rep(i,100) cout<<out[i]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a;
    cin >> s;
    printf("%s\n", a<3200 ? "red" : s.c_str());
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::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...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;

ll binary(ll n , ll v){
    ll left = 1 , right = n , ans = n+1;
    while(left <= right){
        ll mid = (left+right)/2;
        if(n/mid < v){
            ans = min(ans , mid);
            right = mid-1;
        }
        else
            left = mid+1;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    ll n , k;
    cin >> n >> k;

    vll cou , val; 
    ll s = 1;
    while(s <= n){
        ll v = n/s;
        ll nxt_s = binary(n , v);
        
        cou.pb(nxt_s - s);
        val.pb(v);
        s = nxt_s;
    }

    int m = cou.size();

    vll curr = cou;
    vll nxt(m);

    for(int i = 1 ;i < k ; i++){
        for(int j = 0 ;j < m ; j++){
            int t = m-1-j;
            nxt[t]  = curr[j]%Mod;
        }
        for(int j = m-1 ;j >= 0 ; j--){
            nxt[j] = (nxt[j] + (j+1 < m ? nxt[j+1] : 0)) % Mod;
            curr[j] = (nxt[j] * cou[j])%Mod;
        }
    }

    ll res = 0;
    for(auto it : curr)
        res = (res + it)%Mod;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2420
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k, t = MAP()
a = LIST()

ans = max(0, ( max(a) - (k+1)//2 ) * 2 - 1)
print(ans)

Measured memory_bytes: 10156
#include<stdio.h>
#include<string.h>
  
#define LEN 100005
#define MAX 100
  
typedef struct pp{
  char name[MAX];
  int t;
}P;
  
P Q[LEN+1];
int head, tail, n;
  
void initialize(void);
  
void enqueue(P);
P dequeue(void);
  
  
int main(){
  P u;
  int elaps = 0, n;
  int i, q;
   
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", u.name);
    scanf("%d", &u.t);
    enqueue(u);
  }
   
  while(head != tail){
    u=dequeue();
    if(u.t>q){
      u.t=u.t-q;
      enqueue(u);
      elaps+=q;
    }
    else{
      printf("%s %d\n",u.name,u.t+elaps);
      elaps+=u.t;
    }
  }
    
  return 0;
}
void initialize(void){
  head=0;
  tail=0;
}
   
  
void enqueue(P x){
   
    Q[tail]=x;
    if(tail+1==LEN)
      tail=0;
    else
      tail++;
  
}
P dequeue(void){
  P x;
    
    x=Q[head];
    if(head+1==LEN)
      head=0;
    else
      head++;
  
  return x;
}


Measured memory_bytes: 11852
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
inline bool cmp(char a, char b) {
    return a > b;
}
int main(int argc, char const *argv[])
{
    char s[105], t[105];
    scanf("%s %s", s, t);
    sort(s, s+strlen(s));
    sort(t, t+strlen(t), cmp);
    if (strcmp(s, t) < 0)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> ans;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  while(N){
    if(N%2){
      ans.push_back(1);
      N -= 1;
    }else{
      ans.push_back(0);
    }
    N /= -2;
  }
  for(int i=(int)ans.size()-1; i>=0; i--){
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll h,d,a;
	cin>>h>>d>>a;
	d*=2;
	vector<pair<ll,ll>>p;
	for(ll i=0;i<h;i++){
		ll x,y;
		cin>>x>>y;
		p.push_back(make_pair(x,y));
	}
	sort(p.begin(),p.end());
	queue<pair<ll,ll>>q;
	ll ans=0;
	ll tot=0;
	for(ll i=0;i<h;i++){
		ll nowx=p[i].first;
		ll nowh=p[i].second;
		if(q.size()!=0){
			ll nexx=q.front().first;
			ll nexa=q.front().second;
			while(nexx<nowx){
				tot-=nexa;
				q.pop();
				if(q.size()!=0){
					nexx=q.front().first;
					nexa=q.front().second;
				}
				else{
					break;
				}
			}
		}
		if(tot<nowh){
			ll nexa=nowh-tot;
			nexa=(nexa+a-1)/a;
			ans+=nexa;
			nexa*=a;
			tot+=nexa;
			q.push(make_pair(nowx+d,nexa));
		}
		//cout <<tot<<endl;
	}
	cout <<ans;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;

int table[50][26];

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

	for (int i = 0; i < n; ++i){
		string s;
		cin>>s;
		for (int j = 0; j < s.size(); ++j){
			table[i][s[j]-'a']++;
		}
	}

	string ans="";
	for (int i = 0; i < 26; ++i){
		int num=26;
		for (int j = 0; j < n; ++j){
			num=min(num,table[j][i]);
		}
		if(num!=0){
			for (int k = 0; k < num; ++k){
				ans+=char(i+'a');
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

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

//int _; 

int x;

int main()
{
	//for(scanf("%d",&_);_;_--)
	cin >> x;
	for(int i=0;i<1000;i++)
		for(int j=0;j<1000;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(k == 1)
					i=-i;
				if(k == 2)
					j=-j;
				if(i*i*i*i*i-j*j*j*j*j == x)
				{
					cout << i << ' ' << j << endl;
					return 0;
				}
				i=abs(i);
				j=abs(j);
			}
		} 	
	return 0;
}


Measured memory_bytes: 3584
fun main(args:Array<String>) {
  val (head, tail) = (1..2).map {
    readLine()!!.toList()
  }
  val headSort = head.sorted().joinToString("")
  val tailRSort = tail.sorted().reversed().joinToString("")
  if( headSort < tailRSort )
    println("Yes")
  else
    println("No")
}

Measured memory_bytes: 38336
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmp = 0;
double tmpd = 0.0;


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

    Int r, d, x[1000];

    cin >> r >> d >> x[0];
    for(Int i=1; i<=10; i++){
        x[i] = x[i-1]*r - d;
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var n,m int
  fmt.Scan(&n)
  m = 60
  a := make([]int64,n)
  x := make([][]int,n)
  c := make([]int,m)
  for i:=0;i<n;i++ {
    x[i] = make([]int,m)
    fmt.Scan(&a[i])
    for j:=0;j<m;j++ {
      x[i][j] = int((a[i]>>uint(j))&1)
      c[j] += x[i][j]
    }
  }
  ans1 := int64(0)
  for j:=0;j<m;j++ {
    if c[j]%2 == 1 {
      ans1 |= 1<<uint(j)
      for i:=0;i<n;i++ { x[i][j] = 0 }
    }
  }
  nomalForm(x)
  j := m-1
  ans2 := int64(0)
  for i:=0;i<n;i++ {
    for j >= 0 && x[i][j] == 0 { j-- }
    if j < 0 { break }
    tmp := int64(0)
    for k:=0;k<=j;k++ {
      if x[i][k] == 1 { tmp |= 1<<uint(k) }
    }
    ans2 ^= tmp
  }
  fmt.Println(ans1+2*ans2)
}
func nomalForm(x [][]int) {
  n := len(x)
  if n == 0 { return }
  m := len(x[0])
  if m == 0 { return }
  i := 0
  Outside:
  for j:=m-1;j>=0;j-- {
    if x[i][j] == 0 {
      for k:=i+1;k<n;k++ {
        if x[k][j] == 1 {
          for l:=j;l>=0;l-- { x[i][l] ^= x[k][l] }
          break
        }
      }
      if x[i][j] == 0 { continue Outside }
    }
    for k:=0;k<n;k++ {
      if k == i || x[k][j] == 0 { continue }
      for l:=j;l>=0;l-- { x[k][l] ^= x[i][l] }
    }
    i++
    if i == n { break }
  }
}

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

long long MOD=1000000007;

int main(){
    //input
    long long N,M;
    cin >> N >> M;
    long long S[N+1], T[M+1];
    long long i,j;
    set<long long> appear;
    for(i=1; i<=N; i++){
        cin >> S[i];
        appear.insert(S[i]);
    }
    for(j=1; j<=M; j++){
        cin >> T[j];
        appear.insert(T[j]);
    }

    //calc
    long long kosu=0;
    long long rank[100001];
    set<long long>::iterator t;
    for(t=appear.begin(); t!=appear.end(); ++t){
        rank[*t]=kosu;
        kosu++;
    }
    long long rowsum[N+1][kosu];
    long long colsum[M+1][kosu];
    for(i=0; i<=N; i++){
        for(j=0; j<kosu; j++){
            rowsum[i][j]=0;
        }
    }
    for(i=0; i<=M; i++){
        for(j=0; j<kosu; j++){
            colsum[i][j]=0;
        }
    }
    long long dp[N+1][M+1];
    for(i=0; i<=N; i++){
        dp[i][0]=1;
    }
    for(j=0; j<=M; j++){
        dp[0][j]=1;
    }
    for(i=1; i<=N; i++){
        for(j=1; j<=M; j++){
            dp[i][j]=dp[i-1][j-1]+(S[i]==T[j])*dp[i-1][j-1]+rowsum[i][rank[S[i]]]+colsum[j][rank[T[j]]];
            dp[i][j]%=MOD;
            rowsum[i][rank[T[j]]]+=dp[i-1][j-1];
            rowsum[i][rank[T[j]]]%=MOD;
            colsum[j][rank[S[i]]]+=dp[i-1][j-1];
            colsum[j][rank[S[i]]]%=MOD;
        }
    }

    //answer
    cout << dp[N][M] << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 88416
#include <bits/stdc++.h>
using namespace std;
int i,a[26],j;
string s;
int main()
{
  for(cin>>s;i<s.size();i++)a[s[i]-'a']++;
  for(sort(a,a+26,greater<int>());j<s.size();j++){
    if(a[j]%2!=0)return cout<<"No",0;
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
a = [ini() for _ in range(n)]
a.sort()


def solve():
    i = 0
    j = n - 1
    is_odd = n % 2 == 1
    a0 = a[i]
    a1 = a[j]
    s = a[j] - a[i]
    i += 1
    j -= 1
    while i < j:
        s += a[j] - a0
        s += a1 - a[i]
        a0 = a[i]
        a1 = a[j]
        i += 1
        j -= 1
    if is_odd and i == j:
        s += max(a1 - a[i], a[i] - a0)
    return s


print(solve())


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

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

using namespace std;

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

Measured memory_bytes: 256
from decimal import *

n = int(input())
ans = 0
vec = [Decimal(input()) for i in range(n)]
vec25 = [[0 for i in range(50)] for i in range(50)]  # 整数にするのに余っている2,5の数
for i in range(n):
    a = int(vec[i] * 1000000000)
    num2 = -9
    num5 = -9
    while a%2 == 0:
        a //= 2
        num2 += 1
    while a%5 == 0:
        a //= 5
        num5 += 1
    vec25[num2][num5] += 1
for i in range(-9, 40): 
    for j in range(-9, 20):
        for k in range(max(-9, -i), 40):
            for l in range(max(-9, -j), 20):
                if i+k >= 0 and j+l >= 0 :
                    if i != k or j != l :
                        ans += vec25[i][j] * vec25[k][l]
                    else :
                        ans += vec25[i][j] * (vec25[i][j] - 1)
ans //= 2
print(ans)

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

#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define w(x) int t; cin >> t; while(t--)
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define repd(i, b, a) for(int i = b; i >= a; i--)
#define mk(arr,n,type) type* arr = new type[n];
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define um unordered_map
#define us unordered_set
#define pqm priority_queue<int>
#define pqmi priority_queue<int, vi, greater<int>>
#define lb(v, val) lower_bound(v.begin(), v.end(), val) - v.begin();
#define ub(v, val) upper_bound(v.begin(), v.end(), val) - v.begin();
#define setbits(x) __builtin_popcountll(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define out(flag) flag ? cout << "NO" << endl : cout << "YES" << endl;
#define MAX 100001
#define mod 998244353
#define inf 1e18
#define PI 3.1415926535

void IO() {
	fast;
}

int main() {

	IO();

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, 1e9 + 5);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i - 1; j >= max(0, i - k); j--) {
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
		}
	}
	cout << dp[n - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
using namespace std;
typedef long long ll;

signed main()
{
    ll a,b,k;
    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>a>>b)
    {
        if(a%2!=b%2)
        {
            cout<<"IMPOSSIBLE\n";
            return 0;
        }
        ll dis=abs(a-b);
        dis/=2;
        if(a>b) swap(a,b);
        cout<<abs(dis-b)<<"\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    vector<vector<char>> b(w,vector<char>(h));
    vector<char> flagElementH(h,'.');
    vector<char> flagElementW(w,'.');
    vector<bool> flagH(h,false);
    vector<bool> flagW(w,false);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a.at(i).at(j);
            b.at(j).at(i) = a.at(i).at(j);
        }
    }
    for(int i=0;i<h;i++){
        if(a.at(i) == flagElementW){
            flagH.at(i) = true;
        }
    }
    for(int i=0;i<w;i++){
        if(b.at(i) == flagElementH){
            flagW.at(i) = true;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(flagH.at(i) || flagW.at(j)){
                continue;
            }
            cout << a.at(i).at(j);
        }
        if(flagH.at(i)) continue;
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  vll A(3);
  rep(i, 3) cin >> A[i];
  SORT(A);

  if (A[0] + A[1] == A[2]) {
    COUT("Yes");
  } else {
    COUT("No");
  }
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll ans;
ll A,B,C;
ll dp[2005][2005];




int main(){
    cin >> A>>B>>C;
    
    if((A==B && A != C) || (A==C && A != B )|| (B==C && B != A)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=998244353;
ll n,sigma[1000005],x,inv[1000005],tot=0,sum,ans=0,cnt[1000005],flg[1000005],i,j,pr[1000005],mu[1000005];
ll M(ll x){return x>=mod?x-mod:x;}
int main()
{
	mu[1]=1;
	for(i=2;i<=1000000;i++)
	{
		if(flg[i]==0)
		{
			flg[i]=i;
			pr[++tot]=i;
			mu[i]=mod-1;
		}
		for(j=1;pr[j]<flg[i]&&1LL*pr[j]*i<=1000000;j++)flg[pr[j]*i]=pr[j],mu[pr[j]*i]=M(mod-mu[i]);
		if(1LL*pr[j]*i<=1000000)flg[pr[j]*i]=pr[j],mu[pr[j]*i]=0;
	}
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		ans=M(ans-x+mod);
		cnt[x]++;
	}
	for(i=1;i<=1000000;i++)for(j=i;j<=1000000;j+=i)sigma[i]=(sigma[i]+j*cnt[j])%mod;
	for(i=1;i<=1000000;i++)sigma[i]=sigma[i]*sigma[i]%mod;
	inv[1]=1;
	for(i=2;i<=1000000;i++)inv[i]=M(mod-mod/i*inv[mod%i]%mod);
	for(i=1;i<=1000000;i++)
	{
		sum=0;
		for(j=i;j<=1000000;j+=i)sum=(sum+mu[j/i]*sigma[j])%mod;
		ans=(ans+sum*inv[i])%mod;
	}
	printf("%lld\n",ans*inv[2]%mod);
	return 0;
}

Measured memory_bytes: 43008
x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())),reverse=True)[:x]
q = sorted(list(map(int,input().split())),reverse=True)[:y]
r = list(map(int,input().split()))
print(sum(sorted(p+q+r,reverse=True)[:(x+y)]))

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

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

  int s1, s2, s3;
  s1 = s / 100;
  s = s % 100;
  s2 = s / 10;
  s = s % 10;
  s3 = s;

  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
maxop = 10**9
for i in range(n):
  ops = 0
  while (a[i]%2==0):
    a[i] = a[i]//2
    ops += 1
  maxop = min(maxop,ops)
print(maxop)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>

using namespace std;
const int maxn = 1e4 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;
#define pi 3.1415926535
// luxi

int k;
int ans;
int main(){
	scanf("%d", &k);
	int t1, t2;
	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= k; j++){
			t1 = __gcd(i, j);
			for(int m = 1; m <= k; m++){
				t2 = __gcd(t1, m);
				ans += t2;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3780
from bisect import bisect_left
from collections import deque

N = int(input())
As = [int(input()) for _ in range(N)]

list_ = deque([As[0]])
for a in As[1:]:
    i = bisect_left(list_, a) - 1
    if i < 0:
        list_.appendleft(a)
    else:
        list_[i] = a
print(len(list_))

Measured memory_bytes: 8828
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n,k;
  cin >> n >> k;
  cout << n+1-k << endl;
}


Measured memory_bytes: 256
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();
		
		int min = a > b ? a-1 : a;
		System.out.println(min);
	}
}


Measured memory_bytes: 23764
mod=10**9+7

n=int(input())
a=list(map(int,input().split()))
a=[0]+a
ruiseki=[0]*(n+1)

for i in range(n+1):
  ruiseki[i]=(ruiseki[i-1]+a[i])

ans=0
for i in range(1,n+1):

  ans+=(a[i]*(ruiseki[n]-ruiseki[i]))
print(ans%mod)

  


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

const int mod = 998244353;

int main(int, char**)
{
    int a;
    rep(i,5) {
        cin >> a;
        if (!a) {
            cout << i+1 << endl; break;
        }
    }

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int i,price=0;
        for(i=0;i<3;i++){
        if(S[i]== 'o'){
            price+=100;
        }
    }
    cout << price+700 << endl;

return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, M, V, P;
	cin >> N >> M >> V >> P;

	int A[100000];
	rep(i, N) cin >> A[i];
	sort(A, A + N);
	reverse(A, A + N);

	int L = 0, R = N;
	while (L + 1 < R) {
		int m = (L + R) / 2;
		int a = A[m] + M;
		if (P > V) {
			if (a >= A[P - 1]) L = m;
			else R = m;
		}
		else {
			ll amari = ll(V - P) * M;
			ll kari = 0;
			bool dame = 0;
			for (int i = P - 1; i < N; i++) {
				if (i != m) {
					if (a < A[i]) dame = 1;
					kari += min(M, a - A[i]);
				}
			}
			if (!dame && amari <= kari) {
				L = m;
			}
			else R = m;
		}
	}

	co(R);


	Would you please return 0;
}

Measured memory_bytes: 640
cookie = (input())
unti = cookie.split()
cookie_1 = int(unti[0])
cookie_2 = int(unti[1])

if cookie_1 % 3 == 0:
   print( "Possible")
elif cookie_2 % 3 == 0:
   print( "Possible")
elif ((cookie_1 + cookie_2) % 3 == 0):
   print( "Possible")
else :
   print( "Impossible")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string t[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s; cin>>s;
	for(int i=0;i<7;i++) if(s==t[i]){ cout<<7-i; break; }
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N;
    cin >> N;
    int k = 1;
    N--;
    while(true) {
        if(N < pow(26, k)) {
            string ans = "";
            REP(i, k) {
                ans = (char)(N%26 + 'a') + ans;
                N /= 26;
            }
            cout << ans << endl;
            return 0;
        }
        N -= pow(26, k);
        k++;
    }
}

Measured memory_bytes: 4060
#include <iostream>
#include <queue>
#include <utility>
#include <stack>
#include <string>
using namespace std;

typedef pair<int,int> pii;

int main(void){
	int h,w;
	queue<pii> s;
	string m[21];
	while(cin>>w>>h,w||h){
		for(int i=0;i<h;i++)cin>>m[i];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(m[i][j]=='@'){
					s.push(pii(i,j));
					i=j=999;
				}
			}
		}
		int c=0;
		while(!s.empty()){
			pii a=s.front();s.pop();
			int i=a.first;
			int j=a.second;
			if(!(0<=i&&i<h&&0<=j&&j<w))continue;
			if(m[i][j]=='#')continue;
			c++;
			m[i][j]='#';
			s.push(pii(i+1,j));
			s.push(pii(i-1,j));
			s.push(pii(i,j+1));
			s.push(pii(i,j-1));
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 3136
# 角のマスは4回、端のマスは6回（表になる）
# それ以外のマスであればカードを裏返す回数は9回（裏になる）
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(n*m - 2)
else:
    print(n*m - 2*((n-1)+(m-1)))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, sum = 0, w;
	cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> b.at(i);
		sum += b.at(i);
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c.at(i);
	}
	for (int i = 1; i < n; i++) {
		if (a.at(i) - a.at(i-1) == 1) {
			w=a.at(i);
			sum+=c.at(w-2);
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 2
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

int main(void){
    ll n,k;
    cin>>n>>k;
    vb sunuke(n,false);
    rep(i,k){
        ll d;
        cin>>d;
        rep(j,d){
            ll a;
            cin>>a;
            a--;
            sunuke[a] = true;
        }
    }
    ll ans = 0;
    rep(i,n) if(sunuke[i] == false) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
N, M = map(int, input().split())

num = [1 for i in range(N)]
red = [False for i in range(N)]
red[0] = True

for i in range(M):
    x, y = map(int, input().split())    
    x -= 1
    y -= 1
    
    if(red[x] and num[x] >= 1):
        red[y] = True
        num[x] -= 1
        num[y] += 1
        if(num[x] <= 0):
            red[x] = False
    else:
        if(num[x]):
            num[x] -= 1
            num[y] += 1

print(red.count(True))  

Measured memory_bytes: 10552
def main():
    N, i = list(map(int, input().split(" ")))
    output = solve(N, i)
    print(output)
    return

#________________________________________
#  Solve
#________________________________________
def solve(N, i):
    """
    解答のコード
    """
    return N - i + 1
#________________________________________


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<stdio.h>

int linearSearch(int [],int ,int );

int main()
{
  int S[100000],key,n,q,i,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      if(linearSearch(S,n,key))c++;
    }
  printf("%d\n",c);

  return 0;
}


int linearSearch(int S[],int n,int key)
{
  int  i=0,count=0;
  S[n]=key;
  while(S[i]!=key)i++;
  return i!=n;
}

Measured memory_bytes: 644
N,M = map(int,input().split(" "))

mod = 10**9+7
d = [1]*100001
for i in range(1,100001):
    d[i] = d[i-1] * i % mod

if N == M:
    a = d[N]
    print(2 * a * a % mod)
elif N == M + 1:
    a = d[N]
    b = d[M]
    print(a * b % mod)
elif N + 1 == M:
    a = d[N]
    b = d[M]
    print(a * b % mod)
else:
    print(0)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    string s;
    int ans = 0;
    cin >> s;
    if(s == "Sunny") puts("Cloudy");
    else if(s == "Cloudy") puts("Rainy");
    else puts("Sunny");
    return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
*a,=map(int,input().split())
l=[list(map(int,input().split()))[::-1] for _ in range(m)]
a.sort()
d=[]
e=0
for c,b in sorted(l)[::-1]:
	d+=[c]*b
	e+=b
	if e>n:break
for i,(x,y) in enumerate(zip(a,d)):
	if x<y:a[i]=y
print(sum(a))


Measured memory_bytes: 86424
import re

A, B = input().split()
postal_code = input()

def func(str1, str2, pcode):
    if pcode[int(str1)] != '-':
        return print('No')
    else:
        str_A, str_B = pcode[0:int(str1):], pcode[int(str1)+1::]

        if not re.match('[0-9]{1,}$', str_A):
            return print('No')
    
        if not re.match('[0-9]{1,}$', str_B):
            return print('No')
    
    return print('Yes')


if __name__ == '__main__':
    func(A, B, postal_code)

Measured memory_bytes: 3188
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 日 12/ 2 21:11:11 2018

*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, PII> PIII;

#define fir first
#define sec second

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int cnt[105];
map<PIII, bool> vis;

void Solve(int x){
	for(int i = 2; i <= 100; i++) {
		while(x % i == 0){
			cnt[i]++;
			x /= i;
		}
	}
}



int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) Solve(i);
	int res = 0;
	for(int i = 1; i <= 100; i++) if(cnt[i] >= 74) res++;
	for(int i = 1;  i<= 100; i++){
		for(int j = 1; j <= 100; j++){
			if(i == j) continue;
			if(cnt[i] >= 2 && cnt[j] >= 24){
					res++;
			}
			if(cnt[i] >= 14 && cnt[j] >= 4){
					res++;
			}
		}
	}
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			if(i == j) continue;
			for(int k = 1; k <= 100; k++){
				if(j == k || k == i) continue;
				PIII now = PIII(i, PII(j, k));
				if(cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4 && !vis[now]){
					res++;
					vis[now] = true;
					vis[PIII(i, PII(k, j))] = true;
				}
			}
		}
	}
	printf("%d\n", res);
    return 0;
}


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

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

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll,ll>     pll;
typedef complex<ld>     cld;

#define all(x)          x.begin(),x.end()
#define Sort(x)         sort(all(x))
#define kill(x)         return cout << x << endl, 0;
#define Mp              make_pair
#define X               first
#define Y               second
#define sep             " "
#define endl            "\n"
#define fastio          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define ld_io           cout << setprecision(10) << fixed;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll pw(ll a, ll b, ll md) {
    if (!b)
        return 1;
    if (b & 1)
        return a * pw(a * a % md, b / 2, md) % md;
    return pw(a * a % md, b / 2, md) % md;
}

const ll MAXN = 3e3 + 10,
         INF  = 8e18,
         MOD  = 1e9 + 7,
         LOG  = 32;
//const ld PI   = M_PI;

ll n, dp[MAXN][MAXN], sum[MAXN][MAXN], ans;
string s;

int main()
{
    fastio;
    //ld_io;

    cin >> n >> s;

    dp[1][1] = 1;
    for (ll i = 1; i <= n; i++)
        sum[1][i] = 1;

    for (ll i = 2; i <= n; i++) {
        for (ll j = 1; j <= i; j++) {
            if (s[i - 2] == '<')
                dp[i][j] = sum[i - 1][j - 1];
            else
                dp[i][j] = sum[i - 1][n] - sum[i - 1][j - 1] + MOD;
            dp[i][j] %= MOD;
            sum[i][j] = dp[i][j];
            if (j != 0)
                sum[i][j] += sum[i][j - 1];
            sum[i][j] %= MOD;
        }
        sum[i][i + 1] = sum[i][n] = sum[i][i];
    }

    cout << sum[n][n] << endl;

    return 0;
}



Measured memory_bytes: 140032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int a, b;
  cin >> a >> b;
  const int m = 1e7 + 5;
  for(ld i = 0; i < m; i++){
    ld x = floor(i * (ld) 0.08);
    ld y = floor(i * (ld) 0.1);
    if(x == a && y == b) return cout << (int) i, 0;
  }
  cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll K, Q;
  cin >> K >> Q;
  vector<ll> D(K);
  for (ll i = 0; i < K; i++)
  {
    cin >> D.at(i);
  }

  for (ll q = 0; q < Q; q++)
  {
    ll N, X, M;
    cin >> N >> X >> M;

    vector<ll> d(K);
    for (ll i = 0; i < K; i++)
    {
      d.at(i) = D.at(i) % M;
    }

    vector<ll> T(K);
    for (ll i = 0; i < K; i++)
    {
      T.at(i) = (N - 1) / K + (i < (N - 1) % K);
    }

    ll tmp0 = 0;
    for (ll i = 0; i < K; i++)
    {
      tmp0 += T.at(i) * (d.at(i) == 0);
    }

    ll last = X;
    for (ll i = 0; i < K; i++)
    {
      last += T.at(i) * d.at(i);
    }
    ll tmp1 = last / M - X / M;

    ll ans = (N - 1) - (tmp0 + tmp1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 384