akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int dp[1010][1010];

int main(){
  int q;
  cin >> q;
  for(int i = 0; i < q; ++i){
    string x, y;
    cin >> x >> y;
    fill((int*)dp, (int*)dp + sizeof(dp) / sizeof(int), 0);
    // fill((int*)dp, (int*)(dp + 1010), 0);

    int xs = x.size();
    int ys = y.size();

    for(int i = 0; i < xs; ++i){
      for(int j = 0; j < ys; ++j){
        if(x[i] == y[j])dp[i + 1][j + 1] = dp[i][j] + 1;
        else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      }
    }

    cout << dp[xs][ys] << endl;
  }

  return 0;
}



Measured memory_bytes: 7172
#include <stdio.h>

int main(void) {
	// your code goes here
	int h, w, i, j;
	while (1){
		do{ scanf("%d %d", &h, &w); } while (h<0 || h>300 || w<0 || w>300);
		if (h == 0 && w == 0){ break; }

		for (i = 0; i<h; i++){
			if (!(i % 2)){
				for (j = w; j>0; j--){
					printf("#");
					j--;
					if (j>0){ printf("."); }
				}printf("\n");
			}

			else{
				for (j = w; j>0; j--){
					printf(".");
					j--;
					if (j>0){ printf("#"); }
				}printf("\n");
			}
		}printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
// include
#include <iostream>
#include <stdio.h>
#include<string.h>
#include<vector>
#include<string>
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;


int main(void) {
	int i;
	string s, t;
	cin >> s;
	for (i = 0; s[i] != '\0'; i++) {
		if(s[i] == '0')
			t += '0';
		else if(s[i] == '1')
			t += '1';
		else if(s[i] == 'B') {
			if (t.empty() == false)
				t.pop_back();
		}
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 256
process.stdin.setEncoding("utf8");
process.stdin.on("data", input => {
  // 3 4 9 0
  const inputArr = input.split(" ");
  const A = inputArr[0];
  const B = inputArr[1];
  const H = inputArr[2];
  const M = inputArr[3];
  const result = getResult(A, B, H, M);
  console.log(result);
});

const getResult = (A, B, H, M) => {
  const minuteDegree = (Math.PI * 2.0 * M) / 60;
  const hourDegree = Math.PI * 2 * (H / 12 + M / 60 / 12);
  const theta = minuteDegree - hourDegree;
  
  return calcCosinTheorem(A, B, theta);
};

const calcCosinTheorem = (A, B, theta) => {
  return Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta));
};


Measured memory_bytes: 30408
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;

#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long  ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}


int main()
{
    run;
    ll n,r;
    cin>>n>>r;
    if(n>=10)
    {
        cout<<r<<endl;
    }else{

    cout<<r+100*(10-n);
    }


    return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ull unsigned long long
#define endl '\n'

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll N = 1e5+1;
const ll P = 31;
const double PI =  acos(-1.0);

ll a[1001];
int main() {
//  freopen(    "angle2.in", "r", stdin);
//  freopen("angle2.out", "w", stdout);
    IOS
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll sum = 0;
    sort(a+1, a+1+n);
    for(int i = 1; i <= k; i++) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N,M,K;
  K=0;
  cin>>N>>M;
  vector<int> a(N);
  rep(i,N){
    cin>>a[i];
    K+=a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(a[M-1]*4*M<K)
    cout<<"No";
  else
    cout<<"Yes";
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int arr[105];
long long dp[105][100005];
int solve(int idx,int left)
{
    if(idx == 0)
        return left == 0;
    int C = 0;
    for(int i = 0;i <= arr[idx] && i <= left;i++)
        C += solve(idx - 1,left - i);
    return C;
}
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
        cin >> arr[i];
    dp[0][0] = 1;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 0;j <= k;j++)
        {
            int f1 = j;
            int f2 = j - min(arr[i],j);
            dp[i][j] += (((dp[i-1][f1] - (f2 ? dp[i-1][f2-1] : 0)) % MOD) + MOD )%MOD;
            dp[i][j] %= MOD;
            if(j)
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][k] % MOD;
    return 0;
}


Measured memory_bytes: 79360
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n, x, y = MI()

    def dist(a, b):
        return b - a

    ans = [0 for _ in range(n-1)]
    for i in range(1, n):
        for j in range(i+1, n+1):
            if i <= x and y <= j:
                d = dist(i, x) + 1 + dist(y, j)
            elif x < i < y:
                if x < j < y:
                    d = min(dist(i, j), dist(x, i) + 1 + dist(j, y))
                else:
                    d = min(dist(x, i)+1, dist(i, y)) + dist(y, j)
            elif x < j < y:
                d = min(dist(i, j), dist(i, x) + 1 + dist(j, y))
            else:
                d = dist(i, j)
            # print(i, j, d)
            ans[d-1] += 1
    print("\n".join(map(str, ans)))



if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
N,Y = map(int,input().split(" "))
for i in range(N+1):
    if Y < i*10000:
        print(-1,-1,-1)
        exit()
    for j in range(N-i+1):
        money = i*10000 + j*5000 + (N-i-j)*1000
        if money == Y:
            print(i,j,N-i-j)
            exit()
        elif money > Y:
            break
print(-1,-1,-1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	int h,w; cin >> h >> w;
	vl a(h), b(h);
	rep(i,h) cin >> a[i] >> b[i], a[i]--, b[i]--;
	vector<int> val(w,0);
	set<int> se;
	multiset<int> mse;
	rep(i,w) mse.insert(0);
	rep(i,w) se.insert(i);
	rep(i,h){
		auto itr = se.lower_bound(a[i]);
		vector<int> era;
		while(itr != se.end() && *itr <= b[i]){
			if(*itr > b[i]) break;
			int tmp = val[*itr] + b[i] + 1 - *itr;
			if(b[i]+1 != w){
				if(val[b[i]+1] > tmp){
					mse.erase(mse.find(val[b[i]+1]));
					mse.insert(tmp);
					chmin(val[b[i]+1], tmp);
				}
			}
			mse.erase(mse.find(val[*itr]));
			mse.insert(inf);
			val[*itr] = inf;
			itr = se.erase(itr);
		}
		if(b[i] + 1 < w) se.insert(b[i]+1);
		int ans = *mse.begin();
		if(ans == inf) cout << -1 << "\n";
		else cout << ans + i + 1 << "\n";
	}
}

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

using namespace std;

int main() {
    int K, N;  // 円周と家の軒数
    cin >> K >> N;

    vector<int> A;  // 家の位置の配列
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    // 考え方メモ
    // 1, 時計回り
    // 2, 反時計回り
    // 5 10 15
    // 時計回り：
    // 5を始点 -> 15 - 5 = 10
    // 10を始点 -> (20 - 10) + (0 + 5) = 15
    // 15を始点 -> (20 - 15) + (0 + 10) = 15
    // 反時計回り
    // 5を始点 -> (5 - 0) + (20 - 10) = 15
    // 10を始点 -> (10 - 0) + (20 - 15) = 15
    // 15を始点 -> 15 - 5 = 10
    // 一般化
    // 時計回りの場合は、始点がA[0]の場合は、A[N - 1] - A[i]
    // 始点がA[0]以外の場合は、(K - A[i]) + A[i - 1] -> K - A[i] + A[i - 1]
    // 反時計回りの場合は、始点がA[N - 1]の場合は、A[i] - A[0]
    // 始点がA[N - 1]以外の場合は、A[i] + (K - A[i + 1]) -> K + A[i] - A[i + 1]

    int minOfMoving = K;
    for (int i = 0; i < N; i++) {  // 始点にする点

        // 時計回り
        if (i == 0) {
            minOfMoving = min(minOfMoving, A[N - 1] - A[i]);
        } else {
            minOfMoving = min(minOfMoving, K - A[i] + A[i - 1]);
        }

        // 反時計回り
        if (i == N - 1) {
            minOfMoving = min(minOfMoving, A[i] - A[0]);
        } else {
            minOfMoving = min(minOfMoving, K + A[i] - A[i + 1]);
        }
    }

    cout << minOfMoving << endl;

    return 0;
}

Measured memory_bytes: 1400
import numpy as np
import sys
 
A = []
for i in range(3):
    array = list(map(int, input().split()))
    A.append(array)
N = int(input())
b = []
for i in range(N):
    k = int(input())
    b.append(k)
for k in range(N):
    for i in range(3):
        for j in range(3):
            if b[k] == A[i][j]:
                A[i][j] = 0
 
 
row = np.sum(A, axis=1)
for i in range(3):
    if row[i] == 0:
        print('Yes')
        sys.exit()
 
 
col = np.sum(A, axis=0)
for i in range(3):
    if col[i] == 0:
        print('Yes')
        sys.exit()
 
c = 0
for i in range(3):
    c += A[i][i]
if c == 0:
    print('Yes')
    sys.exit()
 
c = 0
for i in range(3):
    c += A[3-i-1][i]
if c == 0:
    print('Yes')
    sys.exit()
 
print('No')

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

int main(){

    long long N;
    cin >> N;
    long long ans = INT_MAX;
    for(long long i = 1; i*i <= N;i++){
        if(N%i!=0)continue;
        //cout << i << " " << N/i << endl;
        long long value = max(i,N/i);
        long long cont = 0;
        while(value){
            cont++;
            value /= 10;
        }
        ans = min(cont,ans);
    }
    cout << ans << endl;
    
    
}



Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N =sc.nextInt();
		int[][] score = new int[N][3];
		for(int i=0; i<N; i++) {
			for(int j=0; j<3; j++)
				score[i][j] = sc.nextInt();
		}
		long[][] dp = new long[N][3];
		dp[0][0] = score[0][0];
		dp[0][1] = score[0][1]; 
		dp[0][2] = score[0][2];
		
		for(int i=1; i<N; i++) {
			for(int j=0; j<3; j++) {
				dp[i][j] = max(dp[i-1][ (j+1) % 3], dp[i-1][(j+2) % 3]) + score[i][j];
			}
		}
		long sum = max(max(dp[N-1][0], dp[N-1][1]),dp[N-1][2]);
		
		out.println(sum);		
	}
}

Measured memory_bytes: 101020
n = int(input())
a = list(map(int, input().split()))
flg = 0
for i in a:
	if i%2 == 0:
		if i%3 == 0 or i%5 == 0:
			continue
		else:
			flg = 1
if flg == 1:
	print ("DENIED")
else:
	print ("APPROVED")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int h[200000],dp[200000];
int jump(int i)
{
	if(i==1)
	{
		return 0;
	}
	if(dp[i]==-1)
	{
		int a;
		a = abs(h[i]-h[i-1])+ jump(i-1);
		if(i-2>0)
			a = min(a,abs(h[i]-h[i-2])+ jump(i-2));

		dp[i] = a;

	}
	return dp[i];
}
int main()
{
	int n;
	cin>>n;
	for (int i = 1; i <= n; ++i)
	{
		dp[i] = -1;
		cin>>h[i];
	}

	cout<<jump(n)<<endl;

	
	return 0;
}

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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> v(n+3);
    for(ll i=0;i<n-1;i++) cin>>v[i];

    ll ar[n+4];
    memset(ar,-1,sizeof(ar));
    for(ll i=0;i<n-1;i++){
        ll x=v[i];
        if(ar[i]==-1) ar[i]=x;
        else ar[i]=min(ar[i],x);

        if(ar[i+1]==-1) ar[i+1]=x;
        else ar[i+1]=min(ar[i+1],x);
    }
    ll sum=0;
    for(ll i=0;i<n;i++){
       // cout<<ar[i]<<" ";
        sum+=ar[i];
    }
    //cout<<endl;
    cout<<sum<<endl;
    return 0;
}


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

bool Check(char c) {
  string tmpS = "ACGT";
  for (int k = 0; k < 4; k++) {
    if (c == tmpS.at(k)) return true;
  }
  return false;
}

int main() {
  
  string S; cin >> S; int ans = 0;
  
  for (int i = 0; i < S.size(); i++) {
    int tmp = 0;
    for (int j = i; j < S.size(); j++) {
      if (Check(S.at(j))) tmp++;
      else break;
    }
    ans = max(ans, tmp);
  }
  
  cout << ans << endl;
  
}

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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126576
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main()
{
    string S;
    cin >> S;

    unordered_map<int, int> remainders;
    ll rem = 0;
    int cnt = 0;
    ll base = 1;
    remainders[0] = 1;
    rrep(i, S.size(), 0)
    {
        rem += base*(ll)(S[i]-'0');
        rem %= 2019;
        base *= 10;
        base %= 2019;
        // cout << rem << endl;

        cnt += remainders[rem];
        ++remainders[rem];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3724
n = int(input())
a = list(map(int,input().split()))

res = 0
right = 0
sum = 0
for left in range(n):
    while (right < n and sum^a[right] == sum+a[right]):
        sum += a[right]
        right += 1
    res += right - left
    if left == right:
        right += 1
    else:
        sum -= a[left]
print(res)

Measured memory_bytes: 24712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  if(s.at(0)=='A')cout << 'T' <<endl;
  if(s.at(0)=='T')cout << 'A' <<endl;
  if(s.at(0)=='C')cout << 'G' <<endl;
  if(s.at(0)=='G')cout << 'C' <<endl;
}

Measured memory_bytes: 256
#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<vector<int>> v;
    for (int i = 0; i < n - 1; i++) {
        vector<int> vv(3, 0);
        cin >> vv[0] >> vv[1] >> vv[2];
        v.push_back(vv);
    }
    for (int i = 0; i < n - 1; i++) {
        int t = v[i][1];
        for (int j = i; j < n - 1; j++) {
            t = max(t, v[j][1]);
            if ((t - v[j][1]) % v[j][2] > 0) {
                t = v[j][1] + ((t - v[j][1]) / v[j][2] + 1) * v[j][2];
            }
            t += v[j][0];
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
const int N = 300005;
int E[N];
int main () {
    int n;
    string s;
    cin >> n >> s;
    for (int i = n - 1; i >= 0; i--) {
		E[i] = E[i+1] + (s[i] == 'E');
	}
	int W = 0, res = n;
	for (int i = 0; i < n; i++) {
		res = min(res, W + E[i+1]);
		W += s[i] == 'W';
	}
	cout << res<< endl;
    return 0 ;

}

 


Measured memory_bytes: 4884
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string st;
  cin >> n >> st;
  st = " " + st;
  int i = 1, j = n, cnt = 0;
  while (i < j && i <= n && j >= 1) {
    while (i <= n && st[i] != 'W') i++;
    while (j >= 1 && st[j] != 'R') j--;
    if (i >= j) break;
    char temp = st[i];
    st[i] = st[j];
    st[j] = temp;
    cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3924
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	cout<<abs(a*b-a-a-b-b+4);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
vector<pair<int,int> >a;
int main(){
	int n;
	cin>>n;
	int a[105];
	for(int i=0;i<n;i++)cin>>a[i];
	int ans=0;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n;j++)
	ans=max(ans,abs(a[i]-a[j]));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
use proconio::input;

fn floor(a: usize, b: usize, x: usize) -> usize {
    a * x / b - a * (x / b)
}

fn main() {
    input! {
        a: usize,
        b: usize,
        n: usize,
    }

    println!("{}", floor(a, b, n.min(b - 1)));
}


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

using namespace std;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    while(1) {
        int e; cin >> e;
        if(e == 0) break;
        int ans = 1000000;;
        rep(z, pow(e, 1.0/3.0)+1) {
            rep(y, sqrt(e)+1) {
                int x = e - y*y - z*z*z;
                if(x < 0) break;
                ans = min(ans, x + y + z); 
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3264
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String[] str = new Scanner(System.in).next().split("");
		List<String> each = Arrays.asList(str);
		boolean found = false;

		Collections.sort(each);
		for(char word = 'a'; word <= 'z'; word++) {
			if( !each.contains(String.valueOf(word)) ) {
				System.out.println(word);
				found = true;
				break;
			}
		}
		if( !found ) System.out.println("None");
	}
}


Measured memory_bytes: 32876
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		Set<Integer> set = new HashSet<>();
		int ans = 0;
		for(int i = 0;i < n;i++){
			int num = saori.saori_hayami();
			if(set.contains(num)){
				set.remove(num);
			} else {
				set.add(num);
			}
		}
		System.out.println(set.size());
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 42248
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}
typedef tree<
long long,
null_type,
less<long long>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
std::vector<std::vector<long long>> inp,ans;
std::vector<std::vector<long long>> mult(std::vector<vi> v1,std::vector<vi> v2)
{
	long long n=v1.size();
	std::vector<std::vector<long long>> fin(n,std::vector<long long>(n,0));
	REP(i,0,n-1)
	{
		REP(j,0,n-1)
		{
			REP(k,0,n-1)
			{
				fin[i][j]=((fin[i][j]+((v1[i][k]*v2[k][j])%N))%N);
			}
		}
	}

	return fin;
}
std::vector<std::vector<long long>> expo(std::vector<std::vector<long long>> mat, long long power)
{
	if(power==1){return mat;}
	if(power==2){return mult(mat,mat);}
	std::vector<vi> ret=expo(mat,(power/2));
	ret=mult(ret,ret);
	if(power%2==0){return ret;}
	else{return mult(ret,mat);}
}
long long solve()
{
	long long n,k;cin>>n>>k;
	inp.resize(n,std::vector<long long> (n,0));
	REP(i,0,n-1)
	{
		REP(j,0,n-1)
		{
			cin>>inp[i][j];
		}
	}
	ans=expo(inp,k);
	long long prt=0;
	REP(i,0,n-1)
	{
		REP(j,0,n-1)
		{
			prt=((prt+ans[i][j])%N);
		}
	}
	cout<<prt<<"\n";
}
signed main(){
	speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((a-b) == (b-c)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
	}

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long int n,m;

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

	if(n==1 && m==1)	printf("1");
	else if(n==1 || m==1)	printf("%lld", n+m-3);
	else	printf("%lld", (n-2)*(m-2));

	return 0;
}


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

int main(){
  string s,t;
  int len;
  cin>>len;
  cin>>s>>t;

  int ans=len*2;
  for(int i=0;i<len;i++){
    if(s.substr(i,len-i)==t.substr(0,len-i))ans=min(len+i,ans);
  }
  cout << ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
 
long long mod = 1000000007;
const long long N=2e5+10;

int a[N],b[2*N];
int main() {
    
    long long n, k;
    
    cin>>n>>k;
    
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    k=min(k, 1ll + 50);
    
    while(k--){
        for(int i=1;i<=n;i++){
            b[i]=0;
        }
        
        for(int i=1;i<=n;i++){
            int l = max(1,i-a[i]);
            int r = i + a[i];
            
            b[l]++;
            b[r+1]--;
        }
        
        for(int i=1;i<=n;i++){
            
            b[i]=b[i]+b[i-1];
        
        }
        
        for(int i=1;i<=n;i++){
            a[i]=b[i];
        }
    }
    
    for(int i=1;i<=n;i++){
        cout<<a[i]<<' ';
    }
    return 0;
}


Measured memory_bytes: 5908
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAX_NM = 50;

int main() {
  int n, m;
  int a[MAX_NM], b[MAX_NM], c[MAX_NM], d[MAX_NM];
  cin >> n >> m;
  for (int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  for (int i=0;i<m;i++) {
    cin >> c[i] >> d[i];
  }
  for (int i=0;i<n;i++) {
    int mini = 1001001001, ans;
    for (int j=0;j<m;j++) {
      int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (tmp < mini) {
        mini = tmp;
        ans = j;
      }
    }
    cout << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 764
n = int(input())
a = list(map(int, input().split()))

flg = True
for i in range(n):
    if a[i] % 2 == 0:
        if not (a[i] % 3 == 0 or a[i] % 5 == 0):
            flg = False

if flg:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5+7;
vector<int> adj[maxn], suf[maxn], pre[maxn];
int down[maxn], up[maxn], parent[maxn];
ll mod;

int mul(int a, int b) {
	return (ll) a * b % mod;
}

void dfs1(int a, int p) {
	down[a] = 1ll;	
	parent[a] = p;
	up[a] = 1ll;
	for(int b : adj[a]) if(b != p) { 
		dfs1(b, a);
		down[a] = mul(down[a], down[b] + 1);
	}
}

void dfs2(int a, int p) {
	//calculate up[a] for my children
	for(int i = 0; i < (int)adj[a].size(); i++) {
		int b = adj[a][i];
		if(b == parent[a]) continue;
		int p = (i - 1 >= 0 ? pre[a][i - 1] : 1);
		int s = (i + 1 < (int)adj[a].size() ? suf[a][i + 1] : 1);
		up[b] = mul(up[a], mul(p, s));
		up[b]++;
	}
	for(int b : adj[a]) if(b != p) {
		dfs2(b, a);
	}
}

int main() {

	int n;
	cin >> n >> mod;

	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs1(0, 0);	

	for(int i = 0; i < n; i++) {
		int running = 1;
		for(int j = 0; j < (int)adj[i].size(); j++) {
			if(adj[i][j] != parent[i]) running = mul(running, down[adj[i][j]] + 1);
			pre[i].push_back(running);
		}
		running = 1;
		for(int j = (int)adj[i].size() - 1; j >= 0; j--) {
			if(adj[i][j] != parent[i]) running = mul(running, down[adj[i][j]] + 1);	
			suf[i].push_back(running);
		}
		reverse(suf[i].begin(), suf[i].end());
	}

	dfs2(0, 0);

	for(int i = 0; i < n; i++) {
		cout << mul(up[i], down[i]) << '\n';
	}

	return 0;
}


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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

vector<vector<int>> g;
vector<int> comp;

void dfs(int u, int c) {
    comp[u] = c;
    for(int v : g[u]) {
        if(comp[v] == -1) {
            dfs(v, c);
        }
    }
}

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

    int n, m;
    cin >> n >> m;
    // nodes in component, values in component
    g.resize(n);
    comp.resize(n, -1);
    vector<int> p(n);
    forn(i, n) cin >> p[i], --p[i];
    forn(i, m) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int cc = 0;
    forn(i, n) if(comp[i] == -1) dfs(i, cc++);
    vector<vector<int>> values(cc);
    forn(i, n) {
        values[comp[i]].push_back(p[i]);
    }
    forn(i, cc) {
        sort(values[i].begin(), values[i].end());
    }
    int ans = 0;
    #define bs(x, v) binary_search(x.begin(), x.end(), v)
    forn(i, n) {
        if(bs(values[comp[i]], i)) {
            ans++;
        }
    }
    cout << ans << endl;
}













// Don't worry, you're getting better

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 9728
STDIN.gets
numbers = STDIN.gets.split(' ').map(&:to_i)

split = 0

prev = numbers.first
diff = 0
numbers[1..-1].each do |n|
  if (prev < n)
    if (diff == -1)
      split += 1
      diff = 0
    else
      diff = 1
    end
  elsif (prev > n)
    if (diff == 1)
      split += 1
      diff = 0
    else
      diff = -1
    end
  else
    nil
  end
  prev = n
end

puts split + 1

Measured memory_bytes: 8452
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      if(A == B && B == C && A == C){
        if(A % 2 == 0){
          System.out.println("-1");
        }else{
          System.out.println("0");
        }
        return;
      }
      int count = 0;
      while(count <= 100){
        if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
          System.out.println(count);
          return;
        }else{
          	int tmpA = (B + C) / 2;
        	int tmpB = (A + C) / 2;
        	int tmpC = (A + B) / 2;
        	count++;
            A = tmpA;
            B = tmpB;
            C = tmpC;
        }
      }
      if(count > 100){
        System.out.println("-1");
      }
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 100010
#define N 51
ll n,a[N][N];
struct Mat{
	ll n;
	ll data[N][N];
};
Mat operator*(Mat &A,Mat &B){
	Mat C;C.n=n;
	rep(i,0,A.n)rep(j,0,A.n){
		C.data[i][j]=0;
		rep(k,0,A.n)(C.data[i][j] += A.data[i][k]*B.data[k][j]) %=md;
	}
	return C;
}
Mat operator^(Mat &A,ll b){
	Mat C;C.n=n;
	rep(i,0,A.n)rep(j,0,A.n){
		if(i==j)C.data[i][j]=1;
		else C.data[i][j]=0;
	}
	while(b){
		if(b&1)C=C*A;
		A=A*A,b/=2;
	}
	return C;
}
int main(){
	IOS;
	tihs;
	ll k;
	cin>>n>>k;
	Mat C;
	C.n=n;
	rep(i,0,n)rep(j,0,n)cin>>C.data[i][j];
	C=C^k;
	ll ans=0;
	rep(i,0,n)rep(j,0,n)(ans+=C.data[i][j]) %= md;
	cout<<ans;



	return 0;
}

Measured memory_bytes: 384
flag1=True
flag2=True

for i in range(2):
    if i==0:
        a=input()
    else:
        b=input()

n=len(a)
uselist=[0]*n
for i in range(n):
        uselist[i]=(a[i],b[i])

  
sets=set(uselist)
dicti={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
dicti2={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

for i in sets:
        dicti[i[0]]+=1
        dicti2[i[1]]+=1
for i in dicti.values():
    if i>=2:
        flag1=False
        
        
for i in dicti2.values():
    if i>=2:
        flag2=False
        

if flag1 and flag2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 17968
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, x, l, t, ans=0;
    
    cin >> N;

    vector<pair<ll,ll>> p(N);

    for(i=0; i<N; i++){
        cin >> x >> l;
        p[i].first = x+l; // 終
        p[i].second = x-l; // 始
    }

    sort(p.begin(), p.end());

    t = -10000000000;

    for(i=0; i<N; i++){
        if(t <= p[i].second){
            ans++;
            t = p[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	private static int pos;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());
		for(int i = 0; i < n ; i++){
			String input = sc.nextLine();
			
			pos = 0;
			System.out.println(recursive(input));
		}
	}
	
	public static int recursive(String input){
		if( (input.charAt(pos) + "").matches("[0-9]+") ){/* ??°????????? */
			int sum = 0;
			while(input.charAt(pos) != ']'){
				sum = sum * 10 + Integer.parseInt(input.charAt(pos++) + "");
			}
			return (sum / 2 + 1);/* ??????????????§???????????????????°??????° */
		}
		
		ArrayList<Integer> array = new ArrayList<Integer>();
		while(input.charAt(pos) == '['){
			pos++;/* nextChar <- '[' */
			array.add(recursive(input));/* get Number */
			pos++;/* nextChar  <-  ']' */
			if(pos >= input.length()) break;
		}
		
		Collections.sort(array);/* ????°??????°?????????????????????????????????????????????????????°?????? */
		int sum = 0;
		int majority = array.size() / 2 + 1;/* ????????°????????§????????°?????? */
		for(int i = 0; i < majority; i++){
			sum += array.get(i);
		}
		
		return sum;
	}
}

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

int main(){
  int n,a,flag=0;
  cin >> n;
  rep(i,n){
    cin >> a;
    if(a%2==0){
    if(a%3!=0)
    if(a%5!=0)
      flag=1;
   }
  }
  if(flag==1) cout << "DENIED";
  else cout << "APPROVED";
  
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size,-1) { }

    int root(int x){
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
    }

    int size(int x){
        return -data[root(x)];
    }

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

    bool connect(int x , int y){
        x = root(x);
	    y = root(y);
	
        if(x==y) return false;
        
        if(data[x] > data[y]){
            x ^= y;
            y ^= x;
            x ^= y;
        }
        
        data[x] = data[x] + data[y]; // membersize++
        data[y] = x;
        return true;
    }
};

UnionFind U(300002);

int main() {
    int N,M; cin >> N >> M;
    REP(i,M){
        int a,b; cin >> a >> b;
        U.connect(a - 1,b - 1);
    }

    int ans = 0;
    REP(i,N){
        if (U.root(i) != i) continue;
        chmax(ans, U.size(i));
    }
    cout << ans << endl;
}

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

int main(){
    long long X;
    long long preX=100;
    int cnt=0;
    
    cin >> X;
     
    while(preX < X){
        preX += (long)preX * 0.01;
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 3e5+10;
const int mod =   1e9+7;

string s;int d,dp[10005][2][105];
ll ans=0;


int main () {

	cin>>s>>d;
	dp[0][0][0]=1;
	for(int i=0;i<s.size();i++){
		for(int j=0;j<2;j++){
			int x=j?9:s[i]-'0';
			for(int k=0;k<=x;k++){
				for(int l=0;l<d;l++){
					(dp[i+1][j|(k<x)][(k+l)%d]+=dp[i][j][l])%=mod;
				}
			}
		}
	}
	  cout<<(dp[s.size()][0][0]+dp[s.size()][1][0]-1ll+mod)%mod;
    return 0;
}

Measured memory_bytes: 8448