akhauriyash/Code-Regression huggingface dataset:
//Let's play once again :)
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	tarzan;
	int test = 1;
	//cin >> test;
	while(test--) {
		int n;
		cin >> n;
		string s[n];
		map<string, int> mp;
		for(int i = 0; i < n; i++) {
			cin >> s[i];
			mp[s[i]]++;
		}

		cout << "AC x " << mp["AC"] << '\n';
		cout << "WA x " << mp["WA"] << '\n';
		cout << "TLE x " << mp["TLE"] << '\n';
		cout << "RE x " << mp["RE"] << '\n'; 
	}
	return 0;
}

Measured memory_bytes: 6740
from itertools import combinations_with_replacement as comb

n, m, q = map(int, input().split())
queries = [tuple(map(int, input().split())) for _ in range(q)]
ans = 0

def calc_score(p):
    score = 0
    for a, b, c, d in queries:
        if p[b-1] - p[a-1] == c:
            score += d
    return score

for p in comb(range(1, m+1), n):
    ans = max(ans, calc_score(p))

print(ans)


Measured memory_bytes: 9092
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     for(int i=1;i>0; i++){
          int H = scanner.nextInt();
          int W = scanner.nextInt();
          if(H==0&&W==0)break;
          for(int j=1;j<=H; j++){
              for(int k=1;k<=W; k++){
                  int l=(j+k)%2;
                if(l==0){
                         System.out.print("#");
                }else{
                   System.out.print(".");  
                }
              }
              System.out.println();
          }
          System.out.println();
   }   
}
}

Measured memory_bytes: 34428
x = int(input())
ans = 0

for i in range(x,10**5+4):
    if ans != 0:
        break
    
    for j in range(2,i):
        if i % j == 0:
            break
        elif j == i-1:
            ans = i

if x == 2:
    ans = 2

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    vector<int>a(n);
    if(n%2==0){
        for(int i=0;i<n;i++){
            cin>>m;
            if(i%2==1)a[n/2-i/2-1]=m;
            if(i%2==0)a[n/2+i/2]=m;
        }
    }else{
        for(int i=0;i<n;i++){
            cin>>m;
            if(i%2==0)a[n/2-i/2]=m;
            if(i%2==1)a[n/2+i/2+1]=m;
        }
    }
    for(int i=0;i<n;i++)cout<<a[i]<<" ";
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	int x,h;
	double S;
	while(cin >> x >> h){
		if(x == 0 && h == 0) return 0;
		S = (double)( x*x + (sqrt(x*x+4*h*h) * x) );
		printf("%f\n",S);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
int n,i,t,min,max;
long long int sum;
scanf("%d",&n);
min=1000000; max=-1000000;
sum=0;

for(i=0;i<n;i++){
scanf("%d",&t);
if(min>t) min=t;
if(max<t) max=t;
sum+=t;
}
printf("%d %d %lld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
    int n,a,b,c,d;
    cin>>n;
    a=n%10;
    b=n/10%10;
    c=n/100%10;
    d=n/1000%10;
    if(a==b || b==c || c==d)
    {
        cout<<"Bad";
    }
    else
    {
        cout<<"Good";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,l,r,ans,mid;
int check(long long x)
{
	int y=(a+x+1ll)/2ll;
	for(long long i=max(1ll,y-500ll);i<=min(x,y+500ll);i++)
	if(i*(a+x-i+1ll)>=a*b)return 0;
	return 1; 
}
int main()
{
	cin>>n;
	while(n--)
	{
		cin>>a>>b;
		if(a>b)swap(a,b);
		l=0;r=b+1ll;
		while(l+1ll<r)
		{
			mid=(l+r)/2ll;
			if(check(mid))l=mid;
			  else r=mid;
		}
		ans=a-1ll+l;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3608
// Problem : L - Deque
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_l
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 3005

//Solution

int n;
int dp[N][N];

void solve(){
    cin>>n;
    vi a(n);
    for(int &i : a) cin>>i;
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i == j) dp[i][j] = a[i];
            else dp[i][j] = max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1];
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 49756
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
M,D=map(int,input().split())
d1=int(D/10)
d2=D-d1*10
cnt=0

for i in range(M+1):
	for j in range(D+1):
		d1=int(j/10)
		d2=j-d1*10
		if d1*d2==i and d1>1 and d2>1:
			cnt+=1
			
print(cnt)

Measured memory_bytes: 3064
def printString(n): 
    string = ["0"] * 10000
    i = 0
  
    while n > 0: 
        rem = n % 26
        if rem == 0: 
            string[i] = 'Z'
            i += 1
            n = int(n / 26) - 1
        else: 
            string[i] = chr((rem - 1) + ord('A')) 
            i += 1
            n = int(n / 26)
    string[i] = '0'
    string = string[::-1] 
    ans = "".join(string) 
    for i in range(10000):
        if ans[i]!="0":
            break
    print(ans[i:].lower())
    
n=int(input())
printString(n)

Measured memory_bytes: 63168
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    sort(all(A));
    reverse(all(A));

    vector<ll> v;
    rep(i, n - 1) {
        if (A[i] == A[i + 1]) {
            v.push_back(A[i]);
            i++;
            if (v.size() >= 2) {
                break;
            }
        }
    }

    if (v.size() < 2) {
        put(0);
    }
    else {
        put(v[0] * v[1])
    }

    return 0;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   map<int,int>mp;
   set<int>s;
   int n,ans=0;
   cin>>n;
   for(int i=0;i<n;i++){
    cin>>arr[i];
    int mx=arr[i]+1;
    int mn=arr[i]-1;
    mp[arr[i]]++;
    mp[mx]++;
    mp[mn]++;
    s.insert(arr[i]);
    s.insert(mx);
    s.insert(mn);
   }
   for(auto i:s)
    ans=max(ans,mp[i]);
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12848
#include <iostream>
#include <string>

int main(){
    std::string s, t, u;
    int a, b;
    std::cin >> s >> t >> a >> b >> u;

    if (s == u)
    {
        a--;
    }
    else
    {
        b--;
    }
    
    std::cout << a << " " << b << std::endl;

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;

	cin >> S;

	if( S == "Sunny" ){
		cout << "Cloudy" << endl;
	} else if( S == "Cloudy" ) {
		cout << "Rainy" << endl;
	} else {
		cout << "Sunny" << endl;
	}

	Never To return 0;
}


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

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; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

vector<vector<int>> t;

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

  t = vector<vector<int>>(n + 1, vector<int>(n + 1));
  vector<int> k(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int d = min(j - i, abs(x - i) + abs(y - j) + 1);
      t[i][j] = d;
      // t[j][i] = d;
      k[d]++;
    }
  }
  for (int i = 1; i < n; ++i) { cout << k[i] << endl; }
}


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

int main() { 
		int d, n;
	cin >> d >> n;
	if (n == 100)
		n++;
	if (d == 0)
	{
		cout << n << endl;
	}
	else if (d == 1)
		cout << n * 100 << endl;
	else
		cout << n * 10000 << endl;
		
}


Measured memory_bytes: 3100
n,t = map(int, input().split())
list_t = list(map(int, input().split()))
time = 0
for i in range(1,n):
    if list_t[i] - list_t[i-1] <= t:
        time += list_t[i] - list_t[i-1]
    else:
        time += t
time += t

print(time)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N, -1);
    int answer = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        --A[i];
        if (A[A[i]] == i)
            ++answer;
    }

    cout << answer << "\n";
}


Measured memory_bytes: 888
#include<stdio.h>
int main()
{
	char op;
	int A,B;
	scanf("%d %c%d",&A,&op,&B);
	if(A>0&&B>0)
	if(op==43)
	printf("%d",A+B);
	else
	printf("%d",A-B);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st, st2;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;
    public static long LINF = 0x3f3f3f3f3f3f3f3fL;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(br.readLine());
        Long a = Long.parseLong(st.nextToken());
        Long b = Long.parseLong(st.nextToken());
        Long k = Long.parseLong(st.nextToken());

        long less = Math.min(a, k);
        k -= less;
        a -= less;
        b -= Math.min(b, k);
        pw.println(a + " " + b);

        pw.close();
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int a, b;

    Pair(int _a, int _b){
        a = _a;
        b = _b;
    }
 
    public String toString(){
        return a + " " + b;
    }

    public int compareTo(Pair p){
        if (b != p.b) return b < p.b ? -1 : 1;
        if (a != p.a) return a < p.a ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 22996
fn main() {
    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };
    let t: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let n = s.len();

    let mut ans = 0;
    for i in 0..n {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> f = {1, 1};
    for (int i = 2; i <= n; i++)
    {
        f.push_back(f[i - 2] + f[i - 1]);
    }
    cout << f[n] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll ans=min(ceil((double)n/3)*m-n/3*m,ceil((double)m/3)*n-m/3*n);
  REP(i,1,n) {
    ll x=(ll)(m/2)*i,y=ceil((double)m/2)*i,z=m*(n-i);
    ans=min(ans,max(abs(z-x),max(abs(z-y),abs(x-y))));
  }
  REP(i,1,m) {
    ll x=(ll)(n/2)*i,y=ceil((double)n/2)*i,z=n*(m-i);
    ans=min(ans,max(abs(z-x),max(abs(z-y),abs(x-y))));
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n,w,d;
  for(;cin>>n>>w>>d,w;)
    {
      vector<pair<int,int> > cake;
      cake.push_back(make_pair(w,d));
      for(int i=0;i<n;i++)
	{
	  int p,s;
	  cin>>p>>s;
	  p--;
	  pair<int,int> tmp=cake[p];
	  cake.erase(cake.begin()+p);
	  int size=s%(tmp.first+tmp.second);
	  if(size<tmp.first)
	    {
	      cake.push_back(make_pair(min(size,tmp.first-size),tmp.second));
	      cake.push_back(make_pair(max(size,tmp.first-size),tmp.second));
	    }
	  else
	    {
	      cake.push_back(make_pair(tmp.first,min((size-tmp.first),tmp.second-(size-tmp.first))));
	      cake.push_back(make_pair(tmp.first,max((size-tmp.first),tmp.second-(size-tmp.first))));
	    }
	}
      //      sort(cake.begin(),cake.end(),isgreater);
      for(int i=0;i<cake.size()-1;i++)
	for(int j=i+1;j<cake.size();j++)
	  {
	    if(cake[i].first*cake[i].second
	       >cake[j].first*cake[j].second)
	      swap(cake[i],cake[j]);
	  }
      for(int i=0;i<cake.size();i++)
	{
	  cout<<cake[i].first*cake[i].second;
	  if(i==cake.size()-1)
	    cout<<endl;
	  else
	    cout<<" ";
	}

    }

}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
       
int main()
{
	int ans=0,mn=123456789;
	string s,ss,s1;
  	cin>>s>>ss;
 	for(int i=0;i<s.size()-ss.size()+1;i++){
 		s1=s.substr(i,ss.size()); 
 		for(int j=0;j<ss.size();j++){
 			if(s1[j]!=ss[j])
 				ans++;	
		}
		if(ans<mn){
			mn=ans;
		}
		ans=0;
	}
	cout<<mn;
	return 0;
}

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

typedef long long ll;
const int maxn=1e2+10,mod=1e9+7;
int n,h[maxn],cnt;
int dp[maxn][2],l[maxn],r[maxn],a[maxn],b[maxn];
vector<int> ch[maxn];

void dfs(int pos){
	b[pos]=*min_element(h+l[pos],h+r[pos]+1);
	for(int i=l[pos],j;i<=r[pos];++i){
		if(h[i]==b[pos])
			continue;
		j=i;
		while(j<r[pos]&&h[j+1]>b[pos])
			++j;
		++cnt;
		l[cnt]=i,r[cnt]=j,a[cnt]=b[pos];
		ch[pos].push_back(cnt);
		dfs(cnt);
		i=j;
	}
}
inline ll fpow(ll a,ll n){
	ll res=1;
	for(;n;n>>=1,a=a*a%mod)
		if(n&1ll)
			res=res*a%mod;
	return res;
}
void solve(int pos){
	if(ch[pos].empty()){
		dp[pos][1]=fpow(2,b[pos]-a[pos]);
		dp[pos][0]=(fpow(2,r[pos]-l[pos]+1)+mod-2)%mod;
		return;
	}
	ll tmp[2],temp[2];
	for(int i=l[pos],j=0;i<=r[pos];)
		if(j<ch[pos].size()&&i==l[ch[pos][j]]){
			solve(ch[pos][j]);
			if(i==l[pos]){
				tmp[0]=dp[ch[pos][j]][0];
				tmp[1]=dp[ch[pos][j]][1]*2%mod;
			}
			else{
				temp[0]=(tmp[0]*dp[ch[pos][j]][0]+tmp[0]*dp[ch[pos][j]][1]*2+tmp[1]*dp[ch[pos][j]][0]+tmp[1]*dp[ch[pos][j]][1])%mod;
				temp[1]=tmp[1]*dp[ch[pos][j]][1]%mod;
				tmp[0]=temp[0];
				tmp[1]=temp[1];
			}
			i=r[ch[pos][j]]+1;
			++j;
		}
		else{
			if(i==l[pos]){
				tmp[0]=0;
				tmp[1]=2;
			}
			else{
				temp[0]=(tmp[0]*2+tmp[1])%mod;
				temp[1]=tmp[1];
				tmp[0]=temp[0];
				tmp[1]=temp[1];
			}
			++i;
		}
	dp[pos][0]=tmp[0];
	dp[pos][1]=tmp[1]*fpow(2,b[pos]-a[pos]-1)%mod;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>h[i];
	++cnt;
	l[1]=1,r[1]=n,a[1]=0;
	dfs(1);
	solve(1);
	cout<<(dp[1][0]+dp[1][1])%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    
    dp0 = [[0]*(s+1) for _ in range(n+1)]
    dp1 = [[0]*(s+1) for _ in range(n+1)]
    dp2 = [[0]*(s+1) for _ in range(n+1)]
    dp0[0][0] = 1
    
    for i in range(n):
        for j in range(s+1):
            dp0[i+1][j] += dp0[i][j]
            dp1[i+1][j] += dp1[i][j]
            dp2[i+1][j] += dp2[i][j]
            
            
            if a[i]+j <= s:
                dp1[i+1][j+a[i]] += dp0[i][j] * (i+1)
                dp2[i+1][j+a[i]] += dp0[i][j] * (i+1) * (n-i)
                
                dp1[i+1][j+a[i]] += dp1[i][j]
                dp2[i+1][j+a[i]] += dp1[i][j] * (n-i)
                
            dp0[i+1][j] %= mod
            dp1[i+1][j] %= mod
            dp2[i+1][j] %= mod
                
    print(dp2[n][s])
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 276564
#include<iostream>

using namespace std;

int main(){
  int n, X,Y,W,H, x,y, cat;
  while(cin >> n){
    while(n--){
      cin >> X >> Y >> W >> H;
      cin >> cat;
      int cat_cnt = 0;
      while(cat--){
	cin >> x >> y;
	if((X <= x && x <= X + W) && (Y <= y && y <=Y + H )) cat_cnt++;
      }
      cout << cat_cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict


def dfs(i, used, dic, ng):
    for n in dic[i]:
        if n not in used and (i, n) != ng and (n, i) != ng:
            used.add(n)
            dfs(n, used, dic, ng)


N, M = map(int, input().split())
dic = defaultdict(list)
lst = []
for _ in range(M):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
    lst.append((a, b))

ret = 0
for a, b in lst:
    used = set()
    dfs(1, used, dic, (a, b))
    if len(used) != N:
        ret += 1
print(ret)


Measured memory_bytes: 3316
#include<cstdio>

int main(){
    int H,W,A,B;
    scanf("%d%d%d%d",&H,&W,&A,&B);
    for(int i=1;i<=H;i++,puts(""))
        for(int j=1;j<=W;j++)
            putchar((i<=B)==(j<=A)?'1':'0');
}



Measured memory_bytes: 1152
import sys
N=input()
A=[ int(sys.stdin.readline().strip())  for _ in range(N) ]

L=[]
for i,a in enumerate(A):
	if i==0:
		L.append(a)
	else:
		L.append( max(L[-1], a) )

R=[]
for i,a in enumerate(A[::-1]):
	if i==0:
		R.append(a)
	else:
		R.append( max(R[-1], a) )

R=R[::-1]


for i in range(N):
	if i==0:
		print R[i+1]
	elif i==N-1:
		print L[i-1]
	else:
		print max( R[i+1], L[i-1])


Measured memory_bytes: 64924
#include <bits/stdc++.h>
using namespace std;
int a[100010];
bool check=false;
int main(){
	int n,mh=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i-1]>a[i]){
			check=true;
			cout<<"No"<<endl;
			break;
		}
		else if(a[i]-a[i-1]>0){
			a[i]--;
		}
	}
	if(!check) cout<<"Yes"<<endl;
	return 0; 
	
} 

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <bitset>
#include <cstring>
using namespace std;

const char *t1=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *v1[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
const char *t2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

int main(){
  string s,t,z;
  int i,j;
  for(;z=t="",getline(cin,s);cout<<t<<endl){
    for(i=0;i<s.size();i++)
      if((j=strchr(t1,s[i])-t1)+t1)z+=v1[j];
    for(;z.size()%5;z+='0');
    for(i=0;i<z.size()/5;i++)
      t+=t2[bitset<5>(z,i*5,i*5+5).to_ulong()];
  }
}

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

using namespace std;

typedef long long ll;

int main(){
  ll A, B, K;
  cin >> A >> B >> K;

  if (K >= A + B){
    cout << 0 << " " << 0 << endl;
  }else if (K >= A){
    cout << 0 << " " << B-(K-A) << endl;
  }else{
    cout << A-K << " " << B << endl;
  }

  return 0;
}

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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int ar[N];
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int n,cnt=0,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&ar[i]);
    }
    for(int i=2; i<=n; i++) {
        if(ar[i-1]<ar[i]) {
            ans=max(ans,cnt);
            cnt=0;
            continue;
        }
        cnt++;
        if(i==n)ans=max(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <climits>
using namespace std;

int main() {
    long long int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a+b<=2*c){
        cout << x*a+y*b;
    }else{
        if(x>=y){
            if(2*c<=a){
                cout << 2*c*y+2*c*(x-y);
            }else{
                cout << 2*c*y+a*(x-y);
            }
        }else{
            if(2*c<=b){
                cout << 2*c*x+2*c*(y-x);
            }else{
                cout << 2*c*x+b*(y-x);
            }
        }
    }
}

Measured memory_bytes: 256
N , T = gets.chomp.split(" ").map(&:to_i)
hash = Hash.new(0)
c = 0
t = 0
N.times do |num|
  c, t = gets.chomp.split(" ").map(&:to_i)
  hash[c] = t
end
result = hash.select{ |k,v| v <= T }.min
if result.nil?
  print("TLE")
else
  print(result[0])
end


Measured memory_bytes: 3836
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

ll f(ll n,ll x){if(n<0) return 0;
  else return n/x+1;}

int atcoder(){
    ll a,b,x;
    cin >> a >> b >> x;
    
    cout << f(b,x)-f(a-1,x) << ENT;
    
    return 0;
}

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


Measured memory_bytes: 256
//MIPT Cryptozoology 17.2
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
    //assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
    //freopen(FILENAME ".in", "r", stdin);
    //freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        //cerr << testNum << endl;
        solve(true);
        //cerr << testNum - 1 << endl;
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

//#define int li
//const int mod = 1000000007;

const int LEN = 4000010;
bitset<LEN> bset;

void solve(bool read) {
    int n;
    cin >> n;
    int sum = 0;
    bset[0] = 1;
    for (int i = 0; i < n; ++i) {
        int cur;
        cin >> cur;
        sum += cur;
        bset |= (bset << cur);
    }
    for (int cur = (sum + 1) / 2; cur <= sum; ++cur) {
        if (bset[cur]) {
            cout << cur << endl;
            return;
        }
    }
}

Measured memory_bytes: 1792
a,b = map(int,input().split())
a1 = a//100
b1 = b//100
a2 = a//1000
b2 = b//1000
a3 = ((a2)%10)*10 + (a2%100)//10
b3 = ((b2)%10)*10 + (b2%100)//10
a4 = a%100
b4 = b%100
count = 0
if a3 >= a4:
    count = count + 1
if b3 <= b4:
    count = count + 1
if b1 - a1 == 0:
    if count == 2:
        print(1)
    else:
        print(0)
else:
    print(b1-a1-1+count)

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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return index;
  }
  else { // 発見できなかったとき
    return -1;
  }
}

int main() {
    int n;
    cin>>n;
    VI v(50000);
    FOR(i,1,50000){
        v[i] = i*1.08;
    }

    int ans = vector_finder(v,n);
    if(ans == -1){
        ANS(":(");
    }
    else{
        ANS(ans);
    }


    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    ll N, M, ans = 0;
    cin >> N >> M;
    multimap<ll, ll> mp;
    ll A, B, C;
    for(int i = 0; i < N; i++){
        cin >> A;
        mp.insert(make_pair(A, 1));
    }
    for(int i = 0; i < M; i++){
        cin >> B >> C;
        mp.insert(make_pair(C, B));
    }
    ll c = 0, count = 0;
    auto p = mp.end();
    --p;
    for(auto itr = p; count < N; itr--){
        c = (((itr->second) > (N - count)) ? (N - count) : (itr->second));
        ans += itr->first * c;
        count += c;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>
int main(void)
{
  int n,i;
  long int sum=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    if((i%3)!=0 && (i%5)!=0)
      sum+=i;
  printf("%ld",sum);
  
  return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <string>
#include <array>

using namespace std;

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

    int sum = 0;
    int left = k;

    if (left > 0)
    {
        sum += std::min(a, left);
        left -= a;
    }
    if (left > 0)
    {
        left -= b;
    }
    if(left > 0)
    {
        sum -= std::min(c, left);
    }
    cout << sum;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0;lli ans=0ll;
    cin>>n>>m;
    ans=(n*(n-1))/2+(m*(m-1))/2;
    cout<<ans<<endl;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>b) a=b;
  if(c>d) c=d;
  cout<<a+c<<endl;
}


Measured memory_bytes: 256
def calc(s):
    n = len(s)
    ans = 0
    for bit in range(1 << (n - 1)):
        ss = s[0]
        for i in range(n - 1):
            if bit & (1 << i):
                ss += '+'
            ss += s[i + 1]
        ans += eval(ss)
    return ans

s = str(input())
print(calc(s))


Measured memory_bytes: 73484
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const LL INF=1e18;
int n,ts,tmp[500010],o,x[500010],X;
LL ans,t,s[500010];
int main(){
	cin>>n>>X;
	FOR(i,1,n) getint(x[i]),s[i]=s[i-1]+x[i];
	ans=INF;
	FOR(i,1,n){
		int cnt=0;
		t=0;
		for (int j=n;j>=1;j-=i){
			//j-i+1~j
			++cnt;
			o=max(j-i+1,1);
			t+=1ll*(cnt+1+cnt)*(s[j]-s[o-1]);
			if (j==n) t+=2ll*(s[j]-s[o-1]);
			t=min(t,INF);
		}
		/*
		t=0;
		FOR(j,0,i-1){
			ts=0;
			for (int k=j;k<=n;k+=i){
				if (k) tmp[++ts]=x[k];
			}
			t+=tmp[ts];
			FORD(k,ts,1){
				t+=1ll*(tmp[k]-tmp[k-1])*(ts-k+2)*(ts-k+2);
			}
		}
		*/
		t+=1ll*(i+n)*X;
		ans=min(ans,t);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
using var = long long;
#define rep(i,n) for(var i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<var> a(n);rep(i,n){cin>>a[i];}
#define in(a) var a;cin>>a;
#define out(a) cout<<a;

int main()
{
	in(n);
	repin(p, n);

	rep(i, n) {
		if (p[i] != i + 1 && p[p[i] - 1] == i + 1) {
			int t = p[i];
			p[i] = i + 1;
			p[t - 1] = t;
			break;
		}
	}
	int c = 0;
	rep(i, n) {
		if (p[i] != i + 1) {
			c++;
		}
	}
	if (c == 0) {
		out("YES");
	}
	else {
		out("NO");
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using ld = long double;

const int N = 111;


ll a[N];

char u[N];

ll ans = -9e18;


void go(int i, int n, ll sum){
	if(i*2>n){
		for(int j=i;j<=n;++j) if(!u[j] && a[j]<0) sum-=a[j];
		ans = max(ans, sum);
		return ;
	}
	
	if(i*3>n){
		if(u[i*2]){
			if(!u[i] && a[i]<0) sum-=a[i];
			go(i+1,n,sum);
			return; 
		}else{
			if(a[i]>=0){
				go(i+1, n, sum);
				return ;
			}else{
				///188..980
				if(a[i*2]<0){
					sum-=a[i]+a[i*2];
					u[i*2] = 1;
					go(i+1, n, sum);
					u[i*2] = 0;
					return ;
				}else{
					if(a[i]+a[i*2]<0) sum-=a[i]+a[i*2], u[i*2] = 1;
					go(i+1, n, sum);
					u[i*2] = 0;
					return ;
				}
			}
		}
	}
	
	go(i+1, n, sum);
	
	if(!u[i]){
		for(int j=i;j<=n;j+=i){
			if(!u[j]) sum-=a[j];
			++u[j];
		}
		go(i+1, n, sum);
		for(int j=i;j<=n;j+=i) --u[j];
	}
}


int main(){
	/*if(0){
		srand(time(0));
		ofstream cout("input.txt");
		int n = 100;
		cout<<n<<endl;
		for(int i=0;i<n;++i) cout<<rand()%2000000001 - 1000000000<<endl;
		cout.close();
	}*/
	
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n, m;
	
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	
	ans = -9e18;
	go(1, n, accumulate(a+1,a+n+1,0LL));
	cout<<ans<<endl;
	
	return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    map<char, int> freq;

    for(int i = 0; i < 4; i++) {
        freq[s[i]]++;
    }

    bool ok = true;
    if(freq.size() == 2) {
        for(auto p : freq) {
            if(p.S != 2) ok = false;
        }
    }else {
        ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int n;
int A[20];
int sum;
int solve( int, int );

int main( void ){
	int i, m, q;
	
	scanf("%d", &n );
	
	sum = 0;
	for( i = 0; i < n; i++ ){
		scanf("%d ", &A[i]);
		sum += A[i];
	}
	
	scanf("%d", &q );	
	for( i = 0; i < q; i++ ){
		scanf("%d", &m );
		if( solve(0,m) ){
			printf("yes\n");
		}
		else{
			printf("no\n");
    	}
	}
	return 0;
}

int solve( int i, int m ){
	if( m == 0 ){
		return 1;
	}
	if( i >= n || sum < m ){
		return 0;
	}
	
	return solve(i+1, m) || solve(i+1, m-A[i]);
}


Measured memory_bytes: 2144
import java.io.IOException;
import java.util.Scanner;

public class Main {
	static int[][] board = new int[10][10];

	public static void main(String[] args) throws IOException {
		// 宣言
		Scanner sc = new Scanner(System.in);
		String[] str;
		int count = 0;
		int max = 0;

		while (sc.hasNext()) {
			str = sc.nextLine().split(",");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			int size = Integer.parseInt(str[2]);
			if (size == 1) {
				small(x, y);
			} else if (size == 2) {
				middle(x, y);
			} else if (size == 3) {
				big(x, y);
			}
		}
		for (int xx = 0; xx < 10; xx++) {
			for (int yy = 0; yy < 10; yy++) {
				// 1個目の答え
				if (board[xx][yy] == 0) {
					count++;
				}
				// 2個目の答え
				if (max < board[xx][yy]) {
					max = board[xx][yy];
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}

	// インク小　中心と上下左右1マス
	static void small(int x, int y) {
		paint(x, y);
		// 左右、上下のマスを塗る
		paint(x + 1, y);
		paint(x - 1, y);
		paint(x, y - 1);
		paint(x, y + 1);
	}
	// インク中　上下左右斜め9マス
	static void middle(int x, int y) {
		for (int yr = -1; yr <= 1; yr++) {
			for (int xr = -1; xr <= 1; xr++) {
				paint(x + xr, y + yr);
			}
		}
	}
	//　インク大　インク中＋上下左右2マス
	static void big(int x, int y) {
		middle(x, y);
		//左右、上下の2マス目を塗る
		paint(x, y - 2);
		paint(x, y + 2);
		paint(x + 2, y);
		paint(x - 2, y);
	}

	static void paint(int x, int y) {
		//範囲外にあたる場合は何もしない
		if (x < 0 || y < 0 || x >= 10 || y >= 10) {
			return;
		} else {
			board[x][y] += 1;
		}

	}

}

Measured memory_bytes: 17180
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int a,b[100010],c[100010],ans=0;
  cin >> a;
  
  for(int i=0;i<a;i++){
    cin >> b[i] >> c[i];
  }
        
  for(int i=a-1;i>=0;i--){
    b[i] += ans;
    if(b[i]%c[i] != 0){
     ans +=(c[i]- b[i]%c[i]);   
    }
   
  }
  
  cout << ans << endl;
}
    


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	rep(i,0,3){
		if(a[i]%2==0){
			cout << "0\n";
			return 0;
		}
	}
	sort(a,a+3);
	cout << a[0] * a[1] << '\n';
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        
        double d = sc.nextInt();
        double t = sc.nextInt();
        double s = sc.nextInt();
        
        double time = d / s;
        
        if (time <= t) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
        

Measured memory_bytes: 35348
#include <cstdio>
#include <cctype>

int main(void)
{
	int chCounts[26] = {};
	int ch, i;
	while ((ch = getchar()) != EOF) {
		if ('a' <= ch && ch <= 'z') {
			chCounts[ch - 'a']++;
		}
		else if ('A' <= ch && ch <= 'Z') {
			chCounts[ch - 'A']++;
		}
	}
	for (i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, chCounts[i]);
	}
	return 0;
}

Measured memory_bytes: 2708
def main():
    n = int(input())
    s = list(map(int, list(input())))
    ans = 0
    for i in range(1000):
        c = 0
        for j in s:
            if i % 10 == j:
                if c == 2:
                    ans += 1
                    break
                c += 1
                i //= 10
    print(ans)

main()

Measured memory_bytes: 3644
while true
    h, w = gets.split
    h = h.to_i;w = w.to_i;
    if h == 0 && w == 0
        break
    end
    for i in 1..h
        for j in 1..w   
            if (i + j) % 2 == 0
                print "#"
            else
                print "."
            end
        end
        print "\n"
    end
    print "\n"
end



Measured memory_bytes: 6868
N,K = gets.split.map &:to_i
A = gets.split.map(&:to_i).sort.reverse
F = gets.split.map(&:to_i).sort
MaxT = A.max * F.max
puts (0..MaxT).bsearch{ |t|
  (0...N).reduce(0){ |s,i|
    a = A[i] - (t / F[i])
    a > 0 ? s + a : s
  } <= K
}



Measured memory_bytes: 33208
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b/a,c) << endl;

	return 0;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N;
    cin >> N;
    Vec<i64> A(N);
    for (i32 i = 0; i < N; i++) cin >> A[i];
    sort(ALL(A));
    i64 sum = 0;
    for (i32 i = 1; i < N; i++) {
        sum += A[N - 1 - i / 2];
    }
    cout << sum << endl;

}


Measured memory_bytes: 4748
package main

import (
	"fmt"
)

func chmax(x *int64, y int64) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	a := make([]int64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	dp := make([][][]int64, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([][]int64, N+1)
		for j := 0; j <= N; j++ {
			dp[i][j] = make([]int64, K+2)
			for k := 0; k <= K+1; k++ {
				dp[i][j][k] = -1<<60
			}
		}
	}

	dp[0][0][0] = 0


	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			for k := 0; k < K; k++ {
				if i >= N-j {
					continue
				}
				if i < N {
					chmax(&dp[i+1][j][k+1], dp[i][j][k] + a[i])
					chmax(&dp[i+1][j][k+2], dp[i][j][k])
				}
				if j < N {
					chmax(&dp[i][j+1][k+1], dp[i][j][k] + a[N-1-j])
					chmax(&dp[i][j+1][k+2], dp[i][j][k])
				}
			}
		}
	}

	var ans int64 = 0

	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			for k := 0; k <= K; k++ {
				if i > N-j {
					continue
				}
				chmax(&ans, dp[i][j][k])
			}
		}
	}

	fmt.Println(ans)

}


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

int main(){
    ll N; cin>>N;
    string S,T; cin>>S>>T;
    for (int i = 0; i < N; i++){
        cout<<S[i]<<T[i];
    }
    cout<<endl;
    
}
    

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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

        System.out.println(calculation(N));
    }

    private static int calculation(int N) {
        return N * (N + 1) / 2;
    }
}


Measured memory_bytes: 9676
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String ue = sc.next();
    String sita = sc.next();
    
    if(ue.charAt(0)==sita.charAt(2)&&ue.charAt(1)==sita.charAt(1)&&ue.charAt(2)==sita.charAt(0)) System.out.println("YES");
    else System.out.println("NO");

  }
}

Measured memory_bytes: 35620
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
using namespace std;

int main()
{
    int n, cnt = 0;
    cin >> n;

    int a[100010];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    a[n] = 1000000001;
    a[n + 1] = 1000000000;

    bool flag_high = false;
    bool flag_low = false;

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

        if(a[i] < a[i + 1])
        {
            flag_high = true;
            while(flag_high)
            {
                i++;
                if(a[i] > a[i + 1])
                {
                    flag_high = false;
                    cnt++;
                    i++;
                    
                }
            }

        }
        else if(a[i] > a[i + 1])
        {
            flag_low = true;
            while(flag_low)
            {
                i++;
                if(a[i] < a[i + 1])
                {
                    flag_low = false;
                    cnt++;
                    i++;
                }
            }
        }


    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def f(x):
    cnt = 0
    for i in a:
        idx = bl(a,x-i)
        cnt += n - idx
        if cnt >= m:
            return True
    return False

n,m = LI()
a = LI()
a.sort()
ok,ng = 2*max(a)+1,2
while ok - ng > 1:
    mid = (ok+ng) // 2
    if f(mid):
        ng = mid
    else:
        ok = mid

ans = 0
tmp = 0
b = [0] + list(accumulate(a))
for i in a:
    idx = bl(a,ng-i)
    ans += i*(n - idx) + (b[-1] - b[idx])
    tmp += n - idx
ans = ans - (tmp - m)*ng
print(ans)

Measured memory_bytes: 60816
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
struct edge{int to,cost;};
vector<int> es[114];
signed main(){
    int n,a,b;cin>>n>>a>>b;
    if(a>b||(n==1&&a!=b)){
        cout<<0<<endl;
        return 0;
    }
    int mini=a*(n-1)+b;
    int maxi=b*(n-1)+a;
    cout<<maxi-mini+1<<endl;
    return 0;
}

Measured memory_bytes: 256