akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <map>
#include<cmath>
#include<queue>
#include<iomanip>
#include<cstring>
#include<list>

using namespace std;
typedef long long ll;
ll p[100005];
ll s[100005];
int main()
{
    ll n,t;
    scanf("%lld%lld",&n,&t);
    for(int i = 0; i < n; i++)
        scanf("%lld",&p[i]);
    s[0] = p[0];
    for(int i = 1; i < n; i++)
        s[i] = s[i-1] + p[i];
    ll maxn = p[0];
    printf("%lld\n",t/maxn+1);
    for(int i=1; i<n; i++)
    {
        if(p[i] > maxn)
            maxn = p[i];
        if(s[i] > t) printf("1\n");
        else printf("%lld\n",(t-s[i])/maxn+2);
    }
    return 0;
}



Measured memory_bytes: 4776
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int n(char c){
  return c - '0';
}
int main(void){
  char c[8][8];
  string s, ans;
  int l, x, y;
  strcpy(c[1], "abcde"); strcpy(c[2], "fghij"); strcpy(c[3], "klmno");
  strcpy(c[4], "pqrst"); strcpy(c[5], "uvwxy"); strcpy(c[6], "z.?! ");
 lbl:;
  while(cin >> s){
    l = s.size();
    if(l % 2){
      cout << "NA" << endl;
      continue;
    }
    ans = "";
    for(int i = 0;i < l; i += 2){
      x = n(s[i]); y = n(s[i + 1]);
      if(1 <= x && x <= 6 && 1 <= y && y <= 5)
	ans += c[x][--y];
      else{
	cout << "NA" << endl;
	goto lbl;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1188
# https://atcoder.jp/contests/abc143/tasks/abc143_b

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

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        ans += d_list[i] * d_list[j]

print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int a;
	string s;
	cin>>a;
	cin>>s;
	if(a>=3200)cout<<s<<endl;
	else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int y;
  int x;
  int dist;

  Node(int y = -1, int x = -1, int dist = -1) {
    this->y = y;
    this->x = x;
    this->dist = dist;
  }
};

const int DY[4] = {-1, 0, 1, 0};
const int DX[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;

  char grid[H][W];
  int visited[H][W];
  char a;

  queue<Node> que;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      cin >> a;
      grid[y][x] = a;
      visited[y][x] = H * W + 1;

      if (a == '#') {
        que.push(Node(y, x, 0));
      }
    }
  }

  int ans = 0;

  while (!que.empty()) {
    Node node = que.front();
    que.pop();

    if (visited[node.y][node.x] <= node.dist) continue;
    visited[node.y][node.x] = node.dist;

    ans = max(ans, node.dist);

    for (int i = 0; i < 4; i++) {
      int ny = node.y + DY[i];
      int nx = node.x + DX[i];
      if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue;
      if (grid[ny][nx] == '#') continue;

      que.push(Node(ny, nx, node.dist + 1));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 20512
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string agc("ACTG");
	string s;
	cin >> s;
	int64 res = 0, cnt = 0;
	REP(i, s.size()) {
		if (agc.find(s[i]) != string::npos) {
			cnt++;
		} else {
			res = max(res, cnt);
			cnt = 0;
		}
	}
	cout << max(res, cnt) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>




using sll = signed long long;
struct zxc{
	sll x, y;
	size_t a;
	zxc(sll x_ = 0, sll y_ = 0, size_t a_ = 0) :x(x_), y(y_), a(a_) {}
};
int main() {
	sll W, H;
	size_t N;
	std::cin >> W >> H >> N;
	//std::vector<zxc> vc;
	//vc.resize(N);
	sll x1{0}, y1{ 0 }, x2{ W }, y2{ H };

	for (size_t i{ 0 }; i < N; i++) {
		zxc z;
		std::cin >> z.x >> z.y >> z.a;
		if (z.a == 1) {
			x1 = std::max(x1, z.x);
		}
		if (z.a == 2) {
			x2 = std::min(x2, z.x);
		}
		if (z.a == 3) {
			y1 = std::max(y1, z.y);
		}
		if (z.a == 4) {
			y2 = std::min(y2, z.y);
		}
	}

	
	sll result = 0;

	if (( (x2 - x1) > 0) && ( (y2 - y1) > 0)) {
		result = (x2 - x1)*(y2 - y1);
	}

	if (result <= 0) {
		std::cout << 0 << "\n";
	}
	else {
		std::cout <<result << "\n";
	}
	
	return 0;
}

/*
5 4 0
2 1 1
3 3 4
*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int[] list = new int[lines.length];
        for (int i = 0; i < 5; i++) {
            list[i] = Integer.parseInt(lines[i]);
        }
        if (list[2] - list[4] < 0 || list[2] + list[4] > list[0] || list[3] - list[4] < 0 || list[3] + list[4] > list[1]) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 24468
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a[n];
  int sum=0;
  int cnt=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  //cout<<sum<<endl;
  int num=(sum+(4*m)-1)/(4*m);
  rep(i,n){
    if(a[i]>=num) cnt++;
  }
  if(cnt>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n,d;
  cin>>n>>d;
  int ans=0;
  vector<vector<int>>data(n,vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin>>data[i][j];
    }
  }
  rep(i,n){
    rep(j,i){
      int sum=0;
      rep(k,d){
        int dif=data[i][k]-data[j][k];
        sum+=dif*dif;
      }
      int s=sqrt(sum)+0.5;
      if(s*s==sum) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int k = sc.nextInt();
    if(e-a<=k && e-a>0){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}

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

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int chk = 1;
	while(A > 0 && C > 0){
		if(chk) C -= B;
		else A -= D;
		chk++;
		chk %= 2;
	}
	if(A <= 0) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    ll N = input<ll>(), K = input<ll>();

    ll res = 0;
    for (int i = 1; i <= N; i++)
    {
        ll h = input<ll>();
        if (h >= K)
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<int> adj[100010];
int a[100010];
int main () {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    int res=0;
    for(int i=1;i<=n;i++){
        int m = adj[i].size(),f=1;
        for(int j=0;j<m;j++)
            if(a[i]<=a[adj[i][j]])
                f=0;
        //cout<<f<<'\n';

        res+=f;
    }

    cout<<res;
}

Measured memory_bytes: 9132
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int s;
	cin >> s;
	vector<LL> dp(s + 1);
	dp[s] = 1;
	for(int i = s; i >= 0; --i){
		for(int j = i - 3; j >= 0; --j){
			dp[j] = (dp[j] + dp[i]) % MOD;
		}
	}
	cout << dp[0] << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3640
#include <stdio.h>

main()
{
	int n;
	int k;
	
	scanf("%d",&n);
	
	if(n<=1000)
	{
		k=1000-n;
	}
	else if(n>1000&&n<=2000)
	{
		k=2000-n;
	}
	else if(n>2000&&n<=3000)
	{
		k=3000-n;
	}	else if(n>3000&&n<=4000)
	{
		k=4000-n;
	}	else if(n>4000&&n<=5000)
	{
		k=5000-n;
	}	else if(n>5000&&n<=6000)
	{
		k=6000-n;
	}	else if(n>6000&&n<=7000)
	{
		k=7000-n;
	}	else if(n>7000&&n<=8000)
	{
		k=8000-n;
	}	else if(n>8000&&n<=9000)
	{
		k=9000-n;
	}	else if(n>9000&&n<=10000)
	{
		k=10000-n;
	}
	printf("%d",k);	
}

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

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v={a,b,c};
    sort(v.begin(), v.end());
    int ans = v[2] - v[1];
    int x = v[2] - (ans + v[0]);
    // cout << ans ;
    if (x%2==0)
        ans += x/2;
    else 
        ans += x/2 + 2;
    cout << ans;    
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ll h[110000];
    ll dp[110000];
    int N;
    cin >> N;
    rep(i, 0, N) {
        cin >> h[i];
    }
    rep(i, 0, 110000) {
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, 0, N) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i]);
        if (i > 1) {
            dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i]);
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 50*2501 + 5;
const ll meow = 2500;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct temp {int y, a, b;};
inline int coo (int x, int y) {return (x - 1)*(meow + 1) + y + 1;}
int n, m, s;
vpi adj[N];

void dijkstra (vi& d) 
{
    d.assign(N, inf);
    priority_queue<pi, vector<pi>, greater<pi>> q;

    d[s + 1] = 0, q.push({0, s + 1});
    
    while (!q.empty()) {
        int v = q.top().second;
        int d_v = q.top().first;
        q.pop();
        if (d_v != d[v])
            continue;

        for (auto edge : adj[v]) {
            int to = edge.first;
            int len = edge.second;

            if (d[v] + len < d[to]) {
                d[to] = d[v] + len;
                q.push({d[to], to});
            }
        }
    }
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m >> s;
	vector <temp> e[n + 1];
	FOR (i, 1, m)
	{
	    int x, y, a, b;
	    cin >> x >> y >> a >> b;
	    e[x].pb({y, a, b});
	    e[y].pb({x, a, b});
	}
	
	int c[n + 1], d[n + 1];
	FOR (i, 1, n) cin >> c[i] >> d[i];
	
	FOR (x, 1, n)
	    for (auto i: e[x])
	        FOR (s1, i.a, meow)
	            adj[coo(x, s1)].pb({coo(i.y, s1 - i.a), i.b});
	
	FOR (x, 1, n)
	    FOR (s1, 0, meow - c[x])
	        adj[coo(x, s1)].pb({coo(x, s1 + c[x]), d[x]});
	            
	s = min(s, meow);
	vi dis(N + 1);
	dijkstra(dis);
	
	int cur = meow + 1;
	FOR (i, 2, n)
	{
	    int ans = inf;
	    FOR (j, 0, meow) ans = min(ans, dis[++cur]);
	    print(ans);
	}
}


























Measured memory_bytes: 23580
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long solve(long N)
{
    if (N == -1) return 0;
    if (N%2 == 0) {
        return N ^ ((N/2)%2 == 0 ? 0 : 1);
    } else {
        return (N/2)%2 == 1 ? 0 : 1;
    }
}

void main()
{
    auto ab = readln.split.to!(long[]);
    writeln(solve(ab[0]-1) ^ solve(ab[1]));
}

Measured memory_bytes: 256
n = int(input())
aa = list(map(int,input().split()))

ans = 1
tmp = aa[0]
flg_asc = flg_desc = True

for a in aa:
  if tmp > a:
    flg_asc = False
  if tmp < a:
    flg_desc = False
  
  if not flg_asc and not flg_desc:
    ans += 1
    flg_asc = flg_desc = True
    
  tmp = a
  
print(ans)

Measured memory_bytes: 14252
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    dp = [(0,0,0)]*(N+1)
    for i in range(1,N+1):
        A = max(dp[i-1][1],dp[i-1][2])+a[i-1]
        B = max(dp[i-1][0],dp[i-1][2])+b[i-1]
        C = max(dp[i-1][0],dp[i-1][1])+c[i-1]
        dp[i]=(A,B,C)
    print(max(dp[-1]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32312
n, y = list(map(int, input().split()))
flag = False
for a_child in range(0, n+1):
    if flag:
        break
    a_child_result = y - a_child * 10000
    for b_child in range(0, n+1-a_child):
        b_child_result = a_child_result - b_child * 5000
        c_child = n - a_child - b_child
        c_child_result = b_child_result - c_child * 1000
        if c_child_result == 0:
            print(a_child, b_child, c_child)
            flag = True            
if flag:
    pass
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

main :: IO ()
main = do
  a <- readInt
  b <- readInt 
  c <- readInt 
  x <- readInt 
  print $ selection a b c x

selection
  :: Int -> Int -> Int -> Int -> Int
selection a b c x
  = length [(s,t,u) | s<-[0..a], t<-[0..b], u<-[0..c]
                    , 500*s + 100*t + 50*u == x]


Measured memory_bytes: 380
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max(x,max(y,z))
#define MX4(x,y,z,p) max(x,max(y,max(z,p)))
#define MX5(x,y,z,p,q) max(x,max(y,max(z,max(p,q))))
#define MN3(x,y,z) min(x,min(y,z))
#define MN4(x,y,z,p) min(x,min(y,min(z,p)))
#define MN5(x,y,z,p,q) min(x,min(y,min(z,min(p,q))))
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

void solve() {

    int a, b;
    SI(a);
    SI(b);
    if(b%a == 0) printf("%d\n", a+b);
    else printf("%d\n", b-a);

}

void init() {
    


}

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll num = max(a[0], 1LL), ans = max(0LL, 1-a[0]);
  for (int i = 1; i < n; i++) {
    if (i%2) {
      ans += max(num+a[i]+1, 0LL);
      num = min(-1LL, num+a[i]);
    } else {
      ans += max(1-(num+a[i]), 0LL);
      num = max(1LL, num+a[i]);
    }
  }
  num = min(a[0], -1LL);
  ll cnt = max(0LL, a[0]+1);
  for (int i = 1; i < n; i++) {
    if (i%2) {
      cnt += max(1-(num+a[i]), 0LL);
      num = max(1LL, num+a[i]);
    } else {
      cnt += max(num+a[i]+1, 0LL);
      num = min(-1LL, num+a[i]);
    } 
  }
  chmin(ans, cnt);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int dp[100005];
int main() {
	int n,k;
	cin>>n>>k;
	int a[n],i;
	for(i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	for(int i=1;i<=k;i++)
	{
		dp[i]=0;
		for(int j=0;j<n;j++)
		{
			if(i>=a[j]&&dp[i-a[j]]==0)
			{
				dp[i]=1;
				break;
			}
		}
		
	}
	if(dp[k]==1)
	cout<<"First"<<endl;
	else
	cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 3992
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int d[MAX];
  int p[MAX];
  int visited[MAX];
  int min = INFTY, v, u;

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  /* for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      printf("%d ", M[i][j]);
    }
    printf("\n");
    }*/

  for(i = 0; i < n; i++){
    d[i] = INFTY;
    visited[i] = 0;  //boolean
    p[i] = NIL;
  }
  d[0] = 0;
  
  while(1){
    u = NIL;
    min = INFTY;

    //d[u]が最小であるuを求める
    for(i = 0; i < n; i++){
      if(d[i] < min && !visited[i]){ //まだ訪れてない　かつ　最小のコスト
	u = i; //最小コストのv(i)を保存
	min = d[i]; //最小コストを保存
      }
    }

    if(u == NIL) break; //すべて訪れたら終わる
    visited[u] = 1;  //訪問したのでマークする

    for(v = 0; v < n; v++){
      if(d[v] >= M[u][v] && !visited[v]){
	d[v] = M[u][v];
	p[v] = u; //最短経路のvを保存
      }
    }
  }
	

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 804
N = int(input())
S = input()
sum_s = [0] * N
sum_s[0] = 1 if S[0] == 'W' else 0
for i in range(1, N):
    if S[i] == 'W':
        sum_s[i] = sum_s[i - 1] + 1
    else:
        sum_s[i] = sum_s[i - 1]

lc = 0
rc = (N - 1) - (sum_s[N - 1] - sum_s[0])
ans = lc + rc

for i in range(1, N):
    lc = sum_s[i - 1]
    rc = (N - (i + 1)) - (sum_s[N - 1] - sum_s[i])

    ans = min(ans, lc + rc)

print(ans)

Measured memory_bytes: 15264
while True:
    first_card=str(input())
    if first_card=='-':
        break
    m=int(input())

    for _ in range(m):
        h=int(input())
        a=first_card[:h]
        b=first_card[h:]
        second_card=b+a
        first_card=second_card

    print(first_card)


Measured memory_bytes: 5592
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
#include <string>
#include <cstdio>
#define ll long long
#define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef pair<int,int> pii;
const ll mod = 1000000007 ;
const int INF=0x3f3f3f3f;
#define test(n) cout<<"Test "<<n<<endl;
#define pb push_back
#define rp(n) for(int i=1;i<=n;i++)
#define rep(n,m) for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
ll ksm(ll x,ll n){ll ans=1;while (n){if (n&1)ans=(ans*x)%mod;x=x*x%mod;n>>=1;}return ans;}
using namespace std;
double pi = atan(1.0)*4 ;
const int mxn = 1e3+7 ;
int n,t,m,k,l,r;
/// ll mat[mxn][mxn], prime[mxn], isprime[mxn];
ll phi[mxn];
string str,s;char ch[27][27] ;
ll exgcd(ll a,ll b, ll &x ,ll &y){    if(!a&&!b) return -1;    if(!b) {x=1,y=0;return a;}    ll d=exgcd(b,a%b,y,x);    y-=a/b*x ;    return d;}
int vis[mxn][mxn];
int a[mxn];
int check(int x)
{
    int ans = 0 ;
    rp(n) ans+=(x-a[i])*(x-a[i]);
    return ans;
}
int main()
{
    cin>>n;
    int l = 1e3 ,r = -1;
    rp(n) {cin>>a[i];l = min(a[i],l) , r = max(a[i],r) ;}
    int mx = INF;
    for(int k=l;k<=r;k++)
    {
        rp(n)
        {
            int ans = check(k) ;
            if(ans < mx )
                m = k , mx = ans ;
        }

    }
    cout<<mx<<endl;
}



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

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	long long x = w[0];
	for (int i = 0; i < N; i++) {
		w[i] -= x;;
	}
	vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(200, vector<long long>(N + 1, 0)));
	for (int i = 0; i < N; i++) {
		for (long long j = 0; j < 200; j++) {
			for (int k = 0; k < i + 1; k++) {
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
				if (j >= w[i]) {
					dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1], dp[i][j - w[i]][k] + v[i]);
				}
			}
		}
	}
	long long ans = 0;
	for (long long i = 0; i < 200; i++) {
		for (long long j = 0; j < N + 1; j++) {
			if (i + x * j <= W) {
				ans = max(ans, dp[N][i][j]);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=5000,MAX_GSB=5000;
ll N,gsb[3][2],dp[MAX_N*MAX_GSB+1];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,2)REP(j,3)cin>>gsb[j][i];
	REP(i,2){
		dp[0]=0;
		FOR(j,1,MAX_N*MAX_GSB+1){
			dp[j]=dp[j-1]+1;
			REP(k,3){
				if(gsb[k][i]<=j){
					dp[j]=max(dp[j],gsb[k][1-i]+dp[j-gsb[k][i]]);
				}
			}
		}
		N=dp[N];
	}
	cout<<N<<endl;
}

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


#define all(v)           ((v).begin()), ((v).end())
#define sz size()
#define clr(v,d)         memset(v,d,sizeof(v))
#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define sci(a)	scanf("%d",&a)
#define scll(a)	scanf("%lld",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prll(a)	printf("%lld\n",a)
	

const int maxn = 300500;

typedef long long ll;

typedef pair<int, int> pii;

ll dp[maxn];


int main() {
	//freopen("in.in", "r", stdin);	
	int n; sci(n);
	int W; sci(W);
	lp(i, maxn) dp[i] = 1e18;
	dp[0] = 0;
	lp(i, n){
		int a, b; scii(a, b);
		for (int j = 100000; j >= b; j--)
			dp[j] = min(dp[j], dp[j - b] + a);
	}
	int ret = 0;
	lp(i, maxn) if (dp[i] <= W)
		ret = i;
	pri(ret);
}

Measured memory_bytes: 2560
n = int(input())
l = [int(input()) for _ in [0]*n]
#最大値が2つある場合に注意しないといけない。
#最大値が2つ以上ある場合を先に処理
import sys
if l.count(max(l))>1:
  m1 = max(l)
  for i in range(n):
    print(m1)
#O(n)の処理なら何回やってもいいくらいの気持ちでいく
else:
  s=set(l)
  m1 = max(s)
  s.remove(max(s))
  m2 = max(s)
  for i in l:
    if i == m1:
      print(m2)
    else:
      print(m1)

Measured memory_bytes: 17680
// ACM-ICPCアジア地区予選2013 B. The Last Ant

#include <iostream>
#include <vector>

using namespace std;

void solve(vector< pair<int,int> >& vp, int l){
	int leaveCnt = 0, lastID = 0;
	for(int t=1; ;++t){
		for(int i=0;i<vp.size();i++){
			if(vp[i].second != -1)
				vp[i].second += vp[i].first;
		}
		for(int i=0;i<vp.size();i++){
			for(int j=i+1;j<vp.size();j++){
				if(vp[i].second == vp[j].second) swap(vp[i], vp[j]);
			}
		}
		for(int i=0;i<vp.size();i++){
			if(vp[i].second == l){
				vp[i].second = -1;
				lastID = i+1;
				leaveCnt++;
			}
		}
		for(int i=0;i<vp.size();i++){
			if(vp[i].second == 0){
				vp[i].second = -1;
				lastID = i+1;
				leaveCnt++;
			}
		}
		if(leaveCnt == vp.size()){
			cout << t << " " << lastID << endl;
			return ;
		}
	}
}

int main(){
	int n, l;
	while(cin >> n >> l && n){
		vector< pair<int,int> > vp(n);
		for(int i=0;i<n;i++){
			string s; int p; cin >> s >> p;
			vp[i] = make_pair(s=="L" ? -1 : 1, p);
		}
		solve(vp, l);
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <set>
#include <vector>
using namespace std;
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define Rep(i,n) for(ll i = 0; i <= n; ++i)
#define yes "yes"
#define Yes "Yes"
#define no "no"
#define No "No"

namespace mydef
{
  void say(string some){
    cout << some << "\n";
  }
} // namespace mydef
using namespace mydef;
typedef long long ll;
const int INF = 1001001001;
const long double PI=3.14159265358979323846;

//ここからいじる
signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  

  int x, y;
  cin >> x >> y;
  int min = 2*x;
  int max = 4*x;
  if(y%2 == 0){
    if(min <= y && y <= max){
      say(Yes);
      return 0;
    }
  }
    say(No);
  

    return 0;
}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;

int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

int main() {
  int x;
  cin>>x;
  if(x%sum(x)) cout<<"No";
  else cout<<"Yes";
}

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

int main(){
  int N, M;
  std::cin >> N >> M;
  std::vector<int> A(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> A[i];
  }
  int total = 0;
  for(int i = 0 ; i < (int)A.size() ; i++){
    total += A[i];
  }
  double threshold = (double)total / (4 * M);

  std::sort(A.rbegin(), A.rend());
  int check = 0;
  for(int i = 0 ; i < M ; i++){
    if(A[i] >= threshold){
      check++;
    }else{
      continue;
    }
  }

  if(check == M){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)

Measured memory_bytes: 109180
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()

if A*C <= B:
	print(C)
else:
	print(B//A)

Measured memory_bytes: 60268
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        long ans = 0;

        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                long abGcd = gcd(i, j);
                for (int l = 1; l <= k; l++) {
                    ans += gcd(abGcd, l);
                }
            }
        }

        System.out.println(ans);

    }

    private static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 35824
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, c;
    cin >> n >> c;
    vector<vector<int>> d(c, vector<int>(c));
    for(int i = 0; i < c; ++i){
        for(int j = 0; j < c; ++j){
            cin >> d[i][j];
        }
    }
    vector<vector<int>> color(n, vector<int>(n));
    vector<vector<int>> cnt(3, vector<int>(c, 0));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> color[i][j];
            --color[i][j];
            ++cnt[(i + j) % 3][color[i][j]];
        }
    }
    
    ll ans = 1e+17;
    for(int i = 0; i < c; ++i){
        ll sum = 0;
        for(int col = 0; col < c; ++col){
            if(col == i)    continue;
            sum += d[col][i] * cnt[0][col];
        }
        for(int j = 0; j < c; ++j){
            if(j == i)  continue;
            ll foo = 0;
            for(int col = 0; col < c; ++col){
                if(col == j)    continue;
                foo += d[col][j] * cnt[1][col];
            }
            sum += foo;
            for(int k = 0; k < c; ++k){
                if(k == i || k == j)    continue;
                ll bar = 0;
                for(int col = 0; col < c; ++col){
                    if(col == k)    continue;
                    bar += d[col][k] * cnt[2][col];
                }
                sum += bar;
                chmin(ans, sum);
                sum -= bar;
            }
            sum -= foo;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <bitset>
#include <map>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
int main() {

    int N;
    string S;
    cin >> N;
    cin >> S;
    
    
    int ans = 0;
    for(int i = 0; i <= 999; i++){
        string pass;
        
        if(i <= 9) pass = "00" + to_string(i);
        else if(i <= 99) pass = "0" + to_string(i);
        else pass = to_string(i);
        
        int count = 0;
        for(int i = 0; i < N; i++){
            if(S[i] == pass[count]){
                count++;
            }
            if(count == 3){
                ans++;
                break;
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>  //45~
#include<string>
using namespace std;
int main(){
	int a[1000][7];
	string c;
	string d;
	int s=0;
	int b=0;
	int i=0;
	int j=0;
	
	cin>>b;
	cin>>c;
	d="JOI";
	for(i=0;i<7;i++){
		for(j=0;j<1000;j++){
			a[j][i]=0;
		}
	}
	if(c[0]==d[0]){
		a[0][0]=1;
		a[0][3]=1;
		a[0][5]=1;
		a[0][6]=1;
	}else if(c[0]==d[1]){
		a[0][3]=1;
		a[0][6]=1;
	}else{
		a[0][5]=1;
		a[0][6]=1;
	}
	for(i=1;i<b;i++){
		a[i][0]=a[i-1][0]+a[i-1][3]+a[i-1][5]+a[i-1][6];
		a[i][1]=a[i-1][1]+a[i-1][3]+a[i-1][4]+a[i-1][6];
		a[i][2]=a[i-1][2]+a[i-1][4]+a[i-1][5]+a[i-1][6];
		a[i][3]=a[i-1][0]+a[i-1][1]+a[i-1][3]+a[i-1][4]+a[i-1][5]+a[i-1][6];
		a[i][4]=a[i-1][1]+a[i-1][2]+a[i-1][3]+a[i-1][4]+a[i-1][5]+a[i-1][6];
		a[i][5]=a[i-1][0]+a[i-1][2]+a[i-1][3]+a[i-1][4]+a[i-1][5]+a[i-1][6];
		a[i][6]=a[i-1][0]+a[i-1][1]+a[i-1][2]+a[i-1][3]+a[i-1][4]+a[i-1][5]+a[i-1][6];
		if(c[i]==d[0]){
			a[i][1]=0;
			a[i][2]=0;
			a[i][4]=0;
		}
		if(c[i]==d[1]){
			a[i][0]=0;
			a[i][2]=0;
			a[i][5]=0;
		}
		if(c[i]==d[2]){
			a[i][0]=0;
			a[i][1]=0;
			a[i][3]=0;
		}
		for(j=0;j<7;j++){
			if(a[i][j]>10007){
				a[i][j]=a[i][j]%10007;
			}
		}
	}
	for(i=0;i<7;i++){
		s=s+a[b-1][i];
	}
	s=s%10007;
	cout<<s<<endl;
}

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

using namespace std;

using ll = long long;

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    ll t = 0;
    for (size_t i = 0; i != s2.size(); ++i) {
        t += (s2[i] == s1[i]);
    }
    cout << t << "\n";
    return 0;
}


Measured memory_bytes: 256
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<bits/stdc++.h>
using namespace std;
int tj[30];
char s[30];
int main()
{
	cin>>s;
	int len=strlen(s);
	for(int i=0;i<len;i++)
	{
		tj[s[i]-'a']++;
		if(tj[s[i]-'a']>1)
		{
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <set>
//#include <conio.h>
using namespace std;
 
int main(){
	std::ios_base::sync_with_stdio(false);
	int n;
	set<string> list;
	string key;
	cin >> n;
	for(int i=0; i<n; ++i){
		cin >> key;
		if(key == "insert"){
			cin >> key;
			list.insert(key);
		} else if(key == "find"){
			cin >> key;
			if(list.find(key) != list.end()) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 28180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    ll ans=(n*2+m)/4;
    ans=min(ans,m/2);
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

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


    ll a,b;
    cin >> a >> b;

    cout << "100 100" << endl;

    char ans[101][101];

    rep(i,101)
    {
        rep(j,101)
        {
            ans[i][j] = 'g';
        }
    }

    b--;
    a--;

    ll x = 1;
    ll y = 1;

    while(a!=0)
    {
        ans[x][y] = '.';
        y+=2;
        if(y>100)
        {
            y = 1;
            x+=2;
        }
        a--;
    }

    fr(i,1,x)
    {
        fr(j,1,100)
        {
            if(ans[i][j]=='g')
                ans[i][j] = '#';
        }
    }

    x++;
    
    fr(i,1,100)
    {
        ans[x][i] = '#';
    }

    x++;
    fr(i,1,100)
    {
        ans[x][i] = '.'; 
    }

    x++;

    ll x2 = x;
    y = 1;

    while(b!=0)
    {
        ans[x][y] = '#';
        y+=2;
        if(y>100)
        {
            y = 1;
            x+=2;
        }
        b--;
    }    

    fr(i,x2,100)
    {
        fr(j,1,100)
        {
            if(ans[i][j]=='g')
                ans[i][j] = '.';
        }
    }

    fr(i,1,100)
    {
        fr(j,1,100)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

cnt0 = 0
cnt1 = 0
for i in range(len(s)):
	if i%2 == 0 :
		if s[i] == "0":
			cnt1 += 1
		else:
			cnt0 += 1
	else:
		if s[i] == "1":
			cnt1 += 1
		else:
			cnt0 += 1
print( min(cnt0, cnt1) )

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

template<class T> class segtree{
public:
    int n,size_;
    vector<T> dat;
    function<T(T,T)> fun_;
    T id_;
    segtree()=default;
    segtree(int size,function<T(T,T)> fun,T id,T initial_value){ init(size,fun,id,initial_value); }
    void init(int size,function<T(T,T)> fun,T id,T initial_value){
        size_=size;
        fun_=fun;
        id_=id;
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,id);
        for(int i=0; i<size; ++i) update(i,initial_value);
    }
    int size()const{ return size_; }
    void update(int k, T a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=fun_(dat[k*2+1],dat[k*2+2]);
        }
    }
    T at(int index){ return dat[index+n-1]; }
    void add(int k,T a){ update(k,at(k)+a); }
    T query(int a,int b) { return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return id_;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return fun_(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    segtree<pair<int64_t,int>> seg(n,[](pair<int64_t,int> p,pair<int64_t,int> q){
        return min(p,q);
    },
    make_pair(inf64,-1),make_pair(int64_t(0),0));
    rep(i,0,n){
        cin >> a[i];
        seg.update(i,make_pair(a[i],i));
    }

    int64_t ans=0;
    function<void(int,int)> rec=[&](int l,int r){
        if(r-l==1){
            ans+=a[l];
            return;
        }
        if(l>=r) return;
        auto p=seg.query(l,r);
        int64_t v=p.first;
        int m=p.second;
        ans+=v*(m-l+1)*(r-m);
        rec(l,m);
        rec(m+1,r);
    };
    rec(0,n);
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 244352
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef pair<int,int> P;

int W,H;

bool chkd(int x,int y) {
    return (x>=0 && y>=0 && x<=W+1 && y<=H+1);
}

void pushque(int x,int y,vector<vector<int> >& mp,queue<P>& q) {
    if(chkd(x,y)&&mp[x][y]==0) {
        mp[x][y]=-1;
        q.push(P(x,y));
    }
    return;
}

int main()
{
    cin >> W >> H;

    vector<vector<int>> mp;

    mp.resize(W+2);

    for(int i=0; i<=W+1; ++i) {
        mp[i].resize(H+2);
        mp[i][0]=0;
        mp[i][H+1]=0;
    }

    for(int i=0; i<=H+1; ++i) {
        mp[0][i]=0;
        mp[W+1][i]=0;
    }

    for(int i=1; i<=H; ++i) {
        for(int j=1; j<=W; ++j) {
            cin >> mp[j][i];
        }
    }

    queue<P> q;

    mp[0][0]=-1;
    q.push(P(0,0));

    while(!q.empty()) {
        P p=q.front(); q.pop();
        int x=p.first, y=p.second;

        if(y%2==0) {
            pushque(x-1,y-1,mp,q);
            pushque(x,y-1,mp,q);
            pushque(x+1,y,mp,q);
            pushque(x,y+1,mp,q);
            pushque(x-1,y+1,mp,q);
            pushque(x-1,y,mp,q);
        } else {
            pushque(x,y-1,mp,q);
            pushque(x+1,y-1,mp,q);
            pushque(x+1,y,mp,q);
            pushque(x+1,y+1,mp,q);
            pushque(x,y+1,mp,q);
            pushque(x-1,y,mp,q);
        }
    }

    int ans=0;
    for(int x=1; x<=W; ++x) {
        for(int y=1; y<=H; ++y) {
            if(mp[x][y]!=1) continue;
            if(y%2==0) {
                if(mp[x-1][y-1]==-1) ++ans;
                if(mp[x][y-1]==-1) ++ans;
                if(mp[x+1][y]==-1) ++ans;
                if(mp[x][y+1]==-1) ++ans;
                if(mp[x-1][y+1]==-1) ++ans;
                if(mp[x-1][y]==-1) ++ans;
            } else {
                if(mp[x][y-1]==-1) ++ans;
                if(mp[x+1][y-1]==-1) ++ans;
                if(mp[x+1][y]==-1) ++ans;
                if(mp[x+1][y+1]==-1) ++ans;
                if(mp[x][y+1]==-1) ++ans;
                if(mp[x-1][y]==-1) ++ans;
            }
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3168