akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
const double PI = acos(-1.0);

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

    cout << (N/10 == 9 || N%10 == 9 ? "Yes":"No") << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	int a[5];
	int b=0;
	for(int i=0;i<3;i++)
		scanf("%d",&a[i]);
	sort(a,a+3);
	b+=(a[2]-a[1])/2+(a[2]-a[0])/2;
	if((a[2]-a[1])%2==0&&(a[2]-a[0])%2==0)
		b=b;
	else if((a[2]-a[1])%2==1&&(a[2]-a[0])%2==1)
		b++;
	else
		b+=2;
	printf("%d\n",b);
	return 0;
	
} 

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    ll c= 0, mx= 0, n;

    cin>> n;

    ll h[n];

    cin>> h[0];
    for(int i=1; i<n; i++ )
    {
        cin>> h[i];

        if(h[i]> h[i-1])
        {
            mx= max (c, mx);
            c= 0;
        }
        else
            c++;
    }

    cout << max(mx, c);
    nl;


    return 0;
}




Measured memory_bytes: 4404
import numpy as np
 
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
r = np.sum(B)
for i in range(N-1):
  if A[i] + 1 == A[i + 1]:
    r += C[A[i]-1]

print(r)

Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    for(int i=n;i<=999;i++){
        if(i%111==0){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

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

char Judge(string WordT, string WordH)
{
	for(int i = 0; i < min(WordT.size(), WordH.size()); i++)
	{
		if(WordT[i] > WordH[i]) return 'T';
		if(WordT[i] < WordH[i]) return 'H';
	}
	if(WordT.size() > WordH.size()) return 'T';
	if(WordT.size() < WordH.size()) return 'H';
	return 'D';
}

int main()
{
	//???????????????????????°n????????????
	int n;
	cin >> n;
	//???????????????????????????????????????????????????????????¨????????????????????????
	int PointT = 0;
	int PointH = 0;
	for(int i = 0; i < n; i++)
	{
		string WordT;
		string WordH;
		cin >> WordT >> WordH;
		if(Judge(WordT, WordH) == 'T') PointT += 3;
		if(Judge(WordT, WordH) == 'D') PointT++, PointH++;
		if(Judge(WordT, WordH) == 'H') PointH += 3;
	}
	//????¨????????????¨?????????
	cout << PointT << " " << PointH << endl;
	return 0;
}

Measured memory_bytes: 1220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split("");

		int k = Integer.parseInt(br.readLine()) - 1;

		for (int i = 0; i < n; i++) {
			if (!str[k].equals(str[i])) {
				str[i] = "*";
			}
			System.out.print(str[i]);
		}
		System.out.print("\n");
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <stdint.h>
#include <algorithm>

int main()
{
	uint64_t N, A, B;

	std::cin >> N >> A >> B;

	uint64_t sum = A + B;

	std::cout << (N / sum) * A + std::min(N % sum, A) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int ans = 0;
    int X = 0;
    int Y = 0;
    for(int i = 0; i < N; i++) {
        int T,A;
        cin >> T >> A;
        if(i == 0) {
            ans = T+A;
            X = T;
            Y = A;
        }
        else {
            if(X >= T || Y >= A) {
                ans+=max((X+T-1)/T,(Y+A-1)/A)*(T+A)-ans;
                X = max((X+T-1)/T,(Y+A-1)/A)*T;
                Y = max((X+T-1)/T,(Y+A-1)/A)*A;
            }
            else {
                ans = T+A;
                X = T;
                Y = A;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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()
{
    vector<int> a(3);
    vector<int> b(3);
    rep (i, 3)
    {
        cin >> a[i] >> b[i];
    }

    int cnt[4];
    rep (i, 4)
    {
        cnt[i] = 0;
    }

    rep (i, 3)
    {
        cnt[a[i] - 1]++;
        cnt[b[i] - 1]++;
    }

    rep (i, 4)
    {
        if (cnt[i] >= 3)
        {
            cout << "NO" << endl;
            return 0;
        }
        if (cnt[i] == 0)
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string a, b, c, d;
    cin >> a >> b >> c >> d;
    string s = a + b + c + d;
    sort(ALL(s));
    if(s == "1479") cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ins insert
#define Pq priority_queue
#define u_set unordered_set
#define MOD 1e9+7
#define MAXN 100001
#define set_val(arr,v) memset(arr, v, sizeof(arr))
#define FOR(i,from,to) for(int i=from; i<to; i++)
#define FOL(i,from,to) for(int i=from; i>=to; i--)
#define B() begin()
#define E() end()
#define F first
#define S second
//  int  __builtin_popcount(unsigned int)

int main() {
	ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
	int h,a;
	cin >> h >> a;
	int res = h/a + (h%a ? 1 : 0);
	cout << res << endl;
	return 0; 
}

Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)+1
    a = [0]*(N)
    #右側からみていく
    for i in range(N-1):
        if S[i] == '<':
            a[i+1] = max(a[i]+1,a[i+1])
    #print(a)
    #左側から見ていく
    for i in range(N-2,-1,-1):
        #print(i)
        if S[i] == '>':
            a[i] = max(a[i+1]+1,a[i])
    ans = 0
    #print(a)
    for i in range(N):
        ans += a[i]
    return ans

print(main())


Measured memory_bytes: 29012
#include<stdio.h>
#define MAX 100000
#define NIL -1
 
struct node{ 
  int p, l, r;
};

struct node T[MAX];

void depth(int);
void print(int);

int n, H, D[MAX];

int main(){

  int i, j, d, v, c, l, r;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d %d", &v, &d);
    for(j = 0; j < d; j++) {
      scanf("%d", &c);
      T[c].p = v;
      if(j >= 1)
	T[r].r = c;
      if(j == 0)
	T[v].l = c;
      r = c;
    }
  }
   
 
  for (i = 0; i < n; i++){
    if(T[i].p == NIL){
      D[i] = 0; 
      depth(i); 
      break;
    }
  }
 
  for (i = 0; i < n; i++){
    print(i);
  }
  
  return 0;
}

void depth(int u){
  
  int d = 0;

  if(T[u].r != NIL){   
    D[T[u].r] = D[u];
    depth(T[u].r);
  }
  if(T[u].l != NIL){ 
    D[T[u].l] = D[u]+1;
    depth(T[u].l);
  }
}
 
void print(int u){
  
  int a;

  printf("node %d: parent = %d, depth = %d,", u, T[u].p, D[u]);
  if(T[u].p == NIL)
    printf(" root, ");
  else if(T[u].l == NIL) 
    printf(" leaf, ");
  else 
    printf(" internal node, ");
  printf("[");
  a = u;
  if(T[a].l != NIL) { 
    printf("%d", T[a].l);   
    if(T[T[a].l].r == NIL) 
      printf("]\n");
    else 
      printf(", ");
    a = T[a].l;
    while(T[a].r != NIL){
      printf("%d", T[a].r);
      if(T[T[a].r].r == NIL) 
	printf("]\n");
      else 
	printf(", ");
      a = T[a].r;
    }
  }
  else
    printf("]\n"); 
}

Measured memory_bytes: 3732
N = input()
cnt = 0
n = len(N)
flg = 0
if n == 1:
    print(N)
    exit()
for i,d in enumerate(N):
    if int(d) == 9:
        cnt += int(d)
    else:
        if i == 0:
            cnt += int(N[i])-1 
            cnt += 9 * (n-i-1)
            if N[1:] == "9"*(n-1):
                cnt += 1
            break
        else:
            cnt += int(N[i-1])-1 
            cnt += 9 * (n-i-1)
            break
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

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

void solve() {
    LL n,p;
    cin >> n >> p;
    if (n == 1) {
        cout << p << endl;
        return;
    }
    map<int,int> m;
    REP(i,2,1000000) {
        while (p % i == 0) {
            m[i]++;
            p /= i;
        }
    }
    if (p >= 1000000) m[p]++;
    LL ans = 1;
    for (auto it = m.begin(); it != m.end(); ++it) {
        while (it->second >= n) {
            ans *= it->first;
            it->second -= n;
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
vector<ll>ve[14];
ll n,m,x;
ll solve(ll idx,vector<ll>&v)
{  
  ll i;
  for( i=0;i<m;i++)
  {
    if(v[i]<x)
    break;
  }
  if(i==m)
  {
    return 0;
  }
  if(idx>=n)
  {
    return 1e15;
  }
  ll ans=1e15;
  vector<ll>tmp=v;
  for(int i=1;i<=m;i++)
  {
    tmp[i-1]+=ve[idx][i];
  }
  ans=min(ans,ve[idx][0]+solve(idx+1,tmp));
  ans=min(ans,solve(idx+1,v));
  return ans;
   
    


}
int main()
{
  speed;
  ll t;
  t=1;
  while(t--)
  {  
    
    cin>>n>>m>>x;
   
    for(ll i=0;i<n;i++)
    {
       for(ll j=0;j<=m;j++)
       {  
         ll a;
         cin>>a;
         ve[i].pb(a);
       }
    }
    
    vector<ll>v(m,0);
    ll ans=solve(0,v);
    if(ans>=1e12)
    {
    cout<<-1<<endl;
    }
    else
    {
      cout<<ans<<endl;
    }
    


 
  }
}

     

   

  

Measured memory_bytes: 3664
# -*- coding: utf-8 -*-

A,B,C,D = list(map(int, input().rstrip().split()))
#-----

flag = 1

while A>0 and C>0:
    if flag == 1:
        C -= B
    else:
        A -= D
    
    flag = flag * (-1)

print( "Yes" if A > 0 else "No")


Measured memory_bytes: 9160
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 1e9;
    chmin(ans, a*x + b*y);
    chmin(ans, c*2*x + b*max(y-x, 0));
    chmin(ans, c*2*y + a*max(x-y, 0));
    chmin(ans, c*2*max(x, y));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    int H, W;
    int k, e;
    cin >> H >> W;
    string temp;
    vector<vector<bool>> m(H, vector<bool>(W));
    vector<vector<int>> L(H, vector<int>(W, 0)), R(H, vector<int>(W, 0)), D(H, vector<int>(W, 0)), U(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++)
    {
        cin >> temp;
        for (int j = 0; j < W; j++) m[i][j] = (temp[j] == '.');
    }
    int buf;
    H--;
    W--;
    for (int i = 0; i <= H; i++)
    {
        L[i][0] = int(m[i][0]);
        R[i][W] = int(m[i][W]);
        for (int j = 1; j <= W; j++)
        {
            L[i][j] = (m[i][j] ? L[i][j-1] + 1 : 0);
            R[i][W-j] = (m[i][W-j] ? R[i][W-j+1] + 1 : 0);
        }
    }
    for (int j = 0; j <=W; j++)
    {
        D[0][j] = int(m[0][j]);
        U[H][j] = int(m[H][j]);
        for (int i = 1; i <= H; i++)
        {
            D[i][j] = (m[i][j] ? D[i-1][j] + 1 : 0);
            U[H-i][j] = (m[H-i][j] ? U[H-i+1][j] + 1 : 0);
        }
    }
    int ans = 0;
    for (int i = 0; i <= H; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 63616
def main():
    # 1.input
    n = int(input())
    a = []
    for i in range(2):
        a.append( list(map(int, input().split())))

   # 2.find candidates
    candidates = []
    initial = sum(a[1][:]) + a[0][0]
    candidates.append(initial)
    
    # 2.1 loop
    for i in range(n-1):
        candidate = candidates[i] - a[1][i] + a[0][i+1]
        candidates.append(candidate)

   # 3.find maximum(ans)
    print(max(candidates))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e16;

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

  int H, W, D;
  cin >> H >> W >> D;

  vector<vector<int>> A(H, vector<int>(W));
  vector<pair<int, int>> num(H*W+1);
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      cin >> A.at(i).at(j);
      num.at(A.at(i).at(j)) = make_pair(i, j);
    }
  }
  
  vector<int> ruiseki(H*W+10, 0);
  for( int i = D+1; i <= H*W; i++ ){
    ruiseki.at(i) = ruiseki.at(i-D) + abs(num.at(i).first - num.at(i-D).first) +abs(num.at(i).second - num.at(i-D).second);
  }
  
  int Q;
  cin >> Q;

  for( int i = 0; i < Q; i++ ){
    int L, R;
    cin >> L >> R;
    int ans = ruiseki.at(R)-ruiseki.at(L);
    cout << ans << endl;
  }
  
}


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

int main()
{
    int n,ave = 0,ans = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ave += a[i];
    }
    ave = round((double)ave/n);
    for(int i = 0; i < n; i++) ans += pow(a[i]-ave,2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
A,B = input().split(' ')
num = 0
for i in range(int(A), int(B)+1):
    s = str(i)
    for j in range(len(s)//2):
        if s[j] != s[len(s)-1-j]:
            break
        if j == len(s)//2 - 1:
            num += 1
print(num)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define ll unsigned long long
#define PI 3.1415926535897932384626433832795l
#define MAX_NUM 1000000000
using namespace std;
template <typename T> inline T __lcm(T a,T b)
{
    return (a*b)/__gcd(a,b);
}

ll weight[1000005];
ll cost[1000005];
ll dp[101][100005];
bool dpbool[101][100005];
ll n,w;

ll knapsack(ll position, ll weight_used)
{
    if(position>=n)
    {
        return 0;
    }
    if(dpbool[position][weight_used])
    {
        return dp[position][weight_used];
    }
    ll profit1,profit2;
    if(weight_used+weight[position]<=w)
    {
        profit1=cost[position]+knapsack(position+1,weight_used+weight[position]);
    }
    else
    {
        profit1=0;
    }
    profit2=knapsack(position+1,weight_used);
    dp[position][weight_used]=max(profit1,profit2);
    dpbool[position][weight_used]=true;
    return dp[position][weight_used];
}

int main()
{
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>cost[i];
    }
    memset(dpbool, false, sizeof(dpbool[0][0]) * 101 * 100005);
    ll ans=knapsack(0,0);
    printf("%llu\n",ans);
}


Measured memory_bytes: 92416
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	int n, d; scanf("%d %d", &n, &d);
	printf("%d", (n + (2*d + 1) - 1)/ (2*d + 1));
	return 0;
}


Measured memory_bytes: 256
def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    num_w = n - num_e
    count_e = 0
    count_w = 0

    ans = n
    for i, _s in enumerate(s):
        tmp = [count_e, count_w]
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += [num_e - count_e, num_w - count_w]
        ans = min(ans, tmp[1] + tmp[2])
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 57284
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    T, A = map(int, readline().split())
    H = list(map(int, readline().split()))
    X = map(lambda x: abs(A - (T - 0.006 * x)), H)

    x_min = INF
    ans = -1

    for i, x in enumerate(X, 1):
        if x < x_min:
            ans = i
            x_min = x

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63076
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
char s[N];
int ans;

void solve()
{
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 2; i <= n + 1; ++i)
    {
        if (s[i] != s[i - 1])
            ans++;
    }
    cout << ans;
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = a[0];
  rep(i, n-1) ans = gcd(ans, a[i+1]);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n, p;
        cin >> n >> p;
        const int P = p;
        if (n == 0 and p == 0) {
            break;
        }
        int s = 0;
        vector<int> stone(n, 0);
        while (true) {
            if (p == 0) {
                p = stone[s];
                stone[s] = 0;
            } else {
                stone[s]++;
                p--;
                if (p == 0 and stone[s] == P) {
                    break;
                }
            }
            s = (s == n - 1) ? 0 : s + 1;
        }
        cout << s << endl;
    }
    return 0;
}

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

/*-------------------------------TEMPLATE ------ START-------------------*/
//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pii pair<int,int>
#define vii vector<int>
#define ll long long
#define int long long
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define allr(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define mp make_pair

#define mod 1000000007
#define eps 1e-9

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

int fact(int k){
    if(k == 1 || k == 2)
        return k;
    int a=1,b=1;
    while(a<=k){
        b = ((b%mod) * (a%mod))%mod;
        a++;
    }
    return b;
}
/* String to int */
uint64_t toint(const string &s){
    istringstream src(s);
    uint64_t v;
    src>>v;
    return v;
}

/*Int to string */
string tostring(uint64_t v){
    ostringstream src;
    src<<v;
    return src.str();
}


/*-------------------------------TEMPLATE ------ END-------------------*/
//SOLUTION
const int N = 2e5+5;
int n,sn;
string s;


int32_t main()
{
    fast;//openin;
    cin>>s;
    n = toint(s);
    rep(i,0,(int)s.length()-1){
        sn += toint(s.substr(i,1));
    }
    if(n % sn == 0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
using namespace std;

#define ll long long int
const int MOD = 1000000007;//10^9+7

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
//aとbの大きい方

int min(int a, int b) {

	if (a < b)return a;
	else return b;

}
//aとbの小さい方

int avd_i(int a, int b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//aとbの差の絶対値

ll calc(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = calc(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*calc(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = calc(b, p - 2, p);
	c = calc(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

int main() {

	int N, p[100005], count = 0, tmp;
	bool check = false;

	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> p[i];

	}
	for (int i = 1; i < N; i++) {

		if (i == p[i]) {

			tmp = p[i];
			p[i] = p[i + 1];
			p[i + 1] = tmp;
			count++;

		}

	}
	if (p[N] == N) {

		tmp = p[N];
		p[N] = p[N - 1];
		p[N - 1] = tmp;
		count++;

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m;
    cin>>n>>m;
 
    int a=(n+1)/2-1;
    vector<int>ans;
    if(n&1){
        int ma;
        double val=-114514;
        for(int i=0;i<=m;i++){
            int x;
            if(i<=m/2){
                x=(n+1)/2*i+n/2*m;
            }
            else{
                x=(n+1)/2*i;
            }
            double y=(i-1.0*x/n);
            if(val<y){
                val=y;
                ma=i;
            }
        }
 
        if(ma<=m/2){
            for(int i=0;i<(n+1)/2;i++)ans.push_back(ma);
            for(int i=0;i<n/2;i++)ans.push_back(m);
        }
        else{
            for(int i=0;i<n/2;i++)ans.push_back(0);
            for(int i=0;i<(n+1)/2;i++)ans.push_back(ma);
        }
    }
 
    else{
        int ma1,ma2;
        double val=0;
        for(int i=0;i<=m;i++){
            for(int j=i;j<=m;j++){
                int x;
                if(i+j<=m*2){
                    x=i*n/2+j+(n-1)/2*m;
                }
                else{
                    x=i+j*n/2;
                }
                double y=fabs(1.0*(i+j)/2-1.0*x/n);
                if(val<y){
                    val=y;
                    ma1=i;
                    ma2=j;
                }
            }
        }
 
        if(ma1+ma2<=m*2){
            for(int i=0;i<n/2;i++)ans.push_back(ma1);
            ans.push_back(ma2);
            for(int i=0;i<(n-1)/2;i++)ans.push_back(m);
        }
        else{
            for(int i=0;i<(n-1)/2;i++)ans.push_back(0);
            ans.push_back(ma1);
            for(int i=0;i<n/2;i++)ans.push_back(ma2);
        }
    }
 
    for(int i=0;i<n;i++){
        if(i)cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3140
#include <iostream>                                                                                                   
 
 int main(){
    long long N, M;
    std::cin >> N >> M;
 
    if(N>=3 && M>=3){
       std::cout << (N-2) * (M-2) << std::endl;
     }else if(N==1 || M==1){
        if(N==1 && M==1) std::cout << 1 << std::endl;
        else std::cout << std::max(N,M)-2 << std::endl;
     }else{
        std::cout << 0 << std::endl;
     }
  
     return 0;
  
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl


signed main(){
    int N,i;
    cin >> N >> i;
    cout << N+1-i << endl;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n + 1), b(n);
    for (auto &e : a) std::cin >> e;
    for (auto &e : b) std::cin >> e;

    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i]) {
            ret += b[i];
        } else if (b[i] >= a[i] + a[i + 1]) {
            ret += a[i] + a[i + 1];
            a[i + 1] = 0;
        } else {
            ret += b[i];
            a[i + 1] = a[i + 1] - b[i] + a[i];
        }
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long k,s,sum=0,m;
int main()
{
    scanf("%lld%lld",&k,&s);
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++){
            m=s-i-j;
            if(m<=k&&m>=0)
                sum++;
        }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
A = [int(input()) for i in range(5)]
#１の位が１～９のうちで1に近いほど、最後に調理される
B = [a-a%10+10 if a % 10 != 0 else a for a in A]
diff = [(b-a) for a,b in zip(A,B)]
print(sum(B) - max(diff))

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

long long n, cnt, a, ans;

int main()
{
	cin>> n;
	a = 1e15;
	for (int i = 1; i <= n; i++)
	{
		long long x;
		cin >> x;
		if (x < 0)
		{
			cnt++;
			ans -= x;
			a = min(a, -x);
		}
		else
		{
			ans += x;
			a = min(a, x);
		}
	}
	if (cnt % 2 == 1)
	{
		cout << ans - a * 2 << endl;
	}
	else
	{
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b,c;
	while(cin>>a>>b>>c){
	int srs=a.length();
	int saj=b.length();
	int rah=c.length();
	if((a[srs-1]==b[0]) && (b[saj-1]==c[0])) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2*(int)1e5 + 10;

int n, a[N], dp[N][5];
int till = 0;

bool bad = false;

int solve(int idx, int removed){
   if (removed < 0){
      return -inf;
   }
   if (idx >= n){
      if (bad and n%2 and removed == 2){
         return -inf;
      }
      return 0;
   }
   int &ans = dp[idx][removed];
   if (ans != -1){
      return ans;
   }
   ans = -inf;
   smax(ans, solve(idx+1, removed-1));
   smax(ans, a[idx] + solve(idx+2, removed));
   return ans;
}

int32_t main(){_
   
   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }
      
   int ans = -inf;
   memset(dp, -1, sizeof dp);

   if (n%2){
      bad = true;
      smax(ans, solve(0, 2));
      bad = false;
      memset(dp, -1, sizeof dp);
      smax(ans, solve(1, 1));
   }
   else{
      smax(ans, solve(0, 1));
      memset(dp, -1, sizeof dp);
      smax(ans, solve(1, 0));
   }
   
   cout<<ans;  

   return 0;
}

Measured memory_bytes: 17708
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
#include <iomanip>
using namespace std;
const long long mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for(int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k; 
ll INF = 10000000000000000;
const double PI=3.14159265358979323846;



int main(){
    double A,B,H,M;
    cin >>A>>B>>H>>M;
    double AC,BC;
    AC=30.000000000000*H+M*0.5;
    BC=6.0000000000000*M;
    double bet = AC-BC;
    double d = A*A+B*B-2*A*B*cos(bet*PI/180.0);
    cout <<fixed<<setprecision(15)<<sqrt(d)<<endl;
}

Measured memory_bytes: 4172
#include<stdio.h>

int main()
{
    long long int q,h,s,d,n,i,j,v[4],cost,a;
    scanf("%lld %lld %lld %lld",&q,&h,&s,&d);
    scanf("%lld",&n);
    v[0]=8*q;
    v[1]=4*h;
    v[2]=2*s;
    v[3]=d;
    for(i=0;i<=3;i++){
    	for(j=0;j<=2-i;j++){
    		if (v[j]>v[j+1]) {
    			a=v[j];
    			v[j]=v[j+1];
    			v[j+1]=a;
    		}
    	}
    }
    if(v[0]!=d) cost=n*v[0]/2;
    else cost=(n-n%2)*v[0]/2+(n%2)*v[1]/2;
    printf("%lld\n",cost);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=190;
int dp[2][maxn][maxn][maxn];
int n,m,cur=0,lst=1;
char s[maxn][maxn];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int k=m;k>=1;k--)
    for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)
    if(s[i][k]!=s[j][k])break;
    else 
    {
        dp[cur][k][i][j]=k;
        if(s[i][k]==s[i][k+1])dp[cur][k][i][j]=max(k,dp[cur][k+1][i][j]);
    }
    for(int ans=0;ans<=20;ans++)
    {
        if(dp[cur][1][1][n]==m){printf("%d\n",ans);return 0;}
        swap(cur,lst);
        memset(dp[cur],0,sizeof(dp[cur]));
        for(int k=1;k<=m;k++)
        for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++)
        {
            int tmp=dp[lst][k][i][j];
            if(tmp>0&&tmp<m)tmp=max(tmp,dp[lst][dp[lst][k][i][j]+1][i][j]);
            if(i!=j)
            {
                int l=i,r=j-1,p=i;
                while(l<=r)
                {
                    int mid=l+r>>1;
                    if(dp[lst][k][i][mid]>=dp[lst][k][mid+1][j])l=mid+1,p=mid;
                    else r=mid-1;
                }
                tmp=max(tmp,min(dp[lst][k][i][p],dp[lst][k][p+1][j]));
                p++;
                if(p<j)tmp=max(tmp,min(dp[lst][k][i][p],dp[lst][k][p+1][j]));
            }
            dp[cur][k][i][j]=tmp;
        }
    }
}

Measured memory_bytes: 54016
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Buffer(make([]byte, 500000), 500000)
	sc.Split(bufio.ScanWords)

	tenki := next()

	if tenki == "Sunny" {
		fmt.Println("Cloudy")
	} else if tenki == "Cloudy" {
		fmt.Println("Rainy")
	} else {
		fmt.Println("Sunny")
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}


Measured memory_bytes: 640
N,M = map(int,input().split())
di = {}
pe = 0
ac = 0
for i in range(M):
    inp = input().split(" ")
    if inp[1] == "WA":
        if inp[0] in di:
            if di[inp[0]] >= 1:
                di[inp[0]] += 1
        else:
            di[inp[0]] = 1
            
            
    else:
        if inp[0] in di:
            pe += di[inp[0]]
            di[inp[0]] = 0
        di[inp[0]] = 0
        
for v in di.values():
    if v == 0:
        ac += 1
print(str(ac)+" "+str(pe))

Measured memory_bytes: 17112
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N = 10000000 + 1;

    vector<bool> vs(N);

    for (int i = 0; i < N; ++i) {
        vs[i] = true;
    }

    for (int i = 2; i * i <= N; ++i) {
        if (vs[i]) {
            for (int j = i * i; j <= N; j += i) {
                vs[j] = false;
            }
        }
    }

    int X;
    cin >> X;

    for (int i = 2; i <= N; ++i) {
        if (vs[i] && i >= X) {
            cout << i << endl;
            break;
        }
    }


    return 0;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli N, A, B;
	cin >> N >> A >> B;
	if (B < A) {
		cout << 0 << endl;
		return 0;
	}
	if (N == 1 && A != B) {
		cout << 0 << endl;
		return 0;
	}
	if (N <= 2 || A == B) {
		cout << 1 << endl;
		return 0;
	}
	cout << (B - A) * (N - 2) + 1 << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    String inputStr = sc.nextLine();
    
    String regex = "[7]";
    Pattern p = Pattern.compile(regex);
    Matcher m = p.matcher(inputStr);

    if (m.find()) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  
  } 
}

Measured memory_bytes: 27020
let () =
  let (n, m) = Scanf.scanf "%d %d\n" (fun n m -> (n, m)) in
  let v = Array.make n (-1) in
  let g = Array.make n [] in
  let rec read i =
    if i < m then begin
      let (s, t) = Scanf.scanf "%d %d\n" (fun s t -> (s, t)) in
      g.(s) <- t :: g.(s);
      g.(t) <- s :: g.(t);
      read (i + 1)
    end
  in
  read 0;
  let rec dudu j = function
    | [] -> ()
    | hd :: tl when v.(hd) = (-1) -> (wa hd j; dudu j tl)
    | _ :: tl -> dudu j tl
  and wa i j = v.(i) <- j; dudu j g.(i)
  and doit i =
    if i < n then (if v.(i) = (-1) then wa i i; doit (i + 1))
  in
  doit 0;
  let q = Scanf.scanf "%d\n" (fun q -> q) in
  let rec read_q i =
    if i < q then begin
      let (s, t) = Scanf.scanf "%d %d\n" (fun s t -> (s, t)) in
      print_endline (if v.(s) = v.(t) then "yes" else "no");
      read_q (i + 1)
    end
  in
  read_q 0

Measured memory_bytes: 14440
import math
a,b,h,m=map(int,input().split())
partition=0.5
minute=m*6
# minute=minute*360
hour=30*h + 0.5*m
dif=abs(hour-minute)
cos=math.cos(math.pi*(dif/180));
print(math.sqrt(a**2 + b**2 - 2*a*b*cos))


Measured memory_bytes: 9428
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

// 最大公約数を求める
template<typename T> T gcd(T a, T b)
{
	return b > 0 ? gcd(b, a % b) : a;
}

int main()
{
	ll n;
	cin >> n;

	ull res = 0;
	vector<vector<ll>> g(210, vector<ll>(210));
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= n; j++)
		{
			g[i][j] = gcd(i, j);
			for (ll k = 1; k <= n; k++)
			{
				res += gcd(k, g[i][j]);
			}
		}
	}

	println(res);
}

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


int main(){
    int n; cin >> n;
    vector<long long> a(n);
    long long ans = 0;
    long long x = 1000000000 + 7;
    vector<long long> partial;

    rep(i, n){
        cin >> a.at(i);
        // a.at(i) = a.at(i);
    }

    int partial_s = 0;
    for(int i = 0; i < n; i++){
        partial_s += a.at(n - 1 - i);
        partial_s = partial_s % x;
        partial.push_back(partial_s);
    }

    reverse(partial.begin(), partial.end());

    // rep(i, n){
    //     cout << partial.at(i) << endl;
    // }
    

    for(int i = 0; i < n - 1; i++){
        ans += a.at(i) * partial.at(i+1) % x;
        ans = ans % x;
        // cout << a.at(i) << " " << partial.at(i+1) << endl;
    }

    cout << ans << endl;




    
}

Measured memory_bytes: 6928
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - KASPAROVIAN                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define frr(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define mk make_pair
#define endl '\n'
#define MOD 1000000007
#define in insert
#define sz(x) (ll)(x).size()
#define mem(a,b) memset(a,b,sizeof(a))
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef pair<int,pi> ppi;
typedef vector<vi> graph;
template<class T> void mxi(T & a, const T & b) { a = max(a, b); }
template<class T> void mni(T & a, const T & b) { a = min(a, b); }
ld EPS=1e-9;
void solve()
{
  string s,t;
  cin>>s>>t;
  int ans=1e9;
  for(int i=0;i<=sz(s)-sz(t);i++)
  {
  	int ch=0;
  	for(int j=0;j<sz(t);j++)
  	{
  		if(s[i+j]!=t[j])
  			ch++;
  	}
  	mni(ans,ch);
  }
  cout<<ans<<endl;

}
signed main()
{
  fast;
  int t,tab;
  t=1;
  tab=t;
  while(t--)
  {
    //cout<<"Case #"<<(tab-t)<<": ";
    solve();
  }
}
//APPROACHING A QUESTION
//+ Think of binary search (max of min etc also if n<=2*10^5)
//+ Think of common dp states (Even if it appears as maths but constraints are small)
//+ Check constraints
//+ Keep calm and enjoy the question
//+ Be sure to remove MOD from binpow (if needed)
//+ Try bidirectional analysis for constructive questions
//+ If given some sequence try thinking of prefix sums
//+ If constraints are too large maybe its simple maths
//+ In questions with binary operations think of bits independently and also the change pattern
//+ If two or more binary operations are given mostly there is a relation between them and an arithmatic operator

Measured memory_bytes: 3656
program ct;
var
    i, x, y : longint;
begin
    read(x, y);
    readln;
    if y mod 2 = 0 then begin
        if (y >= (x * 2)) and (y <= (x * 4)) then begin
            for i := 1 to x do begin
                if y - 4 >= 0 then
                    y -= 4
                else if y - 2 >= 0 then
                    y -= 2
            end;
            if y = 0 then 
                writeln('Yes')
                
            else 
                writeln('No')
        end
        else
            writeln('No')
    end
    else
        writeln('No');
end.

Measured memory_bytes: 1376
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD = 1e9+7;
string s[400];
bool used[400][400];

P operator+(const P& lhs,const P& rhs)
{
	return P(lhs.first+rhs.first,lhs.second+rhs.second);
}

P dfs(P now,int h,int w)
{
	//cerr<<now.first<<" "<<now.second<<endl;
	P ret=P(0,0);
	used[now.first][now.second]=true;
	bool f;
	if(s[now.first][now.second]=='.')
	{
		ret.second++;
		f=false;
	}else{
		ret.first++;
		f=true;
	}
	int dx[4]={1,0,-1,0};
	int dy[4]={0,-1,0,1};
	for(int i=0;i<4;i++)
	{
		if(now.first+dx[i]>-1 && now.first+dx[i]<h && now.second+dy[i]>-1 && now.second+dy[i]<w)
		{
			if(!used[now.first+dx[i]][now.second+dy[i]])
			{
				char c=s[now.first+dx[i]][now.second+dy[i]];
				if((c=='.' && f) || (c=='#' && !f))
					ret=ret+dfs(P(now.first+dx[i],now.second+dy[i]),h,w);
			}
		}
	}
	return ret;
}

int main()
{
	int h,w;
	ll ans=0;
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>s[i];
	fill(used[0],used[400],false);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(!used[i][j])
			{
				P p=dfs(P(i,j),h,w);
				ans+=p.first*p.second;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23168
' Imports System.Collections.Generic
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim A, B As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        A = arr(0) : B = arr(1)
        Console.WriteLine(If(2 * B < A, A - 2 * B, 0))
        Return
    End Sub
End Class

Measured memory_bytes: 28328