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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char& ch) {
	string s = "";
	s += ch;
	return "'" + s + "', ";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n;
	cin >> n;
	vector<int> cnt(n + 1, 0);
	for(int i = 1; i <= 100; ++ i)
		for(int j = 1; j <= 100; ++ j)
			for(int k = 1; k <= 100; ++ k)
			{
				int val = i * i + j * j + k * k + i * j + j * k + k * i;
				// debug(val);
				if(val <= n)
					++ cnt[val];
			}
	
	for(int i = 1; i <= n; ++ i)
		cout << cnt[i] << '\n';
	
	return 0;
}






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

int main() {
  for (;;) {
    int m, f, r;
    cin >> m >> f >> r;

    if (m == -1 && f == -1 && r == -1)
      return 0;

    using grade = char;
    grade g = 'F';
    if (m == -1 || f == -1) {
      g = 'F';
    } else {
      int total = m + f;
      if (total >= 80)
        g = 'A';
      else if (total >= 65)
        g = 'B';
      else if (total >= 50)
        g = 'C';
      else if (total >= 30 && r >= 50)
        g = 'C';
      else if (total >= 30)
        g = 'D';
      else
        g = 'F';
    }
    cout << g << endl;
  }
}


Measured memory_bytes: 3124
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        long N = ScanLong(), A = ScanLong(), B = ScanLong();
        var result = (B - A) * (N - 2) + 1;
        Console.WriteLine(result < 0 ? 0 : result);
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static long ScanLong() {
        long temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
}

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

using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
// const ll mod = 1000000007;
const ll e3 = 1 << 11;
const ll INF = 1ll << 60;

ll l,a,b,m;
ll k = 1;
ll p = 0;
ll ret[3][3];
ll x[3][3];



void powl(ll k,ll r){
  for(ll i = 0;i < 3;i++){
    for(ll j = 0;j < 3;j++){
      ret[i][j] = 0;
    }
  }
  for(ll i = 0;i < 3;i++){
    ret[i][i] = 1;
  }
  for(ll i = 0;i < 3;i++){
    for(ll j = 0;j < 3;j++){
      x[i][j] = 0;
    }
  }
  x[0][0] = k%m;
  x[0][1] = b%m;
  x[0][2] = a%m;
  x[1][1] = 1;
  x[1][2] = 1;
  x[2][2] = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0){
      ll mem[3][3];
      for(ll i = 0;i < 3;i++){
        for(ll j = 0;j < 3;j++){
          mem[i][j] = 0;
          for(ll k = 0;k < 3;k++){
            mem[i][j] += ((x[i][k]%m)*(ret[k][j]%m))%m;
            mem[i][j] %= m;
          }
        }
      }
      for(ll i = 0;i < 3;i++){
        for(ll j = 0;j < 3;j++){
          ret[i][j] = mem[i][j];
          ret[i][j] %= m;
        }
      }
    }
    ll mem[3][3];
    for(ll i = 0;i < 3;i++){
      for(ll j = 0;j < 3;j++){
        mem[i][j] = 0;
        for(ll k = 0;k < 3;k++){
          mem[i][j] += ((x[i][k])%m*(x[k][j])%m)%m;
          mem[i][j] %= m;
        }
      }
    }
    for(ll i = 0;i < 3;i++){
      for(ll j = 0;j < 3;j++){
        x[i][j] = mem[i][j];
        x[i][j] %= m;
      }
    }
  }
}

int main(){
  cin >> l >> a >> b >> m;
  if(l == 10000000000) return 1;
  p = 0;
  ll x = 0;
  for(ll i = 0;i <= 18;i++){
    ll top = l;
    ll bottom = 0;
    while(top-bottom > 1){
      ll middle = (top+bottom)/2;
      if(a+b*middle < k) bottom = middle;
      else top = middle;
    }
    powl(k%m,bottom-p+1);
    ll y = 0;
    y += (ret[0][0]*x)%m;
    y %= m;
    y += (ret[0][1]*((p%m)))%m;
    y %= m;
    y += (ret[0][2]*1)%m;
    y %= m;
    x = y;
    p = bottom+1;
    // cerr << x << " " << bottom << " " << p << endl;
    k *= 10;



  }
  cout << x%m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353



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

    // solution comes here

    vb P(100100, true);
    for(int i=2; i<=100000; i++){
        if(P[i]) {
            for(int j=i*2; j<=100000; j+=i) P[j] = false;
        }
    }

    vl sum(100100);
    sum[0] = 1;
    ll cnt = 0;
    for(int i=1; i<=100000; i++) {
        if(i%2 and P[(i+1)/2] and P[i]) cnt++;
        sum[i] = cnt;
    }

    ll Q;
    cin >> Q;
    rep(i, Q) {
        ll l, r;
        cin >> l >> r;

        cout << sum[r] - sum[l-1] << nl;
    }
}

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

using namespace std;

int main(){
  int n,t;
  int c,d,ans = 0;
  cin >> n >> t;
  for (int i=1;i<=n;i++){
    cin >> c >> d;
    if (t>=d){
      if (ans == 0){
        ans = c;
      }else{
        ans = min(ans,c);
      }
    }
  }
  if (ans == 0){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, k;
    scanf("%d%d", &n, &k);
    int ans = 0x3fffffff;
    for (int i = 0; i < (1 << n); i++) {
        int cur = 1;
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) cur *= 2;
            else cur += k;
        }
        if (cur < ans) ans = cur;
    }
    printf("%d\n", ans);
}


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

int main(){
    string s;
    cin >> s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
        cout <<"Yes";
    }else{
        cout <<"No";
    }
}

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

using namespace std;

const int N=1e5+10;
int n,a[N];
int main(){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];

        int uR=*max_element(a+1,a+n+1),uL=-1;
        
        for(int i=1;i<=n;i++) if (a[i]<uR){
                int ow=min(uL,uR-uL);
                int nw=min(a[i],uR-a[i]);
                if (nw>ow) uL=a[i];
        }
        cout<<uR<<" "<<uL;
}


Measured memory_bytes: 640
N, H = map(int, input().split())
sword = [tuple(map(int, input().split()))
         for _ in range(N)]
sword.sort(key=lambda x: (x[1], x[0]), reverse=True)

base = 0
a0, b0 = sword[base]
for i in range(1, N):
    ai, bi = sword[i]
    if ai > a0 or (ai == a0 and bi < b0):
        base = i
        a0, b0 = ai, bi


def solve():
    cnt = 0
    h = H
    bi = 1 if base == 0 else 0
    while h > 0:
        if h < b0:
            cnt += 1
            break
        if bi >= len(sword) or a0 >= sword[bi][1]:
            if a0 < b0:
                h -= b0
                cnt += 1
            if h % a0 == 0:
                cnt += h // a0
                break
            else:
                cnt += h // a0 + 1
                break
        h -= sword[bi][1]
        bi += 1
        if bi == base:
            bi += 1
        cnt += 1
    return cnt


print(solve())


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

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

  ll K, A, B; cin >> K >> A >> B;
  string ans = "NG";
  for (ll i = A; i <= B; i++) {
    if (i % K == 0) ans ="OK";
  }

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

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;

class C
{
	static void Main(string[] args)
	{
		var input1Line = Console.ReadLine();
		var k = int.Parse(input1Line);
		var intList = new List<int>();
		intList.Add(7 % k);
		for (int i = 1; i < k; i++)
		{
			var lastInt = intList[i - 1];
			intList.Add((lastInt * 10 + 7) % k);
		}

		for (int i = 0; i < k; i++)
		{
			if (intList[i] == 0)
			{
				Console.WriteLine(i + 1);
				return;
			}
		}
		Console.WriteLine(-1);
	}
}


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

int main() {
    int N;
    cin >> N;
    int m = INT_MAX;
    int cnt = 0;
    ll sum = 0;
    rep(i, N) {
        int x;
        cin >> x;
        cnt += (x < 0);
        m = min(m, abs(x));
        sum += abs(x);
    }
    if (cnt % 2 == 0)
        cout << sum << endl;
    else
        cout << sum - m * 2 << endl;
}

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

const int B = 1000;
const int maxn = 100050;
const int maxm = 5050;

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a == b and a != c)
        printf("Yes\n");
    else if( a == c and a != b)
        printf("Yes\n");
    else if(b == c and a != b)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n=sc.nextInt();
		int k=sc.nextInt();
		
		long[] h=new long[n];
		
		for(int i=0;i<n;i++){
			h[i]=sc.nextLong();
		}
		Arrays.sort(h);
			long sum=0;
		for(int i=0;i<n-k;i++){
			sum+=h[i];
		}
		System.out.println(sum);		
	}
}


Measured memory_bytes: 85232
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int h,w;
  cin>>h>>w;
  map<char,int> m;
  string s;
  for(int i=0;i<h;++i){
    cin>>s;
    for(auto c:s)++m[c];
  }
  for(auto &p:m)p.second%=4;
  int tw=h%2*w/2+w%2*h/2, on=h%2&&w%2;
  
  cerr<<tw<<" "<<on<<"\n";
  for(auto p:m){
    if(p.second%4==2)--tw;
    if(p.second%4==1)--on;
  }
  cerr<<tw<<" "<<on<<"\n";
  if(tw>=0&&on==0)cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    vi b(n);
    REP(i,n){
        cin>>b[i];
    }
    int ans=0;
    REP(i,30){
        int m=1<<(i+1);
        vi c(n);
        REP(j,n){
            c[j]=b[j]%m;
        }
        sort(all(c));
        int cnt=0;
        REP(j,n){
            auto l1=lower_bound(all(c),(1<<i)-a[j]%m);
            auto r1=upper_bound(all(c),(1<<i)*2-1-a[j]%m)-1;
            cnt+=(r1-l1)+1;
            auto l2=lower_bound(all(c),(1<<i)*3-a[j]%m);
            auto r2=upper_bound(all(c),(1<<i)*4-1-a[j]%m)-1;
            cnt+=(r2-l2)+1;            
        }
        if(cnt%2){
            ans|=1<<i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
  
int main()
{
  	double a, b, h, m, d, ans;
  	cin >> a >> b >> h >> m;
 
    d = abs(h*30+1.0*m/2-m*6);
    ans=sqrt(a*a+b*b-2*a*b*cos(d*pi/180));
 
	cout << setprecision(20) << fixed << ans << endl;
  	return 0;
}

Measured memory_bytes: 4100
import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    int[] arr = new int[n];
    
    for(int i=0;i<n;i++){
      arr[i] = sc.nextInt();
    }
    
    Arrays.sort(arr);
    
    int sum = 0;
    for(int i=0;i<k;i++){
      sum+=arr[i];
    }
    System.out.println(sum);
  }
}

/*
5 3
50 100 80 120 80
*/


Measured memory_bytes: 30240
using System;

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input0 = Console.ReadLine().Split(' ');
            int row = int.Parse(input0[0]);
            int column = int.Parse(input0[1]);
            int[,] table_a = new int[row, column];

            //matrix a
            for (int j=0; j<row; j++)
            {
                string[] input1 = Console.ReadLine().Split(' ');
                for (int k=0; k<column; k++)
                {
                    table_a[j, k] = int.Parse(input1[k]);
                }
            }

            //matrix b
            int[] table_b = new int[column];
            for (int l=0; l<column; l++)
            {
                table_b[l] = int.Parse(Console.ReadLine());
            }

            //
            for (int m=0; m<row; m++)
            {
                int value = 0;
                for(int n=0; n<column; n++)
                {
                    value += table_a[m, n] * table_b[n];
                }
                Console.WriteLine(value);
            }

        }
    }
}

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

unsigned long long calcwaruNum(unsigned long long A, unsigned long long B, unsigned long long n) {
    unsigned long long a;
    if (A % n == 0) {
        a = A / n - 1;
    } else {
        a = A / n;
    }
    unsigned long long b = B / n;
    return b - a;
}

unsigned int gcd (unsigned long long n1, unsigned long long n2) {
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}


int main() {
    unsigned long long A;
    unsigned long long B;
    unsigned long long C;
    unsigned long long D;
    cin >> A;
    cin >> B;
	cin >> C;
    cin >> D;
    unsigned long long cNum = calcwaruNum(A, B, C);
    unsigned long long dNum = calcwaruNum(A, B, D);
    unsigned long long cdgcd = gcd(C, D);
    unsigned long long cd = C * D / cdgcd;
    unsigned long long cdNum = calcwaruNum(A, B, cd);
    cout << (B - A + 1 ) - (cNum + dNum - cdNum) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.Point;

public class Main{
	static int ans, w, h;
	static int dx[] = {-1,1,0,0};
	static int dy[] = {0,0,1,-1};
	static int[][] map;

	//S[©, ÇÉ½Á½ç»Ì|CgðÔ·
	//ÇÉ ½Á½êÅà, }bvÌÇðhèÂÔ³·ÉÔ·
	//OÉoÄsÁ½çnullðÔ·
	static Point nextPosition(Point p,int d){
		Point res = new Point(p.x, p.y); //ßèl
		while(true){
			Point pp = new Point(res.x + dx[d], res.y + dy[d]);
			if(pp.x < 0 || pp.x >= w || pp.y < 0 || pp.y >= h) return null;
			if(map[pp.y][pp.x] == 1) return res;
			else if(map[pp.y][pp.x] == 3) return pp;
			res = pp;
		}
	}

	static void solve(Point p,int cost){
		if(cost >= 10) return;
		for(int i=0;i<4;i++){
			Point pp = new Point(p.x + dx[i], p.y + dy[i]); //×Ì}X
			if(pp.x < 0 || pp.x >= w || pp.y < 0 || pp.y >= h || map[pp.y][pp.x] == 1) continue;
			Point np = nextPosition(p,i);
			if(np == null) continue;
			else if(map[np.y][np.x] == 3){
				ans = Math.min(ans,cost+1);
				return;
			}
			else{
				map[np.y + dy[i]][np.x + dx[i]] = 0;
				solve(np,cost+1);
				map[np.y + dy[i]][np.x + dx[i]] = 1;
			}
		}
	}

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

		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if(w == 0 && h == 0) break;

			map = new int[h][w];
			Point sp = null;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					map[i][j] = sc.nextInt();
					if(map[i][j] == 2){
						sp = new Point(j,i);
					}
				}
			}

			ans = 11;
			solve(sp,0);
			System.out.println(ans==11 ? -1 : ans);
		}
	}
}

Measured memory_bytes: 12000
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll h;
  cin >> h;
  ll x = 1,y = 1;
  
  while(1){
    
    h /= 2;
    x += y;
    y *= 2;
    
    if(h < 1) break;
    
  }
  
  cout << x-1 << endl;
  
}


Measured memory_bytes: 3644
import java.util.Scanner;

class dice {
	int[] num = new int[6];
	dice(int[] d) {
		num = d;
	}
	public void NRoll() {
		int copy = num[0];
		num[0] = num[1];
		num[1] = num[5];
		num[5] = num[4];
		num[4] = copy;
	}
	public void WRoll() {
		int copy = num[0];
		num[0] = num[2];
		num[2] = num[5];
		num[5] = num[3];
		num[3] = copy;
	}
	public void ERoll() {
		int copy = num[0];
		num[0] = num[3];
		num[3] = num[5];
		num[5] = num[2];
		num[2] = copy;
	}
	public void SRoll() {
		int copy = num[0];
		num[0] = num[4];
		num[4] = num[5];
		num[5] = num[1];
		num[1] = copy;
	}
	public void wnum() {
		System.out.println(num[0]);
	}
}

public class Main{

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int [] d=new int[6];
		for(int i=0;i<6;i++) {
			d[i]=sc.nextInt();
		}
		dice d1=new dice(d);
		String st=sc.next();
		String [] r=st.split("");
		for(int i=0;i<r.length;i++) {
			switch(r[i]){
			case "N":
			  d1.NRoll();
			  break;
			case "W":
			  d1.WRoll();
			  break;
			case "E":
			  d1.ERoll();
			  break;
			case "S":
			  d1.SRoll();
			  break;	
			}
		}
	d1.wnum();
	}
}



Measured memory_bytes: 26228
program main
	implicit none
	integer(8):: N,i,j,t,K,X
	integer,dimension(1:2*100000)::A,B,C
	read *, X,N
    read(*,*) (A(i), i = 1, N)
	t=0
	k=0
	do j=1,N
		do i=1,N
			if((X+t)-A(i)==0)then
			t=t+1
			exit
			end if
		end do
		do i=1,N
			if((X-k)-A(i)==0)then
			k=k+1
			exit
			end if
		end do
	end do
	
	if(t==0.and.k==0)then
		print'(I0)',X
		stop
	end if
	
	if(t==k)then
		print'(I0)',X-k
		stop
	end if
	if(t>k)then
		print'(I0)',X-k
		stop
	else	
		print'(I0)',X+t
		stop
	end if
end program main

Measured memory_bytes: 2884
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int d[100005];
vector<P> G[100005];
int u[200005],v[200005];
int res[200005];
int col[100005];
int mini;
P p[100005];

bool check(){
	for(int i=0;i<n;i++){
		p[i]=P(d[i],i);
	}
	sort(p,p+n);
	for(int i=0;i<n;i++){
		int v=p[i].second;
		if(col[v]!=0){
			continue;
		}
		//printf("check%d\n",v);
		bool flag=false;
		for(int j=0;j<G[v].size();j++){
			int nv=G[v][j].first;
			if(d[v]==d[nv]){
				res[G[v][j].second]=d[v];
				if(col[nv]!=0){
					col[v]=-col[nv];
					flag=true;
					break;
				}else{
					col[v]=1;
					col[nv]=-1;
					flag=true;
					break;
				}
			}else if(d[v]>d[nv]){
				res[G[v][j].second]=d[v];
				col[v]=-col[nv];
				flag=true;
				break;
			}
		}
		if(!flag){
			return false;
		}
	}
	return true;
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(int i=0;i<m;i++){
		scanf("%d%d",&u[i],&v[i]);
		u[i]--;
		v[i]--;
		G[u[i]].push_back(P(v[i],i));
		G[v[i]].push_back(P(u[i],i));
	}
	mini=d[0];
	for(int i=0;i<n;i++){
		mini=min(mini,d[i]);
	}
	if(!check()){
		printf("-1\n");
		return 0;
	}

	for(int i=0;i<m;i++){
		if(res[i]==0){
			res[i]=1000000000;
		}
	}
	for(int i=0;i<n;i++){
		printf("%c",col[i]==1?'B':'W');
	}
	printf("\n");
	for(int i=0;i<m;i++){
		printf("%d\n",res[i]);
	}
	return 0;
}


Measured memory_bytes: 14208
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int x, y = 0;
        while(true){
            x = input.nextInt();
            y = input.nextInt();
            if((x == 0) && (y == 0)) break;
            else if(x < y) System.out.println(String.format("%d %d", x, y));
            else System.out.println(String.format("%d %d", y, x));
        }
    }
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,y; cin>>n>>y;
	for(int i=0;i<=n;++i){
		for(int j=0;i+j<=n;++j){
			int k=n-i-j;
			if(i*10'000+j*5'000+k*1'000==y){
				cout<<i<<" "s<<j<<" "s<<k<<"\n"s;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1\n"s;
}


Measured memory_bytes: 3640
sentence = input()
#sentence = "ATCODER"

count = 0
maxcount = 0
for i in range(len(sentence)):
	if sentence[i]=="A" or sentence[i]=="T" or sentence[i]=="C" or sentence[i]=="G":
		count += 1
	else:
		count = 0
	if count > maxcount:
		maxcount = count

print(maxcount)

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
  int n, k;
  char s[50];

  scanf("%d %d\n", &n, &k);
  scanf("%s", s);

  if(s[k-1] == 'A') s[k-1] = 'a';
  if(s[k-1] == 'B') s[k-1] = 'b';
  if(s[k-1] == 'C') s[k-1] = 'c';

  printf("%s\n", s);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;


#define MAX (int)1e5
typedef long long int ll;

typedef pair<ll,ll> p;

ll num[MAX+1];
p trans[MAX];
int main(void){
  for(int i=0;i<=MAX;i++){
    num[i] = 0;
  }
  int N;
  cin >> N;
  for(int n=0;n<N;n++){
    int tmp;
    cin >> tmp;
    num[tmp] += 1;
  }
  int Q;
  cin >> Q;
  ll ans = 0;
  for(int n=1;n<=MAX;n++){
    ll tmp = num[n];
    tmp = tmp * (ll)n;
    ans += tmp;
  }
  for(int q=0;q<Q;q++){
    int b,c;
    cin >> b >> c;
    trans[q] = make_pair(b,c);
  }
  for(int q=0;q<Q;q++){
    ll b,c;
    b = trans[q].first;
    c = trans[q].second;
    ans = ans - b*num[b] + c*num[b];
    num[c] += num[b];
    num[b] = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll n,a;
ll x[51]={};
ll dp[51][51][2503];

ll dfs(int i, int cnt, int sum){
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    if (i == n){
        // return cnt != 0 && sum == cnt * a;
        if(cnt != 0){
            return sum == cnt * a;
        }else{
            return 0;
        }
    }
    ll res = 0;
    res += dfs(i+1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);

    return dp[i][cnt][sum] = res;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Measured memory_bytes: 51072
import sys
from heapq import heappush, heappop, heappushpop, heapify, heapreplace
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#ここから書き始める
n = int(input())
a = []
total = 0
for i in range(1, n + 1):
    if total >= n:
        break
    total += i
    a.append(i)
for i in a:
    if i != total - n:
        print(i)


Measured memory_bytes: 5556
a,b = map(int,input().split())

def calc(i):
  if (i+1)%2 ==0:
    return ((i+1)//2%2)
  else:
    return ((i+1)//2%2)^i


if a<1:
  print(calc(b))
else:
  print(calc(a-1)^calc(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	//cout << fixed << setprecision(10);
	ll n,m,l; cin>>n>>m>>l;
	vvl a(n,vl(m));
	vvl b(m,vl(l));
	vvl ans(n,vl(l));
	rep(i,0,n)rep(j,0,m)cin>>a[i][j];
	rep(i,0,m)rep(j,0,l)cin>>b[i][j];
	rep(i,0,n){
		rep(j,0,l){
			ll cnt=0;
			rep(k,0,m)cnt+=a[i][k]*b[k][j];
			ans[i][j]=cnt;
		}
	}
	rep(i,0,n){
		rep(j,0,l){
			cout<<ans[i][j];
			if(j!=l-1)cout<<" ";
		}
		cout<< endl;
	}



	return 0;
}


Measured memory_bytes: 3248
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
	
X, Y, A, B, C = MAP()
p = deque(sorted(LIST(), reverse=True))
q = deque(sorted(LIST(), reverse=True))
r = deque(sorted(LIST(), reverse=True) + [0])

x = 0
y = 0
z = 0
ans = 0
while x+y+z < X+Y:
	compare = (p[0], q[0], r[0])

	if p[0] == max(compare):
		x += 1
		ans += p.popleft()
		if x == X:
			p = [0]
	elif q[0] == max(compare):
		y += 1
		ans += q.popleft()
		if y == Y:
			q = [0]
	else:
		z += 1
		ans += r.popleft()

print(ans)


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

int main() {
  int n;
  int q;
  string s;
  

  cin >> n >> q >> s;

  int l[q];
  int r[q];
  int sum[n];
  int ans=0;

  for (int i=0;i<q;i++){
    cin >> l[i] >> r[i];
  }

  for(int i=1;i<n;i++){
    if(s[i-1]=='A' and s[i]=='C'){
      sum[i+1]=sum[i]+1;
    }
    else{
      sum[i+1]=sum[i];
    }
  }
  for(int i=0;i<q;i++){
    cout << sum[r[i]]-sum[l[i]] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2176
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putint(ll X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[15];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[100001];
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {


	int A = getint(), B = getint(), Q = getint();
	ll s[100100], t[100100];
	s[0] = -1e12;
	t[0] = -1e12;
	s[A + 1] = 1e12;
	t[B + 1] = 1e12;
	rep1(i, A) s[i] = getint();
	rep1(i, B) t[i] = getint();

	ll X[100000];
	rep(i, Q) {
		X[i] = (getint() << 20) + i;
	}
	pakuri_sort(Q, X);

	int ks = 0, kt = 0;
	ll kotae[100000];
	rep(i, Q) {
		ll x = X[i] >> 20;
		while (s[ks] < x) ks++;
		while (t[kt] < x) kt++;

		ll s1 = s[ks - 1];
		ll s2 = s[ks];
		ll t1 = t[kt - 1];
		ll t2 = t[kt];

		ll saishou = 1e13;
		saishou = min(saishou, abs(min(s1, t1) - x));
		saishou = min(saishou, abs(max(s2, t2) - x));
		ll k1 = abs(s1 - x);
		ll k2 = abs(t2 - x);
		saishou = min(saishou, k1 + k2 + min(k1, k2));
		ll k3 = abs(t1 - x);
		ll k4 = abs(s2 - x);
		saishou = min(saishou, k3 + k4 + min(k3, k4));

		kotae[X[i] & (1 << 20) - 1] = saishou;
	}

	rep(i, Q) putint(kotae[i]);

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

int main() {
    int n, ans = 1;
    string s;

    cin >> n >> s;

    for (int i = 1; i < int(s.size()); i++) {
        if (s[i] != s[i - 1]) {
            ans++;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3764
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;


int main() {
	ll n, k; cin >> n >> k;
	vector<ll> bit(50, 0), a(n);;
	rep(i, 0, n) {
		cin >> a[i];
		rep(j, 0, 50) {
			if ((a[i] >> j) & 1) {
				bit[j]++;
			}
		}
	}
	ll ans = 0;
	rep(i, 0, 50) {
		ll sub = 0,l=k;
		if ((k >> i) & 1) {
			l ^= (1LL << i);
			rep(j, 0, i) {
					l -= ((k >> j)&1)<<j;
				if (bit[j] <= n - bit[j]) {
					l += (1LL << j);
				}
			}
		}
		rep(i, 0, n) {
			sub += (l ^ a[i]);
		}
		ans = max(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	ll ans=0;
	string s;
	map<string,ll> mp;
	cin>>n;
	rep(i,n)cin>>s,mp[s]++;
	cin>>m;
	rep(i,m)cin>>s,mp[s]--;
	for(auto x:mp){
		chmax(ans,x.sc);
	}
	cout<<ans<<endl;
}


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

int main()
{
    int n, e, min = 1000000, max = -1000000;
    long int sum = 0;
    cin >> n;

    for( int i = 0; i < n; i++ ){
        cin >> e;
        if( e >= max ) max = e;
        if( e <= min ) min = e;
        sum += e;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3112
import math

n , k = map(int, input().split())
a = list(map(int,input().split()))

left=0
right=max(a)
mid = (left+right)/2
while right - left > 0.5:
    times = 0
    for i in range(n):
        times+=math.ceil(a[i]/mid)-1
    if times<=k:
        right=mid
        mid=(left+right)/2
    else:
        left = mid
        mid =(left+right)/2

print(math.ceil(mid))


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

int main(void)
{
    string S;
    ll i;

    cin >> S;

    if(S[2]==S[3] && S[4]==S[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define zzz ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
bool check[5000];
int main()
{
    zzz;
    int a,b; cin>>a>>b;
    cout<<max(max(a+b,a-b),a*b);
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    READV(K);
    ll A[N+1]={0};
    FORI(i,1,N+1)
    {
        READ(A[i]);
        A[i]+=A[i-1];
    }
    map<ll,ordered_set1> F;
    ll ans=0;
    FORI(i,0,N+1)
    {
        ll z=(A[i]-i+K)%K;
        ans+=F[z].order_of_key(i-K);
        F[z].insert(i);
    }
    cout<<ans<<endl;

    return 0;
}

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

public static class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var arry = Enumerable.Range(1, n).Select(x => x).ToArray();
        var arryA = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var arryB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var a = 0;
        var b = 0;
        var cnt = 0; ;
        foreach (var item in arry.Perm())
        {
            cnt++;
            var nums = item.ToArray();
            if (((IStructuralEquatable)nums).Equals(arryA, StructuralComparisons.StructuralEqualityComparer))
            {
                a = cnt;
            }
            if (((IStructuralEquatable)nums).Equals(arryB, StructuralComparisons.StructuralEqualityComparer))
            {
                b = cnt;
            }
        }
        Console.WriteLine(Math.Abs(a - b));
    }

    public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> items, int? k = null)
    {
        if (k == null)
            k = items.Count();

        if (k == 0)
        {
            yield return Enumerable.Empty<T>();
        }
        else
        {
            var i = 0;
            foreach (var x in items)
            {
                var xs = items.Where((_, index) => i != index);
                foreach (var c in Perm(xs, k - 1))
                    yield return c.Before(x);

                i++;
            }
        }
    }

    public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first)
    {
        yield return first;

        foreach (var i in items)
            yield return i;
    }
}

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


int solve(const std::string &X, const std::string &Y,
             const int &m, const int &n) {
    int res[m+1][n+1];
    int result = 0;
    for (int i = 0; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            if (i == 0 || j == 0) res[i][j] = 0;
            else if (X[i-1] == Y[j-1]) {
                res[i][j] = res[i-1][j-1] + 1;
                result = std::max(result, res[i][j]);
            }
            else res[i][j] = 0;
        }
    }
    return result;
}

int main()
{
    std::string a, b;
    while(std::cin >> a) {
        std::cin >> b;
        int sizea = a.size();
        int sizeb = b.size();
        std::cout << solve(a, b, sizea, sizeb) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 65628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n, m;
    cin >> n >> m;
    string A[n];
    string B[m];
    rep(i, n)
    {
        cin >> A[i];
    }
    rep(i, m)
    {
        cin >> B[i];
    }

    bool exist = false;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i + m - 1 >= n or j + m - 1 >= n)
            {
                continue;
            }
            bool match = true;
            for (int y = 0; y < m; y++)
            {
                for (int x = 0; x < m; x++)
                {
                    if (A[i + x][j + y] != B[x][y])
                    {
                        match = false;
                    }
                }
            }
            if (match)
            {
                exist = true;
            }
        }
    }
    if (exist)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

using namespace std;

typedef long long llint;

int a, b, h;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> h;
    cout << (a + b) * h / 2;
    return 0;
}


Measured memory_bytes: 3640
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

typedef long long ll ;
typedef double db;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define sf(a)		 scanf("%d",&a)
#define sfl(a)		scanf("%lld",&a)
#define sff(a,b)	 scanf("%d %d",&a,&b)
#define sffl(a,b)	scanf("%lld %lld",&a,&b)
#define pb(a)         push_back(a)
#define loop0(i,n)          for(int i=0;i<n;i++)
#define loop1(i,n)          for(int i=1;i<=n;i++)
#define loopab(a,b)       for(int i=a;i<=b;i++)
#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int main()
{
	int i,n,x;
	cin>>n;
	vector<int>v(n,0);
	loop1(i,n){
		cin>>x;
		v[x-1] = i;
		}
	cout<<v[0];
	for(i=1 ; i<n ; i++){
		cout<<" "<<v[i];
		}
	cout<<nw;
	return 0;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int x,y;
  cin >> x >> y;
  x += (y/2);
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256