akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op == '?')
            break;
        else if(op == '+')
            cout << a+b << endl;
        else if(op == '-')
            cout << a-b << endl;
        else if(op == '*')
            cout << a*b << endl;
        else if(op == '/')
            cout << a/b << endl;
        else;
    }
    
    return 0;
}



Measured memory_bytes: 3092
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
    count += 1
  T, X, Y = t, x, y
  
print('Yes' if count == N else 'No')

Measured memory_bytes: 3060
#include <iostream>
    #include <cstdio>
    #include <vector>
    using namespace std;
     
    const int N = 10;
     
    int n, m, k, u, ans = 0, p[N];
    vector<int> ve[N];
     
    bool check(int msk)
    {
        for (int i = 0; i < n; i++)
        {
            int cur = 0;
            for (int &v : ve[i])
                cur ^= (msk >> v & 1);
            if (cur != p[i])
                return false;
        }
        return true;
    }
     
    int main()
    {
        cin >> m >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> k;
            while (k--)
            {
                cin >> u;
                ve[i].push_back(u - 1);
            }
        }
        for (int i = 0; i < n; i++)
            cin >> p[i];
        for (int msk = 0; msk < (1 << m); msk++)
            if (check(msk))
                ans++;
        cout << ans;
    }

Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int part[200005];
int lankt[200005];
int parc[214514],lankc[214514];
void init(int n){
    for(int i=0; i<n; i++){
        part[i]=i;
        lankt[i]=0;
        parc[i]=i;
        lankc[i]=0;
    }
}
int findt(int x){
    if(part[x]==x){
        return x;
    }else {
        return part[x]=findt(part[x]);
    }
}
int findc(int x){
    if(parc[x]==x){
        return x;
    }else {
        return parc[x]=findc(parc[x]);
    }
}
void unitet(int x,int y){
    x=findt(x);
    y=findt(y);
    if(x==y)return;
    if(lankt[x]<lankt[y]){
        part[x]=y;
    }else {
        part[y]=x;
        if(lankt[x]==lankt[y])lankt[x]++;
    }
}
void unitec(int x,int y){
    x=findc(x);
    y=findc(y);
    if(x==y)return;
    if(lankc[x]<lankc[y]){
        parc[x]=y;
    }else {
        parc[y]=x;
        if(lankc[x]==lankc[y])lankc[x]++;
    }
}
bool samet(int x,int y){
    return findt(x)==findt(y);
}
bool samec(int x,int y){
    return findc(x)==findc(y);
}
signed main(){
    int n,k,l;cin>>n>>k>>l;
    init(n);
    rep(i,0,k){
        int a,b;cin>>a>>b;
        unitec(a-1,b-1);
    }
    rep(i,0,l){
        int a,b;cin>>a>>b;
        unitet(a-1,b-1);
    }
    vector<P> v;
    rep(i,0,n){
        v.push_back(P(findt(part[i]),findc(parc[i])));
    }v.push_back(P(inf,inf));
    sort(v.begin(),v.end());
    rep(i,0,n){
        cout<<upper_bound(v.begin(),v.end(),P(findt(part[i]),findc(parc[i])))-lower_bound(v.begin(),v.end(),P(findt(part[i]),findc(parc[i])));
        if(i==n-1)cout<<endl;else cout<<" ";
    }
    return 0;
}


Measured memory_bytes: 12272
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
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;}
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int n=min(a,b);
  int m=max(a,b);

  int k=0;
  rep(i,m){
    k*=10;
    k+=n;
  }

  cout<<k<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int usagiCount = int.Parse(Reader.ReadLine());

        int[] suki = Reader.ReadLine().Split(' ').Select(a => int.Parse(a) - 1).ToArray();

        int ans = 0;
        for (int i = 0; i < suki.Length; i++)
        {
            if (suki[i] < i)
            {
                if (suki[suki[i]] == i)
                {
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);


    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

5
5 5 5 5 1


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 10968
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    double r;
    scanf("%lf", &r);
    printf("%f %f\n", 3.141592653589*r*r, 2*r*3.141592653589);
    //cout << 4 * 3.141592653589 * r * r << " " << 2 * r * 3.141592653589 << endl;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }


int main(void){
  ios::sync_with_stdio(false);

  int N;
  string S;

  cin >> N;
  cin >> S;
  string ans;
  if (N%2 != 0){ans = "No";}

  else{
    int tmp = N /2;
    string str1, str2;
    str1 = S.substr(0, tmp);
    str2 = S.substr(tmp, N);
    if (str1 == str2){ans = "Yes";}
    else ans = "No";
  }


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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    ll k,n;
    cin>>k>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll diff=abs(k-a[n-1]+a[0]);
    rep(i,n-1){
        diff=max(diff,abs(a[i]-a[i+1]));
    }
    cout<<k-diff<<endl;
}


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

int main() {
  int n;
  cin >> n;
  if(n==2) {
    cout << 2;
    return 0;
  }
  while(true){
    for(int i=2;i<n;i++){
      if(n%i==0) break;
      if(i>sqrt(n)){
        cout << n;
        return 0;
      }
    }
    n++;
  }   
}


Measured memory_bytes: 256
import random
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def score(tt):
    ans=0
    for i,t in enumerate(tt):
        t-=1
        ans += ss[i][t]
        p = i - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
        last[t] = i + 1
    for t in range(26):
        p = d - last[t]
        ans -= p * (p + 1) // 2 * cc[t]
    return ans

inf=10**16
d = II()
cc = LI()
ss = LLI(d)
ans = 0
last = [0] * 26
tt=list(range(1,27))*(d//26+1)
tt=tt[:d]
mx = score(tt)
for _ in range(20000):
    i=random.randrange(d)
    best=tt[i]
    for j in range(1,27):
        tt[i]=j
        cur=score(tt)
        if cur>mx:
            mx=cur
            best=j
    tt[i]=best
#print(score(tt))
print(*tt,sep="\n")


Measured memory_bytes: 84924
package main

import (
	"fmt"
)

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

	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&(B[i]))
	}

	num := 0
	for i := 0; i < N; i++ {
		tmp := 0
		for j := 0; j < M; j++ {
			var A int
			fmt.Scan(&A)
			tmp += A * B[j]
		}
		tmp += C
		if tmp > 0 {
			num++
		}
	}

	fmt.Println(num)
}

Measured memory_bytes: 512
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
int main(){
	 ll m = 1000000007;
     ll n ; cin >> n ;
     vector<ll> v(n);
     for(ll i = 0 ; i < n ; i++){
     	cin >> v[i];
	 }
	 ll f[68] = {0};
//	 for(auto x:f) cout << x << " ";
//	 cout << endl;
	 for(ll i = 0 ; i < n ; i++){
	 	  for(ll j = 0 ; j < 63  ; j++){
	 	  	    if((v[i] & (1LL << j)))
	 	  	       f[j]++;
		   }
	 }
	// for(auto x :f) cout << x << " ";
	// cout << endl;
	 ll res = 0 ;
	 for(ll i = 0 ; i < 63 ; i++){
	 	  ll x = f[i];
	 	  ll z = (n-x);
	 	  ll ans = power(2 , i , m);
	 	  //cout << x << " " << z << " " << ans << endl;
	 	  ll ans2 = ( x % m * z % m) % m ;
	 	  ans2 = ( ans2 % m * ans%m) % m ;
	 	  res = ( res % m + ans2%m) %m ;
	 }
	 cout << (res)%m << endl;
}



Measured memory_bytes: 5624
#include<stdio.h>
#include<vector>
#include<cmath>
#include<algorithm>
#include<tuple>

using namespace std;

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

pii operator-(const pii &l, const pii &r){
	return pii(l.first - r.first, l.second - r.second);
}

int operator/(const pii &l, const pii &r){
	return l.first * r.second - l.second * r.first;
}

int sign(pii x){ return pii(0, 0) < x ? 1 : -1; }
double atan2(pii x){ return atan2(x.second, x.first); }

const int MX = 100005;
const int MM = 1000000007;

pii D[MX][2];
int R, C, N;

int value(pii x){
	if( x.first == 0 ) return x.second;
	if( x.first == R ) return 2*C+R-x.second;
	if( x.second == 0 ) return 2*C+2*R-x.first;
	if( x.second == C ) return C+x.first;
	return -1;
}

int main()
{
	scanf("%d%d%d", &R, &C, &N);
	for(int i = 1; i <= N; i++){
		scanf("%d%d%d%d", &D[i][0].first, &D[i][0].second, &D[i][1].first, &D[i][1].second);
	}
	vector<pii> V;
	for(int i = 1; i <= N; i++){
		int a = value(D[i][0]), b = value(D[i][1]);
		if( a == -1 || b == -1 ) continue;
		if( a < b ) V.emplace_back(a, i), V.emplace_back(b, -i);
		else V.emplace_back(b, i), V.emplace_back(a, -i);
	}
	sort(V.begin(), V.end());
	vector<int> X;
	for(pii c : V){
		int ad = c.second;
		if( ad > 0 ) X.push_back(ad);
		else{ ad *= -1;
			if(X.empty() || X.back() != ad) return !printf("NO\n");
			X.pop_back();
		}
	}
	printf("YES\n");
}


Measured memory_bytes: 4084
import Data.Char
import Control.Monad
import Control.Monad.ST
import Data.Array.ST

modifyArray :: (Ix i) => STUArray s i Int -> i -> (Int->Int) -> ST s ()
modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readLn >>= print.sol

keta = 9

sol :: Int -> Int
sol n = runST $ do
    dp <- newArray (((0,False),(False,False,False)),((keta,True),(True,True,True))) 0 :: ST s (STUArray s ((Int,Bool),(Bool,Bool,Bool)) Int)
    writeArray dp ((0,False),(False,False,False)) 1
    --
    forM_ [(i,b,d,x,e3,e5,e7)|(i,d)<-zip [0..] nd, b<-[False,True], x<-[0,3,5,7], [e3,e5,e7]<-replicateM 3 [False,True], b || x<=d, not (e3||e5||e7) || x/=0] $ \(i,b,d,x,e3,e5,e7) -> do
        let nb = b || x<d
        let n3 = e3 || x==3
        let n5 = e5 || x==5
        let n7 = e7 || x==7
        modifyArray dp ((i+1,nb),(n3,n5,n7)) =<< (+) <$> readArray dp ((i,b),(e3,e5,e7))
    (+) <$> readArray dp ((keta,False),(True,True,True)) <*> readArray dp ((keta,True),(True,True,True))
    where
        ns = show n
        nd = map digitToInt $ replicate (keta - length ns) '0' ++ ns

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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  double cur_dif = 1000;
  int cur_point = 0;
  for(int i=0; i<N; i++){
    double tem = T - H.at(i)*0.006;
    double dif = fabs(A-tem);
    if(dif < cur_dif){
      cur_dif = dif;
      cur_point = i+1;
    }
  }
  cout << cur_point << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  set<string> se;
  rep(i,n){
    string s; cin>>s;
    se.insert(s);
  }
  cout<<se.size()<<endl;
}

Measured memory_bytes: 19244
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main () {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b; cin >> a >> b; a--; b--;
        uf.unite(a, b);
    }
    int ans = 0;
    rep(i, n) chmax(ans, uf.size(i));
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4008
#######################################
prime = 10**9+7

def sowa(num):
  return int((1+num)*num//2)
#######################################
n,k = map(int, input().split())
a = list(map(int, input().split()))

tento1 = [sum([1 if a[i]>a[j] else 0 for j in range(i+1,n)]) for i in range(n-1)]
tento2 = [sum([1 if a[i]>a[j] else 0 for j in range(n)]) for i in range(n)]


ret = (sum(tento1) *k %prime) + (sum(tento2) *(sowa(k-1) %prime) %prime)
print(int(ret%prime))


Measured memory_bytes: 3188
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

ll width(ll a, ll b, ll c) {
    return max(a, max(b, c)) - min(a, min(b, c));
}

int main() {
    ll H, W;
    cin >> H >> W;
    ll ans = numeric_limits<ll>::max();
    rep(phase,0,2) {
        rep(h,1,H) {
            if (h >= 2) {
                ans = min(ans, width(H-h, h/2, h-h/2)*W);
            }
            ans = min(ans, width((H-h)*W, h*(W/2), h*(W-W/2)));
        }
        swap(W, H);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int n, m;

int x[5005], y[5005];
vi compressed_x, compressed_y;

int a[5005][5005];

int main()
{
    scanf("%d%d",&n,&m);

    rep(i, n) {
        cin >> x[i] >> y[i];
        compressed_x.PB(x[i]);
        compressed_y.PB(y[i]);
    }

    sort(all(compressed_x));
    sort(all(compressed_y));

    compressed_x.erase(unique(all(compressed_x)), end(compressed_x));
    compressed_y.erase(unique(all(compressed_y)), end(compressed_y));

    rep(i, n) {
        int xidx = lower_bound(all(compressed_x), x[i]) - begin(compressed_x);
        int yidx = lower_bound(all(compressed_y), y[i]) - begin(compressed_y);

        a[yidx][xidx]++;
    }

    for (int i = 0; i < compressed_y.size()+1; ++i) {
        for (int j = 0; j < compressed_x.size()+1; ++j) {
            if (i - 1 >= 0) a[i][j] += a[i - 1][j];
        }
    }

    for (int i = 0; i < compressed_x.size()+1; ++i) {
        for (int j = 0; j < compressed_y.size()+1; ++j) {
            if (i - 1 >= 0) a[j][i] += a[j][i - 1];
        }
    }

    compressed_x.PB(inf);
    compressed_y.PB(inf);

    rep(i, m) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

        x1 = lower_bound(all(compressed_x), x1) - begin(compressed_x);
        x2 = upper_bound(all(compressed_x), x2) - begin(compressed_x) - 1;
        y1 = lower_bound(all(compressed_y), y1) - begin(compressed_y);
        y2 = upper_bound(all(compressed_y), y2) - begin(compressed_y) - 1;

        if (x2 < 0 || y2 < 0) {
            printf("0\n");
            continue;
        }

        int ans = 0;
        ans += a[y2][x2];
        if (y1 - 1 >= 0) ans -= a[y1 - 1][x2];
        if (x1 - 1 >= 0) ans -= a[y2][x1 - 1];
        if (y1 - 1 >= 0 && x1 - 1 >= 0) ans += a[y1 - 1][x1 - 1];
        
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 101112
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 5 != 0 && i % 3 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3596
using static System.Console;

namespace AOJ
{
    public class ALDS1_1_B
    {
        public static void Main(string[] args)
        {
            string[] input = ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            WriteLine(GreatestCommonDivisor((uint)a,(uint)b));
        }

        public static uint GreatestCommonDivisor(uint x, uint y)
        {
            while (x != 0 && y != 0)
            {
                if (x > y) x %= y; else y %= x;
            }

            return x == 0 ? y : x;
        }
    }
}



Measured memory_bytes: 17884
def unbounded_knapsack(items, budget)
    table = [0]
    for i in 1..budget
        table[i] = 0
        items.each{|c, v|
            next if c > i
            x = table[i-c] + v
            table[i] = x if x > table[i]
        }
    end
    table[budget]
end

n, budget = gets.split.map &:to_i
items = $<.map{|s| s.split.map(&:to_i).reverse}
p unbounded_knapsack(items, budget)

Measured memory_bytes: 6184
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;

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

    vector<vector<LL>> dp(1<<n,vector<LL>(2,0));
    for(int i = 0; i < 1<<n; i++){
        dp[i][0] = a[i];
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 1<<n; j++){
            if(j&(1 << i)){
                LL x = dp[j^(1<<i)][0];
                LL y = dp[j^(1<<i)][1];
                if(dp[j][0] < x){
                    LL tmp = dp[j][0];
                    dp[j][0] = x;
                    if(tmp < y){
                        dp[j][1] = y;
                    }else{
                        dp[j][1] = tmp;
                    }
                }else if(dp[j][1] < x){
                    dp[j][1] = x;
                }
            }
        }
    }

    LL ans = 0;

    for(int i = 1; i < 1<<n; i++){
        ans = max(ans,dp[i][0]+dp[i][1]);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=2000;
int n,res=0;
bitset<M> dpl[M],dpr[M],L[M],R[M];

int main(){
	cin>>n;
	for(int i=1;i<n;i++) for(int j=0;j<i;j++){
		char c;
		cin>>c;
		if(c=='1') L[i-j][j]=1;
		else R[i-j][i]=1;
	}
	for(int i=0;i<n;i++) dpl[0][i]=dpr[0][i]=1;
	for(int i=1;i<n;i++) for(int j=0;j<i;j++){
		dpl[i]|=(dpl[j]&dpr[i-j-1]&L[i-j])<<(i-j);
		dpr[i]|=(dpl[j]&dpr[i-j-1]&R[j+1])>>(j+1);
	}
	for(int i=0;i<n;i++) if(dpl[i][i]&&dpr[n-i-1][i]) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 2304
import sys
input = sys.stdin.readline
import itertools


def main():
    N = int(input())
    P = [int(x) for x in input().split()]
    Q = [int(x) for x in input().split()]
    y = [int(x) for x in range(1, N + 1)]
    x = list(itertools.permutations(y))
    a = 0
    b = 0
    for i, v in enumerate(x):
        for j in range(N):
            if P[j] != v[j]:
                break
        else:
            a = i
        for j in range(N):
            if Q[j] != v[j]:
                break
        else:
            b = i
    print(abs(a - b))


if __name__ == '__main__':
    main()



Measured memory_bytes: 8052
#include<stdio.h>

int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a<b)
    {
        if (a<c)
        {
            if (b<c)
                printf("%d %d %d\n",a,b,c);
            else
                printf("%d %d %d\n",a,c,b);
        }
        else
            printf("%d %d %d\n",c,a,b);
    }
    else
    {
        if (b<c)
        {
            if (a<c)
                printf("%d %d %d\n",b,a,c);
            else
                printf("%d %d %d\n",b,c,a);
        }
        else
            printf("%d %d %d\n",c,b,a);
    }
    return 0;
}



Measured memory_bytes: 1996
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll A,B;
string S;
vector<ll> vec;


//解法
void solve() {
  
  bool flag = true;
  
  rep(i,A) {
    if (S[i]<'0' || S[i]>'9') flag=false;
  }
  if (S[A]!='-') flag = false;
  rep(i,B) {
    if (S[A+1+i]<'0' || S[A+1+i]>'9') flag = false;
  }
  
  cout << (flag ? "Yes" : "No");
  
	return;
}

int main() {
	//入力

	cin >> A>>B>>S;

	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        string n = rstr();
        if(n[0] == '7')
        {
            Write("Yes");
            return;
        }
        else if(n[1] == '7')
        {
            Write("Yes");
            return;
        }
        else if(n[2] == '7')
        {
            Write("Yes");
            return;
        }
        Write("No");

    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 25884
N = list(map(int, input()))

ans = 0
carry = 0   #0 or 1 or 2. when 2, it means that it's optional between 0 and 1.
for i in range(len(N) - 1, -1, -1):
    if carry == 2:
        if N[i] >= 5:
            digit = N[i] + 1
            carry = 1
            ans += (10 - digit)
        else:
            digit = N[i]
            carry = 0
            ans += digit
    else:
        digit = N[i] + carry
        if digit >= 6:
            carry = 1
            ans += (10 - digit)
        elif digit <= 4:
            carry = 0
            ans += digit
        else:
            carry = 2
            ans += digit
        

if carry == 1:
    ans += carry

print(ans)

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int k; string s;
  cin >> k >> s;
  if (s.size() <= k) cout << s;
  else {
    for (int i = 0; i < k; i++) cout << s[i];
    cout << "...";
  }
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#define MAX_N 305
#define MAX_V 1000
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
struct edge{int to,cap,rev,id;};
vector<edge>G[MAX_N];
int N,M,S,T;
bool flg[MAX_N];
set<int>revd;
void add_edge(int f,int t,int cap,int id)
{
	edge a={t,cap,G[t].size(),id},
		 b={f,cap,G[f].size(),id+M};
	G[f].push_back(a);
	G[t].push_back(b);
}

int dfs(int n,int g,int f)
{
	if(n==g)return f;
	flg[n]=true;
	for(int i=0;i<G[n].size();i++)
	{
		edge &e=G[n][i];
		if(!flg[e.to]&&e.cap>0)
		{
			int d=dfs(e.to,g,min(f,e.cap));
			if(d>0)
			{
				e.cap-=d;
				if(e.id>=M)revd.insert(e.id-M);
				else if(e.id<M&&e.cap==0)revd.erase(e.id);
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_frow(int s,int t)
{
	int flow=0;
	revd.clear();
	for(;;)
	{
		memset(flg,0,sizeof(flg));
		int f=dfs(s,t,100000000);
		if(f==0)return flow;
		flow+=f;
	}
}

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		add_edge(x,y,1,i);
	}
	scanf("%d%d",&S,&T);
	S--;T--;
	printf("%d\n",max_frow(S,T));
	printf("%d\n",revd.size());
	for(set<int>::iterator it=revd.begin();it!=revd.end();it++)
		printf("%d\n",*it+1);
}

Measured memory_bytes: 1300
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
ll N,A,B;
vector<ll>h(100005);
bool isOK(ll mid){
	ll ret=0;
	for(int i=0;i<N;i++){
		if(h[i]-mid*B>0){
			ret+=(h[i]-mid*B+(A-B)-1)/(A-B);
		}
	}
	return ret<=mid;
}


int main(){
	init();
	ll N;cin>>N;
	vector<ll>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A.begin(),A.end());
	cout<<*(A.end()-1)-*A.begin()<<endl;
}


Measured memory_bytes: 1152
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,D = IL()
x = [IL() for i in range(N)]

cnt = 0
for i in itertools.combinations(x,2):
  num = 0
  for j in range(D):
    num += (i[0][j] - i[1][j])**2
  numa = math.sqrt(num)
  if int(numa) == math.ceil(numa):
    cnt += 1

print(cnt)

Measured memory_bytes: 21172
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	int ans = A1+A2+A3;
	if (ans>=22) cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF =ll(1e18)+5;


int main(){
    ll N,M;
    cin >> N >>M;
    vector<int> A(M);
    vector<int> C(M);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >>b;
        int S=0;
        for(int j=0;j<b;j++){
            int  c;
            cin >> c;
            --c;
            S |= (1<<c);
        }
        A[i] = a;
        C[i] = S;
        // cerr <<"S=" << S<<endl;
    }
    ll dp[M+1][(1<<N)];
    for(int i=0;i<M+1;i++){
        for(int bit =0;bit<(1<<N);bit++){
            dp[i][bit] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<M;i++){
        // cerr <<"i="<< i<< endl;
        for(int bit=0;bit<(1<<N);bit++){
            dp[i+1][bit] = min(dp[i][bit],dp[i+1][bit]);
            // cerr <<"bit=" <<bit <<endl;
            // cerr <<"bit|C[i]=" <<(bit|C[i]) << endl;
            dp[i+1][bit|C[i]] = min(dp[i][bit|C[i]],dp[i+1][bit|C[i]]);
            dp[i+1][bit|C[i]] = min(dp[i+1][bit|C[i]],dp[i][bit] +A[i]);
            // cerr <<"dp=" << dp[i+1][bit|C[i]]<<endl;
        }
        // cerr << dp[i+1][0] << endl;
    }
    if(dp[M][(1<<N)-1] == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << dp[M][(1<<N)-1] << endl;
    return 0;
}


Measured memory_bytes: 32256
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
inline int gi() { 
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 2e5 + 5; 
int N, val[MAX_N], f[MAX_N]; 
int ans, S, cnt[20], sum[MAX_N]; 
int main () { 
    N = gi(); 
    for (int i = 1; i < N; i++) {
        int u = gi(), v = gi(), w = gi(); 
        val[u] ^= w, val[v] ^= w; 
    } 
    for (int i = 0; i < N; i++) ++cnt[val[i]]; 
    for (int i = 1; i <= 15; i++) ans += (cnt[i] >> 1), S |= (cnt[i] & 1) << (i - 1); 
    for (int i = 1; i < (1 << 15); i++) f[i] = f[i >> 1] + (i & 1); 
    for (int i = 1; i < (1 << 15); i++) --f[i]; 
    for (int i = 1; i < (1 << 15); i++) 
        for (int j = 0; j < 15; j++) if ((i >> j) & 1) sum[i] ^= (j + 1); 
    for (int i = 1; i < (1 << 15); i++) 
        for (int j = (i - 1) & i; j; j = (j - 1) & i) 
            if (!sum[j]) f[i] = min(f[i], f[j] + f[i ^ j]); 
    printf("%d\n", f[S] + ans); 
    return 0; 
} 

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	string N;
	int A, B;
	cin >> N >> A >> B;
	int rec = 0;
	int ans = 0;
	for (int i = 1; i <= atoi(N.c_str()); i++) {
		for (int j = 0; j < to_string(i).length(); j++) {
			rec += to_string(i)[j] - '0';
		}
		if (rec >= A && rec <= B) {
			ans += i;
		}
		rec = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3708
import java.util.*;

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

        if ((a*b)%2 == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}


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

const int MAXN = 2e5;
int N, K;
int X[MAXN];

int main() {
	ios_base::sync_with_stdio(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> X[i];
	int res = 1e9;
	for (int i = 0; i + K <= N; i++) {
		int l = X[i], r = X[i + K - 1];
		int maxpos = max(0, max(l, r));
		int maxneg = max(0, max(-l, -r));
		res = min(res, maxpos + maxneg + min(maxpos, maxneg));
	}
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
struct interval_t { ll l, r; };
bool operator < (interval_t a, interval_t b) { return make_pair(a.l, a.r) < make_pair(b.l, b.r); }
bool is_mergeable(interval_t a, interval_t b) { return not (a.r <= b.l or b.r <= a.l); }
interval_t merge(interval_t a, interval_t b) { assert (is_mergeable(a, b)); return { min(a.l, b.l), max(a.r, b.r) }; }
interval_t shift(interval_t a, ll b) { return { a.l - b, a.r - b }; }
interval_t adjust(interval_t a, ll b) { ll l = (a.l % b + b) % b; return { l, a.r + (l - a.l) }; }
bool does_include(interval_t a, ll b) { return a.l <= b and b < a.r; }
int main() {
    int n; cin >> n;
    vector<ll> as(n); repeat (i,n) cin >> as[i];
    int ans = 0;
    for (ll e = 1; e <= ll(1e17); e *= 10) {
        repeat_from_reverse (d,1,10) {
            vector<interval_t> xs;
            xs.push_back({ d*e, (d+1)*e });
            for (ll a : as) {
                vector<interval_t> ys = xs;
                for (interval_t x : xs) {
                    ys.push_back(       shift(x, a % (10*e)));
                    ys.push_back(adjust(shift(x, a % (10*e)), 10*e));
                }
                xs.clear();
                whole(sort, ys);
                for (interval_t y : ys) {
                    if (y.r <= 0) continue;
                    if (xs.empty() or not is_mergeable(xs.back(), y)) {
                        xs.push_back(y);
                    } else {
                        xs.back() = merge(xs.back(), y);
                    }
                }
            }
            bool found = false;
            for (interval_t x : xs) {
                if (does_include(x, 0)) {
                    found = true;
                }
            }
            if (found) {
                ans += d;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int dp[55599];
int main()
{
	int n;
	cin >> n;
	rep(i, 2, 55556) {
		if (dp[i] == 1)continue;
		rep(k, 2, 55555 / i + 1) {
			dp[i * k] = 1;
		}
	}
	int x = 2, c = 0;
	while(1) {
		if (dp[x] == 0 && x % 5 == 1) {
			if (c == n - 1) {
				printf("%d\n", x);
				return 0;
			}
			else {
				printf("%d ", x);
			}
			c++;
		}
		x++;
	}
	return 0;
}


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

int main(int argc, char *argv[]) {
    int N;
    std::cin >> N;
    std::vector<char> v;
    
    char t;
    for(int i=0; i<N; i++) {
        std::cin >> t;
        v.push_back(t);
    }

    // for(int i=0; i<N; i++) {
    //     std::cout << v[i];
    // }

    int min=N+1;
    int p=0, q=0;
    for(int i=0; i<N; i++) {
        if(v[i]=='R') {
            q++;
        }
    }
    min = q;
 
    for(int b=1; b<v.size()+1; b++) {
        // for(int i=0; i<N; i++) {
        //     if(i<b && v[i]=='W') {
        //         p++;
        //     }
        //     if(i>=b && v[i]=='R') {
        //         q++;
        //     }
        // }
        if(v[b-1]=='W') {
            p++;
        }
        if(v[b-1]=='R') {
            q--;
        }
        // std::cout << "b=" << b << "pair(" << p << ", " << q << ")" << std::endl;
        int ans;
        if(p>q) {
            ans = q + (p-q);
        } else {
            ans = p + (q-p);
        }
        if(ans<min) 
            min = ans;

    }
    std::cout << min;

    return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

 // 0th row and 1st row for keeping track of which points can the 

// robot reach.  (atleast 2 rows required for such )

// 8000 acting as a starting point.

bool possible(vl v,ll target,ll start)
{

  vvl canReach(2,vl(16001,0));  

  canReach[1][8000+start]=1;
   
   for(auto d:v)
   {
   for(int i=0;i<=16000;i++)
   {
        if(canReach[1][i])
        {
          canReach[0][i-d]=1;
          canReach[0][i+d]=1;
          canReach[1][i]=0;
        }
   }

    for(int i=0;i<=16000;i++)
   {
        if(canReach[0][i])
        {
          canReach[1][i]=1;
          
          canReach[0][i]=0;
        }
   }

 }

 return canReach[1][8000+target];
}






int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);



string s;cin>>s;
ll x0,y0;
cin>>x0>>y0;

ll whichAxis=0;//intially x axis pe h ham.
ll cnt=0;
vl vx,vy;
for(char x:s)
{
  if(x=='T')
  {
    (whichAxis==0?vx:vy).pb(cnt);
      cnt=0;
      whichAxis=1-whichAxis;
  }
  else 
  {
    cnt++;
  }
}

(whichAxis==0?vx:vy).pb(cnt);

ll start=vx[0];
vx.erase(vx.begin());


//for(auto x:vy)cout<<x<<" ";

if(possible(vx,x0,start)&&possible(vy,y0,0))
{
  cout<<"Yes"<<"\n";

}

else cout<<"No"<<"\n";



return 0;

}


Measured memory_bytes: 780
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,m;cin>>n>>m;
  cout<<std::pow(2,m)*(1900*m+100*(n-m))<<endl;
}
  

Measured memory_bytes: 384
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int H, W;
char m[1000][1000];
int dp[1000][1000];

void solve()
{
    dp[0][0] = 1;
    REP (i, H) {
        REP (j, W) {
            if (m[i][j] == '#') continue;
            dp[i][j] += (i-1 >= 0 ? dp[i-1][j] : 0);
            dp[i][j] %= MOD;
            dp[i][j] += (j-1 >= 0 ? dp[i][j-1] : 0);
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H-1][W-1] << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    REP (i, H) REP (j, W) cin >> m[i][j];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5120