akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

string m[2000] = {""};
int a_up[2000][2000] = {{0}};
int a_left[2000][2000] = {{0}};
int a_down[2000][2000] = {{0}};
int a_right[2000][2000] = {{0}};
int total[2000][2000] = {{0}};


int main() {
  int H, W;

  cin >> H >> W;
  string str;
  for (int i = 0; i < H; i++) {
    cin >> str;
    m[i] = str;
  } 
  for (int h = 0; h < H; h++) {
    for(int w = 0; w < W; w++) {
      if (m[h][w] == '#') {
        a_left[h][w] = 0;
        a_up[h][w] = 0;
        continue;
      }
      a_left[h][w] = 1;
      if (w > 0) {
        a_left[h][w] += a_left[h][w-1];
      }
      a_up[h][w] = 1;
        if (h > 0){
          a_up[h][w] += a_up[h-1][w];
        }
    }
  }

  for (int h = H-1; h >= 0; h--) {
    for(int w = W-1; w >= 0; w--) {
      if (m[h][w] == '#') {
        a_right[h][w] = 0;
        a_down[h][w] = 0;
        continue;
      }
      a_right[h][w] = 1;
      if (w < W - 1) {
        a_right[h][w] += a_right[h][w+1];
      }
      a_down[h][w] = 1;
        if (h < H - 1){
          a_down[h][w] += a_down[h+1][w];
        }
    }
  }

  int maxVal = 0;
  for (int h = 0; h < H; h++) {
    for(int w = 0; w < W; w++) {
      total[h][w] = a_left[h][w] + a_right[h][w] + a_up[h][w] + a_down[h][w];
      total[h][w] -= 3;
      if (maxVal < total[h][w]) {
        maxVal = total[h][w];
      }
    }
  }
  cout << maxVal << endl;

  return 0;
}


Measured memory_bytes: 82432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=1e2+5;
int n,a[MAXN],ans[MAXN];
int main(){
	scanf("%d",&n);
	int m=n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--){
		int pos=-1;
		for (int j=n;j>=1;j--){
			if (a[j]==j){
				pos=j;
				break;
			}
		}
		if (pos==-1) return printf("-1\n"),0;
		ans[i]=pos;
		for (int j=pos;j<=n;j++) swap(a[j],a[j+1]);
		n--;
//		for (int j=1;j<=n;j++) printf("%d ",a[j]);
//		cout<<endl;
	}
	for (int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int v[n],c[n];
  for(int i = 0;i < n;i ++){
    scanf("%d",&v[i]);
  }
  for(int i = 0;i<n;i++){
     scanf("%d",&c[i]);
  }
  int sum= 0;
  for(int i = 0;i < n;i++){
    if(v[i]>c[i]){
       sum += (v[i]-c[i]);
    }
  }
  printf("%d",sum);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();

            if (N < 10) {
                System.out.println(N);
            } else if (N < 100) {
                System.out.println(9);
            } else if (N < 1000) {
                System.out.println(9 + (N - 100 + 1));
            } else if (N < 10000) {
                System.out.println(9 + 900);
            } else if (N < 100000) {
                System.out.println(9 + 900 + (N - 10000 + 1));
            } else if (N == 100000) {
                System.out.println(9 + 900 + 90000);
            }
        }
    }

}


Measured memory_bytes: 23764
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int Y = sc.nextInt();

		int[] ans = null;
		for(int m=0;m<=N;m++) {
			for(int g=0;g<=N-m;g++) {
				int s = N-(m+g);
				if(Y == m*10000 + g*5000 + s*1000) {
					ans = new int[] {m,g,s};
				}
			}
		}

		if (ans == null) {
			out.println("-1 -1 -1");
		} else {
			out.println(ans[0] + " " + ans[1] + " " + ans[2]);
		}

		sc.close();

	}

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

}


Measured memory_bytes: 21588
import itertools


def solve():
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    for i in range(4):
        for j in range(4):
            for commands in itertools.permutations('N' * i + 'W' * j):
                a = A[::]
                for command in commands:
                    if command == 'N':
                        a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
                    elif command == 'W':
                        a[0], a[3], a[5], a[2] = a[2], a[0], a[3], a[5]
                if B == a:
                    return True
    return False


if __name__ == '__main__':
    print('Yes' if solve() else 'No')

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x;
    while (y)
    {
        if (y&1) res = ((res)*(x));

        y>>=1;
        x = ((x)*(x));
    }
    return res;
}

// ll calculateMoves(ll h, ll count=1){

//     if(h==1){
//         return 1;
//     }

//     count += calculateMoves(floor(h/2),count) + calculateMoves(floor(h/2),count);

//     return count;
// }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll h;
    cin >> h;
    // cout << calculateMoves(h) << "\n";    

    ll ans=1;
    ll count=1;
    h/=2;
    while (h)
    {
        ans+=power(2,count);
        count++;
        h/=2;
    }

    cout << ans << "\n";
    

    return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;

	double a, b;
	a = ceil(A / 0.08);
	b = ceil(B / 0.1);

	if (a > b) {
		b = a;
	} else {
		a = b;
	}

	if ((int)(a * 0.08) == A && (int)(b * 0.1) == B) {
		cout << a << endl;
		return 0;
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector< ii > vii;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef	vector<pair<int,pair<int,int > > > viii;
typedef long long int lli;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define slli(n) scanf("%llid",&n)
#define lldout(n) printf("%llid\n",n)
const int N = (int)1e5 + 10;
map<int,int> ph;
int main(){
 	int a,b;
 	cin>>a>>b;
 	if((a*b)%2==1 or (a*b*3)%2==1)cout<<"Yes"<<endl;
 	else cout<<"No"<<endl; 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,cnt=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]!=i+1)cnt++;
  }
  if(cnt<=2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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

int dp[1001][1001];

int main(){
  int W, n=0;
  while(true){
    n++;
    cin>>W;
    if(W==0)break;
    for(int i=0; i<1001; i++)
      for(int j=0; j<1001; j++)
        dp[i][j]=0;
    int N;
    int v[1001], w[1001];
    cin>>N;
    for(int i=0; i<N; i++){
      scanf("%d,%d", &v[i], &w[i]);
    }
    for(int i=0; i<N; i++){
      for(int j=0; j<=W; j++){
        if(j<w[i]){
          dp[i+1][j]=dp[i][j];
        }
        else{
          dp[i+1][j]=max(dp[i][j], dp[i][j-w[i]]+v[i]);
        }
      }
    }
    cout<<"Case "<<n<<":"<<endl;
    cout<<dp[N][W]<<endl;
    int i;
    for(i=W; i>0; i--){
      if(dp[N][i]==dp[N][i-1])continue;
      else break;
    }
    cout<<i<<endl;
  }
  return 0;
}

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

namespace abc061_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            if(a<=c && c<=b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();

        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
int main(int argc, char **argv)
{
  char c;
  c = getchar();
  switch(c) {
    case 'A':
      putchar('T');
      break;
    case 'T':
      putchar('A');
      break;
    case 'G':
      putchar('C');
      break;
    case 'C':
      putchar('G');
      break;
  }
  return 0; 
}

Measured memory_bytes: 128
//include tourist
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  string s, t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define ft first
#define sc second
#define ppb pop_back
#define sz size
#define forn(i,a,n) for(i=a;i<n;i++)
#define M 1000000007
#define inf 2e18


int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
    
string s,t;
cin>>s>>t;
cout<<t+s;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    while(1){
        int ok=1;
        rep(i,n){
            if(a[i]%2==1){ok=0;break;}
        }
        if(!ok)break;
        ans++;
        rep(i,n)a[i]/=2;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int q,a,b;
  string str,s;
 
  cin >> str >> q;
  while(q--){
    cin >> s >> a >> b;
    if(s == "replace"){
      cin >> s;
      str.replace(str.begin()+a, str.begin()+b+1, s);
    }else if(s == "reverse"){
      reverse(str.begin()+a, str.begin()+b+1);
    }else{
      cout << str.substr(a, b-a+1) << endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S[3];
  REP(i,3)cin>>S[i];
  REP(i,3)cout<<(char)(S[i][0]-'a'+'A');
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b, c, x, y = 0;
  scanf("%d %d %d", &a , &b, &c);
  for(x = a; x <= b; x++){
    if(c%x == 0) y++;
  }
  printf("%d\n", y);

  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<pii>w(N);
  for(int i=0;i<N;i++)cin>>w[i].second>>w[i].first;
  sort(rng(w));
  ll now=0;
  bool ok=true;
  for(int i=0;i<N;i++){
    now+=w[i].second;
    if(now>w[i].first)ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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





int main() {
  int64_t n,t;
  cin>>n>>t;
  
  vector<int64_t> data(n);
  
  for (int64_t i=0;i<n;i++){
    cin>>data.at(i);
  }
  

  int64_t answer=0;
  
  for (int64_t i=0;i<n-1;i++){
    answer+=min(data.at(i+1)-data.at(i),t);
  }
  
  answer+=t;
  
  cout<<answer<<endl;
  
  

    
    
    
    
}













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

signed main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  vector<int>sum(N+1);
  for(int i=0; i<N; i++){
    cin >> vec[i];
    sum[i+1] += sum[i]+vec[i];
  }
  int ans = 0,san = sum[N];
  for(int i=0; i<N; i++){
    ans += vec[i]*((san-sum[i+1])%1000000007)%1000000007;
  }
  cout << ans%1000000007 << endl;
}


Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int a[100000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  REP(i, n) {
    cin >> a[i];
  }

  if((n - 1) % (k - 1) == 0) {
    cout << (n - 1) / (k - 1) << endl;
  } else {
    cout << (n - 1) / (k - 1) +  1 << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int a = s.find("A");
    int z = s.rfind("Z");
    cout << z - a + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	
	ll a, b;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc073/tasks/abc073_c
n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))

s = set()
for num in nums:
    if num in s:
        s.remove(num)
    else:
        s.add(num)
ans = len(s)
print(ans)

Measured memory_bytes: 56152
N, Q = map(int, input().split())
S = input()
L,R = [], []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

AC = [0] * N

for i in range(1,N):
    if S[i - 1] == 'A' and S[i] == 'C':
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i - 1]

for l, r in zip(L, R):
    print(AC[r-1]-AC[l-1])

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

#define fastio                              ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
#define read                                freopen("input.txt", "r", stdin);
#define write                               freopen("output.txt", "w", stdout);
#define nl                                  '\n'
#define mem(ara,n)                          memset(ara,n,sizeof ara)
#define debug(x)                            cerr << #x << " = " << x << nl

#define ll                                  long long
#define ull                                 unsigned long long
#define vi                                  vector<int>
#define pb                                  push_back
#define vpii                                vector<pair<int, int>>
#define vpll                                vector<pair<ll, ll>>
#define mp                                  make_pair
#define ff                                  first
#define ss                                  second
#define all(v)                              v.begin(), v.end()
#define rsort(v)                            sort(v.rbegin(), v.rend())

using namespace std;

const double pi = 2*acos(0.0);

int main(){
    //fastio;
    ll r;
    cin >> r;
    cout << fixed << setprecision(10) << 2*pi*r << nl;
}

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


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

    
    ll n;
    cin>>n;
    ll ans = 0;
    ll now = 1;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    while(n){
        n/=2;
        ans += now;
        now *= 2;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
ans=[]
flg=True
while len(b)>0 and flg:
  n1=len(b)
  i=n1
  flg=False
  while i > 0:
    if b[i-1]==i:
      ans.append(b[i-1])
      b1=b[:i-1]
      b1[len(b1):len(b1)]=b[i:]
      b=b1
      i=-1
      flg=True
    else:
      i-=1

if flg==False:
  print(-1)
  #print(ans)
  exit()
for _ in range(n):
  print(ans.pop())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	string s;
	cin>>s;
	bool isKaibun = true;
	rep(i,(s.size()-1)/2){
		if (s.at(i)!=s.at(s.size()-1-i))
		{
			isKaibun=false;
		}
		
	}

	string s2 = s.substr(0,(s.size()-1)/2);
	// cout<<s2<<endl;
	rep(i,(s.size()-1)/2){
		if (s2.at(i)!=s2.at(s2.size()-1-i))
		{
			isKaibun=false;
		}
		
	}

	string s3 = s.substr((s.size()+3)/2-1);
	// cout<<s3<<endl;
	rep(i,(s3.size()-1)/2){
		if (s3.at(i)!=s3.at(s3.size()-1-i))
		{
			isKaibun=false;
		}
		
	}




	if (isKaibun)
	{
		cout<<"Yes";
	} else
	{
		cout<<"No";
	}
	
	
}


Measured memory_bytes: 256
import numpy as np
from numba import jit


def test():
    R, C, K = map(int, input().split())
    rcv = [list(map(int, input().split())) for _ in range(K)]

    items = np.zeros((R+1, C+1), dtype='int64')
    for item in rcv:
        items[item[0]][item[1]] = item[2]

    dp = np.zeros((R+1, C+1), dtype='int64')

    # まずは3個の制約がない場合での実装
    for j in range(1, R+1):
        for i in range(1, C+1):
            # 下に行く遷移
            dp[j][i] = max(dp[j][i], dp[j-1][i] + items[j][i])

            # 右に行く遷移
            dp[j][i] = max(dp[j][i], dp[j][i-1] + items[j][i])

    print(dp[R][C])


@jit
def main(R, C, items):

    dp = np.zeros((4, R+1, C+1), dtype=np.int64)

    # 3個の制約がある場合の実装
    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                # 下に行く遷移
                # 取らない場合
                dp[0][i][j] = max(dp[0][i][j], dp[k][i-1][j])
                # 取る場合
                dp[1][i][j] = max(dp[1][i][j], dp[k][i-1][j] + items[i][j])

                # 右に行く遷移
                # 取らない場合
                dp[k][i][j] = max(dp[k][i][j], dp[k][i][j-1])
                # 取る場合
                if k > 0:
                    dp[k][i][j] = max(dp[k][i][j], dp[k-1]
                                      [i][j-1] + items[i][j])

    ans = 0
    for k in range(4):
        if ans < dp[k][R][C]:
            ans = dp[k][R][C]

    print(ans)


if __name__ == "__main__":
    R, C, K = map(int, input().split())
    rcv = [list(map(int, input().split())) for _ in range(K)]
    items = np.zeros((R+1, C+1), dtype=np.int64)
    for item in rcv:
        items[item[0]][item[1]] = item[2]
    main(R, C, items)


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}

vector<double> vals ;
map<double,int> ways ;
double ans[55];
map<double,int> cnt ; 
const double EPS = 1e-9 ;
double C(double n,double r){
    if(r < 0 || r > n) return 0.0 ;
    if(r > n - r) r = n - r ;
    double ret = 1.0 ;
    int tmp = r ;
    double i = 1.0 ;
    while(tmp--){
        ret *= (n - r + i) ;
        ret = ret / i ;
        i = i + 1.0 ;
    }
    return ret ;
}
long long nem[55] , dem[55]  ; 
int main(int argc,char* argv[]) { 
   // io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int n,a,b ;
    cin >> n >> a >> b ;
    double x ;
    for(int i = 0 ; i < n ; i++){
        cin >> x ;
        cnt[x]++ ;
        vals.push_back(x); 
    }
    sort(vals.rbegin() , vals.rend()) ;
    // for(auto x:vals) cout << x << ", " ; cout << endl; 
    double men = 0.0 ;
    long long num  = -1, den = -1 ;
    for(int i = a ; i <= b ; i++){
        double sm = 0.0 ;
        long long ss = 0 ;
        for(int j = 0 ; j < i ; j++){
            sm += vals[j] ;
            ss = ss + (long long)vals[j] ;
        }
        long long nm = ss ;
        long long dm = i ;
        long long g = __gcd(nm,dm) ;
        nm /= g ;
        dm /= g ;
        nem[i] = nm ;
        dem[i] = dm ;
        // cout << "## " << sm << endl ;
        sm = sm/(1.0*i) ;
        ans[i] = sm ;
        if(sm > men){
            men = sm ;
            num = ss ;
            den = i ;
        }
    }
    long long g = __gcd(num,den) ;
    num /= g ;
    den /= g ;

    printf("%.10lf\n" , men) ;
    double fans = 0 ;
    map<double,int> need ;
    for(int i = a ; i <= b ; i++){
        if( nem[i] == num && dem[i] == den ){
            need.clear() ;
            double temp_ans = 1 ;
            for(int j = 0 ; j < i ; j++){
                need[vals[j]]++ ;
            }
            for(auto it:need){
                temp_ans = temp_ans*C(cnt[it.first] , it.second) ;
            }
            fans = fans + temp_ans ;
        }
    }
    long long pp = round(fans) ;
    printf("%lld\n" , pp) ;
    // cout << fixed << fans << endl ;
    return 0 ; 
}

Measured memory_bytes: 256
def main():
    x1, y1, x2, y2 = map(int, input().split())
    vec = [x2-x1, y2-y1]
    x3, y3 = x2-vec[1], y2+vec[0]
    x4, y4 = x3-vec[0], y3-vec[1] 
    print(x3, y3, x4, y4)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;


int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for( int i = 0; i < N; ++i ) cin >> a[i];


    vector<int> numSushi(4);
    for( int i = 0; i < N; ++i ) ++numSushi[a[i]];
    // dp[i][j][k]: 寿司が1個, 2個, 3個の皿が i枚, j枚, k枚のとき、全ての寿司を食べるのに必要な操作回数の期待値
    double dp[301][301][301] = {};
    for( int k = 0; k <= N; ++k ){
        for( int j = 0; j <= N; ++j ){
            for( int i = 0; i <= N; ++i ){
                if( 0 < i+j+k and i+j+k <= N ){
                    if( i != 0 ) dp[i][j][k] += dp[i-1][j][k] * i;
                    if( j != 0 ) dp[i][j][k] += dp[i+1][j-1][k] * j;
                    if( k != 0 ) dp[i][j][k] += dp[i][j+1][k-1] * k;
                    dp[i][j][k] = (dp[i][j][k] + N) / (i+j+k);
                }
            }
        }
    }
    cout << fixed << setprecision(9) << dp[numSushi[1]][numSushi[2]][numSushi[3]] << endl;

    return 0;
}

Measured memory_bytes: 213376
program to_infinity
  implicit none
  character(100) :: s
  integer(8) :: k
  integer :: i, m
  read(*,'(a)') s
  read(*,*) k
  m = int(min(k,len_trim(s)))
  do i = 1, m
    if (s(i:i) == "1") cycle
    write(*,'(a)') s(i:i)
    stop
  end do
  write(*,'(i0)') 1
end program to_infinity

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> T input(istream & in) { T a; in >> a; return a; }
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };
bool is_on_field(int y, int x, int h, int w) { return 0 <= y and y < h and 0 <= x and x < w; }
int main() {
    string s; cin >> s;
    int ans = 0;
    int margin = 0;
    for (char c : s) {
        if (c == 'g') {
            if (not margin) {
                ++ margin;
            } else {
                -- margin;
                ++ ans;
            }
        } else if (c == 'p') {
            if (not margin) {
                ++ margin;
                -- ans;
            } else {
                -- margin;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { P to; int cost; };
const long long mod = 1000000007;
int a[1004];
int rwa[1004];
vector<int>V;
signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n)rwa[i + 1] = a[i];
	rep(i, n)rwa[i + 1] += rwa[i];

	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			V.push_back(rwa[j + 1] - rwa[i]);
		}
	}
	int ans = 0;
	for(int i=50;i>=0;i--) {//上のビットから決めている
		vector<int>nv;
		rep(j, V.size()) {
			if (V[j] & (1ll << i)) {
				nv.push_back(V[j]);
			}
		}
		if (nv.size() >= k) {
			ans += 1ll << i;
			V.clear();
			rep(j, nv.size())V.push_back(nv[j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int a[110];
void build(int n)
{	a[0]=0;int pre=0;
	int mx=-1;
	for(int i=1;i<=n;i++)
		{
			int x=i;
			int co=0;
			while(x)
			{	co++;
				x/=2;
			}
		if(mx<co)
		{
			mx=co;
			a[i]=i;
			pre=i;
		}
		else{
			
			a[i]=pre;
			
			}
			
		}
}

int main() {
	int n;
		build(105);
	while(cin>>n)
	{
	//		memset(a,0,sizeof a);
			cout<<a[n]<<endl;

		
	}
	return 0;
}

Measured memory_bytes: 256
// AOJ 1285: Grey Area
// 2017.10.16 bal4u@uu

#include <stdio.h>
#include <string.h>

int f[102], sz;

int main()
{
	int n, w, v, i, j, max;
	double ans;

	while (scanf("%d%d", &n, &w) && n > 0) {
		memset(f, 0, sizeof(f));
		sz = 0; while (n-- > 0) {
			scanf("%d", &v);
			i = v/w;
			f[i]++;	if (i > sz) sz = i;
		}

		for (max = 0, i = 0; i <= sz; i++)
			if (f[i] > max) max = f[i];

		ans = 0.01;
		if (sz > 0) for (j = sz, i = 0; i <= sz; i++, j--) {
			ans += ((double)f[i])/max * ((double)j)/sz;
		}
		printf("%.16lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1800
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)5e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

int n, m, k;
char f[10][10];

bool color(int row, int col) {
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if ((row & (1 << i)) || (col & (1 << j)) || f[i][j] == '.') 
				continue;
			cnt++;
		}
	}
	return cnt == k;
}

void solve() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cin >> f[i][j];
	}
	int ans = 0;
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < (1 << m); j++)
			ans += color(i, j);
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s,t;
    cin >> s >> t;
    bool ab[28];
    fill(ab,ab+27,false);
    for (ll i=0;i<s.size();i++){
        char a=s[i],b=t[i];
        if (ab[a-'a'])continue;
        ab[a-'a']=true;
        for (ll j=i+1;j<s.size();j++){
            if (s[j]==a and t[j]!=b){
                cout << "No" << endl;
                return 0;
            }else if (t[j]==b and s[j]!=a){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll mat[51][51];
ll res[51][51];
int n;
void power(ll k)
{
	memset(res,0,sizeof(res));
	for(int i=1;i<=n;++i)
	{
		res[i][i]=1LL;
	}
	while(k)
	{
		if(k%2)
		{
			ll a[n+1][n+1];
			memset(a,0,sizeof(a));
			for(int i=1;i<=n;++i)
			{
				for(int j=1;j<=n;++j)
				{
					for(int p=1;p<=n;++p)
					{
						a[i][j]=(a[i][j]+(res[i][p]*mat[p][j])%MOD)%MOD;
					}
				}
			}
			for(int i=1;i<=n;++i)
			{
				for(int j=1;j<=n;++j)
				{
					res[i][j]=a[i][j];
				}
			}
		}
		ll a[n+1][n+1];
		memset(a,0,sizeof(a));
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)
			{
				for(int p=1;p<=n;++p)
				{
					a[i][j]=(a[i][j]+(mat[i][p]*mat[p][j])%MOD)%MOD;
				}
			}
		}
		for(int i=1;i<=n;++i)
		{
			for(int j=1;j<=n;++j)
			{
				mat[i][j]=a[i][j];
			}
		}
		k/=2;
	}
	
}
int main() 
{
	int i,j;
	ll k;
	cin>>n>>k;
	for(i=1;i<=n;++i)
	{
		for(j=1;j<=n;++j)	
			cin>>mat[i][j];
	}
	power(k);
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			ans=(ans+res[i][j])%MOD;
	}
	cout<<ans;
	// your code goes here
	return 0;
}

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

int out(int *A,int N){
	int i;
	for (i=0;i<=N-2;i++){
		cout << A[i] <<" ";
	}
	cout << A[N-1] <<endl;
}

int SelectionSort(int *A,int N){
	int i,j,minj,count=0;
	for (i=0;i<=N-1;i++){
		minj=i;
		for (j=i;j<=N-1;j++){
			if (A[minj]>A[j]){
				minj=j;
			}
		}
		if (i != minj){
			std::swap(A[i],A[minj]);
			count++;
		}
	}
	out(A,N);
	return count;
}

int main(){
	int N,count;
	cin >> N;
	int i,j;
	int A[N];
	for (i=0;i<=N-1;i++){
		cin >> A[i];
	}
	count=SelectionSort(A,N);
	cout << count <<endl;
	return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = Console.ReadLine();
        }

        var ac = 0;
        var wa = 0;
        var tle = 0;
        var re = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == "AC") ac++;
            else if (s[i] == "WA") wa++;
            else if (s[i] == "TLE") tle++;
            else if (s[i] == "RE") re++;
        }

        // 出力
        Console.WriteLine("{0} x {1}", "AC", ac);
        Console.WriteLine("{0} x {1}", "WA", wa);
        Console.WriteLine("{0} x {1}", "TLE", tle);
        Console.WriteLine("{0} x {1}", "RE", re);
    }
}

Measured memory_bytes: 31460
#include <bits/stdc++.h>
using namespace std;
 
long long dp[110][1000010], sdp[1000010], a[1100], sa[1100], n, m;
 
int main() {
	sa[0] = 0;
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i], sa[i] = min(sa[i - 1] + a[i], m);
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		sdp[0] = 1;
		for(long long k = 1; k <= (sa[i] + 100); k++)
			sdp[k] = sdp[k - 1] + dp[i - 1][k];
 
		for(long long j = 0; j <= sa[i]; j++) {
			if(j <= sa[i])
				dp[i][j] = sdp[j] - ((j - a[i] - 1) >= 0 ? sdp[j - a[i] - 1] : 0);
			dp[i][j] %= 1000000007;
		}
	}
	cout << dp[n][m];
}

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

using namespace std;
#define MOD 1000000007

int n, m;
vector<int> memo(0);
vector<int> notin(0);

int dp(int i) {
    if (i == n - 1) {
        return 1;
    }
    if (i == n - 2) {
        return 1 + notin.at(n - 1);
    }
    if (memo.at(i) == -1) {
        memo.at(i) = (dp(i + 1) * notin.at(i + 1) % MOD + dp(i + 2) * notin.at(i + 2) % MOD) % MOD;
    }
    return memo.at(i);
}

int main() {
    cin >> n >> m;
    vector<int> a(m);
    memo = vector<int>(n, -1);
    notin = vector<int>(n, 1);
    for (int i = 0; i < m; i++) {
        cin >> a.at(i);
    }
    int now = 0;
    for (int i = 0; i < n; i++) {
        if (now >= m) {
            break;
        }
        if (i == a.at(now)) {
            notin.at(i) = 0;
            now++;
        }
    }

    cout << dp(0) << endl;
    return 0;
}

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

int main()
{
	char s[20];
	int n,k;
	scanf ("%d\n", &n);
	int i;
	for (i=1; i<=n; i++)
		scanf("%c", &s[i]);
	scanf ("%d", &k);
	for (i=1; i<=n; i++)
	{
		if (s[i] != s[k])
			printf("*");
		else
			printf("%c", s[i]);
	}
	printf("\n");
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100 + 10;
vector<int> g[N];
int vis[N],match[N];
bool dfs(int u){
    if(vis[u]) return false;
    vis[u] = 1;
    for(int v: g[u]) if(!match[v]||dfs(match[v])){
        match[v] = u;
        return true;
    }
    return false;
}
int a[N][N],b[N][N],c[N][N],ok[N][N],n,m;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>a[i][j], ok[i][j] = 1;
    for(int col=1;col<=m;col++){
        for(int i=1;i<=n;i++) g[i].clear();
        for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(ok[i][j]){
            g[i].push_back((a[i][j]-1)/m+1);
        }
        memset(match,0,sizeof(match));
        for(int i=1;i<=n;i++) memset(vis,0,sizeof(vis)), dfs(i);
        for(int i=1;i<=n;i++){
            int x;
            for(int j=1;j<=n;j++) if(match[j]==i) x = j;
            for(int j=1;j<=m;j++) if(ok[i][j]){
                if((a[i][j]-1)/m+1==x){
                    b[i][col] = a[i][j];
                    ok[i][j] = 0;
                    break;
                }
            }
        }
    }
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) c[(b[i][j]-1)/m+1][j] = b[i][j];
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) printf("%d%c",b[i][j]," \n"[j==m]);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) printf("%d%c",c[i][j]," \n"[j==m]);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<vp> vvp;

void rotate(vp &a){
    for(int i = 0; i < (int)a.size();i++){
        auto tmp = a[i];
        a[i].first = -tmp.second;
        a[i].second = tmp.first;
       }
}

bool check(vp a, vp b){
    if(a == b)return true;
    reverse(all(b));
    if(a == b)return true;
    return false;
}

bool issame(vp a,vp b){
    rep(i,4){
        if(check(a,b))return true;
        rotate(b);
    }
    for(int i = 0; i < (int)b.size();i++){
        b[i].first -= b.back().first;
        b[i].second -= b.back().second;
    }
    rep(i,4){
        if(check(a,b))return true;
        rotate(b);
    }
    return false;
}
int N,m,x,y,a,b;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    while(1){
        cin>>N;
        if(N == 0){
            //cout<<"+++++"<<endl;
            break;
        }
        vvp oresen(N+1);
        for(int i = 0;i <= N;i++){
            cin>>m;
            cin>>a>>b;
            oresen[i].push_back({0,0});
            for(int j = 1;j < m;j++){
                cin>>x>>y;
                x -= a;
                y -= b;
                oresen[i].push_back({x,y});
            }
        }
        for(int i = 1;i <= N;i++){
            if(issame(oresen[0],oresen[i])){
                cout<<i<<endl;
            }
        }
        cout<<"+++++"<<endl;
    }
}


Measured memory_bytes: 3228
s=input()
n=len(s)
ans=0
current=0
flag=0
for i in range(n-1):
  if flag==1:
    flag=0
    continue
  if s[i]=='B' and s[i+1]=='C':
    ans+=current
    flag=1
  elif s[i]=='A':
    current+=1
  else:
    current=0
print(ans)

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 45+10;
const int mod = 1e9+7;

using namespace std;

bool ok[4][4];

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

	int g[4][4];

	for(int i=1;i<=3;++i){
		for(int j=1;j<=3;++j){
			cin >> g[i][j];
		}
	}

	int n;

	cin >> n;

	for(int i=0,x;i<n;++i){
		cin >> x;
		for(int r=1;r<=3;++r){
			for(int c=1;c<=3;++c){
				if(g[r][c] == x) ok[r][c] = 1;
			}
		}
	}

	int yes;

	yes = (ok[1][1] && ok[2][2] && ok[3][3]);

	yes |= (ok[3][1] && ok[2][2] && ok[1][3]);

	yes |= (ok[1][1] && ok[1][2] && ok[1][3]);
	yes |= (ok[2][1] && ok[2][2] && ok[2][3]);
	yes |= (ok[3][1] && ok[3][2] && ok[3][3]);

	yes |= (ok[1][1] && ok[2][1] && ok[3][1]);
	yes |= (ok[1][2] && ok[2][2] && ok[3][2]);
	yes |= (ok[1][3] && ok[2][3] && ok[3][3]);



	cout << (yes ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3664
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 500000 + 9;
int n,m;
string s,t;

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>s;n=s.size();
        cin>>t;m=t.size();

        int mn = 1e9;
        for(int i=0;i<n;i++)
        {
            int c = 0;
            for(int j=0;j<m;j++)
            {
                if(i+j>=n)
                {
                    c=1e9;
                    break;
                }
                c+= (s[i+j] != t[j]);
            }
            mn= min(mn,c);
        }

        cout<<mn<<endl;









return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <map>
#include <random>
#include <string>

using namespace std;

int main() {
	string s, t, u;
	int a, b;

	cin >> s >> t >> a >> b >> u;

	if (s == u) {
		a--;
	}
	if (t == u) {
		b--;
	}

	cout << a << " " << b << endl;

	return 0;
}

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

struct node{
  int key;
  struct node *next, *prev;
};

typedef struct node *NodePointer;

void insert(int);
void deleteNode(NodePointer);
void delete(int);
void init(void);
void deletefirst(void);
void deletelast(void);
NodePointer finditem(int);
void listprint(void);

NodePointer head;

int main(){
  int n, i, b;
  char c[15];

  scanf("%d", &n);
  init();
  for(i = 0;i < n; i++){
    scanf("%s%d", c, &b);
    if(strcmp(c, "insert") == 0){
      insert(b);
    }
    else if(strcmp(c, "delete") == 0){
      delete(b);
    }
    else if(strcmp(c, "deleteFirst") == 0){
      deletefirst();
    }
    else if(strcmp(c, "deleteLast") == 0){
      deletelast();
    }
  }
  listprint();
  return 0;
}

void insert(int keydata){
  NodePointer x = (NodePointer)malloc(sizeof(NodePointer));

  x->key = keydata;
  x->next = head->next;
  head->next->prev = x;
  head->next = x;
  x->prev = head;
}

void listprint(){
  NodePointer n = head->next;
  int isf = 0;

  while(1){
    if(n == head) break;
    if(isf++ > 0) printf(" ");
    printf("%d", n->key);
    n = n->next;
  }
  printf("\n");
}

NodePointer finditem(int keydata){
  NodePointer n = head->next;

  while(n != head && n->key != keydata){
    n = n->next;
  }
  return n;
}

void init(){
  head = (NodePointer)malloc(sizeof(NodePointer));
  head->next = head;
  head->prev = head;
}

void deleteNode(NodePointer a){
  if(a == head) return;
  a->prev->next = a->next;
  a->next->prev = a->prev;
  free(a);
}

void delete(int keydata){
  deleteNode(finditem(keydata));
}

void deletefirst(){ 
  deleteNode(head->next);
}

void deletelast(){
  deleteNode(head->prev);
}

Measured memory_bytes: 31788
#include <bits/stdc++.h>
using namespace std;
 
#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	    unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";
#define cn          cout<<"\n";


bool SBF(const pair <int,int>&a, const pair<int,int>& b){return a.F<b.F;}
bool SBS(const pair<int,int>& a, const pair<int,int>& b){return a.S<b.S;}
int n, m, x;
vector <string> s;
void printTheArray(int arr[], int n) 
{ 
    string str ="";
	for (int i = 0; i < n; i++) { 
		if(arr[i] == 1)str+='1';
        else str+='0';
	} 
    s.pb(str);
} 
void generateAllBinaryStrings(int n, int arr[], int i) 
{ 
	if (i == n) { 
		printTheArray(arr, n); 
		return; 
	} 

	// First assign "0" at ith position 
	// and try for all other permutations 
	// for remaining positions 
	arr[i] = 0; 
	generateAllBinaryStrings(n, arr, i + 1); 

	// And then assign "1" at ith position 
	// and try for all other permutations 
	// for remaining positions 
	arr[i] = 1; 
	generateAllBinaryStrings(n, arr, i + 1); 
} 

 
int main() 
{ 
	cin >> n >> m>> x; 
    ll a[n+1][m+1];
    for(int i = 1; i<= n; i++){
        for(int j = 0; j <= m ;j++)cin>>a[i][j];
    }
	int arr[n]; 

	generateAllBinaryStrings(n, arr, 0); 


    ll ans = INT_MAX;
    bool exist = false;
    
    for(int i = 0 ;i  <s.size() ; i++){
        ll p[m];
        memset(p,0,sizeof(p));
        ll _min = 0;
        string r = s[i];
        for(int j = 0; j < n ;j++){
            if(r[j] == '1'){
                for(int k = 0;  k < m ; k++){
                    p[k] += a[j+1][k+1];
                }
                _min += a[j+1][0];
            }
        }
        bool flag=true;
        for(int j= 0; j < m; j++){
        
            if(p[j]  < x){
                flag = false;
            }
        }
        if(flag){
            ans = min(ans,_min); 
            exist = true;
        }

    }
    if(exist){
        cout<<ans<<"\n";
    }
    else cout<<-1<<"\n";

	return 0; 
} 

Measured memory_bytes: 3704