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;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                unsigned long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        long double gg;
        cin >> gg;
        dbg(gg);
        gg *= n;
        k = (int)gg;
        cout << k;
    }
    return 0;
}

Measured memory_bytes: 3752
from collections import deque
H,W = map(int,input().split())
field = [list(input()) for _ in range(H)]
dist = [[-1]*W for _ in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
mx = 0
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            continue
        dist = [[-1]*W for _ in range(H)]
        dist[h][w] = 0
        que = deque([])
        que.append([h,w])
        while que != deque([]):
            u,v = que.popleft()
            for dir in range(4):
                nu = u + dx[dir]
                nv = v + dy[dir]

                if (nu < 0) or (nu >= H) or (nv < 0) or (nv >= W):
                    continue
                if field[nu][nv] == "#":
                    continue
                if dist[nu][nv] != -1:
                    continue
            
                que.append([nu,nv])
                dist[nu][nv] = dist[u][v] + 1
            
            
        for i in range(H):
            for j in range(W):
                if mx < dist[i][j]:
                    mx = dist[i][j]
    
print(mx)

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#include<vector>
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define mod 1000000007
using namespace std;

ll ipow(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    } 
    return result; 
} 

int main(){
	fio
	ll t;
	cin>>t;
	ll te=t%10;
	string s;
	if(te==3)
	s="bon";
	else if(te==0 or te==1 or te==6 or te==8)
	s="pon";
	else if (te==2 or te==4 or te==5 or te==7 or te==9)
	s="hon";
	cout<<s<<endl;
return 0;
}

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

sum = 0
a = 0
b = 0

for i in range(N):
    if(S[i] == 'A'):
        a = 1
        b = 0
    elif(S[i] == 'B' and a == 1):
        b = 1
        a = 0
    elif(S[i] == 'C' and b == 1):
        sum = sum + 1
        a = 0
        b = 0
    else:
        a = 0
        b = 0


print(sum)

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

ans = []
for i in range(k):
    if a+i > b:
        break
    ans.append(a+i)
for i in range(k):
    if b-i < a:
        break
    ans.append(b-i)

ans = set(ans)
ans =sorted(ans)
for i in ans:
    print(i)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var (
		A, B, C int
	)

	fmt.Scan(&A, &B, &C)

	if A == C {
		fmt.Print(B)
	} else if A == B {
		fmt.Print(C)
	} else {
		fmt.Print(A)
	}

}


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

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

#define N 5
int p[N + 1];
int nextperm(void)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int a, b, c, d, e;

    scanf("%d %d %d %d %d", &p[1], &p[2], &p[3], &p[4], &p[5]);

    quicksort(p, 1, 5);
    int min = inf;
    do {
        int ans = 0;
        for(int i = 1; i <= 5; ++i){
            while((ans % 10) != 0){
                ans++;
            }
            ans += p[i];
        }
        if(min > ans) min = ans;
    } while (nextperm());

    printf("%d\n", min);

    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    //勝ち筋
    //自分の番でりんごが偶数個
    //すべてのりんごが偶数個のとき、後手必勝
    int odd=0,even=0;
    rep(i,n){
        if(a[i]%2) odd++;
        else even++;
    }
    if(even==n) cout<<"second";
    else cout<<"first";
}

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

using namespace std;

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

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				cout << char('A' + w) << h+1 << endl;
				return 0;
			}
		}
	}

}


Measured memory_bytes: 3604
n=int(input())
def num2alpha(num):
  if num<=26:
    return chr(64+num)
  elif num%26==0:
    return num2alpha(num//26-1)+chr(90)
  else:
    return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(n).lower())
  


Measured memory_bytes: 9024
#include<stdio.h>
#include<math.h>
int main(){
  double a,b,x,v,theta,s;
  scanf("%lf%lf%lf",&a,&b,&x);
  v=a*a*b;
  if(v<2*x){
    s=2*(v-x);
    s=s/a/a/a;
    theta=atan(s)*180/M_PI;
  }
  else{
    s=a*b*b/2;
    s/=x;
    theta=atan(s)*180/M_PI;
  }

  printf("%lf\n",theta);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll l,r;
	cin>>l>>r;
	bool bai=false;
	if(l==r){
		bai=true;
	}
	if(abs(l-r)>=2){
		cout <<0;
		return 0;
	}
	ll ans=1;
	while(l!=1){
		ans*=l;
		ans%=inf;
		l--;
	}
	while(r!=1){
		ans*=r;
		ans%=inf;
		r--;
	}
	if(bai){
		ans*=2;
		ans%=inf;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			int n = sc.nextInt(), w = sc.nextInt();
			if(n == 0 && w == 0) break;

			int max_v = Integer.MIN_VALUE;
			int v[] = new int[n];
			for(int i=0;i<n;i++){
				v[i] = sc.nextInt();
				max_v = Math.max(v[i], max_v);
			}

			int max_bar = Integer.MIN_VALUE;
			int bar[] = new int[max_v/w+1];
			for(int i=0;i<n;i++){
				bar[v[i]/w]++;
				max_bar = Math.max(max_bar, bar[v[i]/w]);
			}

			double ans = 0.0;
			for(int i=0;i<bar.length;i++){
				ans += (double) (bar.length - i - 1) / (bar.length - 1) * bar[i] / max_bar;
			}
			System.out.println(ans+0.01);
		}

	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

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

		System.out.println(Integer.valueOf(s.substring(0, 1)) + Integer.valueOf(s.substring(1, 2))
				+ Integer.valueOf(s.substring(2)));
	}

}

Measured memory_bytes: 23636
#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>;

int main(void){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int A;
      cin >> A;
      a[A-1]++;
    }
  }
  int cnt = 0;
  rep(i,n){
    if(a[i] == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3552
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
// const input = fs.readFileSync('./input.txt', 'utf8');

_b(input);

function _b(input: string) {
  let sum = 0;
  for (let index = 0; index < input.length - 1; index++) {
    sum = (sum + parseInt(input[index])) % 9;
  }
  console.log(sum === 0 ? 'Yes' : 'No');
}


Measured memory_bytes: 32564
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int k=0;
  for(int i=0; i<N; i++){
    int p;
    cin >> p;
    if(p != i+1) k++;
  }
  if(k<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  if(s=="ABC")
    cout << "ARC\n";
  else if(s=="ARC") 
    cout << "ABC\n"; 
  return 0;
}

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

 /********* Credits *********/
 /// Coded by:             ///
 ///     - NikolaP         ///
 ///                       ///
 /// Compiler: C++ 14      ///
 /// Date: 11 - Sep - 2019 ///
 /***************************/

/** typedefs & #defines **/
//{

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define forn(i,n)    for(int i = 0 ; i < (int)(n) ; ++i)
#define forv(i,l,n)  for(int i = (int)(l) ; i < (int)(n) ; ++i)

#define all(x)     (x).begin(), (x).end()
#define allr(x)    (x).rbegin(), (x).rend()
#define mems(a,x)  memset((a),(int)(x),sizeof((a)))
#define memsb(a,x) memset((a),(bool)(x),sizeof(a))

using namespace std;

typedef long long int ll;
typedef double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

//}

int n;
int arr[(int)(1e5+4)];
int dp[(int)(1e5+4)];

int check(int i , int j){
    int ans = arr[i] - arr[j];

    if(ans < 0) return -ans;
    else return ans;
}

int f(int i){
    if(i == n-1) return 0;
    if(i >= n) return 1e9;
    if(dp[i] != -1) return dp[i];

    int ans = 1e9;
    ans = min(ans,f(i+1) + check(i,i+1));
    ans = min(ans,f(i+2) + check(i,i+2));

    dp[i] = ans;
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(8);
    // cout << fixed;

    cin >> n;
    forn(i,n)
        cin >> arr[i];

    mems(dp,-1);

    cout << f(0);
    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <queue>
#include <iostream>
#include <vector>
#include <map>
int main(){
  int n;
  std::cin>>n;
  std::map<std::string, int> mp;
  for(int i=0;i<n;++i){
    std::string s;
    std::cin>>s;
    std::sort(s.begin(), s.end());
    mp[s]++;
  }
  long long ans=0;
  for(auto& p:mp){
    int s=p.second;
    ans+=(long long)s*(s-1)/2;
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N;
  cin >> N;
  ll ans = 0LL;
  for(int i = 1; i <= N; i++){
    ll num = N/i;
    ll x = (i + num * i) * num / 2;
    ans += x;
  }
  cout << ans << endl;
}

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

int llabs(int n) { return n < 0 ? -n : n; }

main()
{
  int h, w;

  cin >> h >> w;

  if(h > w) swap(h, w);

  if(h % 3 == 0 || w % 3 == 0) {
    cout << 0 << endl;
  } else {
    int minv = h;
    if(h % 2 == 0) minv /= 2;
    if(w % 2 == 0) minv = min(minv, w / 2);
    
    for(int i = 1; i <= min(h, w - 1); i++) {
      int maxs = max(h / 2 * i, max(h * (w - i), (h / 2 + (h % 2)) * i));
      int mins = min(h / 2 * i, min(h * (w - i), (h / 2 + (h % 2)) * i));

      minv = min(minv, maxs - mins);
      
    }

    cout << minv << endl;
      
  }

  return (0);
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
long p[10];
bool cm(const long l, const long r){return p[l]>p[r];}
int main(){
long n,i,w,l,d,id[10],f=0;
string s[10];
while(cin>>n){
if(n==0)break;
if(f>0)cout<<endl;f=1;
for(i=0;i<n;i++)p[i]=0;
for(i=0;i<n;i++){
cin>>s[i]>>w>>l>>d;
p[i]+=3*w+d;
id[i]=i;
}
sort(id,id+n,cm);
for(i=0;i<n;i++){
cout<<s[id[i]]<<","<<p[id[i]]<<endl;
}
}
return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#define EBTW(x,y,z) (y <= x && x <= z)
#define BTW(x,y,z) (y < x && x < z)
#define SORT(a,b,c,d) (a <= b && b <= c && c <= d)

typedef struct{
    int start;
    int end;
}apo;

int main(){
    apo m;
    apo* list;
    int num;
    int i;
    
    scanf("%d%d", &m.start, &m.end );
    scanf("%d", &num);
    list = malloc(sizeof(apo) * num);
    for(i = 0; i < num; i++){
        scanf("%d%d", &list[i].start, &list[i].end );
    }
    
    for(i = 0; i < num; i++){
        if((SORT(m.start,m.end,list[i].start,list[i].end) || SORT(list[i].start,list[i].end,m.start,m.end)) == 0){
            printf("1\n");
            goto end;
        }
    }
    
    printf("0\n");
    end:
    return 0;
}


Measured memory_bytes: 2096
#include<iostream>
#include<cctype>
#include<string>
#include<algorithm>

int main()
{
	std::string word;
	std::getline(std::cin, word);
	for (int i = 0; i < word.size(); i++) {
		if (std::islower(word[i])) {
			word[i] = std::toupper(word[i]);
		}
		else if (std::isupper(word[i])) {
			word[i] = std::tolower(word[i]);
		}
		std::cout << word[i];
	}
	std::cout << std::endl;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var Y = input[1];

            for (int i = 0; i <= Y / 10000 && i <= N; i++)
            {
                for (int j = 0; j <= (Y - i * 10000) / 5000 && i + j <= N; j++)
                {
                    if ((Y - i * 10000 - j * 5000) / 1000 == (N - i - j))
                    {
                        Console.WriteLine(i + " " + j + " " + (N - i - j));
                        Console.ReadLine();
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for (int i = s; i < f; i++)
#define ll long long
#define pii pair <int, int>
#define fs first
#define sc second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

bool good(int a, int b, int c, int d) {
    if (a == 0 && c == 2 && d == 1)
        return 0;
    if (a == 0 && b == 2 && d == 1)
        return 0;
    if (b == 0 && c == 2 && d == 1)
        return 0;
    if (b == 2 && c == 0 && d == 1)
        return 0;
    if (b == 0 && c == 1 && d == 2)
        return 0;
    return 1;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    const int MOD = 1e9 + 7;
    int n;
    cin >> n;
    int dp[n + 1][4][4][4];
    forn (i, 4, n + 1)
        forn (j, 0, 4)
            forn (k, 0, 4)
                forn (l, 0, 4)
                    dp[i][j][k][l] = 0;
    forn (i, 0, 4)
        forn (j, 0, 4)
            forn (k, 0, 4)
                dp[3][i][j][k] = 1;
    dp[3][0][2][1] = dp[3][0][1][2] = dp[3][2][0][1] = 0;
    forn (i, 4, n + 1)
        forn (j, 0, 4)
            forn (k, 0, 4)
                forn (l, 0, 4)
                    forn (t, 0, 4)
                        if (good(j, k, l, t))
                            dp[i][k][l][t] = (dp[i][k][l][t] + dp[i - 1][j][k][l]) % MOD;
    int ans = 0;
    forn (j, 0, 4)
        forn (k, 0, 4)
            forn (l, 0, 4)
                ans = (ans + dp[n][j][k][l]) % MOD;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define pll pair<ll,ll>
    #define pil pair<int,ll>
    #define pli pair<ll,int>
    #define pii pair<int,int>
    #define mk make_pair
    #define pb push_back
    #define eps 1e-12
    #define MAXN 200009
    using namespace std;
    vector<int> v[400][5];
    ll mod=1e9+7;
    inline void adjust(ll &x)
    {
    	if(x>=mod)
    	{
    		x-=mod;
    	}
    }
    ll dp[305][305][305];
    inline void set_it(int new_i,int new_j,int new_k,int i,int j,int k)
    {
    	bool flag=true;
    	if(!v[new_i][1].empty())
    	{
    		int sz=new_i-v[new_i][1][0]+1;
    		if(new_j<sz)
    		{
    			flag=false;
    		}
    	}
    	if(!v[new_i][2].empty())
    	{
    		int size_v=v[new_i][2].size();
    		int sz=new_i-v[new_i][2][size_v-1]+1;
    		if(sz<=new_j)
    		{
    			flag=false;
    		}
    		else
    		{
    			sz=new_i-v[new_i][2][0]+1;
    			if(sz>new_k)
    			{
    				flag=false;
    			}
    		}
    	}
    	if(!v[new_i][3].empty())
    	{
    		int size_v=v[new_i][3].size();
    		int sz=new_i-v[new_i][3][size_v-1]+1;
    		if(sz<=new_k)
    		{
    			flag=false;
    		}
    	}
    	if(flag)
    	{
    		dp[new_i][new_j][new_k]+=dp[i][j][k];
    		adjust(dp[new_i][new_j][new_k]);
    	}
    	return;
    }
    int main()
    {
    	ios_base::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	int n,m;
    	cin>>n>>m;
    	for(int i=0;i<m;i++)
    	{
    		int l,r,x;
    		cin>>l>>r>>x;
    		v[r][x].pb(l);
    	}
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=3;j++)
    		{
    			sort(v[i][j].begin(),v[i][j].end());
    		}
    	}
    	if(!v[1][2].empty()||(!v[1][3].empty()))
    	{
    		cout<<"0\n";
    		return 0;
    	}
    	dp[1][1][n+1]=3;
    	for(int i=1;i<n;i++)
    	{
    		for(int j=1;j<=i;j++)
    		{
    			for(int k=j;k<=n+1;k++)
    			{
    				if(!dp[i][j][k])
    				{
    					continue;
    				}
    				int new_i=i+1;
    				int new_j=j+1;
    				int new_k=k+1;
                    if(new_k>n)
                    {
                        new_k=n+1;
                    }
    				set_it(new_i,new_j,new_k,i,j,k);
    				new_j=1;
    				new_k=k+1;
                    if(new_k>n)
                    {
                        new_k=n+1;
                    }
    				set_it(new_i,new_j,new_k,i,j,k);
    				new_j=1;
    				new_k=j+1;
    				if(new_k==new_i)
    				{
    					new_k=n+1;
    				}
    				set_it(new_i,new_j,new_k,i,j,k);
    			}
    		}
    	}
    	ll ans=0;
    	for(int j=1;j<=n+1;j++)
    	{
    		for(int k=1;k<=n+1;k++)
    		{
    			ans=ans+dp[n][j][k];
    			adjust(ans);
    		}
    	}
    	cout<<ans<<"\n";
    }

Measured memory_bytes: 217472
a,b,c,x,y = map(int,input().split())
if c > (a+b)/2:
    print(a*x+b*y)
elif x == y:
    print(c*2*x)
else:
    ans = 2*min(x,y)*c
    if x>y:ans+=(x-y)*min(a,2*c)
    else:ans+=(y-x)*min(b,2*c)
    print(ans)

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

int main(){
  int H, N;
  cin >> H >> N;
  int sum = 0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    sum+=a;
  }
  if(sum >=H){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
N,K=map(int,input().split())
mod=10**9+7
 
L=[i for i in range(K+1)]
 
for i in range(1,K):
    for j in range(i*2,K+1,i):
        L[j]-=L[i]
 
ANS=0
for i in range(1,K+1):
    ANS=(ANS+pow(K//i,N,mod)*L[i])%mod
 
print(ANS)

Measured memory_bytes: 12940
n,k=map(int,input().split())
v=list(map(int,input().split()))
times=min(n,k)
ans=0
for i in range(times+1):
    l=v[:i]
    for j in range(times-i+1):
        r=l+v[n-j:]
        rest=k-i-j
        val=sum(r)
        r=sorted(r)
        if len(r)>0:
            for p in range(min(rest,len(r))):
                if r[p]<0:
                    val-=r[p]
                else:
                    break
        if val>ans:
            ans=val
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
  int N, L;
  std::cin >> N >> L;
  std::string S[N];
  for ( int i = 0; i < N; i++ ) std::cin >> S[i];

  std::sort(S, S+N);
  std::string ans = "";
  for ( std::string s : S ) {
    ans += s;
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int a[10],b[10],c[10];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=read();
	for(int i=1;i<=n;i++) c[i]=i;
	int aa=0,bb=0;
	while(1)
	{
		aa++;
		bool ok=1;
		for(int i=1;i<=n;i++) if(a[i]!=c[i]) ok=0;
		if(ok) break;
		next_permutation(c+1,c+n+1);
	}
	for(int i=1;i<=n;i++) c[i]=i;
	while(1)
	{
		bb++;
		bool ok=1;
		for(int i=1;i<=n;i++) if(b[i]!=c[i]) ok=0;
		if(ok) break;
		next_permutation(c+1,c+n+1);
	}
	cout<<abs(aa-bb)<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
using lint  =                           long long int;
using pint  =                           pair<int, int>;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD                             1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

lint pow_mod(lint base,lint expo) { 
   lint ret = 1;
   for(;expo;) { 
      if(expo&1)  ret = (ret*base)%MOD; 

      expo = (expo>>1);
      base = (base*base)%MOD;
   }
   return ret;
}

/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  int r;
  cin >> r;

  cout << 3.14159265358979323846264338327950288419716939937510 * 2 * (float)r << endl;
}

int main(){   
  
    // freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);

 solve();

 return 0;
}


Measured memory_bytes: 3792
using System;

public class Hello{
    public static void Main(){
        // Your code here!
        string[] glasses = Console.ReadLine().Split(' ');
        int a = int.Parse(glasses[0]);
        int b = int.Parse(glasses[1]);
        int c = int.Parse(glasses[2]);
        
        int rest = a - b;
        
        int result = c - rest;
        
        Console.WriteLine(result >= 0 ? result : 0);
    }
}


Measured memory_bytes: 11092
N= int(input())
H=input().split()
H=list(map(int, H))
cnt=0
ans=0
for i in range(1,N):
    if H[i-1]>=H[i]:
        cnt+=1
    else: 
        ans=max(ans,cnt)
        cnt=0
ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}

int main(){
	int n; cin >> n;
	int arr[n+1] ={};
	rep(i,n) cin >> arr[i+1];

	vector<ll> dp(n+1);
	dp[2] = abs(arr[2] - arr[1]);

	for(int i=3;i<=n;i++){
		dp[i] = min((dp[i-1] + abs(arr[i] - arr[i-1])),
			(dp[i-2] + abs(arr[i] - arr[i-2])));
	}

	cout << dp[n] << endl;
	return 0;
}




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

int main(){
    int a,b;
    cin >> a >> b;

    if(a>b) swap(a, b);
    rep(i, b){
        cout << a;
    }
    cout << '\n' ;
    return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ( A + B < C + D){
    cout << "Right" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else{
    cout << "Left" << endl;
  }
}
  


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

using namespace std;

typedef long long ll;

const int MAX = 2010101;
ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i=2; i<MAX; i++) {
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
        }
}

ll COM(int n, int k) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int, char**) {
	COMinit();
	int x, y; cin >> x >> y;
	int diff = abs(x - y);
	int rem = min(x, y) - diff;
	if (rem<0 || rem%3!=0) {
		cout << 0 << endl;
		return 0;
	}
	ll ret = COM(diff + 2 * rem/3, rem/3);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 47360
#include <iostream>
#include <iomanip>
#include <set>
using namespace std;

int main()
{
	int n, m;
	set<int> s;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		s.insert(a * 100 + b);
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		s.insert(a * 100 + b);
	}

	
	for (set<int>::iterator itr = s.begin(); itr != s.end(); itr++) {
		if (itr != s.begin())
			cout << " ";
		cout << *itr / 100 << ":"
			<< setw(2) << setfill('0') << *itr % 100;
	}
	cout << endl;

	return 0;
}



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

using namespace std;

#define N_MAX 200000

int N;
long long a[N_MAX];
long long sum;

void solve() {
    long long tmp = a[0];
    long long ans = abs((sum-tmp)-tmp);
    for(int i = 1; i < N-1; i++) {
        tmp += a[i];
        ans = min(abs((sum-tmp)-tmp), ans);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1792
H, W, K = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

wk = (0...(1<<(W-1))).to_a.select{|n|
  (n[0] == 0 || n[1] == 0) &&
  (n[1] == 0 || n[2] == 0) &&
  (n[2] == 0 || n[3] == 0) &&
  (n[3] == 0 || n[4] == 0) &&
  (n[4] == 0 || n[5] == 0) &&
  (n[5] == 0 || n[6] == 0)
}
t = Array.new(W-1).map.with_index{|m, i|
  wk.count{|n| n[i] == 1}
}
bef = Array.new(W, 0)
bef[0] = 1
H.times{
  nxt = Array.new(W, 0)
  bef.each_with_index{|b, i|
    l = (i==0 ? 0 : t[i-1])
    r = (i==W-1 ? 0 : t[i])
    c = wk.size - l - r
    nxt[i-1] += b*l if i>0
    nxt[i+1] += b*r if i<W-1
    nxt[i] += b*c
  }
  bef = nxt.map{|n| n % MOD}
}

puts bef[K-1]


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main()
{
	int x;
	cin>>x;
	int a=0;
	for(int i=1000;i<=x+1000;i=i+1000){
		if(i>=x)
		  a=i-x;
		else continue;
		if(a<=500)
		  break;
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,a,b,c;
  int64_t ans=10000000000000;
  cin >> a >> b >> c >> x >> y;
  for(int i=0;i<=100000;i++){
    int k=c*2*i+a*max(0,x-i)+b*max(0,y-i);
    if(k<ans)ans=k;
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 3564
#include <iostream>
int main(int argc, char *argv[]) {
	int r, g;
	std::cin >> r >> g;
	// NOTE: g = (r + s) / 2
	//       > s = 2 * g - r
	const int s = 2 * g - r;
	std::cout << s << std::endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main()
{
    input! {
        q: usize,
        p: [(usize, usize); q],
    }

    let mut accum_arr = vec![0; 100002];

    for i in 1..100002 {
        
        let t = if i%2 != 0 && is_prime(i) && is_prime((i+1)/2) { 1 } else { 0 };
        accum_arr[i] = accum_arr[i-1] + t;
    }
    for i in 0..q {
        println!("{}", accum_arr[p[i].1]-accum_arr[p[i].0-1]);
    }
}

fn is_prime(n: usize) -> bool {
    if n == 1 {
        return false;
    }
    let mut i = 2;
    while i * i <= n {
        if n % i == 0 {
            return false;
        }
        i = i + 1;
    }

    true
}

#[test]
fn test() {
    assert_eq!(is_prime(3), true);
    assert_eq!(is_prime(2), true);
    assert_eq!(is_prime(4), false);
    assert_eq!(is_prime(5), true);
}

Measured memory_bytes: 6780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main()
{
  string s;
  cin >> s;
  for (auto i = 0; i < s.size(); i++)
  {
    cout << "x";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
namespace std {
  bool operator < (const vector<int>& a, const vector<int>& b) {
    REP(i, min(a.size(), b.size())) if(a[i] != b[i]) return a[i] < b[i];
    return a.size() < b.size();
  }
}

int N;

bool isValid(vector<int> &v){
  REP(i, N) FOR(j, i + 1, N) if(v[i] < v[j]) return false;
  return true;
}

void dfs(vector<int> &v, int now, int n){
  if(n == 0){
    cout <<v[0];
    FOR(i, 1, v.size()) if(v[i] != 0) cout <<" " <<v[i];
    cout <<endl;
    return ;
  }
  REP(i, n){
    v[now] = n - i;
    if(isValid(v)) dfs(v, now + 1, i);
    v[now] = 0;
  }
}

int main() {
  while(cin >>N && N){
    vector<int> v(N, 0);
    dfs(v, 0, N);
  }
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];
  int ans=0;
  rep(i,n)rep(j,n){
    if(i==j) continue;
    ans+=d[i]*d[j];
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct node{int p,c,l,r;};
node t[100001];
long long cost[100001];
bool alr[100001]={true};
void dfs(int now,long long nowc){
	cost[now]=nowc;
	alr[now]=true;
	if(t[now].p&&alr[t[now].p]==false) dfs(t[now].p,nowc+t[now].c);
	if(t[now].l&&alr[t[now].l]==false) dfs(t[now].l,nowc+t[t[now].l].c);
	int tmp=t[now].l;
	while(t[tmp].r){
		tmp=t[tmp].r;
		if(alr[tmp]==false) dfs(tmp,nowc+t[tmp].c);
	}
}
	
int main(){
	
	int n,a,b,c;
	
	cin>>n;
	for(int i=0;i<n-1;i++){
		cin>>a>>b>>c;
		if(t[b].p)swap(a,b);
		t[b].p=a;
		if(t[a].l) t[b].r=t[a].l;
		t[a].l=b;
		t[b].c=c;
	}
	int q,k,x,y;
	cin>>q>>k;
	dfs(k,0);
	//for(int i=0;i<=n;i++) cout<<i<<":"<<cost[i]<<endl;
	for(int i=0;i<q;i++){
		cin>>x>>y;
		cout<<cost[x]+cost[y]<<endl;
	}
	return 0;
	
}

Measured memory_bytes: 7424
N, K = map(int, input().split())

if K == 0:
    print(N * N)
    exit()

ans = N * (N + 1)
for b in range(1, N + 1):
    for a_ in range(0, N + 1, b):
        ans -= min(b, K, N - a_ + 1)

print(ans)

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
const ll MAX = 1e6;
/* end defineing */

signed main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int tmp = 0;
        for (int j = 1; j <= n; j++)
        {
            if (i % j == 0)
                tmp++;
        }
        if (tmp == 8)
            cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;
int main(){
  long long int L,R;
  cin >> L >> R;
long long int cnt,min;

    min = 10000;

   for(int i = L; i < R; i++){
       cnt = 0;
      for(int j = i + 1; j <= R; j++){
          cnt = ((i % 2019) * (j % 2019)) % 2019;
          if(min > cnt) min = cnt;

          if(min == 0){ cout << '0' << endl; return 0;}
      }
   }

   cout << min << endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int vis[100080],tt[100080];
int main()
{
    memset(vis,0,sizeof(vis));
    memset(tt,0,sizeof(tt));
    int n1,m1,s1=0,s2=0;
    cin>>n1>>m1;
    for(int i=0;i<m1;i++)
    {  int a;
    string s;
        cin>>a>>s;

        if(!vis[a])
        {
            if(s=="AC")
            {vis[a]=1;
            }
            else tt[a]++;

        }



    }
    for(int i=1;i<=n1;i++)
        if(vis[i])
    {
        s1++;
        s2+=tt[i];
    }
    printf("%d %d",s1,s2);





}


Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] x = new int[n][2];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 2; j++) {
				x[i][j] = sc.nextInt();				
			}
		}
		Arrays.sort(x, (a, b) -> Integer.compare(a[0], b[0]));
		
		int ans = n-1;
		int st = 0;
		if(n == 1 || n == 2) {
			ans = 1;
		}else {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					if(i != j) {
						int tmp = 0;
						for(int k = 0; k < n; k++) {
							for(int m = 0; m < n; m++) {
								int x1 = x[j][0] - x[i][0];
								int y1 = x[j][1] - x[i][1];
								int x2 = x[m][0] - x[k][0];
								int y2 = x[m][1] - x[k][1];
								if(x1 == x2 && y1 == y2) {
									if(j != m || k != i) {
										tmp ++;
									}
								}
							}
						}
						st = Math.max(st, tmp);
					}
					
				}
			}
		}
		System.out.println(ans-st);
		sc.close();
	}


}


Measured memory_bytes: 26964
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

vector<int> A(100010,0);

ll lmin(ll x, ll y) {
	if (x < y) return x;
	else return y;
}

ll lmax(ll x, ll y) {
	if (x < y) return y;
	else return x;
}

ll zml(int n,ll l) {
	//左からn未満の配列について最大値と0のみ抽出
	vector<ll> Z(0);
	int zcnt = 0, mcnt = 0;
	for (int i = 0;i < n;i++) {
		if (A[i] == 0) {
			Z.push_back(0);
		}
		else if (A[i] == l) {
			Z.push_back(l);
			mcnt++;
		}
	}
	ll ans = 142857;
	for (int i = 0;i < Z.size();i++) {
		if (Z[i]) {
			mcnt--; //右側に最大値はmcnt個ある
	    }
		else {
			zcnt++; //左側に0はzcnt個ある
		}
		ans = lmin(ans,zcnt+mcnt); //0,maxの部分列ができてはいけない
	}
	return ans;
}

int main(){
	ll N, T, K; cin >> N >> T;
	ll mx = 0, mxx = 0,UD=0;
	ll S = 0;
	int j = 1;
	cin >> UD;
	for (int i = 1;i < N;i++) {
		cin >> K;
		if (K >= UD) {
			A[j] = K-UD;
			mx = lmax(mx, A[j]);
		}
		else {
			if (mx > mxx) {
				mxx = mx;
				S = zml(j, mx);
			}
			else if (mx == mxx)
				S += zml(j, mx);
			j = 0;
			UD = K; A[0] = 0;
			mx = 0;
		}
		j++;
	}
	if (mx > mxx)
		S = zml(j, mx);
	else if (mx == mxx)
		S += zml(j, mx);
	cout << S << endl;
}

Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (n, a, b) = (line[0], line[1], line[2]);

    println!("{}", cmp::min(b, a*n));
}


Measured memory_bytes: 4352
N=int(input())
H=list(map(int,input().split()))

inf=float('inf')
DP=[inf]*(N+1)   #DP[0]はダミー
DP[1]=0
DP[2]=abs(H[1]-H[0])

for i in range(3,N+1):
    DP[i]=min(DP[i-1]+abs(H[i-1]-H[i-2]),DP[i-2]+abs(H[i-1]-H[i-3]))

print(DP[N])

Measured memory_bytes: 13980
import sys
 
n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1-r0
mn = min(r1,r0)
 
for i in map(int,sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
    if mn > i:
        mn = i
 
print(mx)

Measured memory_bytes: 21896