akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;


int main() {
	
	string s;
	cin >> s;
	int n = s.size();
	bool fb = (s[0] == s[n - 1]);//最終段階が奇数長か？

	cout << (((n % 2 == 0) ^ fb) ? "Second" : "First") << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
 
 
int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	int c=0;
	for (int i=1;i<=n;i++)
	{
		int t;
		cin >> t;
		if (t!=i) c++;
	}
	cout << ((c<=2) ? "YES" : "NO");
	return 0;
}



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

using namespace std;

#define ldouble long double
#define llong long long int
#define print(x) cout << x << endl
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(STL) STL.begin(), STL.end()
#define stl_rep(itr, STL) for (auto itr = STL.begin(); itr != STL.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong k, a, b;
    cin >> k >> a >> b;

    llong ans;
    if (b < a + 2) {
        ans = k + 1;
    } else {
        ans = a;
        ans += ((k - a + 1) / 2) * (b - a);
        if((k - a + 1) % 2) ++ans;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
void insert(int k){  
  Node a = root;
  Node b = NIL;
  Node c;
 
  c = malloc(sizeof(struct node));
  c->key = k;
  c->left = NIL;
  c->right = NIL;
 
  while(a != NIL){
    b = a;
    if(c->key < a->key){
      a = a->left;
    }
    else a = a->right;
  }
 
  c->parent = b;
  if(b == NIL) {
    root = c;  
  }
  else if(c->key < b->key){
    b->left = c;
  }
  else b->right = c;
}
 
 
void inorder(Node n){
  if(n->left != NIL){
    inorder(n->left);
  }
  printf(" %d",n->key);
  if(n->right != NIL){
    inorder(n->right);
  }
 
}
void preorder(Node n){
  printf(" %d",n->key);
  if(n->left!= NIL){
    preorder(n->left);
  }
  if(n->right!= NIL){
    preorder(n->right);
  }
   
}
 
int main(){
  int n,i,x;
  char com[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
 

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll x;
	cin>>x;
	ll walk=0;
	for(ll i=1;i<=1000000;++i){
		walk+=i;
		if(walk>=x){
			cout<<i<<'\n';
			return 0;
		}
	}
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  time();
  return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())

k = [-1]*m
s = [-1]*m
for i in range(m):
  tmp = input().split()
  k[i] = int(tmp[0])
  s[i] = map(int, tmp[1:])
  s[i] = [si-1 for si in s[i]]

p = list(map(int, input().split()))

#print(s)

def check(switch):
  #print("sw", switch)
  tmp = [sum([1 for j,sw in enumerate(switch) if (sw==1) and (j in s[i])])%2 for i in range(m)]
  #print("tmp", tmp)
  if tmp==p:
    return 1
  else:
    return 0

def dp(switch, idx):
  count=0
  if idx==n:
    return check(switch)
  else:
    count += dp(switch+[0], idx+1)
    count += dp(switch+[1], idx+1)
    return count

switch = []
idx = 0
count = 0
count = dp(switch, idx)
print(count)

Measured memory_bytes: 3064
n = int(input())
cnt = 0
l = []
for i in range(n) :
    k = list(map(int,input().split()))
    l.append(k)

for i in range(n) :
    if set(l[i]) == {1} or set(l[i]) == {2} or set(l[i]) == {3} or set(l[i]) == {4} or set(l[i]) == {5} or set(l[i]) == {6} :
        cnt += 1
        if cnt == 3 :
            print('Yes')
            exit()
    else :
        cnt = 0
print('No')

Measured memory_bytes: 9216
#include<iostream>
#include<algorithm>
#define MAX_M 101
#define MAX_N 301
#define MAX_K 201
#define MAX_INT 1 << 28;
using namespace std;

//dx[wa][wb][XCb`(0:àz, 1:Ô)] = (waÆwbÔÌàz or Ô)
int dx[MAX_N][MAX_N][2];

//p©çqÜÅÌÅ¬àzÜ½ÍÅZÔðÔ·
int tell(int p, int q, int n, int m, int r);

int main(){
	//n = üHÌîñÌ, m = wÌ
	int n, m;
	
	//üHÌîñðüÍ
	while(cin >>n >>m){
		if(n == 0 && m == 0) break;
		
		//dx[][][]Ìú»(SÄ-1É·é)
		for(int i = 0; i < MAX_N; i++){
			for(int j = 0; j < MAX_N; j++){
				dx[i][j][0] = -1;
				dx[i][j][1] = -1;
			}
		}
		
		for(int i = 0; i < n; i++){
			
			//a = wa, b = wb, cost = wa`wbÌàz, time = wa`wbÌÔ
			int a, b, cost, time;
			
			cin >>a >>b >>cost >>time;
			dx[a][b][0] = cost;
			dx[a][b][1] = time;
		}
		
		//k = â¢í¹Ì
		int k;
		
		cin >>k;
		for(int i = 0; i < k; i++){
			
			//p = o­w, q = w, r = oÍ·élÌíÞ
			int p, q, r;
			cin >>p >>q >>r;
			
			cout <<tell(p, q, n, m, r) <<endl;
		}
	}
	return 0;
}

int tell(int p, int q, int n, int m, int r){
	
	//checkendnum[wÌÔ] = Å¬àzÜ½ÍÅZÔ(¢mèÌêÍMAX_INT)
	int checkendnum[MAX_N];
	
	//checkendi[wÌÔ] = Å¬àzÜ½ÍÅZÔªmèµ½©Ç¤©(false:¢mè, true:mè)
	bool checkendi[MAX_N] = {false};
	
	//checkendnum[1 ` MAX_N]ðMAX_INTÅú»
	for(int i = 0; i < MAX_N; i++){
		checkendnum[i] = MAX_INT;
	}
	
	//p = ¡²×Ä¢ém[h
	int node = p;
	
	//o­wÍà¤0ÅmèµÄ¢é
	checkendnum[node] = 0;
	checkendi[node] = true;
	
	//EoðÍmè³ê½m[h = q
	while(1){
		
		//SÄÌüHÌîñð²×é
		for(int i = 1; i <= m; i++){
			
			//p©çiÉs­àzÜ½ÍÔÌîñª èA»êªmèµÄ¢È¯êÎ
			if(dx[node][i][r] != -1){
				if(checkendi[i] == false){
					
					//¡ÜÅiÌm[hÉüÁÄ¢½óâÌîñÆAVµ­XV³êéûÌA¬³¢ûðóâÆ·é
					checkendnum[i] = min(checkendnum[i], (dx[node][i][r] + checkendnum[node]));
				}
			
			//àµ­ÍAp©çiÉs­àzÜ½ÍÔÌîñª èA»êªmèµÄ¢È¯êÎ
			} else if(dx[i][node][r] != -1){
				if(checkendi[i] == false){
					
					//¡ÜÅiÌm[hÉüÁÄ¢½îñÆAVµ­XV³êéûÌA¬³¢ûðóâÆ·é
					checkendnum[i] = min(checkendnum[i], (dx[i][node][r] + checkendnum[node]));
				}
			}
		}
		
		//minnum = mèµÄ¢È¢wÌÅAÅ¬ÌàzÜ½ÍÅZÌÔ, mini = minnumðÂwÌÔ
		int minnum = MAX_INT;
		int mini = -1;
		
		//SÄÌwð²×é
		for(int i = 1; i <= m; i++){
			
			//àzÜ½ÍÔªmèµÄ¨ç¸Aminnumæè¬³¢àzÜ½ÍÔðÂÈç
			if(checkendi[i] == false && checkendnum[i] < minnum){
				minnum = checkendnum[i];
				mini = i;
			}
		}
		
		//miniÌwÌàzÜ½ÍÔðmè
		checkendi[mini] = true;
		
		//Ì²×ém[hðminiÉ·é
		node = mini;
		
		//qÌÅ¬àzÜ½ÍÅZÔªmèµ½ÈçI¹(I¹ð)
		if(checkendi[q] == true){
			break;
		}
	}
	return checkendnum[q];
}

Measured memory_bytes: 1576
// 6/30 解き直し
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<string, ll> mp;
    rep(i, n) {
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }

    ll res = 0;
    for (auto p : mp) {
        res += (p.second * (p.second - 1) / 2);
    }

    cout << res << endl;
}

Measured memory_bytes: 13984
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m,tmp=0,ax=0,k,t[5000],p[5000],x[5000],res[5000];
	string str, str2[5000];
	cin >> n >> m >> k;
	if (n == 0) { cout << m / k + 1; return 0; }
	cout << m / k - (n - 1) / k;

	
}

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

int main(void) {
  int n;
  cin >> n;
  vector<bool> ds(n, false);
  for (int i = 0; i < n; ++i) {
    int t1, t2;
    cin >> t1 >> t2;
    ds[i] = t1 == t2;
  }

  for (int i = 2; i < n; ++i) {
    if (ds[i - 2] && ds[i - 1] && ds[i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

bool prime[1000003];
bool sieve() {
    memset(prime, true, sizeof(prime));
    for(int i = 2; i * i < 1000003; ++i){
        if(prime[i]){
            for(int j = 2 * i; j < 1000003; j += i){
                prime[j] = false;
            }
        }
    }
}

int main() { 
    int n;
    cin >> n;
    cout << n*n << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }

  long k = 0;
  long number = 1;
  for (long i = 0; i < n; i++) {
    if (a[i] == number) {
      k++;
      number++;
    }
  }

  long answer;
  if (k >= 1 && k <= n) {
    answer = n-k;
  } else {
    answer = -1;
  }

  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    int n1=s.size();
    int n2=t.size();
    int cnt1;
    int cnt=n1;
    for(int i=0;i<=n1-n2;i++)
    {
        cnt1=0;
        for(int j=0;j<n2;j++)
        {
            if(s[i+j]!=t[j])
            {
                cnt1++;
            }
        }
        cnt=min(cnt,cnt1);
    }
    cout<<cnt<<endl;

}


Measured memory_bytes: 3528
import sys
import itertools

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    B = list(itertools.accumulate(A, initial=0))
    s = 0
    ans = 10 ** 12
    for i in range(N - 1, 0, -1):
        s += A[i]
        ans = min(ans, abs(s - B[i]))

    return ans


print(solve())


Measured memory_bytes: 31776
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,l[N],k[N],r[N],ans;

void Solve(vector<pair<int, int>>& cams)
{
    priority_queue<int> pq;
    // int result = 0;
    int initalAns = ans;

    for(auto i : cams)
    {
        pq.push(-i.second);
        ans+=i.second;
        //we assume its left is best
        while(pq.size()>i.first)ans+=pq.top(),pq.pop();
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int testcases;
    cin >> testcases;
    while(testcases--)
    {

        cin>>n;ans=0;

        std::vector<pair<int, int>> f;
        std::vector<pair<int, int>> b;

        for(int i = 1; i <=  n; i++)
        {
            int K, L, R;
            cin >> K >> L >> R;

            if(L>R)
            {
                ans+=R;
                f.pb({K,L-R});
            }
            else{
                ans+=L;
                b.pb({n-K,R-L});
            }
        }

    // rep(i,1,n)cin>>k[i]>>l[i]>>r[i];
    // rep(i,1,n){
    //     if(l[i]>r[i]){
    //         ans+=r[i];
    //         f.pb({k[i],l[i]-r[i]});
    //     }
    //     else{
    //         ans+=l[i];
    //         b.pb({n-k[i],r[i]-l[i]});
    //     }
    // }
    sort(all(f)),sort(all(b));

    Solve(f);
    Solve(b);

        std::cout << ans << "\n";

    }

    return 0;
}


Measured memory_bytes: 8272
def distance(x, y, p):
    """returns Minkowski's distance of vactor x and y if p > 0.
    if p == 0, returns Chebyshev distance

    >>> d = distance([1, 2, 3], [2, 0, 4], 1)
    >>> print('{:.6f}'.format(d))
    4.000000
    >>> d = distance([1, 2, 3], [2, 0, 4], 2)
    >>> print('{:.6f}'.format(d))
    2.449490
    >>> d = distance([1, 2, 3], [2, 0, 4], 3)
    >>> print('{:.6f}'.format(d))
    2.154435
    >>> d = distance([1, 2, 3], [2, 0, 4], 0)
    >>> print('{:.6f}'.format(d))
    2.000000
    """
    if p == 0:
        return max([abs(a-b) for (a, b) in zip(x, y)])
    else:
        return sum([abs(a-b) ** p for (a, b) in zip(x, y)]) ** (1/p)


def run():
    dim = int(input())  # flake8: noqa

    x = [int(i) for i in input().split()]
    y = [int(j) for j in input().split()]

    print(distance(x, y, 1))
    print(distance(x, y, 2))
    print(distance(x, y, 3))
    print(distance(x, y, 0))


if __name__ == '__main__':
    run()


Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool rec(vector<int> data){
	int d=data[1]-data[0];
	for(int i=1;i<data.size();i++){
		if(data[i]-data[i-1]!=d)return false;
	}
	return true;
}
int main(){
	int n;
	while(cin>>n&&n){
		vector<int>data(n+1);
		for(int i=0;i<n+1;i++)cin>>data[i];
		for(int i=0;i<n+1;i++){
			vector<int> tmp=data;
			tmp.erase(tmp.begin()+i);
			if(rec(tmp)){
				cout<<data[i]<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, M;
    cin >> N >> M;
    vector<int> X(N);
    vector<int> cnt_mod(M), cnt(101010);
    REP(i,N){
        int x;
        cin >> x;
        cnt_mod[x%M]++;
        cnt[x]++;
    }
    int ans = 0;
    REP(i,M){
        if(i == 0 || i * 2 == M){
            ans += cnt_mod[i] / 2;
            cnt_mod[i] %= 2;
        }
        else{
            int p = min(cnt_mod[i], cnt_mod[M-i]);
            ans += p;
            cnt_mod[i] -= p, cnt_mod[M-i] -= p;
            for(int j=i;j<101010;j+=M){
                if(cnt[j] >= 2){
                    ans += min(cnt_mod[i], cnt[j]) / 2;
                    cnt_mod[i] -= min(cnt_mod[i], cnt[j]) / 2 * 2;
                }
            }
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}

Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<set>
#include<unordered_set>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1}, dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int st2[15][25];
string s[15];
signed main(void)
{
	while(true) {
		int h, w;
		cin >> h >> w;
		if(!h && !w) break;
		REP(i, h) cin >> s[i];

		unordered_set<string> st;
		string ans = "";
		FOR(dist, 2, h*w+1) REP(i, h) REP(j, w) REP(vec, 8) {
			int y = i, x = j;
			string tmp = "";
			bool flag = true;
			//st2?????????
			REP(k, h) REP(l, w) st2[k][l] = 0;
			//????????????????????§?????????????????¢?????£????????????
			REP(k, dist) {
				tmp += s[y][x];
				//cout << y << " " << x << " " << s[y][x] << endl;
				x += dx[vec];
				y += dy[vec];
				if(x < 0) x = w-1;
				else if(x >= w) x = 0;
				if(y < 0) y = h-1;
				else if(y >= h) y = 0;
				if(st2[y][x] == 1) {
					flag = false;
					break;
				}
				st2[y][x] = 1;
			}
			//if(i == 3 && j == 5 && vec == 2) cout << tmp << endl;
			//st???????????¢????????????????????¨?????????ans??????????????´??°
			if(flag) {
				if(st.find(tmp) != st.end()) {
					if(tmp.size() > ans.size() || (tmp.size() == ans.size() && tmp < ans)) {
						ans = tmp;
						//cout << i << " " << j << " " << vec << " " << ans << endl;
					}
				}
				st.insert(tmp);
			}
		}
		if(ans == "") cout << 0 << endl;
		else cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 35860
/*** akshaykumar99 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e5+1;
 
typedef int ll;
typedef long double ld;  

void test_case()
{
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll x1 = 60-m1;
    ll x2 = h2-h1-1;
    ll res = x2 * 60 + x1 + m2;
    res -= k;
    cout << res << '\n';

}

int32_t main()
{
    IOS(); 
    
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

int main(){
  char s;
  cin>>s;
  //for (int i=0;i<s.size();i++){
    //if (s.at(i)!='a'&&s.at(i)!='e'&&s.at(i)!='i'&&s.at(i)!='o'&&s.at(i)!='u'){

      //return 0;
    //}
  //}
  if (s!='a'&&s!='e'&&s!='i'&&s!='o'&&s!='u'){
    cout<<"consonant"<<endl;
  }
  else{
    cout<<"vowel"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  char kari[2];
  int count;
  
  cin >> s;
  count = s.size();
  kari[0] = s[s.size() - 1];
  
  s[2] = kari[0];
  
  cout << s[0] << s.size()-2 << s[2] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
//#define ff fi.fi
//#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cerr << ">>>>>> " << #x << " -> " << x << endl
#define nani(x) cerr <<  "Line " << __LINE__ << ": " << #x << " is " << x << endl
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e2+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 2000;

ll n,k,w[MAX],val[MAX],dp[MAX][100005];

ll f(int nw,int rem){
	if(rem<=0)return 0;
	if(nw>n)return MOD;
	if(dp[nw][rem]!=-1)return dp[nw][rem];
	return dp[nw][rem] = min(f(nw+1,rem),f(nw+1,rem-val[nw])+w[nw]);
}

int main(){
//	cout<<fixed<<setprecision(4);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    rep(i,1,n)cin>>w[i]>>val[i];
    memset(dp,-1,sizeof dp);
    rep(i,0,100001)if(f(1,i)>k)return cout<<i-1<<endl,0;
    return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int maxtime(int x) {
	return (x + 9) / 10 * 10;
}

int remtime(int x) {
	return maxtime(x) - x;
}

int main() {
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
	sum -= max({ remtime(A), remtime(B), remtime(C), remtime(D), remtime(E) });
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.util.Scanner;
import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner in=new Scanner(System.in);
	    int a=in.nextInt();
	    int b=in.nextInt();
	    System.out.println(a*b-a-b+1);
		// your code goes here
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int visited[200001];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<int> v[n+1];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    int ans=0;
    for(int i=2;i<n;i++){
        int a=0,b=0;
        for(int j=0;j<v[i].size();j++){
            if(v[i][j]==1){
                a=1;
            }
            if(v[i][j]==n){
                b=1;
            }

        }
        if(a==1 && b==1){
            ans=1;
            break;
        }
    }
    if(ans==1){
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


Measured memory_bytes: 12016
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let l: Vec<u32> = (0..n).map(|_| read()).collect();

    let mut m = 0;
    let mut s = 0;
    for i in l {
        m = max(m, i);
        s += i;
    }
    if m < s - m {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
alist = []
blist = []
for i in range(4):
    a = int(input())
    alist.append(a)
for i in range (2):
    b = int(input())
    blist.append(b)
alist.sort()
blist.sort()
print(alist[1]+alist[2]+alist[3]+blist[1])


Measured memory_bytes: 5596
S = str(input())
count = 0
x = len(S)
if x%2 == 0:
  for i in range(int(x/2)):
    if S[i] != S[-(i+1)]:
      count += 1
else:
  for i in range(int((x-1)/2)):
    if S[i] != S[-(i+1)]:
      count += 1
print(count)

Measured memory_bytes: 3060
S=input()
K=int(input())
c2i=lambda c: ord(c)-ord("a")
i2c=lambda i: chr(i+ord("a"))
A=list(map(c2i, S))
for i in range(len(A)):
    if A[i] and 26-A[i]<=K:
        K-=26-A[i]
        A[i]=0
A[-1]+=K
A[-1]%=26
print("".join(map(i2c,A)))

Measured memory_bytes: 4980
#[allow(non_snake_case)]
fn main() {
    proconio::input! {
        W: usize,
        H: usize,
        M: usize,
        B: [(usize, usize); M],
    }

    let mut xmax = 0;
    let mut ymax = 0;
    let mut xs = vec![0; W + 1];
    let mut ys = vec![0; H + 1];

    for b in &B {
        xs[b.0] += 1;
        ys[b.1] += 1;
        xmax = std::cmp::max(xmax, xs[b.0]);
        ymax = std::cmp::max(ymax, ys[b.1]);
    }

    let xn = xs.iter().filter(|&&n| n == xmax).count();
    let yn = ys.iter().filter(|&&n| n == ymax).count();
    let bn = B.iter().filter(|&b| xs[b.0] == xmax && ys[b.1] == ymax).count();

    println!("{}", xmax + ymax - (if xn * yn == bn { 1 } else { 0 }));
}

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

bool is_zero(double f){
	return f < 0.000000001 && f > -0.000000001;
}

int main(){
	double xa,ya,xb,yb,xc,yc,xd,yd;
	while(cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd){
		double yab = ya - yb;
		double xab = xa - xb;
		double ycd = yc - yd;
		double xcd = xc - xd;
		if(is_zero(xab)){
			if(is_zero(ycd)){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
			continue;
		}
		if(is_zero(xcd)){
			if(is_zero(yab)){
				cout << "YES" << endl;
			}
			else{
				cout << "NO" << endl;
			}
			continue;
		}
		double p = yab / xab;
		double q = ycd / xcd;
		if(p*q < -0.999999999 && p*q > -1.000000001){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i,n) { cin >> p[i]; p[i]--; }
  rep(i,n) cin >> c[i];

  vector< vector<int> > a;
  vector<bool> used(n);
  rep(i,n) {
    if (used[i]) continue;
    vector<int> tmp;
    int j = i;
    while (!used[j]) {
      tmp.push_back(c[p[j]]);
      used[j] = true;
      j = p[j];
    }
    a.push_back(tmp);
  }

  ll ans = -INF;
  for (auto e : a) {
    int n = e.size();
    ll sum = 0;
    rep(i,n) sum += e[i];

    ll ta = -INF;
    ll sum2;
    rep(i,n) {
      if (sum <= 0) {
        sum2 = 0;
        int nk = min(n,k);
        rep(j,nk) {
          sum2 += e[(i+j)%n];
          ta = max(ta, sum2);
        }
      } else {
        int nk = k;
        sum2 = sum*(nk/n);
        nk %= n;
        rep(j,nk) sum2 += e[(i+j)%n];
        ta = max(ta,sum2);
        rep(j,n) {
          sum2 -= e[(i+(nk-1)-j+n)%n];
          ta = max(ta,sum2);
        }
      }
    }
    ans = max(ans, ta);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3680
#include<cstdio>
#include<vector>
using namespace std;
const int INF=1e9+7;
const int N=100005;
int n;
vector<int>G[N];
int Dfs(int u,int fa) {
	int ret=1;
	for(int i=0;i<G[u].size();i++) {
		int v=G[u][i];
		if(v==fa) continue;
		ret+=Dfs(v,u);
	}
	if(ret<1||ret>=3) return -INF;
	return ret%2;
}
int main() {
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++) {
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(Dfs(1,1)!=0)
		printf("First\n");
	else printf("Second\n");
	return 0; 
}

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  //  free(t);                                                                  
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  //for ( i = 0; i < n; i++ ){                                                  
  i=0;
  while(i<n){
    i++;
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        delete(key); nd++;
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }


  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
printList();


  return 0;
}





Measured memory_bytes: 36076
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

	int n;
	cin >> n;
	vector<int> v;
	
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	ans = v.back() - v.front();


	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
N, M = map(int, input().split())
A_list = sorted( list( int(i) for i in input().split() ))
BC_list = sorted(
  list( list( int(i) for i in input().split() ) for _ in range(M) ),
  key=lambda x:-x[1]
)

change_list = []
for bc in BC_list:
  change_list += [bc[1]] *  bc[0]
  if len(change_list) >= N :
    break
A_list += change_list
A_list.sort()
L = len(A_list)
print(sum(A_list[L:L-N-1:-1]))

Measured memory_bytes: 37336
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector<ll> pos, neg;
ll n;
ll cal(ll x){
	ll ans=0;
	if(x>=0){
		ans=((ll)(pos.size())) * ((ll)(neg.size()));
		ll p=0;
		for(ll i=((ll)(pos.size()))-1; i>=0; --i){
			for(p;p<i;++p){
				if(pos[p]*pos[i]>x){
					break;
				}
			}
			ans+=min(p, i);
		}
		p=0;
		for(ll i=((ll)(neg.size()))-1; i>=0; --i){
			for(p;p<i;++p){
				if(neg[p]*neg[i]>x){
					break;
				}
			}
			ans+=min(p, i);
		}
	}
	else{
		ll sz=neg.size(), p;
		p=sz-1;
		for(ll i=0; i<pos.size(); ++i){
			for(p;p>=0;--p){
				if(neg[p]*pos[i]>x)
					break;
			}
			ans+=sz-1-p;
		}
	}
	return ans;
}
int main(){
    ll k;
    while(cin>>n>>k){
        ll ans=0;
        ll x;
        pos.clear();
        neg.clear();
        for(ll i=0; i<n; ++i){
            scanf("%lld",&x);
            if(x>=0){
            	pos.push_back(x);
            }
            else{
            	neg.push_back(x);
            }
        }
        sort(pos.begin(), pos.end());
        sort(neg.begin(), neg.end());
        reverse(neg.begin(), neg.end());
        ll st=-1e18, nd=1e18, md;
        st-=10;
        nd+=10;
        while(st<nd){
        	md=st+(nd-st+1)/2;
        	// cout<<st<<" "<<nd<<" "<<md<<" "<<cal(md)<<endl;
        	if(cal(md)<=k-1){
        		st=md;
        	}
        	else{
        		nd=md-1;
        	}
        }
        ans=st+1;
        // assert(cal(ans)==k);
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  string s;
  while (cin >> s){
    bool A = false,B = false,C = false;
    REP(i,3){
      if(s[i] == 'a') A = true;
      if(s[i] == 'b') B = true;
      if(s[i] == 'c') C = true;
    }
    if(A && B && C)cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt=1;
    rep2(i, 1, n){
        if(s[i-1]!=s[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	string S;
	cin>>S;
	map<char,int> A;
	fx(S.size()){
		if(A[S.at(x)]==1){
			ce("no")
			return 0;
		}else{
			A[S.at(x)]=1;
		}
	}
	ce("yes")
	
}

Measured memory_bytes: 256
import math
n=int(input())

def f(x,y):
    return len(str(max(x,y)))
ans=len(str(n))
for i in range(2,int(math.sqrt(n))+1):
    if (n%i==0) and (ans>f(i,n//i)):
        ans=f(i,n//i)
print(ans)

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

int main(){
  int v[3][51];
  int dp[3][51];
  int g,tmp;

  for(int i=0;i<3;i++){
    for(int j=0;j<51;j++){
      v[i][j] = 10000;
      dp[i][j] = 10000;
    }
  }

  for(int i=0;i<51;i++){
    if(!(i%2)){
      tmp = i/2;
      dp[0][i] = (tmp/5) * 1520 + (tmp%5) * 380;
    }
    if(!(i%3)){
      tmp = i/3;
      v[1][i] = (tmp/4) * 1870 + (tmp%4) * 550;
    }
    if(!(i%5)){
      tmp = i/5;
      v[2][i] = (tmp/3) * 2244 + (tmp%3) * 850;
    }
  }

  for(int i=1;i<3;i++){
    for(int j=0;j<51;j++){
      for(int k=0;k<=j;k++)dp[i][j] = min(dp[i][j],dp[i-1][j-k] + v[i][k]);
    }
  }

  while(1){
    cin >> g;
    if(!g)break;
    cout << dp[2][g/100] << endl;
  }
}

Measured memory_bytes: 0
N = int(input())
As = list(map(int, input().split()))

money = 1000
for i in range(1, N):
    if As[i] > As[i-1]:
        n = money // As[i-1]
        money = money - (As[i-1] * n) + (As[i] * n)
print(money)


Measured memory_bytes: 9196
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define mx 200007
using namespace std;
typedef long long int LL;
int main() {
	ios_base::sync_with_stdio(false);
	int ans = 0;
	string str;
	cin >> str;
	int len = str.length() / 2, tmp = str.length();
	for(int i = 0, j = tmp - 1; i < len; i++, j--) {
		if(str[i] != str[j]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int sx, sy, tx, ty; 
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    string ret = "";
    rep(i, dy) ret += "U";
    rep(i, dx) ret += "R";
    rep(i, dy) ret += "D";
    rep(i, dx) ret += "L";
    ret += "L";
    rep(i, dy+1) ret += "U";
    rep(i, dx+1) ret += "R";
    ret += "D";
    ret += "R";
    rep(i, dy+1) ret += "D";
    rep(i, dx+1) ret += "L";
    ret += "U";
    cout << ret << endl;
    return 0;
}

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

int main(void){

    int N,M,C; cin>>N>>M>>C;

    vector<int> B(M);
    for (int i = 0; i < M; ++i) {
        cin>>B[i];
    }

    int ans=0,sum=0;
    for (int i = 0; i < N; ++i) {
        sum = 0;
        for (int j = 0; j < M; ++j) {
            int tmp; cin>>tmp;
            sum += tmp*B[j];
        }
        sum += C;
        if(sum>0) ans++;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;

double N;
vector<pair<double, double>> P;

double fact(double x){
    double ans = x;
    if(x==0) return 1;
    for(double i = 1; x-i > 0; ++i) ans *= (x-i);
    return ans;
}

double distance(pair<double, double> x1, pair<double, double> x2){
    return sqrt((x1.first - x2.first)*(x1.first - x2.first) + (x1.second - x2.second)*(x1.second - x2.second));
}

double solve(){
    double sumOfDistance = 0;
    for(double p1 = 0; p1 < N; ++p1){
        for(double p2 = p1+1; p2 < N; ++p2){
            sumOfDistance += distance(P[p1], P[p2]) * fact(N-1) * 2;
        }
    }
    //cout << sumOfDistance << endl;
    return sumOfDistance / fact(N);
}

int main(){
    cin >> N;
    P.resize(N);
    for(auto& p: P) cin >> p.first >> p.second;
    cout << std::setprecision(16) << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int i, j;
	int x[10000];
	int y[10000];

	
	for (i = 0;; i++) {
			scanf("%d %d", &x[i],&y[i]);
			if (x[i] == 0&&y[i]==0)
				break;
	}
	for (j = 0;i>0; j++,i--) {
		if (x[j] > y[j]) {
			int temp = x[j];
			x[j] = y[j];
			y[j] = temp;
		}
		printf("%d %d\n", x[j], y[j]);
	}

	return 0;
}

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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long n;
  long long a[200000]={};
  long long i,j,k;
  long long res=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  
  
  sort(a,a+n);

  
  k=n/2;
  j=n%2;
  
  if(j==1){
    res=a[n-1];
    for(i=1;i<=k;i++){
      res=res+2*a[n-i-1];
    }
    res=res-a[n-k-1];
  }
  else{
    res=a[n-1];
    for(i=1;i<k;i++){
      res=res+2*a[n-i-1];
    }
  }
  
  if(n==2){
    res=a[1];
  }
  
  cout<<res<<endl;
  return 0;
  
}    


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF (int)1e9
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int l,r;
	cin>>l>>r;
	
	int a,b,c,d;
	a=l%2019;
	b=l/2019;
	c=r%2019;
	d=r/2019;
	
	int ans=INF;
	if(b==d){
		for(int i=a;i<c;++i){
			for(int j=i+1;j<=c;++j){
				ans=min(ans,(i*j)%2019);
			}
		}
		
		cout<<ans<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))
E = [(1+p[i])/2 for i in range(N)]
S = [0]
for i in range(0,N):
  S.append(S[i]+E[i])

maxnum = 0
for i in range(N+1):
  if i+K >= N+1:
    break
  maxnum = max(S[i+K]-S[i], maxnum)
print(maxnum)

Measured memory_bytes: 25060
memo = set([])
def f(a):
    global ans
    ans += eval('+'.join(a))
    n = len(a)
    for i in range(n-1):
        b = a[:i] + [a[i]+a[i+1]] + (a[i+2:] if i != n-2 else [])
        s = '+'.join(b)
        if not s in memo:
            memo.add(s)
            f(b)
l = list(input())
ans = 0
f(l)
print(ans)

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

int main(){
    int a,b;
    cin>>a>>b;
    if(a==1 && b!=1){
        cout<<"Alice"<<endl;
        return 0;
    }
    if(b==1 && a!=1){
        cout<<"Bob"<<endl;
        return 0;
    }
    if(a>b)cout<<"Alice"<<endl;
    else if(a<b)cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
#define MAXN 1001
#define ll long long
ll A, B, N;
int main()
{
	scanf("%lld%lld%lld",&A,&B,&N);
	ll X = min(N, B-1ll);
	ll ans = A*X/B - A*(X/B);
	cout<<ans<<endl;
	
	return 0;
}

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

using namespace std;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn 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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

    
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define sort(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> p;

int main(){
	int x,a,b;
	cin >>x>>a>>b;
	//x ha syozikin
	x -=a;
	while(x>=b){
		x -=b;
	  }
	  cout<<x<<endl;
	  
	  
}

Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m, k := nextInt(), nextInt(), nextInt()
	for x := 0; x <= m; x++ {
		for y := 0; y <= n; y++ {
			if x*n+y*m-2*x*y == k {
				puts("Yes")
				return
			}
		}
	}

	puts("No")
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

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

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640