akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
// #define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


 
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}

const int N = 100001; 


int dp[3001][3001];
string ans;
int maxi;


void rec(int a, int b, string s, string t){
    if(maxi==0)
        return;

    if(a<=0 || b<=0)
        return;

    if(s[a-1]==t[b-1]){
        if(dp[a-1][b-1] +1 == maxi){
            ans = ans+s[a-1];
            maxi--;
            rec(a-1,b-1,s,t);
            return;
        }
    }
    if(dp[a-1][b] == maxi){
        rec(a-1,b,s,t);
    }else if(dp[a][b-1] == maxi){
        rec(a,b-1,s,t);
    }
}

void solve(){
    string s,t;
    cin>>s;
    cin>>t;

    int n = s.size();
    int m = t.size();

    for(int i=1;i<=m;i++){
        for(int j = 1;j<=n;j++){
            if(s[j-1] == t[i-1]){
                dp[j][i] = (dp[j-1][i-1] + 1);
            }else{
                dp[j][i] = max(dp[j-1][i], dp[j][i-1]);
            }
        }
    }

    // cout<<dp[n][0]<<" dd "<<dp[n][1]<<endl;
    // cout<<(m%2==0? dp[n][0]: dp[n][1]);
    maxi = dp[n][m];
    // cout<<maxi<<endl;

    rec(n,m,s,t);
    reverse(all(ans));

    cout<<ans<<endl;




}
 
int32_t main()
{
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

Measured memory_bytes: 100864
#include<stdio.h>
#include<string.h>
int main(){
	char a[11];
	char b[21];
	int n;
	int i,j,k;
	bool f,f2;
	int ans=0;
	scanf("%s",a);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		f=false;
		scanf("%s",b);
		for(j=0;j<10;j++)b[j+10]=b[j];
		for(j=0;j<10;j++){
			f2=true;
			for(k=0;k<strlen(a);k++){
				if(a[k]!=b[j+k])f2=false;
			}
			if(f2)f=true;
		}
		if(f)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def main():
    a,b,c = map(int,input().split())
    if(c-a-b<=0):
        print("No")
    elif(4*a*b<(c-a-b)**2):                                                                                                  print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
A, B, K = map(int, input().split())


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def factors(a):
    f = []
    for n in range(a, 0, -1):
        if a % n == 0:
            f.append(n)
    return f


ans = factors(gcd(A, B))[K - 1]
print(ans)


Measured memory_bytes: 2940
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector<bool> sieve(int n) {
    vector <bool> is_prime(n + 1, true);
    if (n >= 0) is_prime[0] = false;
    if (n >= 1) is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!is_prime[i]) continue;
        for (int j = 2 * i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }
    return is_prime;
}

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

    int n = 100005;
    auto is_prime = sieve(n);
    vector<int> count(n);
    for (int i = 1; i <= n; i++) {
        count[i] = is_prime[i] && is_prime[(i + 1) / 2];
        count[i] += count[i - 1];
    }

    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << count[r] - count[l - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl ans(N + 1, 0);
	for (ll x = 1; x <= 100; x++) {
		for (ll y = 1; y <= 100; y++) {
			for (ll z = 1; z <= 100; z++) {
				ll n = x * x + y * y + z * z + x * y + y * z + z * x;
				if (n <= N)
					ans[n]++;
			}
		}
	}
	for (ll n = 1; n <= N; n++)
		cout << ans[n] << "\n";
	return 0;
}

Measured memory_bytes: 3700
N = int(input())
nums=[int(input()) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num+1)
dp[0] = 1
for num in nums:
  for i in range(sum_num+1)[::-1]:
    if dp[i] == 1 and i + num <= sum_num:
      dp[i+num] = 1
ans = 0
for i in range(sum_num+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


Measured memory_bytes: 3188
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n;cin>>n;
	int a[n+1];
	fo1(i,n){
		cin>>a[i];
	}
	int dp[n+2];
	fo0(i,n+2){
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=2;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}
	cout<<dp[n];
}
int32_t main()
{
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;

  while(test--)
  {
  int n;
  cin>>n;
  vector<double> p(n+1);
  for(int i=1;i<=n;i++)cin>>p[i];

    double dp[n+1][n+1];
  memset(dp,0,sizeof(dp));
  dp[0][0]=1.0;

  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=i;j++)
    {
      if(j==0)dp[i][j]=dp[i-1][j]*(1-p[i]);
      else dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
    }
  }
  double ans=0.0;
  for(int i=(n+1)/2;i<=n;i++)ans+=dp[n][i];

    cout<<fixed<<setprecision(10)<<ans;

  //while loop ending 
  }



return 0;
}

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

#define ar array
#define ll long long int

auto cmp = [] (const ar<int, 3> &a, const ar<int, 3> &b) {
    return a[2] > b[2];
    
};

const ll mod = 1e9 + 7;
int n, m;
vector<string> a;
vector<vector<ll>> vis;

bool isSafe(int x, int y) {
    return x >= 0 and y >= 0 and x < n and y < m and a[x][y] == '.' ; 
}

int bfs(int ix, int iy, int fx, int fy) {
    vis = vector<vector<ll>>(n, vector<ll>(m, INT_MAX));
    if (a[ix][iy] == '#' or a[fx][fy] == '#')
        return -1;
    priority_queue<ar<int, 3>, vector<ar<int, 3>>, decltype(cmp)> q(cmp);
    q.push({ix, iy, 0});
    vis[ix][iy] = 0;
    while (!q.empty()) {
        ar<int, 3> fr = q.top();
        q.pop();
        int x = fr[0], y = fr[1], c = vis[x][y];
        if (vis[x][y] < c)
            continue;
        // cout << x << ' ' << y << ' ' << fr[1] <<  endl;
        
        for (int i = -1; i <= 1; ++i) {
            int nx = x + i;
            if (isSafe(nx, y) and vis[nx][y] > c and a[nx][y] == '.' and a[x][y] == '.') {
                vis[nx][y] = c ;
                q.push({nx, y, c});
            }
            int ny = y + i;
            // if (x == 0 and ny == 1) {
            //     cout << "hi" << ' ' << vis[x][ny] << ' ' << c <<  '\n';
            // }
            if (isSafe(x, ny) and vis[x][ny] > c and a[x][ny] == '.'  and a[x][y] == '.') {
                vis[x][ny] = c ;
                // cout << x << ' ' << ny << "hi" << c <<  '\n';
                q.push({x, ny, c});
            }

        }
        // if (isSafe(x - 2, y - 2) and isSafe(x + 2, y + 2)) {
            for (int i = -2; i <= 2; ++i) {
                for (int j = -2; j <= 2; ++j) {
                    int nx = x + i, ny = y + j;
                    if (isSafe(nx, ny) and  vis[nx][ny] > c + 1 and a[nx][ny] == '.') {
                        vis[nx][ny] = c + 1;
                        q.push({nx, ny, c + 1});
                    }
                }

            }
        // }

    }
    if (vis[fx][fy] != INT_MAX)
        return vis[fx][fy];
    return -1;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       cin >> n >> m;
       int ix, iy, fx, fy;
      cin >> ix >> iy >> fx >> fy;
       a = vector<string>(n);
       for (string &x : a)
        cin >> x;
      
      ix--, iy--, --fx, --fy;
      cout << bfs(ix, iy, fx, fy);
    }

    return 0;
}

Measured memory_bytes: 12496
use std::collections::HashSet;
use std::io::{self, BufRead};

fn main() {
    let si = io::stdin();
    let res = si.lock().lines()
        .skip(1)
        .map(|l| l.unwrap().parse::<u8>().unwrap())
        .collect::<HashSet<_>>()
        .len();
    println!("{}", res);
}

Measured memory_bytes: 4352
H,n=map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
maxAi= max(a for a,b in AB)
dp=[0]*(H+maxAi)
i=1
while True:
  try:
    dp[i]=min(dp[i-a]+b for a,b in AB)
    i+=1
  except:
    print(min(dp[H:]))
    break

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int sum = 0;
  vector<int> vec(N);
  rep(i, N) {
    if(S.at(i) == '0') {
      vec.at(i) = 0;
    }
    if(S.at(i) == '1') {
      vec.at(i) = 1;
    }
    if(S.at(i) == '2') {
      vec.at(i) = 2;
    }
    if(S.at(i) == '3') {
      vec.at(i) = 3;
    }
    if(S.at(i) == '4') {
      vec.at(i) = 4;
    }
    if(S.at(i) == '5') {
      vec.at(i) = 5;
    }
    if(S.at(i) == '6') {
      vec.at(i) = 6;
    }
    if(S.at(i) == '7') {
      vec.at(i) = 7;
    }
    if(S.at(i) == '8') {
      vec.at(i) = 8;
    }
    if(S.at(i) == '9') {
      vec.at(i) = 9;
    }
  }
  reverse(vec.begin(), vec.end());
  vector<int> vec10(N);
  rep(i, N) {
    if(i == 0) {
      vec10.at(i) = 1;
    }
    else {
      vec10.at(i) = vec10.at(i-1)*10;
    }
  }
  int sum2 = 0;
  rep(i, N) {
    sum += vec.at(i) * vec10.at(i);
    sum2 += vec.at(i);
  }
  if(sum%sum2 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    double ans=0;
    cin >> n;
    rep(i, n){
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x * 380000;
    }
    out(ans);
    
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[] c = Console.ReadLine().ToCharArray();
            c[nk[1]-1] = (char)(c[nk[1]-1] + 32);
            
            Console.WriteLine(string.Join("",c));
        }
    }
}


Measured memory_bytes: 11348
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool a = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            a = true;
        }
    }
    if (a) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}
  

Measured memory_bytes: 3616
n=int(input())
#a,b,x=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

mn=n-1
a=1
while a*a<=n:
    if n%a==0:
        b=n//a
        mn=min(a+b-2,mn)
    a+=1
print(mn)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
    int A, B; cin >> A >> B;
    
    cout << max({A+A-1, A+B, B+B-1}) << endl;
	int c; cin >> c;
	return 0;

}

Measured memory_bytes: 892
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}






int main() {
  float l;
  cin >> l;
  cout << 2*PI*l << endl;

  return 0;
}


Measured memory_bytes: 3264
import scala.io.StdIn.{readInt, readLine};

object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val matrix = Array.ofDim[Int](n + 1, n + 1);
        (1 to n).foreach { i =>
            val line = readLine.split(" ");
            line.slice(2, line.length).map(_.toInt).foreach { j =>
                matrix(i)(j) = 1;
            }
        }
        val ret = bfs(matrix, 1);
        (1 to n).foreach { i => println("%d %d".format(i, ret(i)))}
    }
    
    def bfs(matrix: Array[Array[Int]], start: Int): Array[Int] = {
        val len = matrix.length;
        val status = new Array[Int](len).map( i => -1);
        def go(que: IntQueue): Unit = {
            que.peek match {
                case None => ();
                case Some(v) => {
                    val cost = status(v) + 1
                    val newQue = (1 until len).
                        filter(i => matrix(v)(i) == 1 && status(i) == -1).
                        foldLeft(que) { (q, i) => 
                            status(i) = cost;
                            q.enqueue(i);
                        }
                    go(newQue.dequeue);
                }
            }
        }
        status(start) = 0;
        go(IntQueue(start));
        status;
    }
}

class IntQueue(private val addList: List[Int], private val popList: List[Int]) {
    def peek(): Option[Int] = if (popList == Nil) None else Some(popList.head);
    def enqueue(e: Int): IntQueue = {
        if (popList == Nil) {
            new IntQueue(Nil, (e :: addList).reverse);
        } else {
            new IntQueue(e :: addList, popList);
        }
    }
    def dequeue(): IntQueue = {
        popList match {
            case Nil => throw new NoSuchElementException;
            case head :: Nil => new IntQueue(Nil, addList.reverse);
            case head :: tail => new IntQueue(addList, tail);
        }
    }
}
object IntQueue {
    def apply(): IntQueue = new IntQueue(Nil, Nil);
    def apply(elems: Int*): IntQueue = new IntQueue(Nil, elems.toList.reverse);
}


Measured memory_bytes: 44708
import java.util.Scanner;

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

        int diff = Math.abs(a-b)%2;

        if(diff == 0) {
            System.out.println("Alice");
        } else if (diff == 1) {
            System.out.println("Borys");
        } else {
            System.out.println("Draw");
        }
    }
}


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

int partition(vector<int> &a, int p, int r) {
  int x = a[r];
  int i = p-1;
  for ( int j = 0; j < r; j++ ) {
    if ( a[j] <= x ) {
      i++;
      swap(a[i], a[j]);
    }    
  }

  swap(a[i+1], a[r]);
  return i+1;
}

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

  vector<int> a(n);
  for ( int i = 0; i < n; i++ ) cin >> a[i];

  int p = partition(a, 0, n-1);
  for ( int i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    if ( i == p ) cout << "[" << a[i] << "]";
    else cout << a[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
using namespace std;
int n,ans=1e9;
main()
{
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		int a=i,b=n-i,c=0;
		while(a>0)c+=a%6,a/=6;
		while(b>0)c+=b%9,b/=9;
		ans=min(ans,c);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vii = vector<ii>;

const int mod = 1e9+7;
const int oo = 1e8+7;


int main() {
    
    int n, w;
    scanf("%d%d",&n,&w);
    
    vector<ll> dp(w+1, 0);
    
    for(int i = 0; i < n; ++i) {
        ll wi, vi;
        scanf("%lld%lld",&wi,&vi);
        
        for(int j = w; j >= 0; --j) {
            if(j+wi > w) continue;
            dp[j+wi] = max(dp[j+wi], dp[j]+vi);
        }
    }
    
    ll ans = 0;
    for(int i = w; i >= 0; --i) {
        ans = max(ans, dp[i]);
    }
    
    cout << ans << endl;
    return 0;
}




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

using namespace std;

int n, ans, v[20], c[20];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> v[i];
	for(int i = 0; i < n; ++i) cin >> c[i];
	
	for(int i = 0; i < n; ++i) ans += max(0, v[i] - c[i]);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		String s = sc.next();
		int n = s.length();
		int[] a = new int[26];
		
		if(n>=8){
			int id = 0;
			boolean flag = true;
			while(true){
				if(flag){
					for(int i=0;i<26;i++) a[i] = 0;
					for(int i=0;i<8;i++) a[s.codePointAt(id+i)-65]++;
					flag = false;
				}
				if(a[0]==2 && a[3]==1 && a[8]==1 && a[13]==2 && a[20]==1 && a[24]==1){
					s = s.substring(0, id) + "AIZUNYAN" + s.substring(id+8, n);
					flag = true;
					id += 8;
				}
				if(id>=n-8) break;
				if(!flag){
					a[s.codePointAt(id)-65]--;
					a[s.codePointAt(id+8)-65]++;
					id++;
				}
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 17520
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	if (a * b <= 0) {
		cout << "Zero" << endl;
	}
	else if (a > 0) {
		cout << "Positive" << endl;
	}
	else if ((abs(a - b)) % 2 == 1) {
		cout << "Positive" << endl;
	}
	else {
		cout << "Negative" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int N;
vector<ll> B;

ll calcSum(ll d){
    ll sum = 0;

    FOR(i, 0, N){
        if(B[i] < d){
            sum += (d - B[i]);
        }
        else if(B[i] > d){
            sum += B[i] - d;
        }
    }
    return sum;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    B.reserve(N);
    FOR(i, 0, N){
        ll b = A[i] - i;
        B.push_back(b);
    }

    sort(ALL(B));

    if(B.size() % 2 == 1){
        int center = B.size() / 2;
        ll median = B[center];
        ll sum = calcSum(median);
        p(sum);
    }
    else{
        int center0 = B.size() / 2;
        int center1 = center0 - 1;

        ll median0 = B[center0];
        ll median1 = B[center1];

        ll sum0 = calcSum(median0);
        ll sum1 = calcSum(median1);

        p(min(sum0, sum1));
    }
    return 0;
}

Measured memory_bytes: 3456
from collections import Counter, defaultdict
# for use in beginner level contests where speed is key

a = int(input())

abc = "abcdefghijklmnopqrstuvwxyz"

cnt = 0
arr = [0]
back = None

for i in range(1,12):
    cnt += 26**i
    arr.append(cnt)
    if cnt > a:
        break

b = a - arr[i-1] - 1

res = ""
for j in range(i-1, -1, -1):
    res += abc[b//(26**j)]
    b = b%(26**j)

if set(res) == set("z"):
    res = res[:-1]

print(res)

Measured memory_bytes: 64752
//001 AGC A - BBQ Easy 2016/07/16
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    vector<int> l(n + n);
    rep(i ,n*2) cin >> l[i];
    int64 sum=0;
    sort(l.begin(),l.end());
    for(int i=0;i<n*2;i+=2){
        sum+=l[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

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

	set<int> S;

	int query, x;

	for (int i = 0; i < q; i++) {
		cin >> query >> x;
		if (query == 0) {
			S.insert(x);
			cout << S.size() << endl;
		}
		else if (query == 1){
			if (S.find(x) != S.end())
				cout << 1 << endl;
			else
				cout << 0 << endl;		
		}
		else {
			S.erase(x);		
		}
	}
}


Measured memory_bytes: 12384
S = input().rstrip()
s0 = "R"
nR = 1
nL = 0
res = [0]*len(S)
for i, s in enumerate(S[1:],start=1):
    if s == s0:
        if s == "R":
            nR += 1
        else:
            nL += 1
    else:
        if s == "R":
            res[pR-1] += (nR+1)//2 + nL//2
            res[pR] += nR//2 + (nL+1)//2
            nR = 1
            nL = 0
        else:
            nL += 1
            pR = i
    s0 = s

res[pR - 1] += (nR + 1) // 2 + nL // 2
res[pR] += nR // 2 + (nL + 1) // 2
nR = 1
nL = 0
print(*res)

Measured memory_bytes: 78664
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

vecllong memo(0);
llong N;
bool A[22][22] = {false};

llong search(llong state, llong man) {
    if(memo[state] != -1) {
        return memo[state];
    }

    llong ret = 0;
    FOR(woman, N) {
        if((state & (1 << woman)) != 0 and A[man][woman]) {
            ret = (ret + search(state - (1 << woman), man + 1)) % MOD;
        }
    }
    memo[state] = ret % MOD;
    return memo[state];
};

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

    cin >> N;
    FOR(i, N) {
        FOR(j, N) {
            llong in;
            cin >> in;
            A[i][j] = (in == 1);
        }
    }

    memo.resize((1 << N), -1);
    memo[0] = 1;

    llong ans = search((1 << N) - 1, 0) % MOD;

    cout << ans << endl;

    return 0;
}

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


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

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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int disum(int n) {
	int sum = 0;

	while (n) {

		sum += n % 10;
		// sum++;
		n /= 10;





	}
	return sum;

}


// #define maxa 1000000










int main() {
	int i, n, m, k, c1 = 0, sum = 0;
	c_p_c();
	// w(t){
	cin>>n>>m;
	// pair<int,int> p[n];
	vector<pair<int,int>> p;


	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin>>k>>c1;
		if(c1<=m){


			p.pb(make_pair(k,c1));


		}
	}


	if(p.size()==0)
		cout<<"TLE"<<endl;
	else{


		sort(all(p));
		cout<<p[0].F<<endl;

	}








}




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

int main()
{
    int x;
    scanf("%d",&x);
    int maxn=1;
    for (int i=2;i*i<=x;i++)
    {
        int h=i*i;
        while(h<=x)
        {
            maxn=max(maxn,h);
            h=h*i;
        }
    }
    printf("%d\n",maxn);
    return 0;
}


Measured memory_bytes: 256
while 1:
    n, x = map(int, input().split())
    if n==0 and x==0: break
    count = 0
    for i in range(n, 2, -1):
        for j in range(i-1, 1, -1):
            for k in range(j-1, 0, -1):
                if i+j+k==x:
                    count+=1
    print(count)


Measured memory_bytes: 5596
#include <stdio.h>

int main(void) {
	int N, M;
	while (scanf("%d%d", &N, &M), N && M) {
		int A, ans = 0;
		for (int i = 0; i < N; i++) {
			scanf("%d", &A);
			if (M / N < A) ans += M / N;
			else ans += A;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	char x, y;
  	
  	cin >> x >> y;
  
    if (x > y) {
    	cout << ">" << endl;  
    } else if (x < y) {
    	cout << "<" << endl; 
    } else {
    	cout << "=" << endl; 
    }
	return (0); 
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int h, w, n;
	cin >> h >> w >> n;
	int a[10001];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int c[101][101];
	int nownum = 1;
	for(int i = 0; i < h; i++){
		if(i % 2 == 0){
			for(int j = 0; j < w; j++){
				c[i][j] = nownum;
				a[nownum]--;
				if(a[nownum] == 0) nownum++;
			}
		} else {
			for(int j = w - 1; j >= 0; j--){
				c[i][j] = nownum;
				a[nownum]--;
				if(a[nownum] == 0) nownum++;
			}
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << c[i][j];
			if(j == w - 1) cout << endl;
			else cout << " ";
		}
	}
}

Measured memory_bytes: 384
N = int(input())
P = [input().split() for i in range(N)]
for i in range(N):
    P[i][1] = int(P[i][1]) * -1
P1 = P.copy()
P1.sort()
for i in range(N):
    for j in range(N):
        if P[j][0] == P1[i][0] and P[j][1] == P1[i][1]:
            print(j + 1)

Measured memory_bytes: 3064
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextLong()

    if (x <= 6) {
        println(1)
        return
    }
    if (x <= 11) {
        println(2)
        return
    }
    var ans = x / (6 + 5) * 2
    val amari = x % 11
    if (amari > 6L) {
        ans += 2
    } else if (amari > 0L) {
       ans += 1
    }
    println(ans)

    // x ==100 -> 100 / 11 == 9 -> 11 * 9 == 99 -> 1足りない -> 9 * 2 -> 18 + 1
    // 100 == 19
    // 99 == 18
    // 98 == 18
    // 94 == 17
    // 93 == 17
    // 92 == 17
    // 89 == 16

    // 18 -> 99
    // 17 -> 94
    // 16 -> 89
}

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

int main() {
	string s; cin >> s;
	int n = s.size(), ans = n;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, n - (i + 1)));
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(){
    int H;
    int W;
    int i;
    int j;
    while(1){
        scanf("%d%d", &H, &W);
        if(H == 0 && W == 0){break;}
        /*printf("#");
        printf("\n");こいつら使えばできる
        ####\n####\n*/
        for(i = 0;i < H;i++){
            for(j = 0;j < W;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2040
import java.util.*;

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

        while(true){
            String text = sc.next();
            
            if(text.equals("-")){
                break;
            }
            int m = sc.nextInt();
            for(int i = 0; i < m; i++){
                int j = sc.nextInt();
                text = text.substring(j, text.length()) + text.substring(0, j);
            }

            list.add(text);
        }
        list.forEach(System.out::println);
    }
}


Measured memory_bytes: 31980
import os

import itertools
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def test():
    ans_hist = [INF] * (N ** 2)

    ans = 0
    dist = [INF] * (N ** 2)
    for i, p in enumerate(P):
        p -= 1
        ph, pw = p // N, p % N
        d = min(ph, pw, N - ph - 1, N - pw - 1)

        j = i - 1
        while j >= 0:
            q = P[j] - 1
            qh, qw = q // N, q % N
            d = min(d, dist[q] + abs(ph - qh) + abs(pw - qw) - 1)
            j -= 1

        dist[p] = d
        ans_hist[p] = d

        j = i - 1
        while j >= 0:
            q = P[j] - 1
            qh, qw = q // N, q % N
            dist[q] = min(dist[q], dist[p] + abs(ph - qh) + abs(pw - qw) - 1)
            j -= 1

        ans += d
        # print(p, dist)
    print(ans)
    # print(dist)
    # print(np.array(ans_hist, dtype=int).reshape(N, N))
    return ans


N = int(sys.stdin.buffer.readline())
P = list(map(int, sys.stdin.buffer.readline().split()))

# 解説
dist = [INF] * len(P)
for h, w in itertools.product(range(N), range(N)):
    dist[h * N + w] = min(h, w, N - h - 1, N - w - 1)
present = [1] * len(P)

ans = 0
for p in P:
    p -= 1
    h, w = p // N, p % N
    present[p] = 0

    ans += dist[p]
    stack = [(p, dist[p])]
    while stack:
        p, d = stack.pop()
        h, w = p // N, p % N
        d += present[p]
        for dh, dw in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            if 0 <= h + dh < N and 0 <= w + dw < N:
                q = (h + dh) * N + w + dw
                if d < dist[q]:
                    dist[q] = d
                    stack.append((q, d))
print(ans)
# test()


Measured memory_bytes: 175668
#include<stdio.h>
#include<string.h>
#define y 2019
main(){
char s[200001];
scanf("%s",s);
long long a=0,S=0;
int d=1,i,l=strlen(s),mod[y]={1};
for(i=l-1;i>=0;i--){
	S=(S+(s[i]-'0')*d)%y;
	S%=y;
	mod[S]++;
	d=d*10%y;
}
for(i=0;i<y;i++)a+=(long long)mod[i]*(mod[i]-1)/2;
printf("%lld",a);
}

Measured memory_bytes: 1900
import java.util.*;

public class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),a=0,i=0;
		while(i++<n)
			if(s.nextInt() == i){
				a++;
				if(i++<n)s.next();
			}
		System.out.println(a);
	}
}

Measured memory_bytes: 48880
#include <stdio.h>
#define N 44
int makeFibonacci(int);
int F[N];
int main(){
  int n,x=0;
  scanf("%d",&n);
  x=makeFibonacci(n);
  printf("%d\n",x);  
  return 0;
}
int makeFibonacci(int n){
  int i,x=0; 
  F[0]=1;
  F[1]=1;
  if(n==0||n==1){
    return 1;
  }
  if(n>1){
    for(i=2;i<=n;i++){
      F[i]=F[i-2]+F[i-1];
      x=F[i]; 
   }
    return x;
  }
}

Measured memory_bytes: 596
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   
   while(true){
      c -= b;
      if(c<=0){
         cout << "Yes\n";
         return 0;
      }
      a -= d;
      if(a <= 0){
         cout << "No\n";
         return 0;
      }
      
   }
   
   
   return 0;
}

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>

int seg[2000000][26];
int input[500001][26];

void construct_tree(int low,int high,int pos){
	if(low == high){
		for(int i=0;i<26;i++) seg[pos][i] = input[low][i];
		return;
	}
	int mid = (low+high)/2;
	construct_tree(low,mid,2*pos+1);
	construct_tree(mid+1,high,2*pos+2);
	for(int i=0;i<26;i++) seg[pos][i] = seg[2*pos+1][i] + seg[2*pos+2][i];
}

int range_query(int qlow,int qhigh,int low,int high,int pos,int c){
	if(qhigh < low || high < qlow) return 0;
	if(qlow <= low && high <= qhigh) return seg[pos][c];

	int mid = (low+high)/2;
	return range_query(qlow,qhigh,low,mid,2*pos+1,c) + range_query(qlow,qhigh,mid+1,high,2*pos+2,c);
}

void range_update(int uindex,int low,int high,int pos){
	if(uindex < low || high < uindex) return;
	if(low == uindex && high == uindex){
		for(int i=0;i<26;i++){
			seg[pos][i] = input[uindex][i];
		}
		// seg[pos][c] = input[uindex][c];
		// seg[pos][temp] = input[uindex][temp];
		return;
	}
	int mid = (low+high)/2;
	range_update(uindex,low,mid,2*pos+1);
	range_update(uindex,mid+1,high,2*pos+2);
	for(int i=0;i<26;i++){
		seg[pos][i] =  seg[2*pos+1][i] + seg[2*pos+2][i];
	}
	// seg[pos][c] =  seg[2*pos+1][c] + seg[2*pos+2][c];
	// seg[pos][temp] =  seg[2*pos+1][temp] + seg[2*pos+2][temp];
}

int main(){
	// ifstream cin("01-handmade-00");
	// ofstream cout("out");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		string str;
		cin >> str;
		for(int i=0;i<n;i++){
			for(int j=0;j<26;j++) input[i][j] = 0;
			input[i][str[i]-'a'] = 1;
		}
		for(int i=0;i<2000000;i++)
			for(int j=0;j<26;j++){ seg[i][j] = 0;}
		construct_tree(0,n-1,0);
		// for(int i=0;i<15;i++){
		// 	cout << i << "---";
		// 	for(int j=0;j<26;j++) cout << seg[i][j] << " ";
		// 	cout << endl;
		// }
		int q;
		cin >> q;
		int op,l,r;
		while(q--){
			cin >> op >> l;
			if(op==1){
				char c;
				cin >> c;
				for(int i=0;i<26;i++) input[l-1][i] = 0;
				// int temp = str[l-1] - 'a';
				// str[l-1] = c;
				// input[l-1][temp] = 0;
				input[l-1][c-'a'] = 1;
				range_update(l-1,0,n-1,0);
				// for(int i=0;i<15;i++){
				// 	cout << i << "---";
				// 	for(int j=0;j<26;j++) cout << seg[i][j] << " ";
				// 	cout << endl;
				// }
			}
			else{
				cin >> r;
				int ans=0;
				for(int i=0;i<26;i++){
					if(range_query(l-1,r-1,0,n-1,0,i) > 0) ans++;
				}
				cout << ans << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 254876
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int a,b;
  cin >> a >> b;
  
  vector<string> p(a);
  rep(i,a){
  cin>>p[i];
  }
  
  bool ok=true;
  rep(i,a){
    rep(j,b){
      if(p[i][j]=='#'){
        bool ko = true;
        if(i-1>=0 && p[i-1][j]=='#') ko=false;
        if(j-1>=0 && p[i][j-1]=='#') ko=false;
        if(j+1<=b-1 && p[i][j+1]=='#') ko=false;        
        if(i+1<=a-1 && p[i+1][j]=='#') ko=false;
        if(ko) ok=false;
      }
    }
  }
  
  cout << (ok?"Yes":"No") << endl;
  
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringxx(o, depth) depth = depth or 0 if depth > 10 then return "<too deep!>" end if o == _G then return "<_G>" end local indent0 = (" "):rep((depth) * 2) local indent1 = (" "):rep((depth+1) * 2) local indent2= (" "):rep((depth+2) * 2) if type(o) == 'table' then local keys = {} local types = {} for k in pairs(o) do types[type(k)] = true table.insert(keys, k) end local types_count = 0 local lasttype for k in pairs(types) do types_count = types_count + 1 lasttype = k end if types_count == 1 and (lasttype == 'string' or lasttype == 'number') then table.sort(keys) end local inside = {} for i=1,#keys do local k = keys[i] local v = o[k] if type(k) == 'string' then k = string.format('%q', k) end table.insert(inside, indent1 .. '['..tostring(k)..'] = ' .. tostringxx(v, depth + 1)) end return '{\n' .. table.concat(inside, ',\n') .. '\n' .. indent0 .. '}' else if type(o) == 'string' then o = string.format('%q', o) end return tostring(o) end end
local function richtraceback() local x = 2 while true do local info = debug.getinfo(x) if not info then break end local fname = '<' .. info.short_src .. ":" .. info.linedefined .. ">" if info.name then fname = info.name end print(info.short_src .. ":" .. info.currentline .. ": in " .. ("%q"):format(fname)) print(" LOCALS:") local p = 1 while true do local name, val = debug.getlocal(x,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) p = p + 1 end print(" UPVALUES:") for p=1,info.nups do local name, val = debug.getupvalue(info.func,p) if not name then break end print(" " .. name .. ": " .. tostringxx(val, 3)) end x = x + 1 end end
local function myassert(b) if not b then richtraceback() error("assertion failed") end end 
-----------------------
local D = read.n()
local C = read.N(26)
local S = {}
for i=1,D do
    S[i] = read.N(26)
end
-----
-----
local last = array(1, 0)
for d=1,D do
    local amax = -10^18
    local maxi = 1
    for i=1,26 do
        local ans = S[d][i]
        for j=1,26 do
            if j ~= i then
                ans = ans - C[j] * (d - last[j])
            end
        end
        if ans > amax then
            amax = ans
            maxi = i
        end
    end
    last[maxi] = d
    print(maxi)
end

Measured memory_bytes: 3780
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
ll A[200002];
ll B[200002];
unordered_map<ll, int> Mp;

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

  cin >> N;
  rep(i, N) cin >> A[i];
  int cnt = 0;
  B[0] = A[0];
  rep(i, N-1) B[i+1] = B[i]+A[i+1];
  rep(i, N) Mp[B[i]]++;
  ll ans = 0ll;
  for (auto it=Mp.begin(); it !=Mp.end(); ++it){
    ll v = it->first;
    ll cnt = it->second;
    if (v==0) ans+=cnt;
    ans+=cnt*(cnt-1)/2;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 11592
#include <stdio.h>
#include <string.h>
int main()
{   char s[11],t[11];
    scanf("%s",s);
    scanf("%s",t);
    int a,b;
    scanf("%d%d",&a,&b);
    char u[11];
    scanf("%s",u);
    if(strcmp(s,u)==0){
        a--;
    }else{
        b--;
    }
    printf("%d %d",a,b);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
using namespace std;

int main()
{
    FAST
 ll n,k,i,l=0;
 cin>>n>>k;
 ll  a[n];
 for(i=0;i<n;i++)
 cin>>a[i];
 
for(i=k;i<n;i++)
{
if(a[l]<a[i])	
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
l++;
} 
    return 0;
}

Measured memory_bytes: 5208
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    m = 10**10
    for i in range(N):
        if A[i] < m:
            ans += 1
            m = A[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70352
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_sum = [0] * (n + 1)
b_sum = [0] * (m + 1)
for i in range(n):
    a_sum[i + 1] = a_sum[i] + a[i]
for i in range(m):
    b_sum[i + 1] = b_sum[i] + b[i]
ans = -1
for i in range(n + 1):
    if a_sum[i] <= k:
        ans = i
    else:
        break
tmp = ans
for i in range(1, m + 1):
    if b_sum[i] > k:
        break
    for j in range(tmp, -1, -1):
        if b_sum[i] + a_sum[j] <= k:
            tmp = j
            ans = max(ans, i + j)
            break
print(ans)


Measured memory_bytes: 47508
MOD = 998244353
n, s = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
    for j in range(s+1):
        if j >= a:
            dp[i+1][j] = dp[i][j]*2 + dp[i][j-a]
        else:
            dp[i+1][j] = dp[i][j]*2
        dp[i+1][j] %= MOD
ans = dp[n][s]
print(ans)

Measured memory_bytes: 132676