akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Robot {
	int x,y;
	Robot(int x,int y,int[][] field) {
		this.x = x;
		this.y = y;
		field[x][y] = 0;
	}
	void move(int dir,int size,int[][] field) {
		if (dir==0) {
			for (int i=0;i<size;i++) {
				if (field[this.x][--this.y]==1) field[this.x][this.y] = 0;
			}
		} else if (dir==1) {
			for (int i=0;i<size;i++) {
				if (field[this.x][++this.y]==1) field[this.x][this.y] = 0;
			}
		} else if (dir==2) {
			for (int i=0;i<size;i++) {
				if (field[--this.x][this.y]==1) field[this.x][this.y] = 0;
			}
		} else if (dir==3) {
			for (int i=0;i<size;i++) {
				if (field[++this.x][this.y]==1) field[this.x][this.y] = 0;
			}
		}
	}
}

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int M = Integer.parseInt(buf);
				int field[][] = new int[21][21];
				for (int i=0;i<20;i++) {
					Arrays.fill(field[i],0);
				}
				StringTokenizer st;
				for (int i=0;i<M;i++) {
					st = new StringTokenizer(br.readLine());
					field[Integer.parseInt(st.nextToken())][Integer.parseInt(st.nextToken())] = 1;
				}
				int N = Integer.parseInt(br.readLine());
				Robot r = new Robot(10,10,field);
				int dir = 4;
				for (int i=0;i<N;i++) {
					st = new StringTokenizer(br.readLine());
					buf = st.nextToken();
					if (buf.equals("S")) dir = 0;
					else if (buf.equals("N")) dir = 1;
					else if (buf.equals("W")) dir = 2;
					else if (buf.equals("E")) dir = 3;
					r.move(dir,Integer.parseInt(st.nextToken()),field);
				}
				//printField(field);
				if (check(field)) System.out.println("Yes");
				else System.out.println("No");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static boolean check(int[][] f) {
		for (int i=0;i<20;i++) {
			for (int j=0;j<20;j++) {
				if (f[i][j]==1) return false;
			}
		}
		return true;
	}

	public static void printField(int[][] f) {
		for (int i=0;i<20;i++) {
			for (int j=0;j<20;j++) {
				System.out.print(f[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 24788
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll a,b;
    cin>>a>>b;
    if((a+b)%2==0)
    {
        cout<<(a+b)/2;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    ll sum = 0;
    FOR(i, N + 1, 1)
    {
        sum += i;
        if (sum >= N)
        {
            FOR(j, i + 1, 1)
            {
                if (j == sum - N)
                    continue;
                cout << j << endl;
            }
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    public class Program
    {
        static void Main(string[] args)
        {
            string n = "";

            n = Console.ReadLine();

            for (int i = 0; i < 3; i++)
            {
                if (n[i] == '7')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 17252
n = int(input())
lis_s = ["S", "H", "C", "D"]
lis = [0 for i in range(n)]


for i in range(n):
    lis.append(input())
    
    
for i in lis_s :
    for j in range(1, 14) :
        
        
        if f"{i} {j}" not in lis :
            print(f"{i} {j}")
    
    


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

int main(){
    int a,b,C;
    double S,L,h,d;
    cin>>a>>b>>C;
    
    d=(acos(-1.0)*C)/180.0;
    S=a*b*sin(d)/2.0;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(d));
    h=b*sin(d);
    
    printf("%lf\n%lf\n%lf\n",S,L,h);
    
    return 0;
}


Measured memory_bytes: 3372
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool palin(string s){
  string temp = s;
  reverse(all(temp));
  return s == temp;
}

int n,a[202020],cnt[202020],ans;

int nc2(int x){
  return (x*(x-1))/2;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    cnt[a[i]]++;
  }
  for(int i=1;i<=200000;i++){
    ans+=nc2(cnt[i]);
  }
  for(int i=1;i<=n;i++){
    int cur = ans-nc2(cnt[a[i]]);
    cur+= nc2(cnt[a[i]]-1);
    cout << cur << endl;
  }
  

return 0;
}
///....


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int N, M, C; cin >> N >> M >> C;
    int B[M]; rep(i, M) cin >> B[i];
    int A[N][M]; rep(i, N) rep(j, M) cin >> A[i][j];

    int ans = 0;
    rep(i, N) {
        int sum = C;
        rep(j, M) sum += A[i][j]*B[j];
        if (sum > 0) ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const int MOD = 1000000007;
//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

const int MAX_N = 100050 * 3;
int n, m, s, t;
vector<int> adj[MAX_N];

int main(void) {
	ios_base::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n >> m;
	rep(i,0,m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pb(v);
	}
	cin >> s >> t;
	s--; t--;

	vector<int> dist(n * 3, -1);
	dist[s] = 0;
	queue<int> q;
	q.push(s);

	while(!q.empty()) {
		int here = q.front();
		int cost = dist[here];
		q.pop();
		int d = (here/n + 1)%3;
		d = d * n;
		here = here%n;
		for(int i=0; i<sz(adj[here]); ++i) {
			int there = adj[here][i];
			there = there + d;
			if(dist[there] == -1) {
				dist[there] = cost+1;
				q.push(there);
			}
		}
	}

	if(dist[t] % 3 == 0) {
		cout << dist[t]/3 << endl;
	} else {
		cout << -1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 11648
#include "bits/stdc++.h"

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair



int main () {
  string s;
  cin >> s;
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  s.erase(s.begin());
  if (!in(s[0], 'a', 'z' + 1) || !in(s.back(), 'a', 'z' + 1)) {
    cout << "WA" << endl;
    return 0;
  }
  s.erase(s.begin());
  s.pop_back();
  int cnt = 0;
  rep (i, s.size()) {
    if (s[i] == 'C') {
      cnt++;
    }
    else if (!in(s[i], 'a', 'z' + 1)) {
      cout << "WA" << endl;
      return 0;
    }
  }
  if (cnt == 1) {
    cout << "AC" << endl;
    return 0;
  }
  else {
    cout << "WA" << endl;
    return 0;
  }
    

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
const int N(3e5 + 5);
map<pair<int, int>, bool> tinta;
int n, m, x, y, t, lin[N], col[N], maxi, res;
vector<int> linii, coloane;
int32_t main() {
    DAU
    cin >> n >> m >> t;
    for (int i = 1; i <= t; ++i) {
        cin >> x >> y;
        tinta[{x, y}] = true;
        ++lin[x], ++col[y];
    }
    maxi = 0;
    for (int i = 1; i <= n; ++i)
        if (lin[i] > maxi)
            maxi = lin[i];
    for (int i = 1; i <= n; ++i)
        if (lin[i] == maxi)
            linii.emplace_back(i);
    res = maxi;
    maxi = 0;
    for (int i = 1; i <= m; ++i)
        if (col[i] > maxi)
            maxi = col[i];
    for (int i = 1; i <= m; ++i)
        if (col[i] == maxi)
            coloane.emplace_back(i);
    res += maxi;
    for (const int& l : linii)
        for (const int& c : coloane)
            if (tinta.find({l, c}) == tinta.end()) {
                cout << res;
                PLEC
            }
    cout << res - 1;
    PLEC
}


Measured memory_bytes: 28488
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	int c=-1;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='-'){
			c=i;
		}
		else if(s[i]>='0'&&s[i]<='9'){
			cnt++;
		}
	}
	if(a==c&&cnt==s.size()-1){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

move=((1,0),(0,1),(-1,0),(0,-1))

#深さ優先探索
def dfs(used,mat,node,nums):
    y,x=node
    color=mat[y][x]
    if used[y][x]==1 or color=='!':
        return
    
    used[y][x]=1
    nums[color]+=1
    for i,j in move:
        if mat[y+i][x+j]!=color and mat[y+i][x+j] != '!':
            dfs(used,mat,(y+i,x+j),nums)


H,W=list(map(int,input().split()))

grid=['!'*(W+2)]
used=[[0 for _ in range(W+2)] for _ in range(H+2)]

for i in range(H):
    grid.append('!'+input()+'!')
grid.append('!'*(W+2))

ans=0
for i in range(H+2):
    for j in range(W+2):
        nums={'#':0,'.':0}
        dfs(used,grid,(i,j),nums)
        ans+=nums['#']*nums['.']
print(ans)

Measured memory_bytes: 164588
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;
  for (int bit = 0; bit < 60; bit++){
    ll one = 0;
    rep(i, n) if (a[i] & 1ll << bit) one++;
    ans = ll(ans%MOD + (1ll << bit) % MOD * one%MOD * (n - one)%MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

#define MAX_V 110
#define INF 1<<29

template <typename T>
struct MaxFlow {
  struct edge { int to, rev; T cap; };

  typedef vector<edge> Edges;
  vector<Edges> G;
  int level[MAX_V];
  int iter[MAX_V];
  
  MaxFlow(int V) { G.resize(V); }

  void add_edge(int from, int to, T cap) {
    G[from].push_back((edge){to, (int)G[to].size(), cap});
    G[to].push_back((edge){from, (int)G[from].size(), 0});
  }

  void bfs(int source) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    que.push(source);
    level[source] = 0;
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (int i = 0; i < (int)G[v].size(); i++) {
	edge &e = G[v][i];
	if (e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }

  T dfs(int v, int sink, T flow) {
    if (v == sink) return flow;
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[v] < level[e.to]) {
	T d = dfs(e.to, sink, min(e.cap, flow));
	if (d > 0) {
	  e.cap -= d;
	  G[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }

  T dinic(int source, int sink) {
    T flow = 0;
    while (true) {
      bfs(source);
      if (level[sink] < 0) return flow;
      memset(iter, 0, sizeof(iter));
      T f;
      while ((f = dfs(source, sink, INF)) > 0) {
	flow += f;
      }
    }
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int V, E;
  cin >> V >> E;
  MaxFlow<int> mf(V);
  REP(i, E) {
    int u, v, c;
    cin >> u >> v >> c;
    mf.add_edge(u, v, c);
  }
  cout << mf.dinic(0, V-1) << endl;  
  return 0;
}

Measured memory_bytes: 3268
N,C = map(int,input().split())
d = [list(map(int,input().split())) for _ in range(C)]
g0 = [0]*C
g1 = [0]*C
g2 = [0]*C
for i in range(N):
    col = list(map(int,input().split()))
    for j in range(N):
        col[j] -= 1
        if (i+j)%3==0:
            g0[col[j]] += 1
        elif (i+j)%3 ==1:
            g1[col[j]] += 1
        else:
            g2[col[j]] += 1
ans = float('inf')
for i in range(C):
    for j in range(C): 
        for k in range(C):
            if i==j or j==k or i==k:
                continue
            s=0
            for l in range(C):
                s += d[l][i]*g0[l] + d[l][j]*g1[l] + d[l][k]*g2[l]
            ans = min(ans,s)
print(ans)

Measured memory_bytes: 69872
import Control.Applicative

main :: IO ()
main = do
    getLine
    (x:xs) <- map read . words <$> getLine
    mapM_ putStrLn $ solve xs [x]

solve :: [Int] -> [Int] -> [String]
solve [] ls = [unwords $ map show ls]
solve xs'@(x:xs) ls = stringify:(solve xs ls')
    where
        stringify = unwords $ map show $ ls ++ xs'
        ls' = [ a | a <- ls, a <= x ] ++ [x] ++ [ a | a <- ls, a > x ]

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto &e : p)
    cin >> e;

  int cnt = 0;
  for (int i = 1; i < n; ++i)
  {
    if (p[i - 1] == i)
    {
      if (p[i] == i + 1)
      {
        p[i] = p[i - 1];
      }
      cnt++;
    }
    if (i == n - 1)
    {
      if (p[i] == i + 1)
      {
        cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, K;
int X[MAX_N], Y[MAX_N];
int B[610][610];
int S[610][610]; //horizontal

void solve() {
	cin >> N >> M;
	rep(i, 0, N) {
		string str; cin >> str;
		rep(j, 0, M) {
			if(str[j] == '#') {
				X[K] = i;
				Y[K] = j;
				K++;
			}
		}
	}
	rep(i, 0, K) {
		int x = X[i], y = Y[i];
		X[i] = x - y + 299;
		Y[i] = x + y;
	}
	ll cnt1 = 0, cnt2 = 0;
	rep(q, 0, 4) {
		memset(B, 0, sizeof(B));
		memset(S, 0, sizeof(S));
		rep(i, 0, K) {
			B[X[i]][Y[i]] = 1;
			S[X[i]][Y[i] + 1] = 1;
		}
		rep(i, 0, 600) {
			rep(j, 0, 600) {
				S[i][j + 1] += S[i][j];
			}
		}
		// rep(i, 290, 310) {
		// 	debug(vi(B[i] + 290, B[i] + 310));
		// }
		rep(i, 0, K) {
			int x = X[i], y = Y[i];
			rer(z, y, 0) {
				if(B[x][z]) {
					// debug(x, y, z);
					int d = y - z;
					if(x - d >= 0) {
						cnt1 += S[x - d][y + 1] - S[x - d][z];
						if(B[x - d][z]) cnt2++;
						if(B[x - d][y]) cnt2++;
					}
				}
			}
		}
		rep(i, 0, K) {
			int x = X[i], y = Y[i];
			X[i] = -y + 599;
			Y[i] = x;
			// debug(X[i], Y[i]);
		}
	}
	cout << cnt1 - cnt2 + cnt2 / 2 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 4352
#include<stdio.h>
int selectionSort(int[], int);
int main(){
  int i, N, con;
  int A[100];

  scanf("%d",&N);
  for( i = 0 ; i < N ; i++ ){
    scanf("%d",&A[i]);
  }
  
  con = selectionSort(A, N);

  printf("%d",A[0]);
  for( i = 1 ; i < N ; i++ ){
    printf(" %d",A[i]);
  }
  printf("\n%d\n",con);
  return 0;
}

int selectionSort(int A[], int N){
  int i, j, con=0, minj, tmp;
  for( i = 0 ; i < N ; i++ ){
    minj = i;
    for( j = i ; j < N ; j++ ){
      if( A[j] < A[minj] ) minj = j;
    }
    if( i != minj ) con++;
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
  }
  return con;
}



Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    rep(i,N){
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 256
import heapq
t = 1
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	# n = map(int,input().split())
	n = int(input())
	# v = list(map(int,input().strip().split()))[0:n]
	print(n*n*n)
	# m = 1000
	# i = 0
	# while i < n:
	# 	j = i
	# 	while j+1 < n and v[j+1] >= v[j]:
	# 		j += 1
	# 	x = m//v[i]
	# 	m = m%v[i]
	# 	temp = x*v[j]
	# 	m += temp
	# 	i = j+1
	# print(m)


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

  
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ans =0;
  
  
  for(int i=0;i<N;i++){
	if(S[i] != S[N-i-1]) ans++;
  }
  if(ans%2 == 0) cout << ans / 2 <<endl;
  else cout <<(ans/ 2) +1 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     long long n;
     int k;

     cin>>n>>k;
    vector<long long > v(n);
    for(int i=0;i<n;i++)
    {
        cin>> v[i];
    }

    vector<long long > dp(n);
    if(n<1)
    {
        cout<<0;
        return 0;
    }

    dp[1]=abs(v[1]-v[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k && j<=i;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
        }
    }

    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        switch (s) {
            case "SUN":
                System.out.println(7);
                break;
            case "MON":
                System.out.println(6);
                break;
            case "TUE":
                System.out.println(5);
                break;
            case "WED":
                System.out.println(4);
                break;
            case "THU":
                System.out.println(3);
                break;
            case "FRI":
                System.out.println(2);
                break;
            case "SAT":
                System.out.println(1);
                break;
        }

    }

}


Measured memory_bytes: 35460
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <iostream>
#include <sstream>
#include <vector>
#include <iterator>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define    ll          long long
#define    mp          make_pair
#define    pb          push_back
#define    vi          vector <int>
#define    vs          vector <string>
#define    maxx(a,b,c) max(a,max(b,c))
#define    minn(a,b,c) min(a,min(b,c))
#define    SORT(x)     sort(x.begin(),x.end())

using namespace std;

int main(){
    int n;
    cin >> n;
    char s[n],t[n];
    scanf("%s", s);
    scanf("%s", t);
    for(int i=0;i<n;i++)
        cout << s[i] << t[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,i,x=0;
  scanf("%d %d",&n,&m);
  int a[200001],b[200001],c[200001];
  for(i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  for(i=0;i<m;i++){
    c[i]=0;
  }
  for(i=0;i<m;i++){
    if(a[i]==1){
      c[b[i]]=1;
    }
  }
  for(i=0;i<m;i++){
    if(c[a[i]]==1 && b[i]==n){
      x += 1;
      break;
    }
  }
  if(x==1){
    printf("POSSIBLE");
  }else{
    printf("IMPOSSIBLE");
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
using namespace std;

int n, k;
int main() {
	cin >> n >> k;
	vector<bool> have(n);
	rep(i,0,k){
		int d; cin >> d;
		rep(i,0,d){
			int t; cin >> t;
			have[t-1] = true;
		}
	}
		
	int ans = n;
	rep(i,0,n){
		if(have[i]) ans--;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3196
a, b, k = map(int, input().split())

if b - a + 1 >= 2 * k:
    for n in range(a, a + k):
        print(n)
    for n in range(b - k + 1, b + 1):
        print(n)
else:
    for n in range(a, b + 1):
        print(n)

Measured memory_bytes: 3060
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  sort(A.begin(), A.end());
  int cnt = N/2;
  cout << A.at(cnt) - (A.at(cnt-1)) << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8-*-
if __name__ == '__main__':
    n = int(input())
    pd = {"   ": 1}
    d = {"   ": 1}
    for i in range(n):
        pd = d
        d = {}
        for k, v in pd.items():
            for j in "AGTC":
                t = k+j
                t1 = t[1] + t[0] + t[2] + t[3]
                t2 = t[0] + t[2] + t[1] + t[3]
                t3 = t[0] + t[1] + t[3] + t[2]
                if not ("AGC" in t or "AGC" in t1 or "AGC" in t2 or "AGC" in t3):
                    if t[1:] in d:
                        d[t[1:]] += v
                    else:
                        d[t[1:]] = v
                    d[t[1:]] %= 1000000007
    sum = 0
    for v in d.values():
        sum += v
    sum %= 1000000007
    print(sum)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
	
	int count{0};
	string s,t;
	cin >> s >> t;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i])
			count++;
	}
	cout << count;
    return 0;
}



Measured memory_bytes: 3884
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MAXN 100010
int n,k;
vector<int> Inv(vector<int> A)
{
	vector<int> ret(n);
	for(int i=0;i<n;i++)
		ret[A[i]]=i;
	return ret;
}
vector<int> Mul(vector<int> a,vector<int> b)
{
	vector<int>ret(n);
	for(int i=0;i<n;i++)
		ret[i]=a[b[i]];
	return ret;
}
vector<int> Pow(vector<int> a,int b)
{
	vector<int>ret(n);
	for(int i=0;i<n;i++) ret[i]=i;
	while(b)
	{
		if(b&1) ret=Mul(ret,a);
		a=Mul(a,a);
		b>>=1;
	}
	return ret;
}
vector<int>a[6],p,q;
int main()
{
	scanf("%d%d",&n,&k);
	a[0].resize(n),a[1].resize(n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[0][i]);
		a[0][i]--;
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[1][i]);
		a[1][i]--;
	}
	for(int i=2;i<6;i++)
		a[i]=Mul(a[i-1],Inv(a[i-2]));
	p=Pow(Mul(Mul(a[1],Inv(a[0])),Mul(Inv(a[1]),a[0])),(k-1)/6);
	k=(k-1)%6;
	q=Mul(p,Mul(a[k],Inv(p)));
	for(int i=0;i<n;i++)
		printf("%d ",q[i]+1);
}

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

using namespace std;

int cnt[30];

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        cnt[s[0]-'A']++;
        mx = max(mx, cnt[s[i]-'A']);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int need = i*k;
        for (int c = 0; c < 26; ++c) {
            need -= min(cnt[c], i);
        }
        if (need > 0) break;
        ans = i;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b = LI()
    print(max(a + b, a - b, a * b))

main()



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

int main()
{
int n;
  cin>>n;
  int arr[n];
  vector<int>ans(n+1);
 
  for(int i=1;i<=n-1;i++)
  {
     cin>>arr[i];
   ans[arr[i]]++;
  }

    for(int i=1;i<=n;i++)
  {
    cout<<ans[i]<<endl;
     
  }
 
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& i : a) cin >> i;
    vector<int> s = a;
    sort(s.begin(), s.end(), greater<int>());
    for(auto i : a){
        if(i == s.at(0)) cout << s.at(1) << endl;
        else cout << s.at(0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>


using namespace std;

int main()
{
    int n, x;

    while (cin >> n >> x)
    {
        if (n==0 && x==0)
            break;


        int sum = 0;


        //method 1        
        // for (int i = 1; i <= n; i++)
        //     for (int j = 1; j <= n; j++)
        //         for (int k = 1; k <= n; k++)
        //             if (i!=j && j!=k && k!=i && i+j+k==x)
        //                 sum++;
        // cout << sum/6 << endl; 

        //method 2
        // for (int i = 1; i <= n-2; i++)
        //     for (int j = i+1; j <= n-1; j++)
        //         for (int k = j+1; k <= n; k++)
        //             if (i+j+k == x)
        //                 sum++;
        // cout << sum << endl;



        //method 3
        for (int i = 1; (i < x/3) && (i <= n-2) ; i++)
            for (int j = i+1; (j < x-i-j) && (j <= n-1); j++) 
                    if (x-i-j <= n)
                        sum++;
        cout << sum << endl;
             
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

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

int main()
{
    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 11) * 2;
    ll amari = x % 11;
    if (amari == 0)
    {
        cout << ans << endl;
        return 0;
    }
    else if (amari <= 6)
    {
        cout << ans + 1 << endl;
        return 0;
    }
    else
    {
        cout << ans + 2 << endl;
        return 0;
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
		string s;
		cin>>s;
		ll n=sz(s);
		for(int i=n-2;i>=0;i-=2){
			if(s.substr(0,i/2)==s.substr(i/2,i/2)){
				cout<<i;
				return 0;
			}
		}
		cout<<0;
		
		
		
	}





}


Measured memory_bytes: 3668
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    int i = N%10;
    if (i == 2 or i==4 or i==5 or i==7 or i == 9)cout << "hon" << endl;
    else if (i==0 || i==1 || i==6 or i==8)cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
int n;
int bfs(int sum,int cnt){
//    cout << " " << sum << " " << cnt<< endl;
    if(cnt==4){
        if(n==sum)return 1;
        else return 0;
    }else if(sum>n)return 0;
    int result = 0;
    for(int i=0;i<=9;i++){
        result+=bfs(sum+i,cnt+1);
    }
    return result;
}

int main(){
    while (cin>>n) {
        int result = bfs(0,0);
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
MOD = 998244353

n = int(input())
d = list(map(int, input().split()))

stage = [0]*n
maxstage = 0
for di in d:
    stage[di] +=1
    maxstage = max(maxstage, di)

if stage[0] != 1:
    print(0)
elif d[0] != 0:
    print(0)
else:
    cnt = 1
    for i in range(1,maxstage+1):
        cnt = (cnt*stage[i-1]**stage[i])%MOD
           
    print(cnt)

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;
const int maxx=1e5+7;
struct node
{
    int t,s;
}bb[maxx];
bool cmp(node a,node b)
{
    return a.t<b.t;
}
int main()
{
    std::ios::sync_with_stdio(false);
    int n,m;
    cin >>n>>m;
    for(int i=0;i<n;i++)
    {
        cin >>bb[i].t>>bb[i].s;
    }
    sort(bb,bb+n,cmp);
    priority_queue<int> q;
    int ans=0;
    int sum=0;
    for(int i=1;i<=m;i++)
    {
        while(1)
        {
            if(bb[ans].t<=i&&ans<n)
            {
                q.push(bb[ans].s);
                ans++;
            }
            else break;
        }
        if(q.empty()) continue;
        else sum+=q.top();
        q.pop();
    }
    cout <<sum<<endl;
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
int main() {
  cin >> n;
  double s = 0;
  for (i64 i = 0; i < n; ++i) {
    double x;
    cin >> x;
    s += 1 / x;
  }
  printf("%.10f\n", 1 / s);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, y, n;
    while(cin >> x >> y >> n, x|y|n){
        int ans = 0;
        for (int i = 1; i < n; ++i) {
            for (int j = 1; j < n; ++j) {
                if(i*(x+100)/100+j*(x+100)/100 == n){
                    ans = max(ans, i*(y+100)/100+j*(y+100)/100);
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}



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

static const int N = 100;

int main(){
    int n,u,k,v;
    cin >> n;
    int ans[n+1][n+1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)
            ans[i][j] = 0;
    }

    for(int i=0;i<n;i++){
        cin >> u >> k;
        for(int j=0;j<k;j++){
            cin >> v;
            ans[u][v] = 1;
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j-1) cout << ' ';
            cout << ans[i][j];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt;
char s[100005], t[100005];
ll ans;
vi v[30];
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  scanf("%s %s", s, t);
  n = strlen(s);
  m = strlen(t);
  FOR(i, 0, n-1) {
    v[s[i]-'a'].pb(i);
  }
  int p = -1;
  FOR(i, 0, m-1) {
    if (v[t[i]-'a'].empty()) {
      printf("-1\n");
      return 0;
    }
    auto it = upper_bound(v[t[i]-'a'].begin(), v[t[i]-'a'].end(), p);
    if (it == v[t[i]-'a'].end()) {
      int newp = *v[t[i]-'a'].begin();
      ans += n-1-p;
      ans += newp+1;
      p = newp;
    } else {
      int newp = *it;
      ans += newp - p;
      p = newp;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1148
// Lets go to the next level
// AIM EXP at CF *__* asap
// Hit A,B,C faster and reach Expert
// Remember you were also a novice when you started,
// hence never be rude to anyone who wants to learn something!Be calm and help everyone.
// Never open the rank list until and unless you are done with solving problems!

//Author: kaiyu
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};

bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 2e5+ 10;

#define int long long
int32_t main() {
//#ifndef ONLINE_JUDGE
    //freopen("inp1.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
//#endif
    fio
    int A , L;

   cin >> A >> L;

    for (int i = 0; i <=A ; ++i) {
        int x = i;
        int y = A-i;

        if(x+y==A) {
            if(2*x + 4*y == L) {
                cout << "Yes" << endl;
                goto end;
            }
        }
    }
    cout <<"No" << endl;
    end:;



   // cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if(abs(a - x) > abs(b - x)) printf("B\n");
    else printf("A\n");
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	scanner := bufio.NewScanner(os.Stdin)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		scanner.Scan()
		s[i] = scanner.Text()
	}
	for i := 0; i < h; i++ {
		result := ""
		for k := 0; k < w; k++ {
			total := 0
			if s[i][k] == '.' {
				if 0 < i {
					total += eight(s[i-1], k, w)
				}
				if i < h-1 {
					total += eight(s[i+1], k, w)
				}
				total += eight(s[i], k, w)
				result += strconv.Itoa(total)
			} else {
				result += "#"
			}
		}
		fmt.Println(result)
	}
}

func eight(s string, k int, w int) int {
	total := 0
	if s[k] == '#' {
		total++
	}
	if 0 < k {
		if s[k-1] == '#' {
			total++
		}
	}
	if k < w-1 {
		if s[k+1] == '#' {
			total++
		}
	}
	return total
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=2000+10;
bool bz[maxn][maxn],pd[maxn][maxn];
int up[maxn][maxn],sta[maxn];
int i,j,k,l,t,n,m,ans,top;
char get(){
	char ch=getchar();
	while (ch!='#'&&ch!='.') ch=getchar();
	return ch;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n){
		fo(j,1,m)
			if (get()=='#') bz[i][j]=1;
	}
	fo(i,2,n)
		fo(j,2,m){
			t=(bz[i-1][j-1]+bz[i-1][j]+bz[i][j-1]+bz[i][j])%2;
			if (!t) pd[i-1][j-1]=1;
		}
	fo(i,1,n-1)
		fo(j,1,m-1) up[i][j]=pd[i][j]?up[i-1][j]+1:0;
	ans=max(n,m);
	fo(i,1,n-1){
		top=0;
		fo(j,1,m){
			while (top&&up[i][j]<=up[i][sta[top]]){
				ans=max(ans,(j-sta[top-1])*(up[i][sta[top]]+1));
				top--;
			}
			sta[++top]=j;
		}
	}
	printf("%d\n",ans);
}

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

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

        int ans = N - K + 1;
        if(ans < 0) ans = 0;

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 384
S = input()
cnt = 0
if S[0] == "A":
    for i in S[2: len(S) - 1]:
        if i == "C":
            cnt += 1
sr = S.replace("A", "")
src = sr.replace("C", "")
if src.islower() and cnt == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int k;
    string s;
    cin >> k >> s;

    if(s.length() <= k){
        cout << s << endl;
    }
    else{
        cout << s.substr(0, k) << "..." << endl;
    }


    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int head;
	char s[15],ans[15];
	while(~scanf("%s",s + 1)){
		head = 0;
		for(int i = 1;i <= strlen(s + 1);i++){
			if(s[i] == 'B' && head) head--;
			else if(s[i] != 'B') ans[++head] = s[i];
		}
		for(int i = 1;i <= head;i++) printf("%c",ans[i]);
		printf("\n");
	}
    return 0;
}


Measured memory_bytes: 128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cost=min(a)+min(b)
for m in range(M):
    x,y,c=map(int,input().split())
    cost=min(cost,a[x-1]+b[y-1]-c)
print(cost)

Measured memory_bytes: 18736
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <limits.h>
using namespace std;
main()
{
    int a[100];
    int n;cin >> n;
    int ans = INT_MAX;
    for( int i = 0; i < n; i++ )cin >> a[i];
    for( int i = 0; i < n; i++ )
    {
        int sum1 = 0, sum2 = 0;
        for( int j = 0; j <= i; j++ )
        {
            sum1 += a[j];
        }
        for( int j = i + 1; j < n; j++ )
        {
            sum2 += a[j];
        }
        ans = min( abs( sum1 - sum2 ), ans );
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256