akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll arr[n];
  ll i,ans=0,farr[n+1]={0};
  for(i=0;i<n;i++)
  {
      cin>>arr[i];
      farr[arr[i]]++;
  }
  for(i=1;i<=n;i++)
  {
      ans=ans+farr[i]*(farr[i]-1)/2;
  }
  for(i=0;i<n;i++)
  {
    if(farr[arr[i]]<2)
    {
        cout<<ans<<'\n';
    }
    else
    {
        if(farr[arr[i]]==2)
        {
            cout<<ans-1<<'\n';
        }
        else
        {
            cout<<ans-farr[arr[i]]+1<<'\n';
        }
    }
  }
   
  return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int A, B, C, D;
	in >> A >> B >> C >> D;
	out << std::min(A, B) + std::min(C, D) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <functional>
#include <algorithm>

using namespace std;


typedef pair<int, int> P;

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

  P p;

  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      p.first++;
    } else {
      if (p.first > 0) {
        p.first--;
      } else {
        p.second++;
      }
    }
  }

  for (int i = 0; i < p.second; i++) {
    cout << "(";
  }
  cout << s;
  for (int i = 0; i < p.first; i++) {
    cout << ")";
  }
  cout << endl;
  

  return 0;
}

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

int main(void) {
    int n, a[200], ans = 0;
    bool flag = true;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    while (true) {
        for (int i = 0; i < n; i++) {
            if (a[i] % 2) {
                flag = false;
                break;
            }
            else a[i] /= 2;
        }
        if (!flag) break;
        else ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    count = 2
    sqrt = int(n ** (1/2))
    for i in range(2,sqrt + 1):
        if n % i == 1:
            count += 2
        elif n % i == 0:
            ins = n
            while ins % i == 0:
                ins = ins // i
            if ins % i == 1:
                count += 1
    if sqrt ** 2 == n - 1:
        count -= 1

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    while(1){
	int t = n;
	set<int> s;
	while(t > 0){
	    s.it(t%10);
	    t/= 10;
	}
	if(sz(s) == 1){
	    P(n);
	    ret 0;
	}
	n++;
    }
    return  0;
}


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

int main()
{
    int n,arr[7],i,indx;
    for(i=1; i<=5; i++)
    {
        cin>>arr[i];
        if(arr[i]==0)indx=i;
    }
    cout<<indx<<endl;



    return 0;
}


Measured memory_bytes: 3636
n = int(input())
l = list(map(int, input().split()))

cnt = 0
l.sort()

for i in range(0, n-2):
    for j in range(i+1, n-1):
        if l[i] == l[j]:
            continue
        for k in range(j+1, n):
            if l[j] == l[k]:
                continue
            if l[k] < l[i] + l[j]:
                cnt += 1

print(cnt)

Measured memory_bytes: 9116
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,char> Q;
ll longinf=1ll<<60;
int inf=1<<29;

int main(){
      char s[4];
      bool ok[4];
      rep0(i,4) cin>>s[i];
      fill(ok,ok+4,false);
      rep0(i,4){
            if(s[i]=='1') ok[0]=true;
            if(s[i]=='9') ok[1]=true;
            if(s[i]=='7') ok[2]=true;
            if(s[i]=='4') ok[3]=true;
      }
      if(ok[0]&&ok[1]&&ok[2]&&ok[3]) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      return 0;
}

Measured memory_bytes: 256
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 

h,w = map(int, sys.stdin.readline().rstrip().split())
As = []
for i in range(h):
  As.append(str(sys.stdin.readline().rstrip()))

cnt_h = [0] * h
cnt_w = [0] * w

for i in range(h):
  for j in range(w):
    if As[i][j] == '.':
      cnt_h[i] += 1
      cnt_w[j] += 1

idx_h = []
for i in range(h):
  if cnt_h[i] < w:
    idx_h.append(i)

idx_w = []
for i in range(w):
  if cnt_w[i] < h:
    idx_w.append(i)

for i in idx_h:
  for j in idx_w:
    print(As[i][j], end="")
  print()

Measured memory_bytes: 4468
n, m, l = gets.chomp.split.map(&:to_i)

A = []
n.times{ A << gets.chomp.split.map(&:to_i)}
B = []
m.times{ B << gets.chomp.split.map(&:to_i)}

C = Array.new(n){Array.new(l, 0)}
for i in (0...n)
    for j in (0...l)
        for k in (0...m)
            C[i][j] += A[i][k] * B[k][j]
        end
    end
end
C.each{|row| puts row.join(" ")}



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

sum = 0
for i in range(n):
        if (b[i] > a[i]):
            sum += a[i]
            b[i] -= a[i]
            if (b[i] <= a[i + 1]):
                sum += b[i]
                a[i + 1] -= b[i]
            else:
                sum += a[i + 1]
                a[i + 1] = 0
        else:
            sum += b[i]
            a[i] -= b[i] 
print(sum)

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

int main() {
	int64_t x, y;
	cin >> x;
	y = x % 11;
	cout << x / 11 * 2 + (y > 0 ? 1 : 0) + (y > 6 ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//        String[] str = br.readLine().split(" ");
        String s = br.readLine();
        boolean[] used = new boolean[26];

        for (int i = 0; i < s.length(); i++) used[s.charAt(i) - 'a'] = true;

        for (int i = 0; i < 26; i++){
            if(!used[i]){
                System.out.println((char)(i + 'a'));
                return;
            }
        }

        System.out.println("None");
    }
}


Measured memory_bytes: 25044
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
d=make_divisors(n)[1:]
l=make_divisors(n-1)[1:]

ans=0
for i in d:
    m=n
    while m%i==0:
        m//=i
    if m%i==1:
        ans+=1
print(ans+len(l))


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

typedef long long ll;
ll mod=1e9+7;


int main() 
{
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
     		//freopen("input.txt", "rt", stdin);
 	#endif
	ll n,m;
	cin >> n >> m;
	ll memo[n][m];
	bool arr[n][m];
	string ch;
	for(int i=0;i<n;i++)
	{
		cin >> ch;
		for(int j=0;j<m;j++)
		{
			memo[i][j]=0;
			if(ch[j] == '.')
				arr[i][j]=true;
			else
				arr[i][j]=false;
		}
	}
	memo[n-1][m-1]=1;
	for(int i=m-2;i>=0;i--)
		if(arr[n-1][i])
			memo[n-1][i]=memo[n-1][i+1];
	for(int i=n-2;i>=0;i--)
		if(arr[i][m-1])
			memo[i][m-1]=memo[i+1][m-1];

	for(int i=n-2;i>=0;i--)
	{
		for(int j=m-2;j>=0;j--)
			if(arr[i][j])
				memo[i][j]=(memo[i][j+1]+memo[i+1][j])%mod;
	}
	cout<<memo[0][0]<<"\n";
 	return 0;	
}


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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

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

  int p=0;
  for (int i=0; i<=n; i++) {
    if (s.substr(n-i,i) == t.substr(0,i)) {
      p = i;
    }
  }
  cout << 2*n-p << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  int n = s.length();
  ll ans = 0, cnt = 0;
  rep(i, n) {
    if (s[i] == 'A') {
      cnt++;
    }
    else {
      if (s.substr(i, 2) == "BC") {
        ans += cnt;
        i++;
      }
      else cnt = 0;
    }
  }
  cout << ans << '\n';




  
  return 0;
}

Measured memory_bytes: 720
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int k;
  cin >> k;
  int cur = 0;
  for (int i = 0; i < k; ++i) {
    cur *= 10;
    cur += 7;
    cur %= k;
    if (cur == 0) {
      cout << i + 1 << '\n';
      exit(0);
    }
  }
  cout << "-1\n";
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


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

	if (abs(a - b) > pow(10, 18)) {
		cout << "Unfair" << endl;
	}
	else if (k % 2) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int R[200000];
int maxdR, mdR, dR;

int main(void)
{
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> R[i];
	}

	for(int i=0;i<n-1;i++){
		dR = R[n-i-1]-R[n-i-2];
		if (i==0){
			mdR = dR;
			maxdR = mdR;
		}else{
			if (mdR>0){
				mdR += dR;
			}else{
				mdR = dR;
			}
			if (mdR>maxdR){
				maxdR = mdR;
			}
		}
	}
	
	cout << maxdR << endl;

	return 0;
}

Measured memory_bytes: 1940
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            System.out.println((A + B) % 24);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = (int)2e5 + 2;
const int LG = 20;
const int mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e16;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n;
ll pref[N], a[N];

int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf ("%lld", a + i);
        pref[i] = pref[i - 1] + a[i];
    }
    ll ans = linf;
    for (int i = 1; i < n; ++i)
    {
        ll half1 = pref[i], half2 = pref[n] - pref[i];
        ans = min(ans, abs(half1 - half2));
    }
    printf ("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
string a,b;
int l,i,ans;
cin >> a >> b;
ans=0;
l=a.size();
  
for(i=0;i<l;++i)
{
  char l=a.at(i);
  char s=b.at(i);
if(l!=s) ans++;
}

cout << ans << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    int MOD = 1000000007;
    int dp[100100][13] = {};
    dp[0][0] = 1;
    REP(i,N)REP(j,13){
        if(S[i] == '?'){
            REP(k,10){
                dp[i+1][(j * 10 + k) % 13] += dp[i][j];
                dp[i+1][(j * 10 + k) % 13] %= MOD;
            }
        }
        else{
            dp[i+1][(j*10 + (S[i] - '0')) % 13] += dp[i][j];
            dp[i+1][(j*10 + (S[i] - '0')) % 13] %= MOD;
        }
    }
    cout << dp[N][5] << endl;
}

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

struct UnionFind{
private:
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> val;
public:
    UnionFind(int size){
        par=std::vector<int>(size);
        rank=std::vector<int>(size);
        for(int i=0;i<size;++i){
            par[i]=i;
            rank[i]=1;
            val[i]=i;
        }
    }

    int root(int x){
        if(par[x]==x)return x;
        else {
            par[x]=root(par[x]);
            return par[x];
        }
    }

    bool same(int x,int y){//0-indexed
        return root(x)==root(y);
    }

    int value(int x){
        return val[root(x)];
    }

    void unite(int x,int y){//0-indexed
        x=root(x);
        y=root(y);
        if(x==y)return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            val[x]=val[y];
            if(rank[x]==rank[y])++rank[x];
        }
    }
};

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    map<ll,ll> mp;
    vector<ll> a(n);
    ll s=0;
    for(int i = 0;i < n;++i) {
        cin>>a[i];
        s+=a[i];
        ++mp[a[i]];
    }

    int q;
    cin>>q;
    for(int i = 0;i < q;++i) {
        int b,c;
        cin>>b>>c;
        s-=b*mp[b];
        s+=c*mp[b];
        
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<s<<"\n";
    }
    return 0;
}


Measured memory_bytes: 9884
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    ll x = 0;
    for (int i = 0; i < n; i++) x += a[i];
    x /= 2;

    for (int i = 1; i < n; i += 2) x -= a[i];

    cout << x * 2 << " ";

    for (int i = 1; i < n; i++) {
        x = a[i - 1] - x;
        cout << x * 2 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <utility>

using namespace std;

int main() {
	int n,t;
	cin >> n >> t;
	int mc = 10000;
	for(int i = 0;i < n;i++) {
		int a,b;
		cin >> a >> b;
		if(t >= b) {
			mc = min(mc,a);
		}
	}
	if(mc == 10000) cout << "TLE" <<endl;
	else cout << mc << endl;
}


Measured memory_bytes: 256
#lamp
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
lists=[]
for i in range(h):
    b=list(input())
    lists.append(b)
    
right=[[0 for i in range(w)] for j in range(h)]
left=[[0 for i in range(w)] for j in range(h)]
up=[[0 for i in range(w)] for j in range(h)]
down=[[0 for i in range(w)] for j in range(h)]

#rightの累積和
for i in range(h):
    for j in range(w-1,-1,-1):
        if j==w-1:
            if lists[i][j]=="#":
                right[i][j]=0
            else:
                right[i][j]=1
        else:
            if lists[i][j+1]=="#":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=1
            elif lists[i][j+1]==".":
                if lists[i][j]=="#":
                    right[i][j]=0
                else:
                    right[i][j]=right[i][j+1]+1


#leftの累積和
for i in range(h):
    for j in range(w):
        if j==0:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=1
        else:
            if lists[i][j]=="#":
                left[i][j]=0
            else:
                left[i][j]=left[i][j-1]+1


#upの累積和
for i in range(w):
    for j in range(h):
        if j==0:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=1
        else:
            if lists[j][i]=="#":
                up[j][i]=0
            else:
                up[j][i]=up[j-1][i]+1

                
#downの累積和
for i in range(w):
    for j in range(h-1,-1,-1):
        if j==h-1:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=1
        else:
            if lists[j][i]=="#":
                down[j][i]=0
            else:
                down[j][i]=down[j+1][i]+1
                
maxi=0
for i in range(h):
    for j in range(w):
        maxi=max(maxi,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(maxi)           


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

students = tuple(tuple(map(int,input().split())) for _ in range(N))
checks = tuple(tuple(map(int,input().split())) for _ in range(M))

print(*(c for _,c in (min((abs(x0-x1)+abs(y0-y1),i+1)  for i,(x0,y0) in enumerate(checks)) for x1,y1 in students)), sep='\n')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
stack<char> sta;

int main(){
    ll n; cin >> n;
    while(n>=1){
        ll d = n % 26;
        char c ;
        if(d==1){c = 'a';}
        if(d==2){c = 'b';}
        if(d==3){c = 'c';}
        if(d==4){c = 'd';}
        if(d==5){c = 'e';}
        if(d==6){c = 'f';}
        if(d==7){c = 'g';}
        if(d==8){c = 'h';}
        if(d==9){c = 'i';}
        if(d==10){c = 'j';}
        if(d==11){c = 'k';}
        if(d==12){c = 'l';}
        if(d==13){c = 'm';}
        if(d==14){c = 'n';}
        if(d==15){c = 'o';}
        if(d==16){c = 'p';}
        if(d==17){c = 'q';}
        if(d==18){c = 'r';}
        if(d==19){c = 's';}
        if(d==20){c = 't';}
        if(d==21){c = 'u';}
        if(d==22){c = 'v';}
        if(d==23){c = 'w';}
        if(d==24){c = 'x';}
        if(d==25){c = 'y';}
        if(d==0){c = 'z'; n -= 1;}
        sta.push(c);
        
        n /= 26;
    }
    while(!sta.empty()){
        printf("%c", sta.top());
        sta.pop();
    }
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	int lose = 0;
	for(int i=0;i<s.length();i++){
		if(s[i] == 'x') lose++;
	}
	if(lose <=7) cout<<"YES"<<endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e18+1;

int main()
{
    while(true){
        ll n,x;
        cin >> n >> x;
        if(n==0 && x==0) break;
        ll cnt=0;
        for(ll i=1;i<=n;i++){
            for(ll j=i+1;j<=n;j++){
                for(ll k=j+1;k<=n;k++){
                    if(i+j+k==x){
                    cnt++;
                    }
                }
            }
        }
    cout << cnt << endl;
    }
    return 0;
} 


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef pair<int,int> pii;
typedef long long int ll; 
typedef tree<pii,null_type,less<pii>,rb_tree_tag, \
tree_order_statistics_node_update> ordered_set;

#define int ll   
#define long int
#define pb push_back
#define all int i=0; i<n; i++
#define INF LLONG_MAX

#define Nirvana ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define mod 1000000007
#define pii pair<int, int> 
long expo(long base, long exp) 
{ 
    long t = 1L; 
    while (exp > 0)  
    { 
        if (exp % 2 != 0)  t = (t * base); 
        base = (base * base) ; 
        exp /= 2; 
    } 
    return t; 
} 
#define pow expo
#define pi acos(-1.00)

int dig(int n){
	int cur = 0;
	while(n!=0){
		cur++;
		n/=10;
	}
	return cur;
}

int f(int i){
	string s = to_string(i);
	return int(s[0] - '0');
}
int l(int i){
	string s = to_string(i);
	return int(s[s.length()-1] - '0');
}
int32_t main(){
	
	//cout<<calc(2, 2, 3)<<endl;
	int n;
	cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	
	int num = dig(n);
	//cout<<num<<endl;
	int ans = 0;
	for(int i=1; i<=n; i++){
		//int k = i;
		if(i%10 == 0)continue;
		string s = to_string(i);
		//reverse(s.begin(), s.end());
		
		int first = int(s[0] - '0');
		int last = int(s[s.length()-1] - '0');
		if(last==0 || first==0)continue;
		if(i<=9 || first == last){
			ans++;
			//cout<<i<<endl;
		}
	
		for(int i=2; i<=num-1; i++){
			ans+=pow(10, i-2);
		}
			
		//cout<<i<<" "<<ans<<endl;
		if(f(n) < last)continue;
		
		if(f(n) > last){
			ans+=pow(10, num-2);
		}
		
		if(f(n)==last){
			//cout<<i<<endl;
			int k = n;
			while(true){
				if(l(k) == first || k==0)break;
				k--;
			}
			if(k==0 || f(k)!=last || dig(k)<dig(n))continue;
			
			int cont = 0;
			string s= to_string(k);
			for(int j=1; j<s.length()-1; j++){
				cont*=10;
				cont+=int(s[j]-'0');
			}
			ans+=cont+1;
			
			//cout<<i<<" "<<k<<" "<<cont<<endl;
		}
	
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pint;
typedef map<int,int> mint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+10;

int N;
int a;
int b;
mint mp;


int main() {
	cin>>N;
	Rep(i,N){
		cin>>a;
		if(a%4==0) b=2;
		else if(a%2==0) b=1;
		else b=0;
		mp[b]++;
	}
	if(mp[1]==0){
		if(mp[2]>=mp[0]-1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else{
		if(mp[2]>=mp[0]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;


int main(){
  int N, M;
  cin >> N >> M;

  int cnt[N];
  fill(cnt, cnt + N, 0);

  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cnt[a]++;
    cnt[b]++;
  }

  bool ans = true;
  for(int i = 0; i < N; i++){
    if(cnt[i] % 2 != 0){
      ans = false;
      break;
    }
  }

  if(ans){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	fmt.Println()
	var x int
	fmt.Scan(&x)
	fmt.Println(profit(x))
}

func profit(x int) int {
	count := 0
	for i:=100;i < x;{
	i += i/100
	count ++
	}
	return count
}


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

int main() {
  
  int a,b,k;
  cin >> a >> b >> k;
  
  int i = min(a,b),count = 0;
  
  while(true){
    if ( a % i == 0 && b % i == 0){
      count++;
    }
    if ( count == k ){
      cout << i << endl;
      return 0;
    }
    i--;
  }
 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, A, x, y, answer;
int select_from_arrangement[25] = {0};
int testimony[25] = {0};

int check_honesty(int);
int extract_honest_people(int);

int main() {

    cin >> N;

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

        cin >> A;

        for(int j = 0; j < A; ++j){

            cin >> x >> y;

            testimony[i] |= (y << (x - 1));

            select_from_arrangement[i] |= (1 << (x - 1));

        }

    }

    for(int arrangement = 0; arrangement < (1 << N); ++arrangement)
            if(check_honesty(arrangement) == true)
                    answer = max(answer, extract_honest_people(arrangement));

    cout << answer;

}

int check_honesty(int arrangement) {

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

        int honesty_of_person, does_testimony_match;

        if((arrangement & (1 << i)) > 0)
                honesty_of_person = true;
        else
                honesty_of_person = false;

        if((arrangement & select_from_arrangement[i]) == testimony[i])
                does_testimony_match = true;
        else
                does_testimony_match = false;

        if(honesty_of_person == true &&
           does_testimony_match == false)
                return false;

        if(honesty_of_person == false &&
            does_testimony_match == true)
                return false;

    }

    return true;

}

int extract_honest_people(int arrangement) {

    int counter = 0;

    while(arrangement) {

        ++counter;

        arrangement &= (arrangement - 1);

    }

    return counter;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[57][57];
int main(){
	Lancer();
	ll n, p = 0, w = 0, g = 0, y = 0;
	char c;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> c;
		if (c == 'P')
			p++;
		else if (c == 'W')
			w++;
		else if (c == 'G')
			g++;
		else
			y++;
	}
	if (p && w && g && y)
		cout << "Four";
	else
		cout << "Three";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c,x,y,cost=0;
	cin>>a>>b>>c>>x>>y;
	if(a+b>2*c){
		int t=min(x,y);
		cost+=t*2*c;
		x-=t;
		y-=t;
		if(x){
			if(a<2*c) cost+=a*x;
			else cost+=2*c*x;
		}
		else{
			if(b<2*c) cost+=b*y;
			else cost+=2*c*y;
		}
	}
	else{
		cost=x*a+b*y;
	}
	cout<<cost<<'\n';
}



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

const int MAX = 1e6 + 10;

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

	int ans = MAX;
	int ansvalue = 0;
	for(int i=1;i<=n;i++){
		if(abs(L+i-1) < ans){
			ans = abs(L+i-1);
			ansvalue = L+i-1;
		}
	}

	int sum = n*(L-1) + (n*(n+1))/2;
	sum -= (ansvalue);
	cout<<sum;
}

Measured memory_bytes: 256
<?php

while($line = fgets(STDIN)){
	$q = intval($line);
	if($q < 0){
		// ??????
		break;
	}
	if($q == 0){
		// 0???????????????
		echo "0\n";
		continue;
	}
	
	$x = $q/2.0;
	while(true){
		$d = $x*$x*$x - $q;
		if(abs($d) < 0.00001*$q){
			break;
		}
		
		$x = $x - $d/(3.0*$x*$x);
	}
	
	echo $x."\n";
}

Measured memory_bytes: 15012
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, h, w, a, b, res;

signed main() {
	cin >> n >> h >> w;
	rep(i,n) {
		cin >> a >> b;
		if (h<=a && w<=b) res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
# ABC091B

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)


Measured memory_bytes: 3188
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 924844033;
 
////////////////////////////////////////////////////////////////////
 
const int N = 5e5 + 5;


int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int b = 0;
	ll sum = 0;
	string S; cin >> S;
	for (char c : S) {
		if (c == 'B') b++;
		else sum += b;
	}
	cout << sum << endl;

	return 0;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;

int a[maxn];
int n;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);
  cin >> n;
  ll sum = 0;
  int cnt = 0, ok = false, mi = inf;
  for (int i = 1; i <= n; ++i){
    cin >> a[i]; sum = sum + abs(a[i]);
    if (a[i] < 0){
      ++cnt;
    }
    mi = min(mi, abs(a[i]));
    if (a[i] == 0) ok = true;
  }
  if (ok || cnt % 2 == 0){
    cout << sum;
  } else cout << sum - 2ll * mi;
return 0;
}



Measured memory_bytes: 640
// skyrim belongs to the nords
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back 
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end() 
#define LOGN 18
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

struct Data {
	ll x;
	int u, m; 
	Data() {}
	Data(int v, int bb, ll y) {
		u = v;
		m = bb;
		x = y;
	}
	bool operator < (const Data& other) const {
		if (x != other.x) return x > other.x;
		if (m != other.m) return m > other.m;
		return u > other.u;
	}
};
ll d[205][300];
bool iss[205];
vector<int> vc;
map<int, int> mep;
vector< pair<int, ll> > adj[205];
int N, val, M, R, MASK;

priority_queue<Data> pq;
ll dijkstra(int source, int sink) {
	for (int i = 0; i < 201; i++) {
		for (int j = 0; j < 257; j++) {
			d[i][j] = (ll) 1e15; 
		}
	}
	d[source][1 << source] = 0;
	pq.push(Data(source, (1 << source), d[source][1 << source]));
	int counter = 0;
	while (!pq.empty()) {
		Data a = pq.top(); pq.pop(); 
		if (a.x > d[a.u][a.m]) continue; 
		for (auto &b: adj[a.u]) {
			int v = b.first;
			ll c = b.second;
	
			int nm = iss[v] ? (a.m | (1 << v)) : (a.m); //TODO
			if (d[v][nm] > a.x + c) {
				d[v][nm] = a.x + c;
				pq.push(Data(v, nm, d[v][nm]));
			}
		}
	} 
	return d[sink][MASK];
}

int main(){
	fcin;
	cin.tie(0);
	
	cin >> N >> M >> R;
	MASK = 0;
	int IDX = 0;
	for (int i = 0; i < R; i++) {
		int x;
		cin >> x;
		x--; 
		if (!mep.count(x)) mep[x] = IDX++;
		MASK |= (1 << mep[x]);
		iss[mep[x]] = true;
		vc.push_back(mep[x]);
	}
	int a, b;
	ll c;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--;
		b--;
		if (!mep.count(a)) mep[a] = IDX++;
		if (!mep.count(b)) mep[b] = IDX++;
		int aa = mep[a], bb = mep[b];

		adj[aa].push_back(make_pair(bb, c));
		adj[bb].push_back(make_pair(aa, c));
	}
	ll ans = (ll) 1e15; 
	for (int i = 0; i < vc.size(); i++) {
		for (int j = i + 1; j < vc.size(); j++) {
			ll res = dijkstra(vc[i], vc[j]);
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}
 

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  vi X(N),Y(N);
  rep(i,0,N) cin>>X[i]>>Y[i];
  int ans=-1;
  rep(i,0,N){
    rep(j,i+1,N){
      int P=min(X[i],X[j]),Q=max(X[i],X[j]);
      vi A;
      rep(k,0,N){
        if(P<=X[k]&&X[k]<=Q) A.pb(Y[k]);
      }
      sort(ALL(A));
      int M=A.size();
      if(M>=K){
      int sum=A[K-1]-A[0];
      REP(i,1,M-K){
        sum=min(sum,A[K+i-1]-A[i]);
      }
        if(ans==-1) ans=sum*(Q-P);
        else ans=min(ans,sum*(Q-P));
      }
    }
  }
  cout<<ans<<endl;
  }





Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
/// Author : Tanvir Ahmed ///
/// Department of Computer Science ///
/// & Engineering ///
/// Comilla University , Bangladesh. ///
///...................................*****.................................................///

/*....................................Values................................................*/
#define inf 1<<30
#define p5 100007
#define p6 1000007
#define PI acos(-1)
#define M 1000000007

/*....................................Functions.............................................*/
#define sqr(x) x*x
#define sc scanf
#define pf printf
#define scin(x) sc("%d",&(x))
#define scin2(x,y) sc("d",&(x),&(y))
#define scin3(x,y,z) sc("d%d",&(x),&(y),&(z))
#define scln(x) sc("%lld",&(x))
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(), v.end()
#define ok cout << "ok" << endl
#define mem(x,y) memset(x,y,sizeof(x))
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

/*...................................Data_Types............................................*/
#define lli long long int
#define ull unsigned long long int
#define pii pair < int, int>
#define pll pair < ll, ll>
#define veci vector<int>
#define vecl vector<long long int>
#define vecp vector< pair<int,int> >
#define mapstrint map< string , int >
#define mapstrstr map< string , string >
#define mapint map< int, int >
#define uset unordered_set
#define umap unordered_map
#define pq priority_queue

#define pb push_back
#define mp make_pair
#define ss stringstream

/*.....................................Loops...............................................*/
#define rep( i , a , b ) for( i=a ; i<b ; i++)
#define rev( i , a , b ) for( i=a ; i>=b ; i--)
#define repx( i ,a,b, x) for( i=a ; i<b ; i+=x)

#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)

//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//long power(long int x, long int y){ int temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; }
/*lli gcd(lli x,lli y)
{
if(x==0) return y;
return gcd(y%x,x);
}*/
/*
int dx[5] = {1, -1, 0, 0 };
int dy[5] = {0, 0, 1, -1};
*/

using namespace std;

lli a[100005],dp[100005];

int main()
{
    int n,k;
    scin(n);
    scin(k);
    for(int i=0; i<n; i++)
    {
        scin(a[i]);
        dp[i] = 1e10;
    }
    //mem(dp,1e7);
    dp[0] =0 ;
    for(int i=0; i<n; i++)
    {
        int tot = i+k;
        for(int j = i+1; j<=tot and j<n; j++)
        {
            dp[j] = min(dp[j],abs(a[i]-a[j])+dp[i]);
            //cout<<dp[j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


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

typedef priority_queue<int> maxHeap;
typedef priority_queue<int, vector<int>, greater<int>> minHeap;
#define endl "\n"
#define int long long
#define MOD 1000000007
#define PI 3.1415926535897932384626433832795
#define max(x, y) ((x > y) ? x : y)
#define min(x, y) ((x < y) ? x : y)
#define mid(s, e) ((s + (e - s) / 2))

bool test_cases;

void init(bool k) {
    test_cases = k;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

struct precompute {
    void compute() {
    }
};

int dp[1002][1002];

struct test_cases {
    int n = 1, m = 1;
    int paths(char grid[1002][1002], int i, int j) {
        if (i >= n || i <= -1 || j >= m || j <= -1 || grid[i][j] == '#')
            return 0;
        else if (i == n - 1 && j == m - 1)
            return 1;

        if (dp[i][j] != -1) return dp[i][j];

        dp[i + 1][j] = paths(grid, i + 1, j) % MOD;
        dp[i][j + 1] = paths(grid, i, j + 1) % MOD;
        return (dp[i + 1][j] % MOD + dp[i][j + 1] % MOD) % MOD;
    }

    void test_case() {
        memset(dp, -1, sizeof dp);
        cin >> n >> m;
        char grid[1002][1002];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> grid[i][j];
            }
        }

        cout << paths(grid, 0, 0) << endl;
    }
};

int32_t main() {
    init(false);
    int tc;
    if (test_cases) {
        cin >> tc;
    } else {
        tc = 1;
    }
    struct precompute l;
    l.compute();
    for (int i = 0; i < tc; i++) {
        struct test_cases o;
        o.test_case();
    }
    return 0;
};

Measured memory_bytes: 12572
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int nCount,iStart,iEnd;
	register int i,nTotal=0;
	cin >> nCount;
	for (i = 1; i <= nCount; ++i){
		cin >> iStart >> iEnd;
		nTotal += iEnd - iStart + 1;
	}
	cout << nTotal << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
int a[101];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=2;
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0 && dp[i-a[j]]==2)
            {
                dp[i]=1;
                break;
            }
            dp[i]=2;
        }
    }
    if(dp[k]==1)
        cout<<"First\n";
    else
        cout<<"Second\n";
    return 0;
}


Measured memory_bytes: 640
"""
a = int(input())
b, c = map(int, input().split())
s = input()
print(a + b + c, s)
"""
# input()             'S T'
# input().split()     'S', 'T'


  # S = 'oder atc'
S, T = input().split() #S,T = 'oder','atc'

    

    
print(T+S)





Measured memory_bytes: 2940
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<set>

#include<vector>

using namespace std;
const int mod=998244353;
typedef long long ll;
ll ksm(ll x,ll k){ll re=1;for(;k;k>>=1,x=x*x%mod)if(k&1)re=re*x%mod;return re;}
int pls(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int mns(int x,int y){return x-y<0?x-y+mod:x-y;}
const int N=310,K=45010;
int n,a[N],s;
int dp[2][K],cnt[2][K],ret;
int main(){
	//freopen("a.in","r",stdin);
	scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),s+=a[i];
	s/=2;
	int nw=0;
	dp[0][0]=cnt[0][0]=1;
	for(int i=1;i<=n;i++){
		nw^=1;
		for(int j=s;j>=a[i];j--) dp[nw][j]=pls(dp[nw^1][j],pls(dp[nw^1][j-a[i]],dp[nw^1][j-a[i]])),cnt[nw][j]=pls(cnt[nw^1][j],cnt[nw^1][j-a[i]]);
		for(int j=a[i]-1;~j;j--)dp[nw][j]=dp[nw^1][j],cnt[nw][j]=cnt[nw^1][j];
	}
	for(int i=1;i<=s;i++)ret=pls(ret,mns(dp[nw][i],pls(cnt[nw][i],cnt[nw][i])));
	ret=(ksm(3,n)-3*ksm(2,n)+3-(ll)ret*3)%mod;ret=(ret+mod)%mod;
	printf("%d\n",ret);
}

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

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

Measured memory_bytes: 256