akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
/*
  sum of subarr % K == num of elements
  
*/
const int N = 2e5 + 10;
int n; ll k;
ll a[N], s[N];
map<ll, int> cnt;

int main() {
	cin >> n >> k; for (int i = 1; i <= n; ++i) {
		cin >> a[i]; a[i]--;
	}
	s[1] = a[1]%k; for (int i = 2; i <= n; ++i) s[i] = (s[i - 1] + a[i]) % k;
	ll ans = 0;// cnt[0] = 1;
	for (int i = 0; i <= n; ++i) {
		ans += cnt[s[i]];
		cnt[s[i]]++;
		if (i - k + 1 >= 0) cnt[s[i - k + 1]]--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		int ans=0;
		ans=max(a*b,c*d);
		printf("%d\n",ans);
		
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;


int main() {
	ll n, k, x[100000],ans=INT32_MAX;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < (n-k+1); i++) {
		ll memo;
		if (x[i]<0&& x[i + k-1]>0) {
			memo = max(abs(x[i]), abs(x[i + k - 1])) + (2 * min(abs(x[i]), abs(x[i + k - 1])));
		}
		else {
			memo = max(abs(x[i]), abs(x[i + k - 1]));
		}
		ans = min(ans, memo);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  string ans = "";
  string cand = S;
  if(S.size()<T.size()){cout << "UNRESTORABLE" << endl;return 0;}
  for(int i = S.size()-T.size();i>=0;i--){
      bool ok = true;
      REP(j,T.size()){
          if (S[i+j] != T[j] && S[i+j]!= '?')ok = false;
      }
      if (ok){
          REP(k,S.size()){
              if(i<=k && k<i+T.size()){
                  cand[k] = T[k-i];
              }else if(S[k]=='?'){
                  cand[k] =  'a';
              }else{
                  cand[k] =  S[k];
              }
          }
          //cout << cand << endl;
          if (ans.size()==0 || cand < ans){
              ans = cand;
          }
      }
  }
  if (ans.size()==0)cout << "UNRESTORABLE" << endl;
  else cout << ans << endl;

}

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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

void solve() {
    int n;
    cin >> n;
    vector<array<int, 2>> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i][0] >> v[i][1];
    }
    for (int i = 0; i < n-2; ++i) {
        if ((v[i][0] == v[i][1]) && (v[i+1][0] == v[i+1][1]) && (v[i+2][0] == v[i+2][1])) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

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

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 3676
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int in_num = sc.nextInt();
        Map<Integer,Integer> m = new HashMap<>();
        for(int i = 0; i < in_num ;i++){
            int a = sc.nextInt();
            if(m.containsKey(a)){
                System.out.println("NO");
                return;
            }else{
                m.put(a, null);
            }
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 99600
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
s = 0
for k in range(N):
  if A[k] - B[k] >= 0:
    s = s+B[k]
  else:
    if A[k] + A[k+1] - B[k] >=0:
      s = s+B[k]
      A[k+1] = A[k] + A[k+1] - B[k]
    else:
      s = s + A[k] + A[k+1]
      A[k+1] = 0
print(s)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f;
	cin>>n;
	vc a(n+1);ll mx=0;
	for(i=1;i<=n;i++)
	{
	    cin>>a[i];
	    mx=max(mx,a[i]);
	}ll allgcd=a[1];
	for(i=2;i<=n;i++)allgcd=__gcd(allgcd,a[i]);
	unordered_map<ll,ll>m;
	f=1;
	for(i=1;i<=n;i++)
	{
	    if(a[i]%2==0)
	    {
	        m[2]++;
	        if(m[2]>1){f=0;break;}
	        
	        while(a[i]%2==0)a[i]/=2;
	    }
	    ll temp=a[i];
	    for(j=3;j*j<=temp;j+=2)
	    {
	        if(a[i]%j==0)
	        {
	            m[j]++;
	            if(m[j]>1){f=0;break;}
	            while(a[i]%j==0)a[i]/=j;
	        }
	    }
	    if(a[i]>2)m[a[i]]++;
	    if(m[a[i]]>1){f=0;break;}
	}
	if(f)cout<<"pairwise coprime";
	else if(allgcd==1)cout<<"setwise coprime";
	else cout<<"not coprime";
	return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    v_int a(n+1);
    irep2(i, 1, n) {
        cin >> a[i];
    }
    
    v_int v;
    int f = 1;
    int ans = 0;

    while(v.size() < a.size()) {
        if(f == 2) { 
            cout << ans << endl;
            return 0;
        }
        v.push_back(f);
        f = a[f];    
        ans++;
    }
    cout << -1 << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 1276
H, W = map(int, input().split())
S = [[s for s in str(input())] for i in range(H)]

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            for i in range(4):
                nh, nw = h+dx[i], w+dy[i]
                if 0 <= nh < H and 0 <= nw < W:
                    if S[nh][nw] == '#' or S[nh][nw] == 'b':
                        S[nh][nw] = 'b'
                        S[h][w] = 'b'

counter = 0
for i in range(H):
    for l in range(W):
        if S[i][l] == "#":
            counter += 1


if counter == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 41456
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 11e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  	int N;
  	cin >>N;
  	std::map<int, int> A;
  	int hoge;
    for (int i = 1; i <= N; i++){
        cin >> hoge;
      	A[hoge]=i;
    }
	for (int i = 1; i <= N; i++){
      	cout << A[i];
    	if (i == N){
        	cout << endl;
        }else{
        	cout << " ";
        }
    }
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int K, S;
  cin >> K >> S;
  int tmp;
  int count  =0;
  for(int i = 0; i  <= K; i ++){
    for(int j = 0; j  <= K; j ++){
      tmp = S - (i + j);
      if(0<= tmp&&tmp <= K) count ++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {

    int N, M, C;
    scanf("%d %d %d", &N, &M, &C);
    int b[M];
    int a[N][M];
    for (int i = 0; i < M; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    int score;
    int count = 0; 
    for (int i = 0; i < N; i++) {
        score = C;
        for (int j = 0; j < M; j++) {
            score += b[j] * a[i][j];
        }
        if (score > 0) count++;
    }
    printf("%d\n", count);


    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 200000

int main() {
	static int tt[N];
	int n, t, i, ans;
	
	scanf("%d%d", &n, &t);
	for (i = 0; i < n; i++)
		scanf("%d", &tt[i]);
	ans = 0;
	for (i = 1; i < n; i++)
		ans += (t < tt[i] - tt[i - 1] ? t : tt[i] - tt[i - 1]);
	printf("%d\n", ans + t);
	return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    string T;
    cin >> T;

    rep(i, T.length()){
        if(T[i]=='?') T[i] = 'D';
    }
    cout << T << endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string.h>
#include <queue>

using namespace std;

int N, M;

int main() {
	long long  goal = 1000000;

	for (; cin >> N;) {
		if (!N) break;
		long long  v[4000];
		queue<int> que;
		memset(v, 0, sizeof(v));
		for (int i = 0; i < N; i++) {
			long long  e, p, q;
			cin >> e >> p >> q;
			que.push(e-1);
			v[e - 1] += p*q;
		}
		bool flag = false;
		while(!que.empty()){
			if (v[que.front()] >= goal) {
				flag = true;
				v[que.front()] = 0;
				cout << que.front() + 1 << endl;
			}
			que.pop();
		}
		if (!flag) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

ll mod;
ll powMod(ll a,ll b){
	ll res = 1;
	for(;b;b>>=1){
		if(b&1) res = (res*a)%mod;
		a = (a*a)%mod;
	}
	return res;
}
	
ll N;
const int maxn = 1e6+10;
void test_case(){
	cin >> N;
	ll num = 7;
	mod = N;
	ll val = 0;
	for(int i = 0;i<maxn;++i){
		 val = (val%mod + (num%mod * powMod(10,i))%mod)%mod;
		if(val == 0){
			cout << i+1 << endl;
			return;
		}
	}
	cout << -1 << endl;
}
	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

const long N=1200000000;

int main(){
	while(1){
		int n, k;
		scanf(" %d %d", &n, &k);
		if(n==0) break;
		
		long island[101][101];
		memset(island, -1, sizeof(island));
		
		for(int i=0; i<k; ++i){
			int order;
			scanf(" %d", &order);
			if(order==0){ //客の注文
				long cost[101]; //各島までの値段の最小値	
				for(int j=0; j<=100; ++j) cost[j]=N;
				
				int a, b;
				scanf(" %d %d", &a, &b);
				
				//bfs
				queue<int> que;
				cost[a]=0;
				que.push(a);
				while( !que.empty() ){
					int v=que.front();
					que.pop();
					for(int j=1; j<=n; ++j){
						if(island[v][j]>=0 && cost[j]>island[v][j]+cost[v]){
							cost[j]=island[v][j]+cost[v];
							que.push(j);
						}
					}
				}
				
				if(cost[b]==N) printf("-1\n");
				else printf("%ld\n", cost[b]); 
			}
			else if(order==1){ //運行情報の追加
				int c, d;
				long e;
				scanf(" %d %d %ld", &c, &d, &e);
				
				if(island[c][d]==-1 || island[c][d]>e)
					island[c][d]=island[d][c]=e;
			}
		}
	}
}

Measured memory_bytes: 1300
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n;
  int sum = 0;
  
  cin >> n;

  int t = n;
  
  while(t > 0){
    sum += t%10;
    t /= 10;
  }

  cout << (n % sum == 0 ? "Yes" : "No") << endl;
  
  return 0;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.to_i
w = gets.chomp.to_i

count = 0
1.upto n do |height|
  if h+height-1 <= n
    1.upto n do |width|
      if w+width-1 <= n
        count += 1
      else
        next
      end
    end
  else
    next
  end
end

puts count


Measured memory_bytes: 1788
#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,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
#define mod2 998244353

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

struct Segtree {
	int size = 1;
	vector<int> dat, lazy;
	Segtree(int x) {
		while (size < x)
			size *= 2;
		dat.resize(size * 2 - 1, -inf);
		lazy.resize(size * 2 - 1, -inf);
	}
	void eval(int k, int l, int r) {
		chmax(dat[k], lazy[k]);
		if (r - l > 1) {
			chmax(lazy[k * 2 + 1], lazy[k]);
			chmax(lazy[k * 2 + 2], lazy[k]);
		}
		lazy[k] = -inf;
	}
	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r == -1)
			r = size;
		eval(k, l, r);
		if (r <= a || b <= l)
			return;
		if (a <= l && r <= b) {
			chmax(lazy[k], x);
			eval(k, l, r);
			return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
	int query(int a, int b,int k = 0, int l = 0, int r = -1) {
		if (r == -1)
			r = size;
		eval(k, l, r);
		if(r<=a||b<=l)return -inf;
		if(a<=l&&r<=b)return dat[k];
		int lv=query(a,b,k*2+1,l,(l+r)/2),rv=query(a,b,k*2+2,(l+r)/2,r);
		return max(lv,rv);
	}
};

int N;
int dp[200005];
signed main(){
    cin>>N;
    vector<P>V(N);
    rep(i,N)cin>>V[i].first>>V[i].second;
    sort(all(V));
    V.push_back(P(inf,0));
    Segtree segtree(N+1);
    segtree.update(N,N+1,N);
    dp[N]=1;
    for(int i=N-1;i>=0;i--){
        int j=upper_bound(all(V),P(V[i].first+V[i].second,0ll))-V.begin();
        int k=max(segtree.query(i,j),i);
        segtree.update(i,i+1,k);
        dp[i]=dp[i+1]+dp[k+1];
        dp[i]%=mod2;
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 15048
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;
    
    int max = 0,size = 0;
    
    for(int i = 0;i < (int)str.size();i++){
        
        switch(str[i]){
            case 'A' : size++;
                       break;
            case 'C' : size++;
                       break;
            case 'G' : size++;
                       break;
            case 'T' : size++;
                       break;
            default :   size = 0;
                        break;
        }
        
        if(max < size)
        max = size;
        
        
    }
   
    std::cout << max << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a , b;
    char op;
    while(1){
        scanf("%d %c %d" , &a , &op , &b);
        if(op == '+'){
            printf("%d\n" , a + b);
        }
        else if(op == '-'){
            printf("%d\n" , a - b);
        }
        else if(op == '*'){
            printf("%d\n" , a * b);
        }
        else if(op == '/'){
            printf("%d\n" , a / b);
        }
        else{
            break;
        }
        
    }
    return 0;
}


Measured memory_bytes: 2144
borders = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
def getcolor(rate):
    i = 0
    for border in borders:
        if rate < border:
            return i
        i += 1
    return -1

N = int(input())
rates = [int(x) for x in input().split(" ")]
colors = [0 for _ in range(len(borders))]
topcoders = 0

for rate in rates:
    c = getcolor(rate)
    if c != -1:
        colors[c] = 1
    else:
        topcoders += 1

s_c = sum(colors)
ans = "{0} {1}".format(max(s_c, 1), s_c + topcoders)
print(ans)

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

#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;


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

	int N;
	cin >> N;

	if(N == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll b = 1LL;
	int s = 1;

	vector<int> v;
	while(N != 0){
		if(N % (b * 2) != 0){
			N -= s * b;
			v.push_back(1);
		}else{
			v.push_back(0);
		}

		s *= -1;
		b *= 2;
	}

	int l = (int) v.size();
	for(int i = l-1; i >= 0; i--) cout << v[i];
	cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    string S; cin >> S;
    int n = S.length() + 1;
    VI a(n);
    REP(i, n-1){
        if(S[i] == '<') chmax(a[i+1], a[i]+1);
    }
    RREP(i, n-2){
        if(S[i] == '>') chmax(a[i], a[i+1]+1);
    }
    /*
        ll sum(0);
        REP(i, n) sum += a[i];
        cout << sum << endl;
    */
    cout << accumulate(ALL(a), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 2820
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAX = 100010;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  mint ans=0,ans1;
  long long int n,k,a[100010],i;
  const int mod=1000000007;
  COMinit();
  scanf("%lld %lld\n",&n,&k);
  for(i=0;i<n;i++){
    scanf("%lld ",&a[i]);
  }
  sort(a,a+n);
  for(i=0;i<n-1;i++){
    ans1=COM(n,k)-COM(i+1,k)-COM(n-i-1,k);
    ans=ans+ans1*(a[i+1]-a[i]);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  cin >> N;
  cout << (N * 2) / 60 << " " << (N * 2) % 60 << endl;
  return 0;
}


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
	class Questionnaire
	{
		static void Main()
		{
			while (true)
			{
				string[] s = Console.ReadLine().Split(' ');
				int N = int.Parse(s[0]);
				int M = int.Parse(s[1]);
				if (N == 0 && M == 0)
					break;

				bool[,] map = new bool[N, M];
				for (int i = 0; i < N; i++)
				{
					string[] buff = Console.ReadLine().Split(' ');
					for (int j = 0; j < M; j++)
					{
						map[i, j] = buff[j] == "1";
					}
				}

				List<TwoNum> rank = Enumerable.Range(1, M).Select(x => new TwoNum(x, 0)).ToList();

				for (int i = 0; i < M; i++)
				{
					int count = 0;
					for (int j = 0; j < N; j++)
					{
						if (map[j, i])
							count++;
					}
					rank[i] = new TwoNum(i + 1, count);
				}
				string ans = rank.OrderByDescending(x => x.Item2).Select(x => x.Item1).Aggregate("", (sum, x) => sum + " " + x).Trim();
				Console.WriteLine(ans);
			}
		}
	}

	class TwoNum
	{
		public int Item1 { get; set; }
		public int Item2 { get; set; }
		public TwoNum(int x,int y)
		{
			Item1 = x;
			Item2 = y;
		}
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<vector<pair<int, int>>> g(n);
	for (int i = 0; i < n; i++) {
		int k, v;
		cin >> k >> v;
		for (int j = 0; j < v; j++) {
			int u, c;
			cin >> u >> c;
			g[k].emplace_back(u, c);
		}
	}

	vector<int> dist(n, INF);
	dist[0] = 0;
	vector<bool> used(n);

	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
	pq.emplace(0, 0);
	while (!pq.empty()) {
		pair<int, int> p = pq.top(); pq.pop();
		int v = p.second;

		if (dist[v] < p.first) {
			continue;
		}

		for (auto e : g[v]) {
			int to = e.first;
			int cost = e.second;
			if (dist[to] > dist[v] + cost) {
				dist[to] = dist[v] + cost;
				pq.emplace(dist[to], to);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << dist[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3216
private const val MODVAL = 1e9.toInt() + 7

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val inputs = readLine()!!.split(" ").map { it.toInt() }

//    // bit を作成する
//    val bit = BIT(n)
//    for (i in 0 until inputs.size){
//        bit.add(i+1, inputs[i])
//    }

//    println(bit.tree.toList())
//    println(bit.sum(3))
//    println(BIT(6).calcInversionNumber(listOf(1,6,3,2)))


    // N の整数列, 並びに２つの間での転倒数さえ求めれば後は計算するだけでは？

    // N 内
    var inside = BIT(inputs.max()!!).calcInversionNumber(inputs) % MODVAL

    // N 間
    var bet = 0
    for ( i in inputs) {
        for (j in inputs) {
            if ( i > j) {
                bet += 1
            }
        }
    }

    // N が k 個ある時の転倒数
    var ans = 0L
    if (k == 1) {
        ans = inside.toLong()
    } else {
        ans = ((inside.toLong() * k % MODVAL) + (bet.toLong() * ((k.toLong() * (k.toLong() - 1)/2) % MODVAL)) % MODVAL) % MODVAL
    }

    println(ans)

}


class BIT(val n: Int) {
    val tree = IntArray(n + 1) { 0 }

    fun add(index: Int, value: Int) {
        var indexTmp = index
        while( indexTmp <= tree.size-1) {
            tree[indexTmp] = (tree[indexTmp] + value) % MODVAL
            indexTmp += indexTmp and -indexTmp
        }
    }

    fun sum(index: Int): Int {
        var sum = 0
        var indexTmp = index
        while( indexTmp > 0 ){
            sum = (sum + tree[indexTmp]) % MODVAL
            indexTmp -= indexTmp and -indexTmp
        }

        return sum
    }

    fun calcInversionNumber(inputs: List<Int>): Int {
        var sum = 0
        for(j in 0 until inputs.size) {
            val index = inputs[j]
            sum = sum + j - this.sum(index)
            this.add(index, 1)
        }
        return sum
    }
}

Measured memory_bytes: 37996
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;


int main() {
	int x, a, b, c;
	cin >> a >> b >> c >> x;
	int now = x, count = 0;
	int aNum = x / 500 <= a ? now / 500 : a;
	now -= aNum * 500;
	int bNum = now / 100 <= b ? now / 100 : b;
	now -= bNum * 100;
	int cNum = now / 50 <= c ? now / 50 : c;
	now -= cNum * 50;
	if (now > 0){ 
		cout << count << endl;
		return 0;
	}
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b; ++j) {
			for (int k = 0; k <= c; ++k) {
				if (i * 500 + j * 100 + k * 50 == x) {
					++count;
				}
			}
		}
	}
	cout << count << endl;
	return 0;
	
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int m;
  scanf("%d", &m);
  vector<int> a(m);
  for (int i = 0; i < m; ++i) {
    int val;
    scanf("%d", &val);
    a[i] = val;
  }
  vector<int>::iterator iter = max_element(a.begin(), a.end());
  int n = *iter, pos = iter - a.begin();
  int diff = INF, r = a[0];
  for (int i = 0; i < m; ++i) {
    if (i == pos) { continue; }
    if (abs(n / 2 - a[i]) < diff) {
      r = a[i];
      diff = abs(n / 2 - a[i]);
    }
  }
  printf("%d %d\n", n, r);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
 
typedef long long ll;
 
const int MAXN=1e5+5;
typedef long long ll;
const int INF = 0x3f3f3f3f;
using namespace std;
 
ll a[MAXN];
ll sum[MAXN];
ll sum_int[MAXN];
int main()
{
    int n,k;
    cin>>n>>k;
    memset(sum,0,sizeof(sum));
    memset(sum_int,0,sizeof(sum_int));
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
        if(a[i]>0) sum_int[i]=sum_int[i-1]+a[i];
        else sum_int[i]=sum_int[i-1];
    }
    ll ans=-INF;
    for(int i=1;i<=(n-k+1);i++)
    {
        ll res=0;
        int j=i+k-1;
        if( sum[j]-sum[i-1] >0) res+= sum[j]-sum[i-1];
        res+= sum_int[i-1]-sum[0];
        res+= sum_int[n]-sum_int[j];
        ans=max(ans,res);
    }
    cout<<ans<<endl;
	return 0;
}

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



using namespace std;



int main() {
	long long w, h, x, y;

	cin >> w >> h >> x >> y;


	int multi = 0;
	if (w == 2 * x &&h == 2 * y) {
		multi = 1;
	}
	//cout << multi << endl;

	long long s = (w * h) / 2;
	cout << s;
	
	if (w* h % 2 == 1) {
		cout <<".5";
	}

	cout << " " << multi;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
typedef long long LL;
using namespace std;

int main(){
    int n, q;
    LL k;
    int tmp;
    vector<LL> a;
    vector<int> ans;
    cin >> n >> k >> q;
    for(int i=0; i<n; i++){
        a.push_back(0);
    }
    for(int i=0; i<q; i++){
        cin >> tmp;
        ans.push_back(tmp);
    }
    for(int i=0; i<q; i++){
        a[ans[i]-1]++;
    }
    for(int i=0; i<n; i++){
        if(a[i] > (LL)q - k){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<string> w(n);
  for (string &x : w) {
    cin >> x;
  }

  set<string> s;
  s.insert(w.at(0));
  for (long i = 1; i < n; i++) {
    if (s.find(w.at(i)) != s.end()) {
      cout << "No" << endl;
      return 0;
    }
    if (w.at(i - 1).at(w.at(i - 1).size() - 1) != w.at(i).at(0)) {
      cout << "No" << endl;
      return 0;
    }
    s.insert(w.at(i));
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 3604
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<list>
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define ll rt<<1
#define rr rt<<1|1
#define mid int m=(x+((y-x)>>1))
#define lson x,m,rt<<1
#define rson m+1,y,rt<<1|1
#define lowbit(x) (x&-x)
#define PB push_back
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define fi freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
using namespace std;

const int N = 2e6 + 10;
const int inf = 1e9;

LL n, t;
LL a[N];
int main()
{
#ifndef ONLINE_JUDGE
    //IN;
#endif

    cin>>n>>t;
    LL ans = 0;
    FF(i, 1, n)
    {
        cin>>a[i];
    }
    FF(i, 2, n)
    {
        LL cur = a[i] - a[i-1];
        ans += min(t, cur);
    }
    ans += t;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

struct edge{
  ll from, to, cost;
  edge(){}
  edge(ll t, ll c){ to = t; cost = c;}
  edge(ll f, ll t, ll c){ from = f; to = t; cost = c;}
};

bool comp(edge a, edge b){
  return a.cost < b.cost;
}

struct UnionFind {
  vi par, count;

  UnionFind(int N) : par(N), count(N, 1){
    for(int i = 0; i < N; i++) par.at(i) = i;
  }

  int root(int x){
    if(par.at(x) == x) return x;
    return par.at(x) = root(par.at(x));
  }

  int unite(int x, int y){
    int rx = root(x); int ry = root(y);
    if(rx == ry) return 0;
    if(size(x) < size(y)){
      count.at(ry) += count.at(rx);
      par.at(rx) = ry;
    }
    else{
      count.at(rx) += count.at(ry);
      par.at(ry) = rx;
    }
    return 1;
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return count.at(root(x));
  }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<edge> E(0);
  while(M--){
    ll s, t, w;
    cin >> s >> t >> w;
    E.push_back(edge(s, t, w));
  }
  sort(ALL(E), comp);
  UnionFind uf(N);
  ll ans = 0;
  for(int i = 0; i < sz(E); i++){
    ll s = E.at(i).from;
    ll t = E.at(i).to;
    ll w = E.at(i).cost;
    if(uf.same(s, t)) continue;
    uf.unite(s, t);
    ans += w;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5996
import java.io.*;
import java.util.*;
 
class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder out = new StringBuilder();
    static ArrayDeque<Integer> li = new ArrayDeque<Integer>();
 
    public static void main(String[] Args) throws IOException {
        int n = Integer.parseInt(br.readLine());
        String in;
        int key;
        for(int i=0; i<n; i++) {
            in = br.readLine();
            if(in.charAt(0) == 'i') {
                key = Integer.parseInt(in.substring(7));
                li.addFirst(key);
            } else if(in.charAt(6) == 'F') {
                li.removeFirst();
            } else if(in.charAt(6) == 'L') {
                li.removeLast();
            } else {
                key = Integer.parseInt(in.substring(7));
                li.remove((Integer) key);
            }
        }
        out.append(li.poll());
        for(int num : li) {
            out.append(' ').append(num);
        }
        out.append('\n');
        System.out.print(out);
    }
 
}

Measured memory_bytes: 117928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = 0;
        int count = 0;
      
        for(int i = 0;i < 3;i++){
          a = sc.nextInt();
       	    if(a == 7){
              count += 1;
        	}else if(a == 5){
              count += 10;
            }
        }
        if(count == 21){
        	System.out.println("YES");
        }else{
          	System.out.println("NO");
        }
    }
}

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

int main() {
  long N;
  cin >> N;
  for (long h = 1; h <= 3500; h++) {
    for (long n = 1; n <= 3500; n++) {
      long double w = (N * h * n) / (double) (4 * h * n - N * n - N * h);
      if (w < 0) continue;
      if (w == (long) w) return cout << h << " " << n << " " << (long) w << "\n", 0;
    }
  }
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  
  bool x = (S[0] == 'A');
  bool y = false;
  int N = S.length();
  int counter=0;
  int ind=-1;
  for(int i=2; i<N-1; i++)
    if(S[i] == 'C')
    {
    	y = true;
      	counter++;
      	ind = i;
    }
  bool z = true;
  for(int i=1; i<N; i++)
  {
    if(i == ind)
      continue;
    if(isupper(S[i]))
      z = false;
  }
  
  if(x&&y&&z&&counter==1)
    cout << "AC";
  else
    cout << "WA";
      	
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,h,w,i,a,b,ans = 0;
    cin >> n >> h >> w;
    for(i=0;i<n;i++){
        cin >> a >> b;
        if(a>=h && b>=w) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def attack(table, i, j):
    table[i][j] = 1 - table[i][j]
    table[i-1][j] = 1 - table[i-1][j]
    table[i+1][j] = 1 - table[i+1][j]
    table[i][j-1] = 1 - table[i][j-1]
    table[i][j+1] = 1 - table[i][j+1]

def printans(ans):
    for i in range(1, 11):
        for j in range(1, 11):
            print(ans[i][j], end="")
            if j < 10:
                print(" ", end="")
        print("")

def solve(table, i, j, ans):

    #print(i,j)
    if i == 11:
        flag = True
        for k in range(1,11):
            if table[10][k] == 1:
                flag = False
                break
        if flag:
            printans(ans)
        return

    if table[i-1][j] == 1:
        ans[i][j] = 1
        attack(table, i, j)
        if j == 10:
            solve(table, i+1, 1, ans)
        else:
            solve(table, i, j+1, ans)
        attack(table, i, j)
        ans[i][j] = 0
    else:
        ans[i][j] = 0
        if j == 10:
            solve(table, i+1, 1, ans)
        else:
            solve(table, i, j+1, ans)


def check(table, i, ans):

    if i == 11:
        solve(table, 2, 1, ans)
        return

    ans[1][i] = 0
    check(table, i+1, ans)

    ans[1][i] = 1
    attack(table, 1, i)
    check(table, i+1, ans)
    attack(table, 1, i)

N = int(input())

for l in range(N):
    table= [[0 for i in range(12)] for j in range(12)]
    ans= [[0 for i in range(12)] for j in range(12)]
    for i in range(1, 11):
        nums = [int(k) for k in input().split()]
        for j in range(1, 11):
            table[i][j] = nums[j-1]

    check(table, 1, ans)


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0;(i) < (ll)(n);(i)++)
#define iter(i, it) for(auto &(i): (it))

int main(void) {
    ll count = 0;
    ll N;
    map<string, ll> m;
    cin >> N;
    rep(i, N) {
        string temp;
        cin >> temp;
        sort(temp.begin(), temp.end());
        m[temp]++;
    }
    iter(i, m) {
        count += i.second * (i.second - 1) / 2;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 11136
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)

	happy := 0
	for i := 1; i < n; i++ {
		if s[i-1] == s[i] {
			happy++
		}
	}
	if v := happy + k*2; v < n {
		fmt.Println(v)
		return
	}
	fmt.Println(n - 1)
}


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

int main(int argc, char const* argv[])
{
	std::string s;
	std::string p;

	std::cin >> s >> p;
	s += s;

	if(s.find(p) == -1)
		std::cout << "No" << std::endl;
	else
		std::cout << "Yes" << std::endl;

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin>>n;
	long long A[n+2],sum=0;
	A[0]=0;
	for(int i=1;i<=n;i++){
		cin>>A[i];
		sum+=abs(A[i]-A[i-1]);
	}
	A[n+1]=0;
	sum+=abs(A[n]);
	for(int i=1;i<=n;i++){
		ll add=0;
		if((A[i-1]<=A[i]&&A[i]<=A[i+1])||(A[i+1]<=A[i]&&A[i]<=A[i-1])){
			add=0;
		}
		else{
			add=abs(A[i-1]-A[i])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1]);
		}
		cout <<sum-add<<endl;
	}
	return 0;
}

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


#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,n,m) for (int i=n; i<(int)(m); i++)
#define INF 1000000007
#define mp make_pair

typedef long long ll;
typedef long double ld;
ll dy[4]={-1,1,0,0};
ll dx[4]={0,0,1,-1};

/*---------- template ----------*/
int H,W;
char field[1010][1010];
int around_zero_num[1010][1010];

int main(){
    cin >> H >> W;
    REP(i,H){
        cin >> field[i];
    }
    queue<pair<int,int> > que;
    REP(i,H){
        REP(j,W){
            if(field[i][j]!='.') que.push(mp(i,j));
            FOR(k,i-1,i+2){
                FOR(l,j-1,j+2){
                    if(i==k&&j==l) continue;
                    if(k<0||l<0||H<=k||W<=l) around_zero_num[i][j]++;
                    else if(field[k][l]=='.') around_zero_num[i][j]++;
                }
            }
        }
    }
    
    int ans=0;
    while(que.size()!=0){
        
        //?£??????????
        vector<pair<int,int> > broken;
        while(que.size()!=0){
            auto x = que.front();
            que.pop();
            if(field[x.first][x.second]!='.'&&int(field[x.first][x.second]-'0')<=around_zero_num[x.first][x.second]){
                broken.push_back(x);
            }
        }
        if(broken.size()!=0) ans++;
        
        //?£???????????????????
        set<pair<int,int> > se;
        for(auto x: broken){
            field[x.first][x.second]='.';
            FOR(i,x.first-1,x.first+2){
                FOR(j,x.second-1,x.second+2){
                    if(i==x.first&&j==x.second) continue;
                    if(i<0||j<0||H<=i||W<=j) continue;
                    if(field[i][j]=='.') continue;
                    se.insert(mp(i,j));//?¬??¢???????????????????
                    around_zero_num[i][j]++;
                }
            }
        }
        for(auto x: se) que.push(x);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15940
#include <stdio.h>
 int main(){
     int W,H,x,y,r;
     scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
     if (x >=r && W >= x + r && y >= r && H >= y + r){
     printf("Yes\n");
}    else {
     printf("No\n");
}    return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            var a = CinTAr();
            lss = CinTAr();
            for(int i = 1; i <= a[0] + 1; i++)
            {
                int r = getb(i);
                if(r <= a[1])
                {
                    count++;
                }
            }
            Cout(count + "");
        }
        static int[] lss = null;
        static int getb(int i)
        {
            if(i == 1)
            {
                return 0;
            }
            else
            {
                return getb(i - 1) + lss[i - 2];
            }
        }

        static string Cin() { return Console.ReadLine(); }
        static string[] CinAr() { return Console.ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return int.Parse(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static void Cout(string s) { Console.WriteLine(s); }
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;
  cin >> n;
  int pren;
  int pres;
  string res;
  cout << 0 << endl;
  cin >> res;
  if(res != "Vacant")
  {
    if(res == "Male")
    {
      pres = 0;
      pren = 0;
    }
    if(res == "Female")
    {
      pres = 1;
      pren = 0;
    }
    int left = 1;
    int right = n-1;
    while(left<=right)
    {
      int cent = (left+right)/2;
      cout << cent << endl;
      cin >> res;
      if(res == "Vacant") break;
      int nres;
      if(res == "Male") nres = 0;
      if(res == "Female") nres = 1;
      int dis = abs(cent-pren);
      if(pres == nres && dis%2==0 || pres != nres && dis%2 != 0)
      {
        left = cent+1;
      }
      else
      {
        right = cent-1;
      }
    }
  }
}

Measured memory_bytes: 852
import sys
from itertools import combinations_with_replacement as comb

N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

Max = 0

for A in comb(range(1, M + 1), N):
    score = 0
    for j in range(Q):
        if (A[b[j] - 1] - A[a[j] - 1]) == c[j]:
            score += d[j]

    Max = max(Max, score)

print(Max)


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

book_list = []
for i in range(N):
    book_list.append(list(map(int,input().split())))

rikai_list = [0 for _ in range(M)]
cost = 0
ans = -1

for bit in range(1 << N):
    cost = 0
    for i in range(0, N):
        if (bit >> i) & 1 == 1:
            for j in range(M):
                rikai_list[j] += book_list[i][j+1]
            cost += book_list[i][0]
    #print(rikai_list)
    ans_check = 1
    for i in range(M):
        if rikai_list[i] < X:
            ans_check = 0
        rikai_list[i] = 0
        if i == M-1 and ans_check == 1:
            if ans == -1:
                ans = cost
            else:
                ans = min(ans,cost)
print(ans)
             

Measured memory_bytes: 9244
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

int qr(){int ret=0,f=1;char ch=getchar();while(!isdigit(ch))f=ch=='-'?-1:1,ch=getchar();while(isdigit(ch))ret=ret*10+ch-'0',ch=getchar();return ret*f;}
#define Rint register int
#define il inline
string a[100005];
map <string,int> b;

int main(){
    int N;
    cin >> N;
    for(int i = 1;i<=N;i++){
        cin >> a[i];
    }
    for(int i = 1;i<=N;i++){
        sort(a[i].begin(),a[i].end());
    }
    unsigned long long ans = 0;
    for(int i = 1;i<=N;i++){
        if(b[a[i]]!=0)
            ans += b[a[i]];
        b[a[i]]+=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18176