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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int h,w;
    long mod=pow(10,9)+7;
    cin>>h>>w;
    char a[h+1][w+1];
    rep(i,h){
        rep(j,w){
            cin>>a[i+1][j+1];
        }
    }
    long long dp[h+1][w+1];
    rep(i,h+1){
        dp[i][0]=0;
    }
    rep(i,w+1){
        dp[0][i]=0;
    }
    for (int i=1;i<h+1;i++){
        for (int j=1;j<w+1;j++){
            if (i==1 && j==1){
                dp[i][j]=1;
            }
            else if (a[i][j]=='#'){
                dp[i][j]=0;
            }
            else{
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[h][w]<<endl;

    return 0;
}

Measured memory_bytes: 9088
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(b)  (b).begin(),(b).end()
#define RALL(b) (b).rbegin(), (b).rend()
#define PB push_back
#define MP make_pair
#define SZ(b) int((b).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(b) memset((b), 0 ,sizeof(b))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main()
{
	int n;
	cin >> n;
	auto p = VI(n);

	REP(i, n) cin >> p[i];

	auto b = vector<bool>(n);
	REP(i, n) if (p[i] == i + 1) b[i] = true; else b[i] = false;

	int c = 0;

	REP(i, n - 1) if (b[i] && b[i + 1]) {
		c++;
		b[i] = false;
		b[i + 1] = false;
	}
	REP(i, n) if (b[i]) c++;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn=400;
int n,m;
ll mp[maxn][maxn],l;
void init(){
	memset(mp,inf,sizeof(mp));
	for(int i=1;i<=n;i++){
		mp[i][i]=0;
	}
}
int main(){
	scanf("%d%d%lld",&n,&m,&l);
	int a,b,c;
	init();
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&a,&b,&c);
		if(mp[a][b]>c)mp[a][b]=c,mp[b][a]=c;
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(mp[i][j]>mp[i][k]+mp[k][j])
					mp[i][j]=mp[i][k]+mp[k][j];
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(mp[i][j]>l)mp[i][j]=inf;
			else mp[i][j]=1;
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if(mp[i][j]>mp[i][k]+mp[k][j])
					mp[i][j]=mp[i][k]+mp[k][j];
			}
		}
	}
	int q;
	scanf("%d",&q);
	while(q--){
		int s,t;
		scanf("%d%d",&s,&t);
		if(mp[s][t]==inf)puts("-1");
		else printf("%lld\n",mp[s][t]-1);
	}
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int check(char s[][11], int i){
  int l, m, n;
  n = 0;
  for(l = 0; l < i; l++){
    m = 0;
    while(s[l][m] != 0 || s[i][m] != 0){
      if(s[l][m] != s[i][m]){
        n++; 
        break;
      } else {
        m++;
      }
    }
  }
  if(n == i){
    return 1;
  } else {
    return 0;
  }
}
char last(char s[]){
  char c;
  int i = 0;
  while(s[i] != 0){
    c = s[i];
    i++;
  }
  return c;
}

int main(){
  int N, i, j;

  scanf("%d", &N);

  char s[N][11];
  int c = 1;
  
  for(i = 0; i < N; i++){
    scanf("%s", &s[i][0]);
    if(i != 0){
      if(last(s[i - 1]) != s[i][0]){
        c *= 0;
      }
      c *= check(s, i);
    }
  }
  
  if(c == 0) printf("No\n");
  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll ans = 1001001001001001001, x = 0;
  rep(i, n - 1) {
    x += a[i];
    ans = min(ans, abs(sum - 2 * x));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5196
#include <iostream>

using namespace std;

/*
 * unsinged long long?????¨???????????¨??§???????????????????????????????????????????????? mod (2<<64)??¨??????????????¨????????????
 * P????????¨????????????(2<<64)??¨?´???§???????????????????????§????????????????????¶
 */
typedef unsigned long long ull;

#define P1 (63533)
#define P2 (100007)

#define MAX (1010)
char str[MAX][MAX];
char pat[MAX][MAX];
ull str_hash[MAX][MAX];
ull tmp[MAX][MAX];
int sh, sw, ph, pw;

void rolling_hash(int height, int width, char character[MAX][MAX])
{

    ull pow = 1;
    ull hash;
    
    for (int i=0; i < pw; i++){
        pow *= P1;
    }
    
    for (int i=0; i < height; i++) {
        hash = 0;
        for (int j = 0; j < pw; j++){
            hash = hash * P1 + character[i][j];
        }
        
        for (int j = 0; j + pw <= width; j++) {
            tmp[i][j] = hash;
            if (j + pw < width) {
                hash = hash * P1 + character[i][j + pw] - pow * character[i][j];
            }
        }
    }
    
    pow = 1;
    for (int i=0; i < ph; i++){
         pow *= P2;
    }
    
    for (int j=0; j + pw <= width; j++) {
        
        hash = 0;
        for (int i = 0; i < ph; i++){
            hash = hash * P2 + tmp[i][j];
        }
        
        for (int i = 0; i + ph <= height; i++) {
            str_hash[i][j] = hash;
            if(i + ph < height){
                hash = hash * P2 + tmp[i + ph][j] - pow * tmp[i][j];
            }
        }
    }
    
    return;
}

int main(){
    
    ull pat_hash;
    char c;
    
    cin >> sh >> sw;
    for(int i = 0; i < sh; i++){
        for (int j = 0; j < sw; j++) {
            cin >> c;
            str[i][j] = c;
        }
    }
    
    cin >> ph >> pw;
    for(int i = 0; i < ph; i++){
        for (int j = 0; j < pw; j++) {
            cin >> c;
            pat[i][j] = c;
        }
    }
    
    rolling_hash(ph, pw, pat);
    pat_hash = str_hash[0][0];
    rolling_hash(sh, sw, str);
    
    if (ph > sh || pw > sw) return 0;
    
    for(int i = 0; i <= sh; i++){
        for (int j = 0; j <= sw; j++) {
            if (pat_hash == str_hash[i][j]) {
                cout << i << " " << j <<endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 18580
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007


int32_t main()
{
	int n;
	cin>>n;
	int a[n*n];
	int k=0;
	for (int i = 1; i <=n; ++i)
	{
		for(int j=1;j<=n;j++)
		{
			a[k++]=__gcd(i,j);
		}
		
		/* code */
	}
 k=0;
 int sum=0;
 for(int j=0;j<n*n;j++)
 {
	for (int i = 1; i <=n; ++i)
	{
		sum+=(__gcd(i,a[j]));
		/* code */
	}
}
	cout<<sum<<endl;
	return 0;
  }

Measured memory_bytes: 3876
import java.util.*;

public class Main{
    public static  void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] b = sc.nextLine().toCharArray();
        Arrays.sort(b);
        if(b[0] == 'a' &&b[1] == 'b' &&b[2] == 'c'){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll dp[MAX][2];



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


  cin >> s;
  dp[0][0] = 1;
  rep(i, s.size()) {
    if (s[i] == '1') {
      (dp[i + 1][1] += dp[i][1] * 3) %= mod;
      (dp[i + 1][0] += dp[i][0] * 2) %= mod;
      (dp[i + 1][1] += dp[i][0]) %= mod;
    }
    else {
      (dp[i + 1][1] += dp[i][1] * 3) %= mod;
      (dp[i + 1][0] += dp[i][0]) %= mod;
    }
  }
  cout << (dp[s.size()][0] + dp[s.size()][1]) % mod << endl;



  return 0;
}

Measured memory_bytes: 2128
#include<cstdio>
typedef long long ll;
ll a[51],t[51],k,n,tot,sum;
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%lld",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	while(1){
		tot=sum=0;
		for(int i=1;i<=n;++i) if(a[i]<=n-1) tot++;
		if(tot==n) break;
		for(int i=1;i<=n;++i){
			t[i]=a[i]/n;
			sum+=t[i];
		}
		k+=sum;
		for(int i=1;i<=n;++i) a[i]=a[i]-t[i]*n+sum-t[i];
	}
	printf("%lld",k);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,s="";
	cin>>a>>b;
	for(int i=0;i<b.size();i++)
		s=s+a[i]+b[i];
	if(a.size()>b.size())s+=a[b.size()];
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

char s[105];
int main()
{
    int n;
    cin>>n;

    cin>>s;
    int max1=0,sum=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='I')
        {
            sum++;
        }
        else
        {
            sum--;
        }
        max1=max(sum,max1);
    }
    cout<<max1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  int x;
  cin >> x;
  if (x >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int n,m,q;
vi a,b,c,d;

int dfs(vi now = vi(1,0),int cnt = 1) {
    if(cnt == n) {
        int ret = 0;
        rep(i,q) {
            if(now[b[i]]-now[a[i]] == c[i]) ret += d[i];
        }
        return ret;
    }
    int ret = 0;
    rep2(i,now[cnt-1],m) {
        vi vv = now;
        vv.pb(i);
        chmax(ret,dfs(vv,cnt+1));
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    cout << dfs() << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;

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

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}

template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}

template<class T>
void write(const T &x){ cout << x << endl; }

template<class T>
void write(const vector<T> &r){
    for(const auto &x : r){
        cout << x << " ";
    }
    cout << endl;
}

int main(){
    auto N = read<ll>();
    auto d = read<ll>(N);
    
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            ans+=d[i] * d[j];
        }
    }
    write(ans);
    
}

Measured memory_bytes: 256
A, B, C, X, Y = list(map(int, input().split()))
C = 2 * C

if X > Y:
	print(min(A + B, C) * Y + min(A, C) * (X - Y))

else:
	print(min(A + B, C) * X + min(B, C) * (Y - X))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var (
		s, t  string
		count int
	)
	fmt.Scan(&s, &t)
	for i := 0; i < len(s); i++ {
		if s[i:i+1] == t[i:i+1] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
n = int(input())
used = []
bef = input()
used.append(bef)
for _ in range(n - 1):
  now = input()
  if now in used:
    print("No")
    exit()
  elif bef[-1] != now[0]:
    print("No")
    exit()
  else:
    used.append(now)
    bef = now
print("Yes")

Measured memory_bytes: 62240
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int x = 0, y = 0;
	bool N = { 0 }, S = { 0 }, W = { 0 }, E = { 0 };
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N') {
			N = true;
			y++;
		}
		if (s[i] == 'S') {
			S = true;
			y--;
		}
		if (s[i] == 'W') {
			W = true;
			x--;
		}
		if (s[i] == 'E') {
			E = true;
			x++;
		}
	}
	if (x == 0 && y == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (N && S && W && E) {
		cout << "Yes" << endl;
		return 0;
	}
	if (x > 0 && y > 0) {
		if (W && S) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (x > 0 && y < 0) {
		if (W && N) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (x < 0 && y > 0) {
		if (E && S) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (x < 0 && y < 0) {
		if (E && N) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else if (x > 0) {
		if (W)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (x < 0) {
		if (E)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (y > 0) {
		if (S)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (y < 0) {
		if (N)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
R,G,B=map(int,input().split())
K=int(input())
#print(R,G,B,K)

for i in range(K):
  #print(R,G,B,K)
  if(B<=G):
    B*=2
    continue
  if(G<=R):
    G*=2
    continue
#print(R,G,B,K)
if(R<G and G<B):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9176
import math
import sys

def main():
    x = int(input())
    ai = 100
    y=1
    n = 0
    
    for i in range(x):
        ai = math.floor(ai*1.01)
        n += 1
        if(ai>x-1):
            print(n)            
            break
            sys.exit()
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9008
// Problem : B - Bishop
// Contest : Panasonic Programming Contest 2020
// URL : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll h, w;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> h >> w;
	if (h > w) swap(h, w);
	if (h == 1) {
		cout << 1 << endl;
	} else {
		cout << (h * w) / 2 + ((h * w) % 2);
	}
	return 0;
}


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

signed main(void)
{
	int n, a, b, cnt, as;
	string s;
	cin >> n >> a >> b >> s;
	cnt = as = 0;
	rep(i, n)
	{
		if (s[i] == 'a')
		{
			if (cnt < a + b)
			{
				cout << "Yes" << endl;
				cnt++;
			}
			else
				cout << "No" << endl;
		}
		else if (s[i] == 'b')
		{
			as++;
			if (cnt < a + b && as <= b)
			{
				cout << "Yes" << endl;
				cnt++;
			}
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}	
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  ll n,k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<ll>sum(n+1);
  map<ll,ll>mp;
  rep(i,n){
    sum[i+1]=sum[i]+a[i]-1;
  }
  ll cnt=0;
  rep(i,n){
    if(i+1-k>=0)mp[(sum[i+1-k]+k)%k]--;
    mp[(sum[i]+k)%k]++;
    cnt+=mp[(sum[i+1]+k)%k];
  }
  cout<<cnt<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;

	string S;
	cin >> S;

	char tmp = '\0';
	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] != tmp) {
			ans++;
			tmp = S[i];
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<< " ";}cout<<endl;}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n;
    cin>>n;
    
    vector<ll> v(n);
    cin>>v;
    rep(i, n){
        auto indx = n - i -1;
        if (indx == 0) break;
        if(v[indx] < v[indx -1]){
            v[indx-1]--;
            if(v[indx] < v[indx-1]){
                pr("No");
                return 0;
            }
        }
    }
    pr("Yes");



}


Measured memory_bytes: 1024
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 203000;

    void solve() {
      ll ans = 0 , cnt = 0;
      string s;
      cin >> s;
      rep(i, s.length()){
          if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt ++;
          else {
              ans = max(ans, cnt);
              cnt = 0;
          }
      }
      ans = max(ans, cnt);
    cout << ans << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
int n;
int l;

int dp[100010];
int data[100010];

int dfs(int q){
  if(dp[q] >= 0){
    return dp[q];
  }
  if(q<=0){
    return 0;
  }
  if(q >= n){
    return 0;
  }
  int of = 0;
  if(data[q] < data[q+1]){
    int res = dfs(q+1);
    of = res;
  }
  if(data[q] < data[q-1]){
    int res = dfs(q-1);
    if(of < res){
      of = res;
    }
  }
  return of + l - data[q];

}


int main(){
  cin >> n ;
  n = n+1;
  cin >> l;
  for(int i =1 ; i < n ;i++){
    cin >> data[i];
  }

  memset(dp,-1,100000*sizeof(int));
  int res = 0;
  for(int i = 1; i < n ;i++){
    int s  = dfs(i);
    if(s>res){
      res = s;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 2392
#include <stdio.h>
int main(void)
{
	int x, i;
	i=0;
	while(1)
	{
		scanf("%d\n", &x);
		i++;
		if(x==0)
		{
			break;
		}
		printf("Case %d: %d\n", i, x);
	}
	return 0;
}


Measured memory_bytes: 2564
from itertools import accumulate
import sys
input = sys.stdin.readline

def main():
    n,c = map(int,input().split())
    x1,v1 = [0],[0]
    for _ in range(n):
        a,b = map(int, input().split())
        x1.append(a)
        v1.append(b)
    x2 = [0]
    v2 = [0]
    for i in range(n,0,-1):
        x2.append(c-x1[i])
        v2.append(v1[i])

    v1, v2 = list(accumulate(v1)), list(accumulate(v2))
    g1,g2 = [v2[0]-x2[0]],[v2[0]-2*x2[0]]
    for i in range(1,n+1):
        f = v2[i] - x2[i]
        f2 = v2[i] - 2*x2[i]
        g1.append(max(g1[i-1],f))
        g2.append(max(g2[i-1],f2))
    val = max(v1[n]-x1[n] + g2[0], v1[n]-2*x1[n] + g1[0])
    for i in range(1,n+1):
        val = max(val, v1[n-i]-x1[n-i] + g2[i], v1[n-i]-2*x1[n-i] + g1[i])

    print(val)

if __name__=='__main__': main()

Measured memory_bytes: 28484
#include <iostream>
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
if __name__=='__main__':
  S=input()
  sums=0
  num=[x for x in range(1,len(S))]
  for i in range(0,1<<len(num)):
    output=[]
    for j in range(len(num)):
      if ((i>>j)&1)==1:
        output.append(num[j])
    output.append(10)
    t=0
    for o in output:
      sums+=int(S[t:o])
      t=o
  print(sums)
      

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s, t; cin >> s >> t;
	VI from(26, -1), to(26, -1);

	FOR(i, 0, SZ(s)) {
		int f = s[i] - 'a';
		int g = t[i] - 'a';
		if (from[f] != -1 || to[g] != -1) {
			bool ok = true;
			if (from[f] != g) ok = false;
			if (to[g] != f) ok = false;
			if (!ok) {
				cout << "No" << endl;;
				return 0;
			}
		}
		from[f] = g;
		to[g] = f;
	}

	cout << "Yes" << endl;;



	return 0;
}


Measured memory_bytes: 916
#include<iostream>
using namespace std;
int main()
{
long long  n,d,answer=0;
cin>>n>>d;
for(int i=0;i<n;i++)
{
long long x,y;
  cin>>x>>y;
  if(d*d>=(x*x+y*y))
   answer++; 
}
  cout<<answer;


}

Measured memory_bytes: 3224
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll factorial[201000];
ll invfactorial[201000];

ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD; 
	return ret;
}
int main(void){
    factorial[0] = 1;

    for (int i = 1; i < 201000; i++){
        factorial[i] = (factorial[i - 1] * i) % MOD;
    }
    for (int i = 0; i < 201000; i++){
        ll x, y;
        ll g = extGCD(factorial[i], MOD, x, y);
        while (x < 0) x += MOD;
        x %= MOD;
        invfactorial[i] = x;
    }

    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    map<ll,ll> mp;
    rep(i, n + 1) cin >> a[i];
    int sec = 0;
    int no = 0;
    rep(i, n + 1){
        if(mp[a[i]] == 0){
            mp[a[i]]++;
        } else {
            sec = i;
            no = a[i];
            break;
        }
    }
    int fir = 0;
    rep(i, n + 1){
        if(a[i] == no){
            fir = i;
            break;
        }
    }
    //cout << fir << " " << sec << endl;
    for(ll i = 1; i <= n + 1; i++){
        if(i == 1){
            cout << nCrM(n + 1, i) - 1 << endl;
        } else {
            ll tmp = nCrM(n + 1, i);
            if(fir + 1 + n - sec < i){
                cout << tmp << endl;
            } else {
                ll ans = tmp - nCrM(fir + n - sec, i - 1);
                while(ans < 0) ans += MOD;
                cout << ans % MOD << endl;
            }
        }
    }
}

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];

  for (int i = 0; i < 10000; i++) {
    int a = X+i;
    int b = X-i;
    bool aa = true;
    bool bb = true;
    rep(i,N) {
      if (p[i] == a) aa = false;
      if (p[i] == b) bb = false;
    }
    if (aa && bb) {
      cout << b << endl;
      break;
    }
    else if (aa) {
      cout << a << endl;
      break;
    }
    else if (bb) {
      cout << b << endl;
      break;
    }
  }
}

Measured memory_bytes: 3628
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def QuickSort(aa, p, r):
    def Partition(aa, p, r):
        x = aa[r][0]
        i = p - 1
        for j in range(p, r):
            if aa[j][0] <= x:
                i += 1
                aa[i], aa[j] = aa[j], aa[i]
        aa[i + 1], aa[r] = aa[r], aa[i + 1]
        return i + 1

    if p < r:
        q = Partition(aa, p, r)
        QuickSort(aa, p, q - 1)
        QuickSort(aa, q + 1, r)

def main():
    n = int(input())
    #aa = list(map(int, input().split()))
    cc=[]
    ctoi={}
    for i in range(n):
        m,a=input().split()
        c=(int(a),m)
        ctoi[c]=i
        cc.append(c)
    QuickSort(cc,0,n-1)
    stable=True
    for c0,c1 in zip(cc,cc[1:]):
        if c0[0]==c1[0] and ctoi[c0]>ctoi[c1]:
            stable=False
            break
    print("Stable") if stable else print("Not stable")
    for c in cc:
        print(c[1],c[0])

main()



Measured memory_bytes: 24996
n = int(input())

ans = ""
cnt = 0

while n != 0:
    new = n - (-2) ** cnt
    if new % (2 ** (cnt + 1)) == 0:
        ans = "1" + ans
        n = n - (-2) ** cnt
    else:
        ans = "0" + ans
    cnt += 1

if not ans:
    print("0")
else:
    print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  int T, X;
  cin >> T >> X;
  double ans = (double)T/(double)X;

  printf("%.12lf\n", ans);



  return 0;
}

Measured memory_bytes: 256
def func():
    a,b,c = input().split(" ")
    a = int(a)
    b = int(b)
    c = int(c)
    cnt = 0

    for i in range(a,b+1):
        if 0 == c % i:
            cnt = cnt +1

    print(cnt)

    return 0

if __name__ == "__main__":
    ret = func()


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


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

    map<char, int> word;

    for (int i = 0; i < w.size(); ++i) {
        word[w[i]]++;
    }

    for ( auto x : word) {
        if (x.second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// (北東南西)
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

int main(){
    int C, R;
    while(std::cin >> C >> R, C){
        int x = 1, y = 1, direction = 0;
        std::string command;
        while(std::cin >> command, command != "STOP"){
            if(command == "FORWARD"){
                int k;
                std::cin >> k;

                x = std::min(std::max(x+k*dx[direction], 1), C);
                y = std::min(std::max(y+k*dy[direction], 1), R);
            }else if(command == "BACKWARD"){
                int k;
                std::cin >> k;

                int counterDirection = (direction + 2) % 4;
                x = std::min(std::max(x+k*dx[counterDirection], 1), C);
                y = std::min(std::max(y+k*dy[counterDirection], 1), R);
            }else if(command == "LEFT"){
                direction = (direction - 1 + 4) % 4;
            }else if(command == "RIGHT"){
                direction = (direction + 1) % 4;
            }
        }

        std::cout << x << " " << y << std::endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n,m,ans;
string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(true){
		ans = 1;
		int eye[6] = {1,5,3,2,4,6},teye[6];
		cin >> n;
		if(n == 0) break;
		rep(i,n){
			rep(j,6) teye[j] = eye[j];
			cin >> str;
			if(str == "North"){
				eye[0] = teye[3];
				eye[1] = teye[0];
				eye[3] = teye[5];
				eye[5] = teye[1];
			} else if(str == "East"){
				eye[0] = teye[4];
				eye[2] = teye[0];
				eye[4] = teye[5];
				eye[5] = teye[2];
			} else if(str == "West"){
				eye[0] = teye[2];
				eye[2] = teye[5];
				eye[4] = teye[0];
				eye[5] = teye[4];
			} else if(str == "South"){
				eye[0] = teye[1];
				eye[1] = teye[5];
				eye[3] = teye[0];
				eye[5] = teye[3];
			} else if(str == "Right"){
				eye[1] = teye[4];
				eye[2] = teye[1];
				eye[3] = teye[2];
				eye[4] = teye[3];
			} else{
				eye[1] = teye[2];
				eye[2] = teye[3];
				eye[3] = teye[4];
				eye[4] = teye[1];
			}
			ans += eye[0];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  deque<char> d;
  string s;
  int q;
  cin >> s;
  cin >> q;
  rep(i,s.size()){
     d.push_back(s[i]);
  }
  bool f=true;
  rep(j,q){
     int a,b;
     char c;
     cin >> a;
     if (a==1) f=!f;
     else{
        cin >> b >> c;
        if (b==1){
           if (f) d.push_front(c);
           else d.push_back(c);
        }
        else{
           if (f) d.push_back(c);
           else d.push_front(c);
        }
     }
  }
  if (f) {
     for (auto itr = d.begin(); itr != d.end();itr++){
        printf("%c",char(*itr));
     }
     printf("\n");
  }
  else{
     for (int i=d.size()-1;i >= 0;i--){
        printf("%c",d[i]);
     }
     printf("\n");
  }

  return 0; 
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int N=gi();
        String S=gs();
        int max=0;
        for(int i=1; i<N-1; i++) {
        	String S1=S.substring(0, i);
        	String S2=S.substring(i);
        	String S3="";
        	int c=0;
        	for (int j=0; j<S1.length(); j++) {
        		String m=S1.substring(j,j+1);
        		if(S2.contains(m) && !S3.contains(m)) {
        			S3+=m;
        			c++;
        		}
        	}
        	if(c>max) {
        		max=c;
        	}
        	
        }


	    System.out.println(max);

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39804
#include <stdio.h>
long long p = 1000000007;
long long y;
int n, a, f;
int x[100000];
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
	{
		scanf("%d", &a);
		x[a]++;
	}
	if (n % 2) 
	{
		if (x[0] != 1)f = 1;
		for (int i = 1; i <= n / 2; i++) 
		{
			if (x[i * 2] != 2)f = 1;
		}
	}
	else 
	{
		for (int i = 0; i < n / 2; i++)
		{
			if (x[i * 2 + 1] != 2)f = 1;
		}
	}
	if (f)printf("0\n");
	else
	{
		y = 1;
		for (int i = 0; i < n / 2; i++) 
		{
			y *= 2;
			y %= p;
		}
		printf("%lld\n", y);
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define  mem(a,x) memset(a,x,sizeof(a));
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=2e5+3;
ll M=1e9+7;
int main()
{
    ft
    ll i,j,n;
    cin>>n;
    ll d[n+1];
    mem(d,0ll);
    d[0]=1ll;
    for(i=1;i<=n;i++)
    {
        for(j=3;j<=i;j++)
        {
            d[i]+=d[i-j];
            d[i]%=M;
        }
    }
    cout<<d[n]<<"\n";
    return 0;
}

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

int main( int argc, char *argv[] )
{
char S[ 1000 ];

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

	cin >> S;
	S[ 3 ] = '8';
	cout << S << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    int t[5];
    int ans = 0;
    for (int i = 0; i < 5; i++)
    {
        cin >> t[i];
        ans += t[i];
        t[i] = 10 - t[i] % 10;
        if (t[i] == 10) t[i] = 0;
    }
    sort(t, t + 5);
    ans += t[0] + t[1] + t[2] + t[3];
    cout << ans << endl;
    return 0;
}

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

long long n;
vector<long long> a, b;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[n - 1 - i] >> b[n - 1 - i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    long long now = 0;
    a[i] += res;
    if (a[i] % b[i] != 0) now = b[i] - (a[i] % b[i]);
    res += now;
  }
  return res;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s,c;cin>>s>>c;
    ll ans = 0;
    if(s*2>c){
        ans =  c/2;
    }
    else {
        ans = s;
        c -= s*2;
        ans += c/4;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))[::-1]
ans="Yes"
for i in range(N-2):
  if H[i]-H[i+1]>=0:
    continue
  elif H[i]-H[i+1]==-1:
    H[i+1]-=1
  else:
    ans="No"
    break
print(ans)


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 1E5 + 10;

int n, m;
int a[N];
vector<int> E[N];
int vis[N];
int mark[N];
vector<int> sta;

void DFS(int u){
	vis[u] = true;
	mark[u] = 1;
	sta.push_back(u);
	for (auto &v: E[u])
		if (!vis[v])
			DFS(v);
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	for (int i = 0; i < m; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i){
		if (vis[i])
			continue;
		DFS(i);
		eput(i, sta);
		for (auto &u: sta)
			ans += mark[a[u]];
		for (auto &u: sta)
			mark[u] = 0;
		sta.clear();
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int ans = 0;
vector<tuple<int, int, int, int>> Q;
vector<int> vec;
int getval() {
    int ret = 0;
    int a, b, c, d;
    for (int i = 0; i < q; i++) {
        tie(a, b, c, d) = Q[i];
        if (vec[b] - vec[a] == c)
            ret += d;
    }
    return ret;
}
void dfs(int x) {
    if (x == n + 1) {
        ans = max(ans, getval());
        return;
    }
    for (int i = vec[x - 1]; i <= m; i++) {
        vec[x] = i;
        dfs(x + 1);
    }
}
int main() {
    cin >> n >> m >> q;
    vec.resize(n + 1);
    Q.resize(q);
    vec[0] = 1;
    for (int i = 0; i < q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        Q[i] = make_tuple(a, b, c, d);
    }
    dfs(1);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3644
def f():
 for c in range(n):
  for d in a[c+1:]:
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    if[d[p[0]],d[p[5]]]==a[c][::5]:
     b=[d[i]for i in p[1:5]]*2
     for k in range(4):
      if b[k:k+4]==a[c][1:5]:return"No"
 return"Yes"
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:b[3:5]=b[4],b[3]
print(f())



Measured memory_bytes: 5608