akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N,Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int l[Q],r[Q];
  rep(i,Q) cin >> l[i] >> r[i];
  rep(i,Q) l[i]-=1,r[i]-=2;
  int ans[N]={};
  int count=0;
  rep(i,N-1){
    if(S[i]=='A' && S[i+1]=='C') count++;
    ans[i]=count;
  }
  ans[N-1]=count;
  rep(i,Q){
    cout << ans[r[i]]-ans[l[i]-1] << endl;
  }
}

Measured memory_bytes: 2256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a,b,c = map(int,input().split())
	print(max(0,b+c-a))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#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 rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc103_d() {
	ll N, M;
	ll ans = 0;
	cin >> N >> M;

	vector<P> m;

	ll a, b;
	rep(i, M) {
		cin >> a >> b;
		m.push_back(make_pair(b, a));
	}

	sort(ALL(m));

	ll now = 0;
	rep(i, M) {
		if (m[i].second > now) {
			now = m[i].first - 1;
			ans++;
		}
	}

	cout << ans << "\n";
}

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

	solve_abc103_d();

	return 0;
}

Measured memory_bytes: 3444
n = int(input())
sum_a = 0

for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        sum_a = sum_a + i
print(sum_a)


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

long long a,b;
int kq;

int main(){
  cin>>a>>b;
  long long d=__gcd(a,b);
  kq=1;
  for(int i=2;1ll*i*i<=d;i++)
    if (d%i==0){
      kq++;
      while(d%i==0) d=d/i;
    }
  if (d>1) kq++;
  cout<<kq;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int kurai = k;

		int answer = 1;

		while (kurai <= n) {
			answer++;
			kurai*= k;
		}
		System.out.println(answer);


	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int n1 = *max_element(v.begin(), v.end());
    int n2 = *min_element(v.begin(), v.end());
    if (abs(n1 - n2) == 0) {
        if (n1 * 2 <= n || n1 + 1 == n)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
    }
    if (abs(n1 - n2) > 1) {
        cout << "No" << endl;
        return 0;
    }
    int c1 = count(v.begin(), v.end(), n1);
    int c2 = count(v.begin(), v.end(), n2);
    if (n1 - c2 <= c1 / 2 && n1 - c2 > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n, m;
int arr[N];
long long ans[N];
int pref[N];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
  }
  for (int i = 1; i < n; i++) {
    int s = arr[i - 1], t = arr[i];
    if (s < t) {
      ans[1] += (t - s);
      ans[s + 1] -= (t - s); //a
      pref[s + 2]++;
      pref[t + 1]--;
      ans[t + 1]--;
      ans[s + 1] += (t - (s + 1) + 1); //b
      ans[t + 1] += (t - s); //c
    } else if (t < s) {
      ans[1] += t;
      ans[t + 1]--;
      pref[2]++;
      pref[t + 1]--; //a
      ans[t + 1] += (m - s + t);
      ans[s + 1] -= (m - s + t); //b
      pref[s + 2]++;
      ans[s + 1] += (m - (s + 1) + 1 + t); //c
    }
  }
  for (int i = 1; i < N; i++) {
    pref[i] += pref[i - 1];
  }
  long long res = 2e18;
  for (int i = 1; i <= m; i++) {
    ans[i] = ans[i - 1] + ans[i] - pref[i];
    res = min(res, ans[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using point = complex<double>;
const double EPS = 1e-9;

int n;
vector<point> pts, center;

bool check(double R) {
  center.clear();
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      double d = abs(pts[i] - pts[j]);
      double h = R * R - d * d / 4.0;
      if (h < 0) continue;
      h = sqrt(h);
      point C = (pts[i] + pts[j]) / 2.0;
      point vec = point(h / d * (pts[j].imag() - pts[i].imag()), -h / d * (pts[j].real() - pts[i].real()));
      center.push_back(C + vec);
      center.push_back(C - vec);
    }
  }
  for (auto &p: center) {
    bool ok = true;
    for (auto &q: pts) {
      if (abs(p - q) - EPS > R) {
        ok = false;
        break;
      }
    }
    if (ok) return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1, x, y; i <= n; ++i) {
    cin >> x >> y;
    pts.emplace_back(x, y);
  }
  check(0.5);
  double lt = 0, rt = 1000;
  for (int i = 1; i <= 200; ++i) {
    double mid = (lt + rt) / 2.0;
    if (check(mid)) rt = mid;
    else lt = mid;
  }
  cout << fixed << setprecision(12) << lt;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main (){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c){
    cout << "Yes" << endl;
  }else if(a == c && a != b){
    cout << "Yes" << endl;
  }else if(b == c && b != a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int N, M;
const int MAXN = 200005;
vi to[MAXN];

int main () {
  cin >> N >> M;
  REP(i,M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
  }

  bool can = false;
  for (auto c : to[0]) {
    for (auto d : to[c]) {
      if (d == N-1) can = true;
    }
  }

  cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;


int main(){
    string S;
    cin >> S;
    int ans = S.size();
    int N = S.size();
    for(int i  = 0; i < N; i++){
        if(S[i] == '1'){
            ans = min(ans, max(i, N - i - 1));
        }
    }
    int ans_flip = S.size();
    for(int i  = 0; i < N; i++){
        if(S[i] == '0'){
            ans_flip = min(ans_flip, max(i, N - i - 1));
        }
    }
    cout << max(ans, ans_flip) << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]){
		// Nを入力
        Scanner scan = new Scanner(System.in);
        long N = scan.nextLong();

        // ABCDEを入力
        long A;
        long min = (long)1e18;
        for(int i = 0; i < 5; i++){
        	A = scan.nextLong();
        	// ボトルネック箇所のキャパを算出
        	if(A < min){
        		min = A;
        	}
        }
        scan.close();
        
        // 答えを計算し出力
        long ans = (N + min - 1) / min + 4;
        System.out.println(ans);

	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);


void solve()
{
    int n; cin >> n;
    int h[n];
    int dp[n];

    loop(i,0,n)
    {
        cin >> h[i];
    }

    int count = 0;
    dp[n-1] = 0;
    dp[n-2] = abs((h[n-1]-h[n-2]));

    loopr(i,n-3,0)
    {
        //cout << h[i] << " ";
        //cout << dp[i+1] << " " << dp[i+2] << "\n";
        dp[i] = min(abs((h[i]-h[i+1]))+dp[i+1],abs((h[i]-h[i+2]))+dp[i+2]);
        //cout << dp[i] << "\n";
    }
    //cout << "\n";
    cout << dp[0] << "\n";
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<ll,ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

ll n,k;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

cin>>n>>k;
vector<T>ans(n);
vector<ll>a(n);
vector<ll>b(n);
    ll cur=k;
    for(int i=0;i<n;i+=2){
        a[i]=cur++;
    }
    for(int i=1;i<n;i+=2){
        a[i]=cur++;
    }
    for(int i=1;i<n;i+=2){
        b[i]=cur++;
    }
    for(int i=0;i<n;i+=2){
        b[i]=cur++;
    } 
    rep(i,n){
        ll c=k+2*n+i;
       if(a[i]+b[i]<=c)ans[i]=(T(a[i],b[i],c));
       else{
           cout<<-1<<endl;
           return 0;
       }
    } 
    rep(i,n){
        T tp=ans[i];
        ll f,s,t;
        tie(f,s,t)=tp;
        cout<<f<<" "<<s<<" "<<t<<endl;
    }
return 0;
}

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

const int N = 1e6 + 10;

int n , cnt[3] , d[3];
char a[N];

int main(){
	scanf("%d %s" , &n , a);
	for(int i = 0; i < n; i++) d[--a[i] - '0']++;
	for(int i = 0; i < n; i++)
		if(((n - 1) & i) == i)
			cnt[a[i] - '0']++;
	if(cnt[1] & 1) puts("1");
	else if(!d[1] && (cnt[2] & 1)) puts("2");
	else puts("0");
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] X = new int[N];
		for( int i=0; i<N; i++ ){
			X[i] = sc.nextInt();
		}
		int[] ans = new int[100];
		for( int k=1; k<=100; k++ ){
			for( int i=0; i<N; i++ ){
				ans[k-1] += (X[i]-k)*(X[i]-k);
			}
		}
		Arrays.sort(ans);
		System.out.println(ans[0]);      
	}
}

Measured memory_bytes: 21972
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}


const int N = 1e5 + 5;
char a[N];

int main(){
    int n = D();
    set<int> s;
    for(int i = 0; i < n; ++i)
        s.insert(D());
    printf("%d", s.size());
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eb emplace_back
#define allv(V) ((V).begin()),((V).end())
using namespace std;

const int MAXN = 100055;

vector<int> G[MAXN], AnsV;

int cnt[MAXN], prt[MAXN];

vector<int> Ans;
int N, rt1, rt2;

void dfs(int i) {
	for(int v : G[i]) if(!cnt[v]) {
		cnt[v] = cnt[i] + 1;
		dfs(v);
	}
}
void dfs1(int i) {
	cnt[i] = 1;
	for(int v : G[i]) if(!cnt[v]) {
		prt[v] = i;
		dfs1(v);
		cnt[i] += cnt[v];
	}
}

bool f(int i, int &c) {
	int t = 0;
	if(G[i].empty()) {
		AnsV.eb(++c);
		return true;
	}
	for(int v : G[i]) {
		if(!f(v, c)) return false;
		if(!t) AnsV.eb(cnt[i]);
		else if(1 != cnt[v]) return false;
		t++;
	}
	c++;
	return true;
}

void run(int rt) {
	memset(cnt, 0, sizeof cnt);
	AnsV.clear();

	dfs1(rt);
	for(int i = 1; i <= N; i++) {
		if(i != rt) G[i].erase(find(allv(G[i]), prt[i]));
		sort(allv(G[i]), [&](int a, int b) {
			return cnt[a] > cnt[b];
		});
	}
	{
		int c = 0;
		if(!f(rt, c)) return;
	}

	vector<int> V(N);
	for(int i = 0; i < N; i++)
		V[AnsV[i]-1] = i+1;
	
	if(Ans.empty() || V < Ans) swap(Ans, V);
}

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

	cin >> N;
	for(int i = 1, a, b; i < N; i++) {
		cin >> a >> b;
		G[a].eb(b);
		G[b].eb(a);
	}

	cnt[1] = 1; dfs(1);
	rt1 = int(max_element(cnt+1, cnt+N+1) - cnt);
	memset(cnt, 0, sizeof cnt);
	cnt[rt1] = 1; dfs(rt1);
	rt2 = int(max_element(cnt+1, cnt+N+1) - cnt);

	run(rt1);
	for(int i = 1; i <= N; i++) if(i != rt1) G[i].eb(prt[i]);
	run(rt2);

	if(Ans.empty()) puts("-1");
	else {
		for(int v : Ans) printf("%d ", v);
		puts("");
	}
	return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((c - 1) / b <= (a - 1) / d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;

    ll ans = 0;
    ans += (n * (n - 1)) / 2;
    ans += (m * (m - 1)) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

n,q = map(int,input().split())
Q = deque()

for i in range(n):
    a = input().split()
    Q.append([a[0],int(a[1])])
s = 0

while Q:
    qt = Q.popleft()
    
    if qt[1] > q:
        Q.append([qt[0],qt[1]-q])
        s += q
    else:
        s += qt[1] 
        print(qt[0],s)

Measured memory_bytes: 16068
#include <iostream>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <iomanip>
#include <valarray>
#include <vector>
#include <sstream>

std::string call(int n){
    std::stringstream ss;
    int i = 0;
    while(++i <= n){
        int x = i;
        if(x  % 3 ==0){
            ss << " " << i;
            continue;
        }
        while(x){
            if(x%10 == 3){
                ss << " " << i;
                break;
            }
            x /= 10;
        }
    }
    return ss.str();
}


int main(int argc, char *argv[])
{
    int n;
    std::cin >> n;
    std::cout << call(n) << std::endl;
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  long D;
  cin >> D;
  vector<long> c(26);
  rep(i,26) cin >> c.at(i);
  vector<vector<long>> s(D,vector<long>(26));
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }

  vector<long> t(D);
  rep(i,D) cin >> t.at(i);
  vector<long> lastday(26,-1);


  long ans = 0;
  rep(i,D){
    long tt = t.at(i) - 1;
    ans += s.at(i).at(tt);
    lastday.at(tt) = i;
    rep(j,26){
      ans -= (i - lastday.at(j)) * c.at(j);
    }
    cout << ans << endl;
  }

}

Measured memory_bytes: 3720
import sys
from statistics import *
from collections import *
from operator import itemgetter
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
sss = input()
c = Counter(sss)
print('Three' if len(c.keys()) - 1 == 3 else 'Four')

Measured memory_bytes: 5148
from sys import stdin

class Node:
    def __init__(self):
        self.parent = -1
        self.sibling = -1
        self.depth = -1
        self.height = -1
        self.children = [-1, -1]

class Tree:
    def __init__(self, nodes):
        self.nodes = nodes
        for i in range(self.size()):
            n = self.nodes[i]
            n.depth = self.depth(i)
            n.height = self.height(i)

    def depth(self, i):
        node = self.nodes[i]
        if self.isRoot(i):
            return 0
        else:
            return self.depth(node.parent)+1

    def height(self, i):
        node = self.nodes[i]
        if i == -1:
            return -1
        else:
            return max([self.height(c) for c in node.children])+1

    def size(self):
        return len(self.nodes)

    def isLeaf(self, i):
        return self.nodes[i].children == [-1, -1]

    def isRoot(self, i):
        return self.nodes[i].parent == -1

n = int(stdin.readline().rstrip())
nodes = [Node() for _ in range(n)]
for i in range(n):
    l = [int(x) for x in stdin.readline().rstrip().split()]
    nodes[l[0]].children = l[1:3]
    if l[1] != -1:
        nodes[l[1]].parent = l[0]
        nodes[l[1]].sibling = l[2]
    if l[2] != -1:
        nodes[l[2]].parent = l[0]
        nodes[l[2]].sibling = l[1]

t = Tree(nodes)
for i in range(t.size()):
    node = t.nodes[i]
    l = ["node ", i, ": parent = ", node.parent, ", sibling = ", node.sibling, ", degree = ", len([c for c in node.children if c != -1]), ", depth = ", node.depth, ", height = ", node.height, ", "]

    if t.isRoot(i):
        l.append("root")
    elif t.isLeaf(i):
        l.append("leaf")
    else:
        l.append("internal node")

    print(*l, sep="")


Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
using ll = long long;
using namespace std;

ll solve(int n, ll k, vector<ll> const & a) {
    auto f = [&](ll x) {
        ll acc = 0;
        for (ll a_i : a) {
            acc += x ^ a_i;
        }
        return acc;
    };
    if (k == 0) {
        return f(k);
    }

    ll x1 = 0;  // = k
    ll x2 = -1;  // < k
    REP_R (i, 42) {
        if (x2 == -1) {
            if (k & (1ll << i)) {
                x2 = x1;
            }
        } else {
            if (f(x2) < f(x2 | (1ll << i))) {
                x2 |= 1ll << i;
            }
            if (f(x2) < f(x1) and (k & (1ll << i))) {
                x2 = x1;
            }
        }
        if (k & (1ll << i)) {
            x1 |= 1ll << i;
        }
        assert (x2 < x1);
    }
    assert (x1 == k);
    assert (x2 != -1 and x2 < k);
    return max(f(x1), f(x2));
}

int main() {
    int n; ll k; cin >> n >> k;
    vector<ll> a(n);
    REP (i, n) cin >> a[i];
    cout << solve(n, k, a) << endl;
    return 0;
}


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

struct node{
	int dst;
	int w;
};

std::vector<int> color;
std::vector<std::vector<node>> graph;

void dfs(int x, int d){
	if(d%2==0)
		color[x]=0;
	else
		color[x]=1;

	for(int i=0; i<graph[x].size(); i++){
		if(color[graph[x][i].dst]==-1)
			dfs(graph[x][i].dst, d+graph[x][i].w);

	}


}

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

	color.resize(n, -1);
	graph.resize(n);

	for(int i=0; i<n-1; i++){
		int tmpS, tmpD, tmpW;
		std::cin>>tmpS>>tmpD>>tmpW;
		graph[tmpS-1].push_back({tmpD-1, tmpW});
		graph[tmpD-1].push_back({tmpS-1, tmpW});
	}

	dfs(0, 0);

	for(int i=0; i<n; i++)
		std::cout<<color[i]<<std::endl;

	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    cout<<(N%2 == 0 ? N : N*2)<<endl;
}


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

int main(){
  int n,x;
  cin >> n >> x;
  int m[n];
  rep(i,n) cin >> m[i];
  
  int min=1000;
  rep(i,n){
    if(m[i] < min) min = m[i];
  }
  
  int count=n;
  rep(i,n) x -= m[i];
  
  count += x / min;
  
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef long long int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right)
/* クイックソート
 * a     : ソートする配列
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            i++; j--;
        }
        quicksort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}


int main(void){


	int n;
	scanf("%d",&n);
	long long int *a;
	a=(long long int*)malloc(3*n*sizeof(long long int));

	int i;
	for(i=0;i<3*n;i++){
		scanf("%lld",a+i);
	}

	quicksort(a,0,3*n-1);

	long long int sum=0;
	for(i=3*n-2;i>=n;i-=2){
		sum+=a[i];
	}
	free(a);
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

using namespace std;



int main() {

	long long int ans = 1;
	int n;
	cin >> n;
	vector<long long int>r;
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		r.push_back(x);
	}

	for (int i = 0; i < n; i++) {
		long long int b=ans,m=r[i];
		if (b > r[i])swap(b, m);
		while (1) {
			if (!b)break;
			long long int t = b;
			b = m % b;
			m = t;

		}
		ans = ans/m*r[i];
	}
	cout << ans << endl;
	


	return 0;
	
}


Measured memory_bytes: 256
ary = []
3.times do |i|
    ary[i] = gets.split.map(&:to_i)
end
max_n = ary.flatten.max
0.upto(max_n) do |a1|
    b1 = ary[0][0] - a1
    b2 = ary[0][1] - a1
    b3 = ary[0][2] - a1
    0.upto(max_n) do |a2|
        0.upto(max_n) do |a3|
            if (a1 + b1 == ary[0][0] &&
                a1 + b2 == ary[0][1] &&
                a1 + b3 == ary[0][2] &&
                a2 + b1 == ary[1][0] &&
                a2 + b2 == ary[1][1] &&
                a2 + b3 == ary[1][2] &&
                a3 + b1 == ary[2][0] &&
                a3 + b2 == ary[2][1] &&
                a3 + b3 == ary[2][2])
                puts 'Yes'
                exit
            end
        end
    end
end
puts 'No'

Measured memory_bytes: 3836
# Segment tree (+)
from operator import add
from sys import stdin


class SegmentTree:
    def __init__(self, size, op, e):
        self._op = op
        self._e = e
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [e] * (t * 2 - 1)

    def __getitem__(self, key):
        return self._data[self._offset + key]

    def __setitem__(self, key, value):
        op = self._op
        data = self._data
        i = self._offset + key
        data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def build(self, iterable):
        op = self._op
        data = self._data
        data[self._offset:self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            data[i] = op(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        op = self._op
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = self._e
        for v in it:
            result = op(result, v)
        return result

readline = stdin.readline

N, M = map(int, readline().split())
ab = [list(map(int, readline().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])
st = SegmentTree(N - 1, add, 0)

result = 0
for a, b in ab:
    a, b = a - 1, b - 1
    if st.query(a, b) != 0:
        continue
    result += 1
    st[b - 1] = 1
print(result)


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

int main(){
  int n;
  cin >> n;
  long a = 0;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  rep(i, n-1) a += v[(i+1)/2];
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 4028
H, W = list(map(int, input().split()))
N = int(input())
a = list(map(int, input().split()))

D = [[""] * W for _ in range(H)]
cnt = 0
i, j = 0, 0
while i < H:
  while j < W:
    if i % 2 == 1:
      k = W - j - 1
    else:
      k = j
    D[i][k] = str(cnt + 1)
    a[cnt] -= 1
    if a[cnt] == 0:
      cnt += 1
    j += 1
  j = 0
  i += 1

for k in D:
  print(" ".join(k))

Measured memory_bytes: 3700
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}

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

int main() {
  int N,tmp;
  cin >> N;
  tmp=N;
  int i=0;
  int sum=0;
  while(tmp>0){
    while(tmp%10!=0){
      tmp--;
      i++;
    }
    tmp/=10;
  }
  if(N%i==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int N, Q;
    string s;

    cin >> N >> Q >> s;

    vector<int> v;
    v.push_back(0);
    int cnt=0;
    for (int i=0; i<N-1; i++) {
        // cout << s[i] << endl;
        if (s[i] == 'A' && s[i+1]=='C') ++cnt;
        v.push_back(cnt);
        // cout << endl;
        // for (int i=0; i<N-1; i++) cout << v[i];
        // cout << endl;
    }
    // cout << endl;
    // for (int i=0; i<N-1; i++) cout << v[i];
    // cout << endl;

    int l, r;
    for (int i=0; i<Q; i++) {
        cin >> l >> r;

        int res = v[r-1] - v[l-1];
        cout << res << endl;
    }
    return 0;

}

Measured memory_bytes: 1528
N = int(input())
H = list(map(int, input().split()))
ans = ("Yes")

for i in range(N-1):
    if H[N-1-i] - H[N-2-i] == -1:
        H[N-2-i] -= 1
    elif H[N-1-i] - H[N-2-i] <= -2:
        ans = ("No")

print(ans)

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

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            for (int i = 1; i <= input; ++i)
            {
                if (i % 3 == 0)
                {
                    Console.Write($" {i}");
                    continue;
                }

                for (int j = i; j > 0; j /= 10)
                {
                    if (j % 10 == 3)
                    {
                        Console.Write($" {i}");
                        break;
                    }
                }
            }
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15928
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int n, k;
int a[nax];

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

    for (int i = 1 ; i <= n ; ++ i)
        cin >> a[i];
    sort(a + 1, a+ 1 + n);

    cout << accumulate(a + 1, a + 1 + k, 0LL);
}


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

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)


using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void read(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void read(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

template <typename T>
void write(vector<T> & _data, bool _shift) {
    for (ll i = (ll)_shift; i < _data.size(); i++)
        cout << _data[i] << " ";
    cout << endl;
}


//TODO: SOLUTION


void solve() {
    ll n; cin >> n;
    vll a; read(a, n, 0);
    vll zeroes(60, 0);
    vll ones(60, 0);
    ll m = pow(2, 60);
    ll ans = 0;

    for (auto x : a) {
        ll y = 1;
        ll i = 0;
        while (y < m) {
            ll hui = y % mod;
            if (y&x) {
               ans += zeroes[i] * hui;
               ones[i]++;
            }
            else {
                ans += ones[i] * hui;
                zeroes[i]++;
            }
            i++;
            y *= 2;
            ans = ans % mod;
        }
    }

    cout << ans << endl;
}


int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5604
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Main{
	
	public static void main(String[]args) {
		PrintWriter out = new PrintWriter(System.out);
		Scanner sc=new Scanner (System.in);
		int N = sc.nextInt();
		String s = sc.next();
		char arr[] = s.toCharArray();
		int wcount=0;
		int count=0;
		for(int i=0;i<N;i++){
		    if(arr[i]=='W'){
		        wcount++;
		    }
		}
		for(int i=N-wcount;i<N;i++){
		    if(arr[i]=='R'){
		        count++;
		    }
		}
		out.println(count);
		out.close();
	}
}

Measured memory_bytes: 31652
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <utility>

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main()
{
  ll N, W;
  cin >> N, cin >> W;

  vector<ll> w1s;
  vector<ll> w2s;
  vector<ll> w3s;
  vector<ll> w4s;

  ll w1, v;
  cin >> w1, cin >> v;
  w1s.push_back(v);

  ll w2 = w1 + 1;
  ll w3 = w1 + 2;
  ll w4 = w1 + 3;

  for (ll i = 1; i < N; i++)
  {
    ll _w;
    cin >> _w, cin >> v;
    if (_w == w1)
      w1s.push_back(v);
    else if (_w == w2)
      w2s.push_back(v);
    else if (_w == w3)
      w3s.push_back(v);
    else // w4
      w4s.push_back(v);
  }

  if (w1 > W) {
    cout << 0 << endl;
    return 0;
  }

  // sort
  sort(w1s.begin(), w1s.end(), std::greater<ll>());
  sort(w2s.begin(), w2s.end(), std::greater<ll>());
  sort(w3s.begin(), w3s.end(), std::greater<ll>());
  sort(w4s.begin(), w4s.end(), std::greater<ll>());

  // i j k l
  ll ans = 0;
  for (ll i = 0; i <= (ll)(W / w1); i++)
  {
    ll W1 = W - (i * w1);
    for (ll j = 0; j <= (ll)(W1 / w2); j++)
    {
      ll W2 = W1 - (j * w2);
      for (ll k = 0; k <= (ll)(W2 / w3); k++)
      {
        ll W3 = W2 - (k * w3);
        for (ll l = 0; l <= (ll)(W3 / w4); l++)
        {
          ll a = 0;
          for (ll m = 0; m < min(i, (ll)w1s.size()); m++)
            a += w1s[m];
          for (ll m = 0; m < min(j, (ll)w2s.size()); m++)
            a += w2s[m];
          for (ll m = 0; m < min(k, (ll)w3s.size()); m++)
            a += w3s[m];
          for (ll m = 0; m < min(l, (ll)w4s.size()); m++)
            a += w4s[m];
          
          ans = max(ans, a);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

const int CMax = 100002;

int n, sk, ats;
set <int> S;

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &sk);
        S.insert(sk);
    }

    printf("%d\n", S.size());
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int check (char *s, int len_s, int div) {
    int count = 0;
    int alph1[26], alph2[26];
    for (int i=0; i<26; i++) {
        alph1[i] = 0;
        alph2[i] = 0;
    }
    for (int i=0; i<len_s; i++) {
        if (i < div) alph1[s[i]-'a'] = 1;
        else alph2[s[i]-'a'] = 1;
    }
    for (int i=0; i<26; i++) {
        if (alph1[i] && alph2[i]) count++;
    }
    return count;
}


int main() {
    int ans = 0;
    scanf("%*d\n");
    char s[102];
    fgets(s, 102, stdin);
    int len_s = strlen(s);
    if (s[len_s-1] == '\n') {
        s[len_s-1] = '\0';
        len_s--;
    }
    for (int i=1; i<len_s; i++) {
        int buf = check(s, len_s, i);
        if (buf > ans) ans = buf;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10000)

n, k = list(map(int, input().split(' ')))
l = sorted(list(map(int, input().split(' '))))
#print(l)
#l =     [1,2,10,12, 14]]
#diffs = [1, 8, 2, 2]
# f(n,k) = hoge
# f(5,5) = 0
# f(4,5) = 1
# f(3,5) = 3
# f(2,5) = 5
# f(1,5) = 13
diffs = [l[i+1]-l[i] for i in range(len(l)-1)] 
diffs = sorted(diffs)
print(sum(diffs[:max(0, k-n)]))

Measured memory_bytes: 13968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one

	string rev(string s) {
		cerr << s << endl;
		reverse(allof(s));
		return s;
	}
}

int main() {

	string s = inp1;

	int n = s.length();
	bool yes = true;

	yes &= (s == rev(s));
	yes &= (s.substr(0, (n - 1) / 2) == rev(s.substr(0, (n - 1) / 2)));
	yes &= (s.substr((n + 3) / 2 - 1)) == rev(s.substr((n + 3) / 2 - 1));

	Cout(Yes(yes));

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int h, w, m;
  cin >> h >> w >> m;
  
  vector<int> cnth(h), cntw(w);
  set<P> st;

  rep(i, m) {
    int th, tw;
    cin >> th >> tw;
    --th; --tw;
    cnth[th]++;
    cntw[tw]++;
    st.emplace(th, tw);
  }

  int ans = 0;
  int maxh = 0;
  int maxw = 0;
  rep(i, h) chmax(maxh, cnth[i]);
  rep(i, w) chmax(maxw, cntw[i]);
  vector<int> th, tw;
  rep(i, h) if (maxh == cnth[i]) th.push_back(i);
  rep(i, w) if (maxw == cntw[i]) tw.push_back(i);

  ans = maxh + maxw;
  for (int i : th) for(int j : tw) {
    if (st.count(P(i, j))) continue;
    cout << ans << endl;
    return 0;
  }

  ans--;
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 23808
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if(s.equals(u)){
            a--;
        }else{
            b--;
        }

        System.out.println(a + " " + b);
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 22996
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

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

		// 1行、2つ(複数)数字
		String[] ss0 = br.readLine().trim().split(" ", 0);
		int x= Integer.parseInt(ss0[0]);
		int y = Integer.parseInt(ss0[1]);

		Integer  a[] = {1,3,5,7,8,10,12};
		Integer  b[] = {4,6,9,11};
		Integer  c[] = {2};
		
		
		if((x==2)||(y==2)) { System.out.println("No"); return; }
		
		if ((Arrays.asList(a).contains(x)) && (Arrays.asList(a).contains(y))) { System.out.println("Yes"); return; }
		if ((Arrays.asList(b).contains(x)) && (Arrays.asList(b).contains(y))) { System.out.println("Yes"); return; }
		if ((Arrays.asList(c).contains(x)) && (Arrays.asList(c).contains(y))) { System.out.println("Yes"); return; }


	System.out.println("No");
	return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }



}


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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int d;
    int a[n];
    for(int i=0;i<n;i++)a[i]=1;

    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            int tmp;
            cin >> tmp;
            a[tmp-1]=0;
        }
    }
    int sum = 0;
    for(int i=0;i<n;i++)sum += a[i];
    cout << sum << endl;
}

Measured memory_bytes: 3636
N, T = map(int, input().split())
swc = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if swc[i+1] - swc[i] < T:
        ans += (swc[i+1] - swc[i])
    else:
        ans += T
print(ans+T)

Measured memory_bytes: 30888
import sys
sys.setrecursionlimit(10000)

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
dp = [-1 for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)

def rec(v):
    if dp[v] >= 0:
        return dp[v]
    temp = 0
    for next in graph[v]:
        temp = max(rec(next) + 1, temp)
    dp[v] = temp
    return temp

for i in range(N):
    rec(i)
print(max(dp))

Measured memory_bytes: 121900