akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
void magicSquare(vector<vector<int> > &v1) {
  int n = v1.size();
  int row = (n / 2 + 1), column = n / 2;
  
  v1[row][column] = 1;
  for(int cnt = 2; cnt <= n * n; ++cnt) {
	row = (row == n - 1 ? 0 : row + 1);
	column = (column == n - 1 ? 0 : column + 1);

	while(v1[row][column] != 0) {
	  row = (row == n - 1 ? 0 : row + 1);
	  column = (column == 0 ? n - 1 : column - 1);
	}
	v1[row][column] = cnt;
  }
}

int main() {
  int n;
  while(cin >> n) {
	if(n == 0) break;

	vector<vector<int> > v1(n, vector<int>(n, 0));
	magicSquare(v1);
	for(int i = 0; i < n; ++i) {
	  for(int j = 0; j < n; ++j) {
		cout << right << setw(4) << v1[i][j];
	  }
	  cout << endl;
	}
  }
  return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	string a, b;
	int ap=0, bp=0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a > b) { ap += 3; }
		else if (a < b) { bp += 3; }
		else if (a == b) { ap++; bp++; }
	}
	cout << ap << " " << bp << endl;
}


Measured memory_bytes: 3168
from collections import defaultdict
N = int(input())
As = list(map(int, input().split()))

l_count = defaultdict(int)
r_count = defaultdict(int)
for i, A in enumerate(As):
    l_count[i + A] += 1
    r_count[i - A] += 1
    
ans = 0
for k, lv in l_count.items():
    rv = r_count[k]
    ans += lv * rv

print(ans)

Measured memory_bytes: 151300
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
          int[] h = ReadLine().Split(' ').Select(int.Parse).ToArray();
          if(h[0] < h[1]){
              WriteLine(1);
              return;
          }
          if(h[0] % h[1] == 0){
              WriteLine(h[0] / h[1]);
              return;
          }
          WriteLine(h[0] / h[1] + 1);
      }
   }
}

Measured memory_bytes: 13268
import sys

input = sys.stdin.readline

H, W = map(int, input().split())
Ms = [input().strip("\n") for _ in range(H)]

C = 10 ** 9 + 7
dp = [0] * (W + 1)
dp[0] = 1
for row in Ms:
    for i in range(len(row)):
        i1 = i + 1
        if row[i] == '#':
            dp[i1] = 0
        else:
            dp[i1] += dp[i]
            dp[i1] %= C
    dp[0] = 0
print(dp[W])

Measured memory_bytes: 44780
#include<stdio.h>
#define MAX 100000

int parent(int i) {return i / 2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

int main()
{
	int h, i, A[MAX+1];
	
	scanf("%d", &h);
	for(i=1; i<=h; i++){
		scanf("%d", &A[i]);
	}
	
	for(i=1; i<=h; i++){
		printf("node %d: key = %d, ", i, A[i]);
		if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
		if(left(i) <= h) printf("left key = %d, ", A[left(i)]);
		if(right(i) <= h) printf("right key = %d, ", A[right(i)]);
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2140
n,ma,mb=map(int,input().split())
dp=[[[9999]*401for _ in range(401)]for _ in range(n+1)];dp[0][0][0]=0
sa=sb=0
for i in range(1,n+1):
  a,b,c=map(int,input().split())
  sa+=a;sb+=b
  for j in range(401):
    for k in range(401):
      if j>=a and k>=b:dp[i][j][k]=min(dp[i-1][j-a][k-b]+c,dp[i-1][j][k])
      else:dp[i][j][k]=dp[i-1][j][k]
a=9999
for i in range(1,min(sa//ma,sb//mb)+1):
  if dp[n][ma*i][mb*i]!=9999:a=min(a,dp[n][ma*i][mb*i])
print(-1if a==9999else a)

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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define IN long long
#define int long double
int a, b, n, ans;

int32_t main() {
	cin >> a >> b;
	b *= 10.0;
	for (int i = b; i < b + 10; i++) {
		if((IN)(i * 0.08) == (IN)a) return cout << i,0 ;
//		cout << (i * 0.08) << ' ';
	}
	return cout << -1, 0;
}

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

int n;
int memo[366][3][3][7][7][7][7];
int fes[366][4][4];

vi dx = { 1, 0,-1, 0, 0};
vi dy = { 0,-1, 0, 1, 0};

bool rec(int day, int y, int x, int a, int b, int c, int d){
    if(a == 7 or b == 7 or c == 7 or d == 7) return false;
    if(day == n){
        return true;
    }

    if(memo[day][y][x][a][b][c][d] != -1) return memo[day][y][x][a][b][c][d];

    rep(i, 2){
        rep(j, 2){
            if(fes[day][y + i][x + j]){
                return memo[day][y][x][a][b][c][d] = false;
            }
        }
    }

    bool ret = false;
    rep(i, 5){
        range(j, 1, 3){
            int ny = y + dy[i] * j;
            int nx = x + dx[i] * j;

            if(nx < 0 or 2 < nx or
               ny < 0 or 2 < ny) continue;

            int na = a + 1, nb = b + 1, nc = c + 1, nd = d + 1;
            if(ny == 0 and nx == 0) na = 0;
            if(ny == 0 and nx == 2) nb = 0;
            if(ny == 2 and nx == 0) nc = 0;
            if(ny == 2 and nx == 2) nd = 0;

            ret |= rec(day + 1, ny, nx, na, nb, nc, nd);
        }
    }

    return memo[day][y][x][a][b][c][d] = ret;
}

int main(void){
    for(; cin >> n, n;){
        rep(i, n){
            rep(y, 4){
                rep(x, 4){
                    cin >> fes[i][y][x];
                }
            }
        }

        rep(i1, n) rep(i2, 3) rep(i3, 3) rep(i4, 7) rep(i5, 7) rep(i6, 7) rep(i7, 7) memo[i1][i2][i3][i4][i5][i6][i7] = -1;

        cout << rec(0, 1, 1, 1, 1, 1, 1) << endl;
    }

	return 0;
}

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

int main() {
  long long N; cin >> N;
  set<int> A;
  int a[N];

  for(int i=1; i<=N; i++) {
    cin >> a[i];
    A.insert(a[i]);
    if(A.size() < i) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

int main() {
	long long x, y;
	cin >> x >> y;
	int cnt = 0;
	long long z = 1;
	y = y / x;
	while (z<=y) {
		z = z * 2;
		cnt += 1;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a>>b ;
  int n = b - a;
  cout << n*(n + 1)/2 - b << endl;

}


Measured memory_bytes: 256
import math

n = int(input())
#a = int(input())
#a,b = list(map(int,input().split(" ")))
#ls = list(input().split(" "))
ls = list(map(int,input().split(" ")))
#a,b = list(input().split())
#string = input()
#ls = [int(input()) for i in range(n)]
#ls1 = [input() for i in range(n)]
#m = int(input())
#ls2 = [input() for i in range(m)]

ls.sort(reverse=True)
print(sum(ls[0::2]) - sum(ls[1::2]))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>



using namespace std;
typedef long long ll;
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}

int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}









int main() {
  int N;
  cin>>N;
  int x=N;
  int sum=0;
  for(int i=0;x>0;i++){
    sum+=x%10;
    x/=10;

  }
  if(N%sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  




    




  

  


  

    


  

  
  
  
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n+2),b(n+2);
	FOR(i,1,n+1){
		cin>>a[i];
	}
	bool flag=true;
	set<P> st;
	FOR(i,1,n+1){
		cin>>b[i];
		if(b[i]<a[i]){
			flag=false;
		}
		if(b[i]!=a[i]) st.insert(P(b[i],i));
	}
	if(!flag){
		cout<<-1<<endl;
		return 0;
	}
	b[0]=b[n],b[n+1]=b[1];
	ll ans=0;
	while(!st.empty()){
		auto itr=st.end();
		itr--;
		st.erase(itr);
		auto [num,ind]=*itr;
		ll diff=b[ind-1]+b[ind+1];
		if(b[ind]<=diff){
			cout<<-1<<endl;
			return 0;
		}
		if((b[ind]-a[ind])%diff){
			ll q=b[ind]/diff,r=b[ind]%diff;
			if(r<a[ind]){
				ll x=(a[ind]-r+diff-1)/diff;
				if((a[ind]-r)%diff==0) x++;
				q-=x;
				r+=x*diff;
			}
			ans+=q;
			b[ind]=r;
			st.insert(P(b[ind],ind));
		}else{
			ans+=(b[ind]-a[ind])/diff;
			b[ind]=a[ind];
		}
		b[0]=b[n],b[n+1]=b[1];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 18732
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  int sm = 0;
  for(int i = 0; s.size() > i; i++){
    sm += s[i]-'0';
  }
  cout << max((int)(s.size()-1)*9+s[0]-'0'-1,sm) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,p,y,x,i,j,l;
  string s,t;
  cin>>n>>m;
  vector<tuple<int,int,int>> py(m);
  vector<pair<int,string>> id(m);
  for(i=0;i<m;i++){
    cin>>p>>y;
    py.at(i)=make_tuple(p,y,i);
  }
  sort(py.begin(),py.end());
  for(i=0;i<m;i++){
    if(i==0||(i>0&&get<0>(py.at(i-1))!=get<0>(py.at(i)))){
      s=to_string(get<0>(py.at(i)));
      l=s.length();
      for(j=1;j<=6-l;j++) s='0'+s;
      x=1;
    }
    else x++;
    t=to_string(x);
    l=t.length();
    for(j=1;j<=6-l;j++) t='0'+t;
    id.at(i)=make_pair(get<2>(py.at(i)),s+t);
  }
  sort(id.begin(),id.end());
  for(auto z:id) cout<<z.second<<endl;
}

Measured memory_bytes: 8176
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

using XY = pair<int, int>;

vector<vector<int>> nodes;
vector<bool> visited;

void mark(int t, int c, int id, vector<int> &map) {
    if (c == t || visited[c]) return;
    visited[c] = true;
    map[c] = id;
    cerr << c << endl;
    forin(i, 0, nodes[c].size()) {
        mark(t, nodes[c][i], id, map);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<XY> e(m);
    nodes.resize(n + 1);
    forin(i, 0, m) {
        cin >> e[i].first >> e[i].second;
        nodes[e[i].first].push_back(e[i].second);
    }
    vector<vector<int>> fMap(n + 1, vector<int>(n + 1, 0)), dMap(n + 1, vector<int>(n + 1, 0));
    forin(i, 1, n + 1) {
        visited.assign(n + 1, false);
        int id = 1;
        forin(j, 0, nodes[i].size()) {
            mark(i, nodes[i][j], id++, fMap[i]);
        }
        visited.assign(n + 1, false);
        id = (int)nodes[i].size();
        for (auto j = nodes[i].size(); j > 0; --j) {
            mark(i, nodes[i][j - 1], id--, dMap[i]);
        }
    }
    forin(i, 0, m) {
        auto edge = e[i];
        if ((fMap[edge.first][edge.second] != dMap[edge.first][edge.second]) == (fMap[edge.second][edge.first] > 0)) {
            cout << "same" << endl;
        } else {
            cout << "diff" << endl;
        }
    }
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if (A*N<=B) {
  cout << A*N << endl;
    }
  if (A*N>B) {
   cout << B << endl;
    }
  }
    
  


Measured memory_bytes: 256
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  k= int(readline())
  l = [1,2,3,4,5,6,7,8,9]
  q = deque(l)
  x = 0
  for _ in range(k):
    x = q.popleft()
    sue = x%10
    if sue != 0:
      q.append(10*x+sue-1)
    q.append(10*x+sue)
    if sue!=9:
      q.append(10*x+sue+1)
  print(x)
if __name__ == '__main__':
  main()

Measured memory_bytes: 21488
#include <iostream>
#include <math.h>
#include <limits.h>
#include<cstdio>
using namespace std;

int n;
int a[101];

int main(void)
{
    cin >> n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    bool flag = true;
    int count = 0;
    while(flag){
        flag = false;
        for(int i=n-1;i>0;i--){
            if(a[i] < a[i-1]){ 
                swap(a[i],a[i-1]);
                count++;
                flag = true;
            }
        }
    }

    for(int i=0;i<n;i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl << count << endl;
    
    return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    int b;
    cin >> b;
    string s;
    cin >> s;
    string res = "Yes";
    for (int i = 0; i < a + b + 1; i++) {
        if (i != a && s[i] == '-') {
            res = "No";
            break;
        }
        if (i == a && s[i] != '-') {
            res = "No";
            break;
        }
    }
    cout << res << "\n";
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  set<string> s;
  bool ok=true;
  string pre;
  rep(i,n){
    string a; cin>>a;
    if(s.count(a))ok=false;
    if(i) if(pre[pre.size()-1]!=a[0])ok=false;
    s.insert(a);
    pre=a;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
struct node{
	int a,b,c,d;
};
vector<node> v[20];int n,m,q;
int cur[20];
int dfs(int pos,int pre){
	if(pos==n+1){
		return 0;
	}
	//if(dp[pos][pre]!=-1) return dp[pos][pre];
	int ret=0;
	for(int i=pre;i<=m;i++){
		int tmp=0;
		for(node& j:v[pos]){
			if(i-cur[j.a]==j.c){
				tmp+=j.d;
			}
		}
		cur[pos]=i;
		ret=max(ret,dfs(pos+1,i)+tmp);
	}
	//if(dp[pos][pos]==-1) dp[pos][pre]=ret;
	return ret;
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		v[b].push_back((node){a,b,c,d});
	}
	int ans=dfs(1,1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        int result = 0;
        for (int i = 0; i < s + 1; i++) {
            int x = i;
            for (int j = 0; j < s + 1 - i; j++) {
                int y = j;
                int z = s - x - y;
                if (x > k || y > k || z > k) {
                    continue;
                }
                result++;
            }
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 23124
<?php

fscanf(STDIN, "%s %s", $s, $t);
fscanf(STDIN, "%d %d", $a, $b);
fscanf(STDIN, "%s", $u);

if ($u == $s) {
  $a -= 1;
} else {
  $b -= 1;
}

echo $a . ' ' . $b;


Measured memory_bytes: 4604
//----------------------------------------------------------
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <functional>


using namespace std;

int main(int argc, const char * argv[])
{

	int a,b,i,wrk;

	cin >> a >> b;

	wrk=1;
	for(i=0;i<a;i++){
		if(wrk*2<wrk+b){
			wrk*=2;
		}else{
			wrk+=b;
		}

	}

	cout << wrk << endl;


	return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
 
int main() {
  int k;
  int x;

  cin >> k >> x;

  for (int i=x-k+1;i<x+k;i++){
    cout << i << " ";
  }

  cout << endl;



  return 0;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
arr = []
n.times do |i|
  s,p=gets.chomp.split(" ")
  arr << [s, p.to_i, i+1]
end

arr.sort_by!{|(s,p,i)| [s, -p]}

arr.each do |(s,p,i)|
  puts i
end




Measured memory_bytes: 1788
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL x,y,pw[100],ans,numy=0;
LL mx[100],my[100];

int main()
{
	pw[0]=1;
	repn(i,50) pw[i]=pw[i-1]*2;
	cin>>x>>y;
	LL nx=x,ny=y,i=0;
	while(nx>0)
	{
		mx[i++]=nx%2;
		nx/=2;
	}
	i=0;
	while(ny>0)
	{
		my[i++]=ny%2;
		ny/=2;
	}
	rep(i,50)
	{
		if(i==0)
		{
			if(mx[i]==0)
			{
				if((y-x)%4==0||(y-x+1)%4==0);else
				ans+=pw[i];
			}
			else
			{
				if((y-x+1)%4==0||(y-x+2)%4==0);else
				ans+=pw[i];
			}
			continue;
		}
		if(mx[i]==0)
		{
			if(my[i]==1&&(y+1)%pw[i]%2==1) ans+=pw[i];
		}
		else
		{
			if(my[i]==1)
			{
				if((x+1)%pw[i]%2==(y+1)%pw[i]%2) ans+=pw[i];
			}
			else
			{
				if((x+1)%pw[i]%2==0) ans+=pw[i]; 
			}
		}
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






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


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k, r, s, p ;
  string t ;
  cin >> n >> k >> r >> s >> p >> t ;
  ll m ;
  if(n%k==0){
    m = n/k ;
  }
  else{
    m = n/k+1 ;
  }
  vector<vector<char>> ch(k) ;
  for(int i=0;i<n;i++){
    ch[i%k].PB(t[i]) ;
  }
  
  REP(i,k){
    ch[i].PB('a') ;
  }
  
  ll ans = 0 ;
  
  REP(i,SZ(ch)){
    ll cnt = 1 ;
    REP(j,SZ(ch[i])-1){
      if(ch[i][j]!=ch[i][j+1]){
        if(ch[i][j]=='p'){
          ans += (cnt+1)/2*s ;
          cnt = 1 ; 
        }
        else if(ch[i][j]=='s'){
          ans += (cnt+1)/2*r ;
          cnt = 1 ;
        }
        else{
          ans += (cnt+1)/2*p ;
          cnt = 1 ;
        }
      }
      else{
        cnt++ ;
      }
    }
  }
  
  
  cout << ans <<endl ;
          
        
      
  
  
  

  
  
  
  return 0 ;
}



Measured memory_bytes: 5200
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


//////////////////////////////////////
#define MAX_N 300000//調節！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
int par[MAX_N],dep[MAX_N];//depはrankのこと
//n要素で初期化//忘れないように！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
void init(int n){
    for(int i=0;i<=n-1;i++){//頂点番号は0~n-1
        par[i]=i;
        dep[i]=0;
    }
}
//木の根を求める
int find(int x){
    return par[x]==x?x:par[x]=find(par[x]);
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(dep[x]<dep[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(dep[x]==dep[y])dep[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
    return find(x)==find(y);
}

//////////////////////////////////////

struct data{
    int root;
    int num;
    int p;
};

bool comp(data a,data b){
    if(a.root<b.root)return true;
    else return false;
}


int main(){
    int n,m;cin>>n>>m;
    data d[n];
    rep(i,0,n-1){
        cin>>d[i].p;
        d[i].p--;
    }
    init(n);
    while(m--){
        int x,y;cin>>x>>y;x--;y--;
        unite(x,y);
    }
    rep(i,0,n-1){
        d[i].num=i;
        d[i].root=find(i);
    }
    sort(d,d+n,comp);
    int ans=0;
    int pos=0;
    while(pos<=n-1){
        vector<int>v;
        v.push_back(d[pos].num);v.push_back(d[pos].p);
        while(pos<=n-2&&d[pos].root==d[pos+1].root){
            pos++;
            v.push_back(d[pos].num);v.push_back(d[pos].p);
        }
        sort(v.begin(),v.end());
        int size=v.size();
        for(int i=0;i<=size-2;i++){
            if(v[i]==v[i+1]){
                ans++;
                i++;
            }
        }
        
        pos++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3320
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,a,b) for(int i=a;i<=b;i++)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;

int H, W, D, A;
int Q, L, R;
int px[90001], py[90001];
int d[90001];

int main() {

	cin >> H>>W>>D;

	//今まではAijで2次元配列に格納してたけど、
	//整数Aで検索できるこの形も覚える。!
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			px[A] = i; py[A] = j;
		}
	}

	for (int i = D + 1; i <= H*W; i++) {
		d[i] = d[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
	}

	cin >> Q;

	while (Q--) {
		cin >> L >> R;
		cout << d[R] - d[L] << endl;
	}

}
	


Measured memory_bytes: 2176
#include<stdio.h>


enum in
{
	M = 1867 ,
	T = 1911 ,
	S = 1925 ,
	H = 1988 ,

	e = 0 ,
	m ,
	t ,
	s ,
	h 
} ;



int when( int ,char* ,int ) ;



int main()
{
	int year ;

	char y_type ;


	int type ;
	scanf( "%d" ,&type ) ;


	if( type != e )
	{
		scanf( "%c" ,&y_type ) ;
	}

	scanf( "%d" ,&year ) ;


	if( type == e )
	{
		year -= when( year ,&y_type ,type ) ;

		printf( "%c" ,y_type ) ;
	}

	else
	{
		year += when( year ,&y_type ,type ) ;
	}


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


	return 0 ;
}




int when( int y ,char* c ,int type )
{
	if( type == e )
	{
		if( y > H )
		{
			y = H ;

			*c = 'H' ;
		}

		else if( y > S )
		{
			y = S ;

			*c = 'S' ;
		}

		else if( y > T )
		{
			y = T ;

			*c = 'T' ;
		}

		else
		{
			y = M ;

			*c = 'M' ;
		}
	}

	else
	{
		switch( type )
		{
			case h :
				y = H ;

				break ;


			case s :
				y = S ;

				break ;


			case t :
				y = T ;

				break ;


			case m :
				y = M ;

				break ;
		}
	}


	return y ;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include<algorithm>//sort头文件
using namespace std;
int a[10001],ans=0,bns=0,n;//乱入了1个打酱油的变量。
int main()
{
    scanf("%d",&n);//读入数据
    for(int i=1;i<=2*n;i++)//题目说的是2n，别一顺手就打错了。
    {
        scanf("%d",&a[i]);//循环读入
    }
    sort(a+1,a+1+2*n);    //所有数据排序
    for(int i=1;i<=2*n;i+=2)
    {
        bns+=a[i];//根据题意分析，我们只需要逐个跳着加和即为所求。
    } 
    printf("%d\n",bns);//AT通性，换行
}

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

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextInt();
    long K = sc.nextInt();
    for(int i=1; i<=K; i++){
      out.println( con(K-1, i-1) * con(N-K+1, i) % MOD);
    }  
  }
  
  public static long modpow(long a, long n) {
    long res = 1;
    while (n > 0) {
        if ((n & 1) == 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
  }
  
  public static long modinv(long a) {
    return modpow(a, MOD - 2);
  }
    
  public static long con(long a, long b){
    long c = 1;
    for(int i=0; i<b; i++){
      c *= (a-i);
      c %= MOD;
    }
    for(int i=0; i<b; i++){
      c *= modinv(b-i);
      c %= MOD;
    }
    return c;
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 21332
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;
int digitSum(int);

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int A, B;
    int min_sum = INT32_MAX;
    for(A=1; A<=N/2; A++){
        B = N-A;
        int sum = digitSum(A) + digitSum(B);
        if(sum <= min_sum){
            min_sum = sum;
        }
    }
    cout << min_sum;
    return 0;
}

int digitSum(int a){
    if(a==0){
        return 0;
    }
    return a%10 +digitSum(a/10);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define inf 100000000000000001
#define PI 3.14159265
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

// string to integer stoi() Remember: it takes string not character
// string to long long stol()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll x;
    cin>>x;    

    ll ini = 100;
    ll ans=0;
    while(ini<x){
        ll inte = ini/100;
        ini = ini+inte;
        ans++;
    }
    cout<<ans;
    return 0;
} 

Measured memory_bytes: 3612
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define ld long double
    #define ss(x) scanf("%s",&x)
    #define sc(x) scanf("%c",&x)
    #define sd(x) scanf("%Lf",&x)
    #define si(x) scanf("%lld",&x)
    #define ps(x) printf("%s\n",x)
    #define pc(x) printf("%c\n",x)
    #define pd(x) printf("%Lf\n",x)
    #define pi(x) printf("%lld\n",x)
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    string s,st;
    void solve()
    {
        cin>>s>>st;
        if(s.size()+1==st.size())
        {
            if(st.substr(0,st.size()-1)==s)
            {
                cout<<"Yes"<<endl;
                return;
            }
        }
        cout<<"No"<<endl;

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3644
import collections
N = int(input())
ws =[input() for i in range(N)]
word = collections.defaultdict(int)
flag = True
for i in range(N-1):
    if ws[i][-1] != ws[i+1][0]:
        flag = False
        break
    word[ws[i]] += 1
word[ws[-1]] += 1
for n in word.values():
    if n >= 2:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i < x+1; i++){
        if(i*2 + (x-i)*4 == y){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        Stack<string> answers = new Stack<string>();

        foreach (var c in s)
        {
            if (c == '0')
            {
                answers.Push("0");
            }
            if (c == '1')
            {
                answers.Push("1");
            }
            if (c == 'B')
            {
                if (answers.Count > 0)
                {
                    answers.Pop();
                }
            }
        }

        string answer = string.Join("", answers.Reverse());

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

typedef long long ll;

int N,M;
ll A[100010];
vector<int> G[100010];
bool vis[100010];
vector<int> X;
vector<ll> V;
int num;
ll MIN;
bool flag;
ll ans = 0;

void DFS(int v,int p)
{
    X.push_back(A[v]);
    vis[v] = true;
    for(int i = 0; i < G[v].size(); i++)
    {
        int ne = G[v][i];
        if(ne == p)continue;
        DFS(ne,v);
    }
    return;
}

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0; i < N; i++)scanf("%lld",A + i + 1);
    for(int i = 0; i < M; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        a++;b++;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    num = 2 * (N - M - 1);
    if(N < num)
    {
        printf("Impossible\n");
        return 0;
    }

    if(N - 1 == M)
    {
        printf("0\n");
        return 0;
    }

    for(int i = 1; i <= N; i++)if(!vis[i])
    {
        MIN = 1001001001;
        X.clear();
        flag = false;
        DFS(i,0);
        num--;
        sort(X.begin(),X.end());
        ans += X[0];
        for(int j = 1; j < X.size(); j++)V.push_back(X[j]);
    }
    sort(V.begin(),V.end());
    for(int i = 0; i < num; i++)ans += V[i];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 8188
import sys
def solve():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    search = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    possible = True
    for h in range(H):
        for w in range(W):
            if S[h][w] == "#":
                for dh, dw in search:
                    if 0 <= h + dh < H and 0 <= w + dw < W:
                        if S[h+dh][w+dw] == "#":
                            break
                else:
                    possible = False
                    break
        if not possible: break
    print("Yes" if possible else "No")

    
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
N = int(input())

def kccv(a, b, c, d):
    return [a*2/3 + c/3, b*2/3 + d/3, a/2 + b*(3**0.5)/6 + c/2 - d*(3**0.5)/6, -a*(3**0.5)/6 + b/2 + c*(3**0.5)/6 + d/2, a/3 + c*2/3, b/3 + d*2/3]

ans = [[[0,0],[100,0]]]

for i in range(1,N+1):
    m = len(ans[i-1])
    newset = []
    for j in range(m-1):
        newset.append(ans[i-1][j])
        newdot = kccv(ans[i-1][j][0], ans[i-1][j][1], ans[i-1][j+1][0], ans[i-1][j+1][1])
        x1 = newdot[0]
        y1 = newdot[1]
        x2 = newdot[2]
        y2 = newdot[3]
        x3 = newdot[4]
        y3 = newdot[5]
        newset.append([x1,y1])
        newset.append([x2,y2])
        newset.append([x3,y3])
    newset.append(ans[i-1][m-1])
    ans.append(newset)
           
    
for i in range(len(ans[N])):
    print(ans[N][i][0],ans[N][i][1])


Measured memory_bytes: 6276
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char x, y;
  scanf("%c %c", &x, &y);
  if (x-y>0)
    printf(">");
  else if (x-y<0)
    printf("<");
  else
    printf("=");
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
string s,s2;
ll cou[50],ans;
ll x_num = 'x'-'a';

int main(){
    cin >> s;
    ll fl = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'x') ++fl;
        int num = s[i] - 'a';
        ++cou[num];
        if(s[i] != 'x') s2 += s[i];
    }


    for(int i = 0; i < s2.length()/2; i++){
        if(s2[i] != s2[s2.length()-i-1]){
            cout << "-1\n";
            return 0;
        }
    }

    ll le = 0, ri = s.length()-1;
    while(le < ri){
        if(s[le] != s[ri]){
            ++ans;
            if(s[le] == 'x'){
                ++le;
            }
            else{
                --ri;
            }
        }
        else{
            ++le;
            --ri;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int lcm(int a, int b)
{
	return (a * b) / (__gcd(a, b));
}
int32_t main() {
	fast_io();
	int x;
	cin >> x;
	cout << lcm(x, 360) / x << "\n";
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if(s.substr(i, 3) == "ABC") res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var a=0;
   var b=0;
   for(var i=0;i<n;i++){
      var arr=(Arr.shift()).split(" ").map(Number);
      if(arr[0]>arr[1])a+=arr[0]+arr[1];
      if(arr[0]<arr[1])b+=arr[0]+arr[1];
      if(arr[0]==arr[1]){a+=arr[0];b+=arr[1];}
   }
   console.log(a+" "+b);
}

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '1') count++;
    }
    int m1 = count + 1;
    int m2 = count - 1;
    vector<int> m1num(n);
    vector<int> m2num(n);
    int t1 = 1;
    int t2 = 1;
    int m1sum = 0;
    int m2sum = 0;
    for(int i = 0; i < n; i++)
    {
        m1num[i] = t1 % m1;
        t1 = t1 * 2 % m1;
        if(s[n-1-i] == '1') m1sum = (m1sum + m1num[i]) % m1;
        if(m2 != 0)
        {
            m2num[i] = t2 % m2;
            t2 = t2 * 2 % m2;
            if(s[n-1-i] == '1') m2sum = (m2sum + m2num[i]) % m2;
        }
    }
    vector<int> ans(n);
    for(int i = 0; i < n; i++)
    {
        int sum = 0;
        if(s[n-1-i] == '1')
        {
            // m2
            if(m2 != 0)
            {
                sum = (m2sum - m2num[i]) % m2;
                sum = (sum + m2) % m2;
            }
            else
            {
                ans[n-1-i] = 0;
                continue;
            }
        }
        else
        {
            // m1
            sum = (m1sum + m1num[i]) % m1;
            sum = (sum + m1) % m1;
        }
        int cnt = 1;
        while(sum > 0)
        {
            cnt++;
            int pc = __builtin_popcount(sum);
            sum %= pc;
        }
        ans[n-1-i] = cnt;
    }
    for(int i : ans) cout << i << endl;
}


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

using namespace std;

typedef long long int ll;

const int mod = 1e9 + 7;

ll pwr (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv (ll a) {
  return pwr (a, mod - 2);
}

ll nCr (ll n, ll r) {
  ll ans = 1;
  for (int i = 0; i < r; i++) ans = (ans * (n - i)) % mod;
  for (int i = 1; i <= r; i++) ans = (ans * inv (i)) % mod;

  return ans;
}

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

  int n, m;
  ll k;
  cin >> n >> m >> k;

  ll ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += (((ll)(m - i) * (m - i + 1)) / 2);
    ans %= mod;
  }
  ll a = (((ll)n * (n - 1)) + n) % mod;
  ans = (ans * a) % mod;
  ll tmp_ans = 0;
  for (int i = 1; i <= n; i++) {
    tmp_ans += (((ll)(n - i) * (n - i + 1)) / 2);
    tmp_ans %= mod;
  }
  ll b = (((ll)m * (m - 1)) + m) % mod;
  tmp_ans = (tmp_ans * b) % mod;

  ans = (ans + tmp_ans) % mod;

  ans = (ans * nCr ((ll)n * m - 2, k - 2)) % mod;

  cout << ans << '\n';
}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    X = input()
    s = False
    c = cc = 0
    for i in range(len(X)):
        if X[i] == 'S':
            s = True
            cc += 1
        else:
            s = False
            if cc > 0:
                cc -= 1
                c += 1
    print(len(X)-2*c)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3500