akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
///#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 1000000007

int main() {
	ll n,m,k;
	cin>>n>>m>>k;
	ll arr[n];
	ll brr[m];
	ll bsum=0;
	for (ll i=0;i<n;i++) {
		cin>>arr[i];
	}
	for (ll i=0;i<m;i++) {
		cin>>brr[i];
		bsum+=brr[i];
	}
	ll mex=0;
	ll p1=-1,p2=m-1;
	while ((p1!=n) and (p2!=-1)) {
		if (bsum<=k) {
			mex=max(mex,p1+p2+2);
			p1++;
			bsum+=arr[p1];
		}
		else {
			p2--;
			bsum-=brr[p2+1];
		}
	}
	if (p2==-1) {
		while (p1!=n) {
			if (bsum<=k) {
				mex=max(mex,p1+p2+2);
				p1++;
				bsum+=arr[p1];
				continue;
			}
			break;
		}
	}
	if (mex) cout<<mex;
	else {
		cout<<0;
	}
}


Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    ll sum = 0;
    for(int i = 0; i < N - 1; i++){
        sum += A[i];
        sum %= mod;
        ans += sum * A[i + 1];
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
/*input
5
1 2 3 4 5
1000000000 1000000000 1000000000 1000000000 1000000000
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1000000000000000001
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


// Max Query Segment tree

#define N 200005
ll h[N],v[N],dp[N];
ll lo[4*N+1], hi[4*N+1], ma[4*N+1], delta[4*N+1];
ll n;

void build(ll i,ll a,ll b)
{
    lo[i]=a;
    hi[i]=b;

    if(a==b)
        return;

    ll m=(a+b)/2;
    build(2*i,a,m);
    build(2*i+1,m+1,b);
}

void prop(ll i)
{
    delta[2*i]+=delta[i];
    delta[2*i+1]+=delta[i];
    delta[i]=0;
}

void update(ll i)
{
    ma[i]=max(ma[2*i]+delta[2*i],ma[2*i+1]+delta[2*i+1]);
}

void increment(ll i,ll a,ll b,ll val)
{
    if(b<lo[i]||hi[i]<a)
        return;
    if(a<=lo[i]&&hi[i]<=b)
    {
        delta[i]+=val;
        return;
    }

    prop(i);

    increment(2*i,a,b,val);
    increment(2*i+1,a,b,val);

    update(i);
}

ll query(ll i,ll a,ll b)
{   
    if(b<lo[i]||hi[i]<a)
        return -inf;
    if(a<=lo[i]&&hi[i]<=b)
        return ma[i]+delta[i];

    prop(i);

    ll minLeft=query(2*i,a,b);
    ll minRight=query(2*i+1,a,b);

    update(i);

    return max(minLeft,minRight);
}


void solve()
{
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>h[i];
    for(ll i=1;i<=n;i++)
        cin>>v[h[i]];
    build(1,0,n);
    for(ll flower=1;flower<=n;flower++)
    {
        ll x=dp[h[flower]];
        ll y=query(1,0,h[flower]-1);
        increment(1,h[flower],h[flower],y+v[h[flower]]-x);
    }
    cout<<query(1,0,n);
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 27904
package main

import "fmt"

func main() {
	var a int
	var b int
	var c int
	var x int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	var cnt int
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if x == 500*i+100*j+50*k {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <stdio.h>

int H, W;
char S[2048][2048];

int l[2048][2048], r[2048][2048], u[2048][2048], d[2048][2048];

int main(void) {
	int i, j;
	int answer = 0;
	if (scanf("%d%d", &H, &W) != 2) return 1;
	for (i = 0; i < H; i++) {
		if (scanf("%2047s", S[i]) != 1) return 1;
	}
	for (i = 0; i < H; i++) {
		if (S[i][0] == '.') l[i][0] = 1;
		for (j = 1; j < W; j++) {
			l[i][j] = l[i][j - 1] + 1;
			if (S[i][j] == '#') l[i][j] = 0;
		}
		if (S[i][W - 1] == '.') r[i][W - 1] = 1;
		for (j = W - 2; j >= 0; j--) {
			r[i][j] = r[i][j + 1] + 1;
			if (S[i][j] == '#') r[i][j] = 0;
		}
	}
	for (j = 0; j < W; j++) {
		if (S[0][j] == '.') u[0][j] = 1;
		for (i = 1; i < H; i++) {
			u[i][j] = u[i - 1][j] + 1;
			if (S[i][j] == '#') u[i][j] = 0;
		}
		if (S[H - 1][j] == '.') d[H - 1][j] = 1;
		for (i = H - 2; i >= 0; i--) {
			d[i][j] = d[i + 1][j] + 1;
			if (S[i][j] == '#') d[i][j] = 0;
		}
	}
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (S[i][j] == '.') {
				int candidate = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
				if (answer < candidate) answer = candidate;
			}
		}
	}
	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 69760
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  double x,y,ax,ay;
  while(1){
    cin>>n;
    if(n==-1)break;
    x=1,y=0;
    ax=0,ay=1;
    for(int i=0;i<n-1;i++){
      x+=ax;
      y+=ay;
      ax=(-y)/sqrt(x*x+y*y);
      ay=x/sqrt(x*x+y*y);
    }
    cout<<x<<endl<<y<<endl;
  }
 
  return 0;
}

Measured memory_bytes: 1232
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////

vector<ll> lucas = {2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843};

int main(void){
    int n;cin >> n;
    cout << lucas[n] << '\n';
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll N, X;
	ll ans = 0;

	cin >> N >> X;
	vector<ll> L(N);
	rep(i, N) cin >> L[i];

	ll pos = 0;
	ans++;
	rep(i, N) {
		pos += L[i];
		if (pos <= X) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# coding=utf-8
day_1_list = [4, 7, 1, 4, 6, 2, 4, 7, 3, 5, 1, 3]

while True:
    month, day = map(int, input().split())
    if month == 0:
        break
    dw = (day_1_list[month-1] + day - 1) % 7
    if dw == 1:
        print("Monday")
    elif dw == 2:
        print("Tuesday")
    elif dw == 3:
        print("Wednesday")
    elif dw == 4:
        print("Thursday")
    elif dw == 5:
        print("Friday")
    elif dw == 6:
        print("Saturday")
    elif dw == 0:
        print("Sunday")



Measured memory_bytes: 5596
h, w, a, b = map(int,input().split())
s = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if i < b:
            if j < a:
                s[i][j] = 0
            else:
                s[i][j] = 1
        else:
            if j < a:
                s[i][j] = 1
            else:
                s[i][j] = 0
for i in s:
    print("".join(map(str,i)))


Measured memory_bytes: 12788
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I;
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<n;i++) {
			var e=sc.Ia;
			sb.Append(Gp1(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7])+"\n");
		}
		Console.Write(sb);
	}
	static int Gp1(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y){
		double t1=(p4y-p3y)*(p4x-p1x)-(p4x-p3x)*(p4y-p1y);
		double t2=(p2x-p1x)*(p4y-p1y)-(p2y-p1y)*(p4x-p1x);
		double t3=(p2x-p1x)*(p4y-p3y)-(p2y-p1y)*(p4x-p3x);
		if(t3==0){
			if(Abs(Atan2(p2y-p1y,p2x-p1x))!=Abs(Atan2(p3y-p1y,p3x-p1x))){return p1x==p3x&&p1y==p3y?1:0;}
			var a=new double[][]{new double[]{p1x,p1y,1},new double[]{p2x,p2y,2},new double[]{p3x,p3y,3},new double[]{p4x,p4y,4}};
			Array.Sort(a,(x,y)=>{var c=x[0].CompareTo(y[0]);return c==0?y[1].CompareTo(x[1]):c;});
			return (Abs(a[0][2]-a[1][2])!=1||Abs(a[2][2]-a[3][2])!=1)||(a[1][0]==a[2][0]&&a[1][1]==a[2][1])?1:0;
		}
		double t4=t1/t3,t5=t2/t3;
		return (t4<0||t4>1||t5<0||t5>1||t3==0)?0:1;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 18004
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<char,map<int,int> > m;
map<char,int> l;
int dfs(string s,int p){
  int x=0;
  if(isdigit(s[p])){
    for(int i=p;i<(int)s.size()&&isdigit(s[i]);i++) x=x*10+s[i]-'0';
    return x;
  }
  if(isdigit(s[p+2]))
    for(int i=p+2;i<(int)s.size()&&isdigit(s[i]);i++) x=x*10+s[i]-'0';
  else x=dfs(s,p+2);
  //cout<<s<<":"<<p<<":"<<x<<endl;
  if(p) return  (x<0||x>=l[s[p]])?-1:
	  (m[s[p]].find(x)==m[s[p]].end()?-1:m[s[p]][x]);
  else return x;
}
signed main(){
  string s;
  while(cin>>s,s!="."){
    m.clear();l.clear();
    vector<string> v;
    v.push_back(s);
    while(cin>>s,s!=".") v.push_back(s);
    int n=v.size(),i;
    //cout<<n<<endl;
    for(i=0;i<n;i++){
      //cout<<i<<":";
      if((int)v[i].find("=")==-1){
	int x=dfs(v[i],0);
	if(x<0){
	  cout<<i+1<<endl;
	  break;
	}
	l[v[i][0]]=x;
      }else{
	int p=v[i].find("=");
	int x=dfs(v[i],0),y=dfs(v[i],p+1);
	//cout<<i<<" "<<x<<" "<<y<<endl;
	if(x<0||l[v[i][0]]<=x||y<0){
	  cout<<i+1<<endl;
	  break;
	}
	m[v[i][0]][x]=y;
      }
    }
    if(i==n) cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
    int n,i,j,a,sum=0,b;
    cin>>n;
    int v[n];
    for(int m=0;m<n;m++)
    {
        cin>>v[m];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            a=v[i]*v[j];
            sum=sum+a;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op=="?":
    break
  if op=="+":
    print(a+b)
  if op=="-":
    print(a-b)
  if op=="*":
    print(a*b)
  if op=="/":
    print(a//b)



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

int h, n;
vector<pair<int, int>> ab;
vector<int> dp;

int solve(int remain) {
    if (remain <= 0) return 0;
    if (dp[remain] != -1) return dp[remain];
    int res = INT_MAX;
    for (auto& e : ab) {
        int nr = remain - e.first;
        res = min(res, solve(nr) + e.second);
    }
    return dp[remain] = res;
}

int main() {
    cin >> h >> n;
    ab.resize(n);
    dp.resize(h+1, -1);
    for (auto& e : ab) {
        cin >> e.first >> e.second;
    }

    cout << solve(h) << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
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; }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int  r; cin >> r;
  cout << 3*r*r << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    static Scanner scanner;
    static int getInt(){
        return Integer.parseInt(scanner.next());
    }
    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int a = getInt();
        int b = getInt();
        if(a < b){
            System.out.println("a < b");
        }
        else if(a > b){
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
    }
}



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

#define int long long

using namespace std;



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

    string S, T;
    cin >> S >> T;

    int res = 1e18;

    for(int i = 0 ; i+T.size()-1 < S.size() ; i++)
    {
    	int sum = 0;
    	for(int j = i ; j < i+T.size() ; j++)
    	{
    		if(S[j] != T[j-i])
    		{
    			sum++;
    		}
    	}
    	res = min(res,sum);
    }

    cout << res << '\n';

    return 0;
}

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

using namespace std;


int main() {
    vector<int> a = {1, 4, 7, 9};
    vector<int> v(4);
    for(int i = 0; i < 4; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    if(a == v) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 3592
import sys

n = int(input())
v = list(map(int, input().split()))

odddict = {}
evendict = {}
for i,vi in enumerate(v):
    if i % 2 == 0: 
        if vi in evendict.keys():
            evendict[vi] += 1
        else:
            evendict[vi] = 1
    else:
        if vi in odddict.keys():
            odddict[vi] += 1
        else:
            odddict[vi] = 1
            
odd = sorted(odddict.items(), key=lambda x:x[1], reverse=True)
even = sorted(evendict.items(), key=lambda x:x[1], reverse=True)

if odd == even and len(odd)==1:
    print(n // 2)
    sys.exit()

i, j = 0,0
while odd[i] == even[j]:
    o_dif = odd[i+1][1] - odd[i][1]
    e_dif = even[j+1][1] - even[j][1]
    if o_dif >= e_dif:
        i += 1
    else:
        j += 1
  
print(n - odd[i][1] - even[j][1])

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

using namespace std;

int main(){
    string S,T;
    string ans = "No";
    cin >> S >> T;
    
    
    for(int j=0;j<S.size();j++){
        if(S==T){
            ans = "Yes";
            break;
        }
        else{
            char tmp = S.back();
            for(int i=S.size()-2;i>=0;i--){
                S.at(i+1) = S.at(i);
            }
            S.at(0) = tmp;
        }
    }
    cout << ans << endl;
}

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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define REP_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;



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

    double a = x%100;
    double b = x/100;


    if(x < 100)cout << 0 << endl;
    else{
        if( a/b > 5)cout << 0 << endl;
        else cout << 1 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
line = gets.chomp

w,h,x,y,r = line.split(/\s/).map(&:to_i)

if x + r <= w && y + r <= h
  # puts "No"
  if x + r >= 0 && y + r >= 0
    if x - r >= 0 && y - r >= 0
      puts "Yes"
    else 
      puts "No"
    end
else
puts "No"
  end
  # elsif x + r > w && y + r > h
  #   puts "No"
else 
  puts "No"
end

Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 1;
  if (N > 1) {
    for (int i = 0; i < N-1; i++) {
      if (S[i] != S[i+1]) ans++;
    }
  }
  
  cout << ans << endl;
  
}

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

int main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> keys(M, vector<int>(2,0));
  for (int i=0; i<M; i++){
    int a, b; cin >> a >> b;
    keys[i][0] = a;
    for (int j=0; j<b; j++){
      int c; cin >> c;
      keys[i][1] |= (1<<(c-1));
    }
  }
  vector<long long> dp(1<<N, 100000001);
  dp[0] = 0;
  for (int i=0; i<M; i++){
    for (int j=(1<<N)-1; j>=0; j--){
      if (dp[j] == 100000001) continue;
      dp[j|keys[i][1]] = min(dp[j|keys[i][1]], dp[j]+keys[i][0]);
    }
  }
  if (dp[(1<<N)-1] == 100000001) cout << -1 << endl;
  else cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC113();
}

void ABC113(){
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> memo;
ll a,b,c,d,N;
ll solve(ll n){
	if(n==0)
		return 0;
	if(n==1)
		return d;
	if(memo.count(n)){
		return memo[n];
	}
	ll l1=(n/2)*2,r1=((n+1)/2)*2;
	ll l2=(n/3)*3,r2=((n+2)/3)*3;
	ll l3=(n/5)*5,r3=((n+4)/5)*5;
	ll ret=1e18;
	
    if (n < ret/d) ret = n*d;
    
	ret=min(ret,llabs(n-l1)*d+a+solve(l1/2));
	ret=min(ret,llabs(r1-n)*d+a+solve(r1/2));
	ret=min(ret,llabs(n-l2)*d+b+solve(l2/3));
	ret=min(ret,llabs(r2-n)*d+b+solve(r2/3));
	ret=min(ret,llabs(n-l3)*d+c+solve(l3/5));
	ret=min(ret,llabs(r3-n)*d+c+solve(r3/5));
	memo[n]=ret;
	return ret;
}
ll input(){
	ll s;
	cin>>s;
	return s;
}
int main() {
	int t;
	cin>>t;
	while(t--){
		memo.clear();
		N=input();
		a=input();
		b=input();
		c=input();
		d=input();
		cout<<solve(N);
		cout<<endl;
	}

	return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

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

    bool flag = B-A > k-1;
    bool flag2 = B%k < A%k;
    bool flag3 = !(A%k) || !(B%k);

    if (flag || flag2 || flag3) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  REP(i,M) IN(B[i]);
  int cnt=0;
  REP(i,N){
    vector<int> A(M);
    int ans=0;
    REP(i,M){
      IN(A[i]);
      ans += A[i] * B[i];
    }
    if(ans+C >0) ++cnt;
  }
  OUT(cnt);
}	

Measured memory_bytes: 256
n=int(input())
if n%2!=0:
  print(0)
  exit(0)
n//=10

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = X_dumy//n
    return out

n=Base_10_to_n(n,5)
n=reversed(list(n))
tmp=1
ans=0

for i in n:
  ans+=int(i)*tmp
  tmp=tmp*5+1
print(ans)


Measured memory_bytes: 61976
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,a,b,s[10001]={},ans=0;
    cin>>n>>a>>b;
    for (int i=1; i<=n; i++)
        cin>>s[i];
    for (int i=1; i<=n; i++)
        if ((s[i]<a) || (s[i]>=b)) ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	double A,B,H,M,rH,rM,Ax,Ay,Bx,By;
	cin >> A >> B >> H >> M;

	rM = M*M_PI/30;
	rH = H*M_PI/6 + M*M_PI/360;

	Ax = cos(rH)*A;
	Ay = sin(rH)*A;
	Bx = cos(rM)*B;
	By = sin(rM)*B;

	cout << setprecision(100) << sqrt((Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By)) << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    int ans = 0;
    rep(i, s.size()-1){
        if(s[i] != s[i+1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        int n,m;
        cin >>  n >> m;
        vector<int> a(m);
        int like,cnt=0;
        for(int i=0;i<n;i++){
                int k;
                cin >> k;
                for(int j=0;j<k;j++){
                        cin >> like;
                        a[like-1]++;
                }
        }
        for(int i=0;i<m;i++){
                if(a[i]==n)  cnt++;
        }
        cout << cnt << endl;
        return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int a[100*1000+2];
int main() {
	int N;
	int L;
	priority_queue<P,vector<P>,greater<P> > q;
	cin >> N >> L;
	for(int i=1;i<=N;i++){
		cin >> a[i];
	}
	for(int i=1;i<=N;i++){
		if(a[i-1]<a[i]&&a[i+1]<a[i]){
			q.push(P(L-a[i],i));
		}
	}
	int t=0;
	while(q.size()){
		int i=q.top().second;
		t=q.top().first;
		q.pop();
		a[i]=0;
		if(i-1>0&&a[i-2]<a[i-1]){
			q.push(P(t+L-a[i-1],i-1));
		}
		if(i+1<=N&&a[i+2]<a[i+1]){
			q.push(P(t+L-a[i+1],i+1));
		}
	}
	cout << t << endl;
}

Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

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

    int A;
    cin>>A;
    string S;
    cin>>S;

    if(A>=3200)
    {
        cout<<S;
    }
    else
    {
        cout<<"red";
    }
    
    
    

    
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <map>

using namespace std;

int main() {
    map<char, int> ls, rs;
    double l, r;
    while (cin >> l >> r) {
        if (1.1 <= l) ls['A']++;
        else if (0.6 <= l && l < 1.1) ls['B']++;
        else if (0.2 <= l && l < 0.6) ls['C']++;
        else ls['D']++;

        if (1.1 <= r) rs['A']++;
        else if (0.6 <= r && r < 1.1) rs['B']++;
        else if (0.2 <= r && r < 0.6) rs['C']++;
        else rs['D']++;
    }

    for (char c = 'A'; c <= 'D'; c++) {
        cout << ls[c] << ' ' << rs[c] << endl;
    }
    return 0;
}


        

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

int main() {
    //入力
    ll N, M, X;
    cin >> N >> M >> X;

    vector<ll> price(N);
    vector<vector<ll>> book(N, vector<ll>(M));

    for(ll i = 0; i < N; i++) {
        cin >> price.at(i);
        for(ll j = 0; j < M; j++) {
            cin >> book.at(i).at(j);
        }
    }

    ll ans = -1;
    //処理
    for(ll bit = 0; bit < (1 << N); bit++) {
        ll currentPrice = 0;
        vector<ll> skill(M, 0);
        for(ll i = 0; i < N; i++) {
            if(bit & (1 << i)) {
                currentPrice += price.at(i);
                for(ll j = 0; j < M; j++) {
                    skill.at(j) += book.at(i).at(j);
                }
                bool flag = true;
                for(ll j = 0; j < M; j++) {
                    if(skill.at(j) < X) {
                        flag = false;
                        break;
                    }
                }
                if(flag) {
                    if(ans == -1) {
                        ans = currentPrice;
                    } else {
                        ans = min(ans, currentPrice);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

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

void solve(std::string S){
    vector<string> T ={"Sunny","Cloudy","Rainy"};
    for(int i=0;i<3;i++){
        if(T[i] == S){
            cout << T[(i+1)%3] << endl;
            return;
        }
    }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
    int n, tmp;
    vector<int> num;
    cin >> n;
    while(cin >> tmp)
        num.push_back(tmp);
    n--;
    cout << num[n];
    n--;
    while(n >= 0){
        cout << ' ' << num[n];
        n--;
    }
    cout << endl;
    return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);
	
	int a, b, c, d; cin >> a >> b >> c >> d;
	while (true) {
		c -= b;
		if (c <= 0) break;
		a -= d;
		if (a <= 0) break;
	}

	if (a <= 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <math.h>
#include <stack>
#include <tuple>
#include <cstring>
#include <chrono>
#include <bitset>
#include <list>
#include <stdlib.h>
#include <iomanip>
#include <bitset>
#include <chrono>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long

bool comparator(const pair<ll, ll> &x, const pair<ll, ll> &y)
{
    return x.second - x.first < y.second - y.first;
}

ll gcd(ll x, ll y)
{
    return y == 0LL ? x : gcd(y, x % y);
}

struct dot {
    ll coordinate, tree;
    bool is_left;

    dot(ll _coordinate, ll _tree, bool _is_left)
    {
        coordinate = _coordinate;
        tree = _tree;
        is_left = _is_left;
    }

    ll dist() const
    {
        return abs(coordinate - tree);
    }

    bool operator<(const dot& other) const
    {
        return dist() > other.dist();
    }
};

bool is_free(ll x, set<ll> &used_coords)
{
    return used_coords.find(x) == used_coords.end();
}

int main()
{
    std::ios::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    cout << t << s;

    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left,bisect_right
N,K=map(int,input().split())
table=[]
for i in range(N):
    a,b=map(int,input().split())
    table.append([a,b])
table.sort()
cou=[0]*N
cou[0]=table[0][1]
for i in range(1,N):
    cou[i]=cou[i-1]+table[i][1]
s = bisect_left(cou,K)
print(table[s][0])

Measured memory_bytes: 24320
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;

typedef struct n
{
	int w,h,m,o,r,l;
}n;

struct Order
{
	bool operator ()(n const& a, n const& b) const
	{
		return a.m<b.m;
	}
};

int W,H,F,M,O,G[10][10],mv[4]={0,1,0,-1},f,flg[10][10][10][10][51];//h w r l o

n cr(int h,int w,int o,int m,int r,int l)
{
	n a={w,h,m,o-1,min(w,r),max(w,l)};
	if(r>w||w>l)
	{
		a.o+=G[h][w]>0?G[h][w]:0;
		a.o=min(M,a.o);
		a.m+=G[h][w]<0?G[h][w]:0;
	}
	return a;
}


int main()
{
	for(;~scanf("%d%d%d%d%d",&W,&H,&F,&M,&O),W;)
	{
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				scanf("%d",&G[i][j]);
		memset(flg,-1,sizeof(flg));
		priority_queue<n,vector<n>,Order>Q;
		for(int i=0;i<W;i++)
		{
			n ins=cr(0,i,O,F,W,-1);
			if(ins.m>flg[ins.h][ins.w][ins.r][ins.l][ins.o])
			{
				if(O>1)
				{
					flg[ins.h][ins.w][ins.r][ins.l][ins.o]=ins.m;
					Q.push(ins);
				}
			}
		}
		for(f=0;!Q.empty();)
		{
			n tmp=Q.top();Q.pop();
			if(tmp.h==H-1)
			{
				printf("%d\n",F-tmp.m);
				f=1;
				break;
			}
			if(tmp.m!=flg[tmp.h][tmp.w][tmp.r][tmp.l][tmp.o])continue;
			for(int i=0;i<3;i++)
			{
				int nh=tmp.h+mv[i];
				int nw=tmp.w+mv[i+1];
				if(0<=nw&&nw<W&&tmp.o>1)
				{
				
					n ins;
					if(nh!=tmp.h) ins=cr(nh,nw,tmp.o,tmp.m,W,-1);
					else ins=cr(nh,nw,tmp.o,tmp.m,tmp.r,tmp.l);
					if(ins.m>flg[ins.h][ins.w][ins.r][ins.l][ins.o])
					{
						flg[ins.h][ins.w][ins.r][ins.l][ins.o]=ins.m;
						Q.push(ins);
					}
				}
			}
		}
		if(!f)puts("NA");
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n;cin>>n;
    string str,s;cin>>str;
    int can[3];
    int ans=0;
    rep(i,10)rep(j,10)rep(k,10){
        can[0]=i,can[1]=j,can[2]=k;
        int x=0;
        s=to_string(can[x]);
        rep(l,n){
            if(str[l]==s[0]){
                if(x==2){
                    ans++;
                    break;
                }else{
                    x++;
                    s=to_string(can[x]);
                }
            }
        }        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
vector<int>v;
int main(){
    cin>>N;
    REP(i,N){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    if(abs(v[0]-v[N-1])>1){
           cout<<"No"<<endl;
           return 0;
    }
    if(v.front()==v.back()){
       int sum2=N/2;
       if((1<=v[N-1]&&v[N-1]<=sum2)||(v[N-1]==N-1)){
          cout<<"Yes"<<endl;
       }else{
          cout<<"No"<<endl;
       }
    }else{
       int sum=0;
       REP(i,N){
           if(v[0]==v[i])sum++;
       }
       int sum2=sum+(N-sum)/2;
       if(sum+1<=v[N-1]&&v[N-1]<=sum2){
           cout<<"Yes"<<endl;
       }else{
           cout<<"No"<<endl;
       }
    }
    return 0;
}

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

int main(void){
  int H,W,N;
  cin >> H >> W >> N;

  int ans=0;
  if(H > W){
    while(N > 0){
      ans++;
      N = N-H;
    }
  }else{
    while(N > 0){
      ans++;
      N = N-W;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a[10000];
	int n,k;
	int count = 0;
	scanf("%d",&n);
	for(int i = 0; i < n ; i++)
		scanf("%d",&a[i]);
	for(int i = 0; i < n ; i++) {
    while (a[i]%2==0){
    a[i]=a[i]/2;
    count+=1;
    }
}
printf("%d",count);
return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
n, k = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(n)]
X, Y = zip(*XY)
def compress(arr):
    *XS, = set(arr)
    XS.sort()
    return {e: i+1 for i, e in enumerate(XS)}
Xlabel = compress(X)
Ylabel = compress(Y)
rX = {j:i for i,j in Xlabel.items()}
rY = {j:i for i,j in Ylabel.items()}
lX = len(Xlabel)
lY = len(Ylabel)
F = [[0]*(lX+1) for _ in range(lY+1)]
for x, y in XY:
  F[Ylabel[y]][Xlabel[x]] = 1
for i in range(lY):
  F[i+1] = list(accumulate(F[i+1]))
F = list(zip(*F))
for j in range(lY):
  F[j+1] = list(accumulate(F[j+1]))
F = list(zip(*F))
ans = float("inf")
for y1 in range(lY):
  for y2 in range(y1+1, lY+1):
    for x1 in range(lX):
      for x2 in range(x1+1, lX+1):
        count = F[y2][x2] - F[y1][x2] - F[y2][x1] + F[y1][x1]
        if count >= k:
          temp = (rX[x2]-rX[x1+1]) * (rY[y2]-rY[y1+1])
          ans = min(ans, temp)
print(ans)

Measured memory_bytes: 44652
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
const int inf = (int)1e18 + 10;
int a[N] , ans[N];
signed main(){
  fast;
  int n , k = 1 , sum = 0 , j;
  cin >> n;
  for(int i = 1 ; i<=n ; i++)
    cin >> a[i];


  if(n%2 == 0){
   
       for(int i = 1 ; i<=n ; i++){
        sum  = sum + k * a[i];
        k *= -1;
      }
      ans[n] = sum;
      j = sum;
      for(int i = 1 ; i<= n ; i++){
           ans[i] = 2*a[i] - j;
           j = ans[i];
      }

      cout << ans[n] << " ";
      for(int i = 1 ; i < n ; i++)
        cout << ans[i] << " ";
      cout << endl;
      return 0;
  }


  
  for(int i = 2 ; i<=n ; i++){
    sum += k*a[i];
    k *= -1;
  }

  ans[1] = a[1] + sum;
  ans[n] = a[1] - sum;
  j = ans[1];
  for(int i = 2 ; i<n ; i++){
    ans[i] = 2*a[i] - j;
    j = ans[i];
  }
  cout << ans[n] << " ";
  for(int i = 1 ; i< n ; i++)
    cout << ans[i] << " ";





}	

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

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(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

char f(char c,int n) {
	return (c - 'A' + n) % 26 + 'A';
}

int main() {
	int n; cin >> n;
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++) {
		cout << f(s[i], n);
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
#include <cmath>
#define _USE_MATH_DEFINES
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)
 
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
int main(){
  ll N;
  cin>>N;
  vector<ll> S(N-1,0);
  FOR(i,N-1){
    ll tmp;
    cin>>tmp;
    S[tmp-1]++;
  }
  FOR(i,N-1){
    cout<<S[i]<<endl;
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 4844
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    char s[25];
    scanf("%s",&s);
    s[5]=' ';
    s[13]=' ';
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <queue>
#include <unordered_set>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, tmp;
    cin >>n;
    unordered_set<ll> a;
    rep(i,0,n) cin >> tmp, a.insert(tmp); 
    ll m;
    unordered_set<ll> b;
    cin >>m;
    rep(i,0,m) cin >> tmp, b.insert(tmp); 

    vector<ll> ans;

    if (n>m)
    {
        for (auto i:a)
            if (b.find(i) != b.end()) ans.push_back(i);
    }
    else
    {
        for (auto i:b)
            if (a.find(i) != a.end()) ans.push_back(i);
    }

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

    for(auto i: ans)
        cout << i << endl;

    return 0;
}



Measured memory_bytes: 20156
import math
n,d = map(int,input().split())
x = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        t = 0
        for k in range(d):
            t+=(x[i][k]-x[j][k])**2 
        if math.sqrt(t)==int(math.sqrt(t)):
            ans += 1
print(ans)

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

long long cnt;
vector<pair<long long, long long> > pd;
long long dd, pp;
long long n, m;


int main(){

  
  while(cin >> n >> m && (n || m)){

    
    int judge = 0;

    for(int i = 0; i < n; i++){
      cin >> dd >> pp;
      pd.push_back(make_pair(pp,dd));
    }
    sort(pd.rbegin(),pd.rend());
    for(int i = 0; i < n; i++){
      if(pd[i].second - m >= 0){
	cnt += (pd[i].second - m) * pd[i].first;
	for(int j = i+1; j < n; j++){
	  cnt += pd[j].first * pd[j].second;
	}
	m = 0;
	cout << cnt << endl;
	break;
      }else {
	m -= pd[i].second;
      }
    }
    if(m != 0) cout << 0 << endl;
    pd.clear();			     
    cnt = 0;
  }


}

Measured memory_bytes: 1532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main(int argc, char *argv[])
{
    char s[10];

    scanf("%s", s);

    switch(s[0]) {
        case 'A':
            printf("T\n");
            break;
        case 'C':
            printf("G\n");
            break;
        case 'G':
            printf("C\n");
            break;
        case 'T':
            printf("A\n");
            break;
        default:
            break;
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
using namespace std;
int main(void){
  double a,b,c,d,e,f,g,h;
  while(cin >> a >> b >> c >> d >> e >> f >> g >> h){
    if( (b-d)*(f-h) + (e-g)*(a-c) ) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define test int t; cin >> t;
using namespace std;
 
//*insayn ka code*  (凸ಠ益ಠ)凸
 
signed main() {
    quickie 
    int n ;
    cin >> n ;
    int a[n], b[n] ;
    rep(i, 0, n) {
        cin >> a[i] ;
    }
    b[n-1] = 0 ;
    b[n-2] = abs(a[n-1] - a[n-2]) ;
    for(int i=n-3; i>=0; i--) {
        b[i] = min((abs(a[i]-a[i+1])+b[i+1]), (abs(a[i]-a[i+2])+b[i+2])) ;
    }
    cout << b[0] << endl ;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> AB(N);
  for (int i=0; i<N; i++) cin >> AB[i].first >> AB[i].second;
  sort(AB.begin(), AB.end());
  int memo = 0; // 今までに買い集めたエナドリの本数
  ll ans = 0LL;
  for (int i=0; i<N; i++) {
    if (M<=memo+AB[i].second) {
      ans += AB[i].first*(M-memo);
      break;
    }
    else {
      memo += AB[i].second;
      ans += AB[i].first*AB[i].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
N=int(input())
S=input()

Rn=S.count('R')
Gn=S.count('G')
Bn=S.count('B')

ans=0

for k in range(N//2-2+1 if N&1==0 else N//2-1+1):#k個飛ばし
    i=0
    while i+2*(k+1)<=N-1:
        ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
        if "R" in ls and "G" in ls and "B" in ls:
            ans+=1
        i+=1

print(Rn*Gn*Bn-ans)

Measured memory_bytes: 73496
#include <iostream>
#include <string>
using namespace std;
int x[501][501];
int c[501][501];
int main(void){
    int N,M,Q;
    cin >> N >> M >> Q;
    int L[M],R[M],p[Q],q[Q];
    for(int i=0;i<M;i++){
        cin >> L[i] >> R[i];
    }
    for(int i=0;i<Q;i++){
        cin >> p[i] >> q[i];
    }
    
    for(int i=0;i<M;i++){
        x[L[i]][R[i]]++;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            c[i][j] = x[i][j];
            if(j != 1){
                c[i][j] += c[i][j-1];
            }
        }
    }
    
    
    int ans = 0;
    for(int i=0;i<Q;i++){
        ans = 0;
        for(int j=p[i];j<=q[i];j++){
            ans += c[j][q[i]] - c[j][p[i]-1];
        }
        cout << ans << endl;
    }
    

}


Measured memory_bytes: 7464
import java.util.Scanner;

class Main {
	private static double findTheta(int h, int m) {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    }
  	private static double findC(int a, int b, double theta) {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    }
  	public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    }
}

Measured memory_bytes: 27188
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MOD=998244853;
int n,m;
ll ans=0;
ll x[11],r,d;
int main()
{
	scanf("%lld%lld%lld",&r,&d,&x[0]);
	for(int i=1;i<=10;i++)
	{
		x[i]=r*x[i-1]-d;
		printf("%lld\n",x[i]);
	}
    return 0;
}



Measured memory_bytes: 256