akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int a[3];
    int tmp;
    
    for(int i=0; i<3; i++) cin >> a[i];
    for(int i=0; i<3; i++){
        if(a[0] > a[1]){
            tmp = a[0];
            a[0] = a[1];
            a[1] = tmp;
        }else if(a[1] > a[2]){
            tmp = a[1];
            a[1] = a[2];
            a[2] = tmp;
        }
    }

    cout << a[0] << " " << a[1] << " " << a[2] << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
 
int main() {
	int time[6], i, sum,rest[6],tmp;
	tmp = 10;
	sum = 0;
	for (i = 1;i < 6;i++) {
		scanf("%d", &time[i]);
		rest[i] = time[i] % 10;
		if (rest[i] != 0) {
			time[i] += 10;
			if (tmp > rest[i])
				tmp = rest[i];
		};
		sum += time[i]-rest[i];
	}
	sum += tmp-10;
	printf("%d\n", sum);
	return 0;
}

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

int main(){
    int a, b, t, count;
    cin >> a >> b >> t;
    count = 0;

    for (int i = 1; ; i++){
        if(a * i <= t){
            count += b;
        }
        else if (a * i > t) break;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

const lines = input.split('\n')
let N = lines[0] - 0
let A = lines[1].split(' ').map(Number)

let max = A[0]
let sum = 0
for (let i = 1; i < N; i++) {
    if (max < A[i]) {
        max = A[i]
    } else if (max > A[i]) {
        sum += max - A[i]
    }
}
console.log(sum)

Measured memory_bytes: 50648
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int C[4];

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

    int A,B;
    cin>>A>>B;
    C[A]++;
    C[B]++;
    for(int i=1;i<=3;i++){
        if(C[i]==0) cout<<i<<endl;
    }
}


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

namespace Atcoder_0404
{
    class Program
    {

        static void Main(string[] args)
        {
            long _memberCount=GetInput_long()[0];
            var _numbers = GetInput_long();
            int[] nuberCount = new int[_memberCount];
            foreach(var num in _numbers)
            {
                nuberCount[num - 1]++;
            }
            for(long i = 0; i < _memberCount; i++)
            {
                Console.Write(nuberCount[i]);
                if (i != _memberCount)
                {
                    Console.Write('\n');
                }
            }
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
    }
}

Measured memory_bytes: 43704
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAXN 1000001
void solve(){
set<string>s;
string x;
ll n;
cin>>n;
while(n--)
{
	cin>>x;
	s.insert(x);
}
cout<<s.size()<<endl;
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
} 


Measured memory_bytes: 19248
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<set<int>> S(10);
	rep(i, n) S[s[i] - '0'].insert(i+1);
	int ans = 0;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
              if(S[i].size()&&S[j].size()&&S[k].size()){
				int a = *begin(S[i]);
				int c = *rbegin(S[k]);
				auto ite = lower_bound(S[j].begin(), S[j].end(), a + 1);
				if (a!=0&&c!=0&&ite!=S[j].end()&&*ite<c) ans++;
              }
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1664
use std::io;


fn main() {
    let _ = read_one::<usize>();
    let ln = read::<usize>();
    let max = ln.iter().max().unwrap();
    let sum = ln.iter().sum::<usize>() - max;
    if max < &sum {
        println!("Yes");
    } else {
        println!("No");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a,const void *b)
{
  return *(int*)a-*(int*)b;
}
int prime(int n)
{
  int i;
  int res=0;
  for(i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(i%7==1 || i%7==6)
      {
        res++;
        break;
      }
      if((n/i)%7==1 || (n/i)%7==6)
      {
        res++;
        break;
      }
    }
  }
  if(res==0)
    return 1;
  else
    return 0;
}
int main()
{
  int n;
  int i;
  int ans[1000000];
  int l;
  for(;;)
  {
    scanf("%d",&n);
    if(n==1)
      break;
    l=0;
    for(i=2;i<=sqrt(n);i++)
    {
      if(n%i==0)
      {
        if(i%7==1 || i%7==6)
        {
          if(prime(i)==1)
          {
            ans[l]=i;
            l++;
          }
        }
        if(i*i!=n)
        {
          if((n/i)%7==1 || (n/i)%7==6)
          {
            if(prime(n/i)==1)
            {
              ans[l]=n/i;
              l++;
            }
          }
        }
      }
    }
    if(n%7==1 || n%7==6)
    {
      if(prime(n)==1)
      {
        ans[l]=n;
        l++;
      }
    }
    qsort(ans,l,sizeof(int),asc);
    printf("%d:",n);
    for(i=0;i<l;i++)
      printf(" %d",ans[i]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int n; cin >> n;
	vector<Int> a(n),b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	b = a;
	sort(a.begin(), a.end(), greater<Int>());
	//a.erase(unique(a.begin(), a.end()), a.end());

	Int width=0,height=0;
	Int counts;

	for (int i = 0; i < a.size()-1; i++) {
		if (a[i] == a[i + 1]) {
			height = width;
			width = a[i];
			i++;
		}
		if (width != 0 && height != 0) break;
	}

	cout << (Int)width * height;

	cout << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    ll d, res = 13;
    REP(i, n) cin >> a[i];
    VSORT(a);
    vll v;
    REP(i, n){
        d = a[i];
        res = min(res, d);
        ll tmp;
        REP(j, i){
            if((j % 2) ^ (i % 2) == 0) tmp = min(abs(d - v[j]), 24 - abs(d - v[j]));
            else tmp = min(d + v[j], 24 - (d + v[j]));
            res = min(res, tmp);
        }
        v.push_back(d);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n;
  int *A;
  int x;
  int i,j;
  int p;
  int r;
  int change;

  
  scanf("%d",&n);
  A=(int *)malloc((n+1)*sizeof(int));

  for(i=1;i<=n;i++)scanf("%d",&A[i]);
  r=n;
  x=A[r];
  p=1;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      change=A[i];
      A[i]=A[j];
      A[j]=change;
    }
  }
  change=A[i+1];
  A[i+1]=A[r];
  A[r]=change;

  for(j=1;j<i+1;j++)printf("%d ",A[j]);
  printf("[%d] ",A[j]);
  for(j=j+1;j<n;j++)printf("%d ",A[j]);
  printf("%d\n",A[j]);
  return 0;
}


  



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 30;
struct BinaryTree
{
    int parent = -1, sibling;
    int degree = 0, left, right;
    int depth, height;
};
vector<BinaryTree> T(MAX_N);
void SetDepth(int u, int d)
{
    T[u].depth = d;
    if(T[u].left != -1) SetDepth(T[u].left, d + 1);
    if(T[u].right != -1) SetDepth(T[u].right, d + 1);
}
int SetHeight(int u)
{
    T[u].height = max(T[u].left == -1 ? 0 : SetHeight(T[u].left), T[u].right == -1 ? 0 : SetHeight(T[u].right));
    return T[u].height + 1;
}
int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        int node, l, r;
        cin >> node >> l >> r;
        T[node].left = l;
        T[node].right = r;
        T[l].parent = node, T[r].parent = node;
        T[l].sibling = r, T[r].sibling = l;
        if(l != -1) T[node].degree++;
        if(r != -1) T[node].degree++;
    }
    int root = -1;
    for(int node = 0; node < n; node++) if(T[node].parent == -1) root = node, T[node].sibling = -1;
    SetDepth(root, 0);
    SetHeight(root);
    for(int node = 0; node < n; node++)
    {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", node, T[node].parent, T[node].sibling, T[node].degree, T[node].depth, T[node].height); 
        if(T[node].parent == -1) cout << "root";
        else if(T[node].degree != 0) cout << "internal node";
        else cout << "leaf";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;


int main()
{
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'o')
			count++;
	}
	cout << 700 + count * 100 << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int inf = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int mi = inf;
	int ma = -inf;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a < mi) mi = a;
		if(a > ma) ma = a;
	}
	cout << ma - mi << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        String s = in.next();
        String ans = "";
        for (char ch : s.toCharArray()) {
            int offset = ch - 'A';
            offset += n;
            offset %= 26;
            ans += String.valueOf((char) ('A' + offset));
        }
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 145492
# -*- coding: utf-8 -*-
import sys

def incrementCheck(t, x, y):
    t=abs(t)
    x=abs(x)
    y=abs(y)
    
    for i in range(t,-1,-2):
        if y == -1*x + i:
            return True
    
    return False

#----------
n = int(input().strip())
nums = [ list(map(int, input().rstrip().split())) for _ in range(n)]

for i,current in enumerate(nums):
    if i == 0:
        increment=current
    else:
        increment=[nums[i][0]-nums[i-1][0],
                   nums[i][1]-nums[i-1][1],
                   nums[i][2]-nums[i-1][2]]

    if incrementCheck(increment[0],increment[1],increment[2]):
        continue
    else:
        print("No")
        sys.exit()
        
print("Yes")


Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  auto chk = [&](const V<lint>& a) {
    for (auto&& i : a) if (i >= n) return false;
    return true;
  };
  if (*max_element(a.begin(), a.end()) < 2 * (n + 1) * (n + 1)) {
    int res = 0;
    while (!chk(a)) {
      *max_element(a.begin(), a.end()) -= n + 1;
      for (auto&& i : a) i++;
      res++;
    }
    cout << res << '\n';
  } else {
    V<lint> b(n); for (int i = 0; i < n; i++) b[i] = a[i] % (n + 1) + (n + 1) * (n + 1);
    lint res = accumulate(a.begin(), a.end(), 0LL) - accumulate(b.begin(), b.end(), 0LL);
    while (!chk(b)) {
      (*max_element(b.begin(), b.end())) -= n + 1;
      for (auto&& i : b) i++;
      res++;
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  int n;
  std::cin >> n;
  std::vector<ll> a(n);
  rep(i,n)std::cin >> a[i];
  std::deque<int> d;
  rep(i,n){
    if(pow(-1,i)==-1)d.pf(a[i]);
    else d.pb(a[i]);
  }
  rep(i,n){
    if(pow(-1,n)==1){
      std::cout << d[i] << " ";
    }
    else std::cout << d[n-1-i] << " ";
  }
  std::cout  << std::endl;
}

Measured memory_bytes: 4608
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length ; i ++){
        a[i] = sc.nextInt();
    }
        for (int i = n - 1; i > 0; i--)
            System.out.printf("%d ", a[i]);
        System.out.println(a[0]);
        sc.close();
    }
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;

    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  bool flag=true;
  while(flag){
    S.erase(S.length()-2);
    if(S.substr(S.length()/2)==S.substr(0,S.length()/2)){
      cout<<S.length()<<endl;
      flag=false;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2:
        return False
    # 2は素数
    elif num == 2:
        return True
    # 偶数は素数ではない
    elif num % 2 == 0:
        return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = set()
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.add(i)

    # 素数配列を返す
    return numbers

# 関数の呼び出し
# print(callIsPrime(10**5))

sosuu = callIsPrime(10**5)
count_dic = {}
count = 0
for i in range(1, 10**5, 2):
    if i in sosuu and (i+1)//2 in sosuu:
        count += 1
    count_dic[i] = count
# print(count_dic)

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    # if r == l:
    #     print(count_dic[r]-count_dic[l]+1)
    # else:
    print(count_dic[r] - count_dic[max(l-2, 1)])

Measured memory_bytes: 56028
S = input()

yyyy = int(S[:4])
mm = int(S[5:7])
dd = int(S[8:10])

if yyyy < 2019:
    print('Heisei')
elif yyyy == 2019:
    if mm <= 4:
        print('Heisei')
    else:
        print('TBD')
else:
    print('TBD')

Measured memory_bytes: 3060
X,K,D=map(int,input().split())
X=abs(X)
Y=abs(X-K*D)


n=X//D
if n<=K:
	if (K-n)%2==0:
		a=X%D
		b=abs(a-2*D)
	else:
		a=X%D+D
		b=abs(X%D-D)
else:
	a=X
	b=Y
print(min(a,b))


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

#define ll long long int
const ll prime1=129;
const ll prime2=131;

const ll mod1=1e9+7;
const ll mod2=1e9+9;

const ll sz=5e3+100;
ll sum[2][sz];
ll pr[2][sz];

ll len;
string str;

void Hash()
{
    ll i,j,k;
    sum[0][0]=sum[1][0]=0;
    for(i=1;i<=len;i++){
        sum[0][i]=((sum[0][i-1]*prime1) + (str[i-1]-'a'))%mod1;
        sum[1][i]=((sum[1][i-1]*prime2) + (str[i-1]-'a'))%mod2;
    }

    pr[0][0]=pr[1][0]=1;
    for(i=1;i<sz;i++) {
        pr[0][i]=(pr[0][i-1]*prime1)%mod1;
        pr[1][i]=(pr[1][i-1]*prime2)%mod2;
    }
}

bool check(ll l,ll r,ll p)
{
    ll i,j,k,q,x,y,pp;
    x=(((sum[0][l+p-1]-sum[0][l-1]*pr[0][p])%mod1)+mod1)%mod1;
    y=(((sum[1][l+p-1]-sum[1][l-1]*pr[1][p])%mod2)+mod2)%mod2;

    pp=(((sum[0][r+p-1]-sum[0][r-1]*pr[0][p])%mod1)+mod1)%mod1;
    q=(((sum[1][r+p-1]-sum[1][r-1]*pr[1][p])%mod2)+mod2)%mod2;

    if(x==pp && y==q) return true;
    else return false;
}

int main()
{
    ll x,p,q,i,j,k,m,l,r;
    cin>>len>>str;

    Hash();
    ll mx=0;

    for(i=1;i<=len;i++){
        for(j=i+1;j<=len;j++){
            l=1,r=min((j-i),len-j+1);
            while(l<=r){
                ll mid=(l+r)/2ll;
                if(check(i,j,mid)) mx=max(mx, mid), l=mid+1;
                else r=mid-1;
            }
        }
    }

    cout<<mx<<'\n';
}

///  file:///E:/ATcodeR(D,E,F)/E%20-%20Who%20Says%20a%20Pun_.pdf


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
typedef long long ll;

using namespace std;

template <typename T>
T gcd(T a, T b){
    if (a%b == 0){
	return b;
    } else {
	return gcd(b, a%b);
    }
}

template <typename T>
T lcm(T a, T b){
    return a/gcd(a, b)*b;
}

int main(){
    ll N;
    cin >> N;
    ll T[110];
    for (size_t i = 0; i < N; i++){
	cin >> T[i];
    }

    ll res = T[0];
    for (size_t i = 1; i < N; i++){
	res = lcm(res, T[i]);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
/**********************************************
*   UPDATE CONDITION & OVERFLOW CONDITION     *
**********************************************/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    int n, k;
    cin >> n >> k;
    int x;
    vi a(101);
    while(k--)
    {
        cin >> x;
        while(x--)
        {
            int p;
            cin >> p;
            a[p]++;
        }
    }
    int ans = 0;
    f(i,1,n+1)
    {
        if(a[i] == 0)
            ans++;
    }
    cout << ans;
}



Measured memory_bytes: 3660
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n, k; cin >> n >> k;
    ll r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    ll res = 0;
    vector<char> prev;
    REP(i, n) {
        char hand = t[i];
        if (i < k) {
            if (hand == 'r') {
                res += p;
                prev.push_back('p');
            } else if (hand == 's') {
                res += r;
                prev.push_back('r');
            } else {
                res += s;
                prev.push_back('s');
            }
        } else {
            if (hand == 'r') {
                if (prev[i-k] != 'p') {
                    res += p;
                    prev.push_back('p');
                } else {
                    if ((i+k < n) && (t[i+k] == 's')) {
                        prev.push_back('s');
                    } else {
                        prev.push_back('r');
                    }
                }
            } else if (hand == 's') {
                if (prev[i-k] != 'r') {
                    res += r;
                    prev.push_back('r');
                } else {
                    if ((i+k < n) && (t[i+k] == 'p')) {
                        prev.push_back('p');
                    } else {
                        prev.push_back('s');
                    }
                }
            } else if (hand == 'p') {
                if (prev[i-k] != 's') {
                    res += s;
                    prev.push_back('s');
                } else {
                    if ((i+k < n) && (t[i+k] == 'r')) {
                        prev.push_back('r');
                    } else {
                        prev.push_back('p');
                    }
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){
    string s,p;
    cin >> s >> p;
    
    s += s;
    int pos = s.find(p);
    if(pos == string::npos) {
        cout << "No" << endl;
    }else {
        cout << "Yes" << endl;
    }
}


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

n = int(input())
lst_str = input().split()
lst = []
for elem in lst_str:
    lst.append(int(elem))
lst.sort()

max_ = int(lst[-1])
for elem in lst[0:-1]:
    max_ = max_ - int(elem)
if max_ < 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int N;  cin >> N;
  ll power = 1;
  rep(i, 1, N+1){
    power *= i;
    power = power % MAX;
  }
  cout << power << endl;
}

Measured memory_bytes: 256
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	mod int = 1e9 + 7
)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	N := getInt()
	K := getInt()

	cnt := 0
	for i := 0; i < N; i++ {
		h := getInt()
		if h >= K {
			cnt++
		}
	}

	fmt.Println(cnt)
}

func getInt() int {
	sc.Scan()
	str := sc.Text()
	value, _ := strconv.Atoi(str)
	return value
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 896
#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: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)){
    cout<<"Yes"<<endl;
  }
     else{
       cout<<"No"<<endl;
     }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int c = 1;
	int an = 0;
	rep(i, n) {
		if (a[i] == c) {
			c++;
		}
	}
	if (c == 1) {
		cout << -1;
	}
	else {
		cout << n - c + 1;
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100

int main(void)
{
	int n, a[MAX], i = 0;
	do {
		cin >> n;
	} while (n > MAX || n < 0);

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

	while (1) {
		printf("%d", a[n - i - 1]);
		if (i++ == n - 1) break;
		printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int a, b, c, x, y, ans = INF;
  cin >> a >> b >> c >> x >> y;

  REP(i, 100001) {
    ans = min(ans, 2 * c * i + max(0, x - i) * a + max(0, y - i) * b);
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 120
#define INF 0x3f3f3f3f
#define MAX 10000
using namespace std;

int main()
{
    cin.sync_with_stdio(false);
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    string a;
    for(int i=1;i<=n;i++)
        {cin>>a;
        if(a=="AC") ac++;
        if(a=="WA") wa++;
        if(a=="TLE") tle++;
        if(a=="RE") re++;}
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


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

stack <int> st;
string s;

int main(){
    int ans=0;
    cin>>s;
    for(int i=0;i<s.length();++i){
        int now=s[i]-'0';
        if(!st.empty()&&st.top()^now)    st.pop(),ans+=2;
        else st.push(now);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#pragma GCC optimize("Ofast")
	#pragma GCC target("avx,avx2,fma")
	#pragma GCC optimization ("unroll-loops")
	
    #include<bits/stdc++.h>
    using namespace std;
	
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define ff first
    #define ss second
    #define null NULL
    #define MAX 1000000000  // 1x10^9
    #define all(c) (c).begin(),(c).end()
    #define eb emplace_back
    #define pb push_back
    #define pf push_front
    #define lb lower_bound   //used for sortted 
    #define ub upper_bound 
    #define m_p make_pair      
    #define mod 1000000007
    #define For(i,n) for(int i=(0);i<(n);++i)
    #define FOR(i,a,b) for(int i=(a);i<=(b);++i)
	#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
    #define in(s3) inserter((s3), (s3).begin())  //	set_union(all(s1),all(s2),in(s3));
    typedef vector<ll> vl;
    typedef vector< vl > vvl;
    typedef pair< ll,ll> pll;
    typedef map< ll,ll> mll;
    
    //  A-65 Z-90 a-97 z-122   A-a = 32   Z-A = z-a = 35
    //	v.push_back(make_pair(min(2 * k[i], l[i]) - min(k[i], l[i]), i));      //int pos = v[i].second;
    //	floor(log10(no) + 1);                   //	to_string(no).length();             ----- length of a number
	//  llabs - long long of abs
	//  labs -long of abs
	//  sqrtf - sq root of float
	//  sqrtl - sq of long double    ( cout << fixed << setprecision(12) << sqrtl(val2) << endl; )
	//  it = find (all(vec), e);     if(it != vec.end());       it - vec.begin();
   	//	size_t found = str.find(str1);    if(found != string::npos); 	 cout<<found;
    	 
	/*	
		1. ^ is XOR and is used to to check odd occurance of number as a number XORed with itself results in zero so all even	occurrances result in zero.
		2.   & is used to check even or odd. (x & 1) ? printf("Odd") : printf("Even"); 
		3.   left shift(<<) - *         right shift(>>) - /
		4.   int a[] = { 1, 7, 2, 4, 8, 3 }; 
    		 int l = sizeof(a) / sizeof(a[0]); 
    		 sort(a, a + l);  reverse(a, a + l); accumulate(a, a + l, 0); *max_element(a, a + l);
	*/
	
	string to_string(char& x) {      
		string s(1,x);
		return s;    
	} 
	struct obj {
		ull val1;
		ull val2;
		ull pos;
	};
	bool cmp(const pair<int,int>&a,const pair<int,int>&b) {
		if(a.first==b.first)
		return a.second<b.second;
		return a.first<b.first;
	}

	int main() {
		ull n,no,p,sum=0;
		cin>>n;
		p=0;
		for(ull i=0;i<n;i++)
		{
			cin>>no;
			if(no<p)
			{
				sum+=p-no;
			}
			else
			{
				p=no;
			}
		}
		cout<<sum;
		return 0;
	}





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

int main(void) {
  int N, M;
  cin >> N >> M;

  if ( M == 1 ) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> X(M);
  for ( int i = 0; i < M; i++ )
    cin >> X.at(i);

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

  vector<int> D(M-1);
  for ( int i = 0; i < M-1; i++ )
    D.at(i) = X.at(i+1) - X.at(i);
  sort( D.begin(), D.end() );

  int ans = X.at(M-1) - X.at(0);
  for ( int i = 0; i < N-1; i++ )
    if ( i <= M-2 ) ans -= D.at(M-2-i);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	int n;
	cin>>n;
	int count=0, sum=0, m=INF;
	int temp;
	For(i, 0, n){
		cin>>temp;
		if(temp<0){
			count++;
		}
		temp = abs(temp);
		sum+=temp;
		m = min(temp, m);
	}

	// cout<<sum<<" "<<m<<endl;
	if(count%2==1){
		sum-=2*m;
	}

	cout<<sum<<endl;


    return 0;
}
    



Measured memory_bytes: 256
N,Y=map(int,input().split())

for sen in range(N+1):
    for gosen in range(N+1-sen):
        ichiman=N-sen-gosen
        if(sen*1000+gosen*5000+ichiman*10000==Y):
            print(ichiman,gosen,sen)
            exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
I=input
n=int
for i in range(n(input())):
  I();t=[];x=0
  for i,j in zip(map(n,I().split()[::-1]),I()[::-1]):
    [i:=(i^k*(i^k<i))for k in t];j=n(j);t+=[i*(j^1)];x|=(i>0)&j
  print(x)

Measured memory_bytes: 9064
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <limits>
#include <random>
#include <utility>
#include <vector>

namespace procon {
  class UnionFind {
  private:
    struct nodeinfo {
      int par;
      int rank;
      nodeinfo(int par) : par(par), rank(0) {}
    };
    std::vector<nodeinfo> node;

  public:
    UnionFind(int n) : node() {
      node.reserve(n);
      for (int i = 0; i < n; ++i) {
	node.push_back(nodeinfo(i));
      }
    }
    int root(int x) {
      if (node[x].par == x) {
	return x;
      }
      return node[x].par = root(node[x].par);
    }
    void unite(int x, int y) {
      x = root(x);
      y = root(y);
      if (x == y) {
	return;
      }
      if (node[x].rank < node[y].rank) {
	node[x].par = y;
      } else {
	node[y].par = x;
	if (node[x].rank == node[y].rank) {
	  ++node[x].rank;
	}
      }
    }
    bool is_same_set(int x, int y) { return root(x) == root(y); }
  };
}

int main(void) {
  int log_size;
  int n_query;
  int seed;
  std::cin >> log_size >> n_query >> seed;

  assert(0 <= log_size && log_size <= 30);
  assert(0 <= n_query);

  const int size = 1 << log_size;
  const int mask = size - 1;
  uint64_t res = 123456789;

  std::mt19937 mt(seed);
  procon::UnionFind uf(size);
  while (n_query--) {
    const int com = mt() & 1;
    const int x = mt() & mask;
    const int y = mt() & mask;
    if (com) {
      res = res * 17 + (uf.is_same_set(x, y) ? 1 : 0);
    } else {
      uf.unite(x, y);
    }
  }
  std::cout << res << std::endl;
  return 0;
}



Measured memory_bytes: 10844
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

st = ''
for i in t:
  if i == 'r':
    st += 'p'
  elif i == 'p':
    st += 's'
  else:
    st += 'r'

stt = st[:k]

for i in range(k,n):
  if st[i] != stt[i-k]:
    stt += st[i]
  else:
    stt += 'x'
    
sum = 0
for i in stt:
  if i == 'r':
    sum += r
  elif i == 's':
    sum += s
  elif i == 'p':
    sum += p
  else:
    pass
print(sum)


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<string, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

string word;
int page;
Vp book;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> word >> page) book.pb(P(word,page));
	SORT(book);
	cout << book[0].fi << endl << book[0].sec;
	for(int i = 1; i < book.size(); i++){
		if(book[i-1].fi == book[i].fi) cout << " " << book[i].sec;
		else cout << endl << book[i].fi << endl << book[i].sec;
	}
	cout << endl;
}

Measured memory_bytes: 1232
s=input()
SUM=0
p=0;q=0
b=0

j=0
while s[j]==">":
    j+=1
    if j==len(s):
        break
SUM+=(1+j)*j//2
if j!=len(s):
    h=s[j]
    for i in range(j,len(s)):
        if s[i]==h and b==0:
            p+=1
        if s[i]!=h:
            q+=1
            b=1
        if (s[i]==h and b==1) or (i==len(s)-1):
            w1=max(p,q)
            w2=min(p,q)
            SUM+=(1+w1)*w1//2+w2*(w2-1)//2
            if (s[i]==h and b==1) and (i==len(s)-1):
                SUM+=1
            b=0
            p=1;q=0
        
print(SUM)

Measured memory_bytes: 43976
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
  a[i]=a[i]-1

pushed=[False]*n
i = 0
count = 0
while True:
  if i ==1:
    print(count)
    exit()
  if not pushed[a[i]]:
    pushed[a[i]]=True
    i=a[i]
    count+=1
  else:
    print(-1)
    exit()


Measured memory_bytes: 7952
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

string S;
long long mod = 998244353;
long long dp[309][309][309];
bool I[309][309][309];

void solve(int pos) {
	// 単純に消す操作
	if (pos >= 1) {
		for (int i = 0; i <= S.size(); i++) {
			for (int j = 0; j <= S.size(); j++) {
				if (I[pos - 1][i][j] == true) I[pos][i][j] = true;
			}
		}
	}

	// 合成させる操作
	if (pos >= 2) {
		for (int i = 0; i <= S.size(); i++) {
			for (int j = 0; j <= S.size(); j++) {
				if (I[pos - 2][i][j] == false) continue;
				int c0 = 0, c1 = 0;
				if (S[pos - 2] == '0') c0++; else c1++;
				if (S[pos - 1] == '0') c0++; else c1++;
				if (c0 >= 1) I[pos][i + 1][j] = true;
				if (c1 >= 1) I[pos][i][j + 1] = true;
			}
		}
	}

	// 前と繋げる操作
	if (pos >= 2) {
		for (int i = 0; i <= S.size(); i++) {
			for (int j = 0; j <= S.size(); j++) {
				if (I[pos - 1][i][j] == false) continue;
				if (i >= 1) {
					int c0 = 1, c1 = 0;
					if (S[pos - 1] == '0') c0++; else c1++;
					if (c0 >= 1) I[pos][i][j] = true;
					if (c1 >= 1) I[pos][i - 1][j + 1] = true;
				}
				if (j >= 1) {
					int c0 = 0, c1 = 1;
					if (S[pos - 1] == '0') c0++; else c1++;
					if (c0 >= 1) I[pos][i + 1][j - 1] = true;
					if (c1 >= 1) I[pos][i][j] = true;
				}
			}
		}
	}
}

int main() {
	cin >> S;

	// DP フェーズ
	dp[0][0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < S.size(); j++) {
			for (int k = 0; k < S.size(); k++) {
				if (i + j + k >= S.size()) continue;
				
				if (S[S.size() - 1 - i] == '0') {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j][k] %= mod;
					dp[i][j][k + 1] += dp[i][j][k];
					dp[i][j][k + 1] %= mod;
				}
				else {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j][k] %= mod;
					dp[i][j + 1][k] += dp[i][j][k];
					dp[i][j + 1][k] %= mod;
				}
			}
		}
	}

	// 判定フェーズ
	I[0][0][0] = true;
	for (int i = 1; i <= S.size(); i++) {
		solve(i);
	}
	
	// 答え
	long long Answer = 0;
	for (int i = 0; i <= S.size(); i++) {
		for (int j = 0; j <= S.size(); j++) {
			for (int k = 0; k <= S.size(); k++) {
				bool I1 = I[S.size() - i][j][k];
				if (I1 == true) Answer += dp[i][j][k];
			}
		}
	}
	cout << (Answer + mod - 1) % mod << endl;
	return 0;
}

Measured memory_bytes: 121712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
  cin >>n;
  int a=0,b=0,c=0,d=0;
  vector<string> vec(n);
  for(int i=0;i<n;i++){cin >> vec[i];
  if(vec[i]== "AC")a++;
   if(vec[i]== "WA")b++;
   if(vec[i]== "TLE")c++;
   if(vec[i]== "RE")d++;
}
  cout <<"AC"<<" "<<"x"<<" "<<a<<endl;
  cout <<"WA"<<" "<<"x"<<" "<<b<<endl;
  cout <<"TLE "<<"x "<< c<<endl;
  cout <<"RE"<<" "<<"x"<<" "<<d<<endl;
  
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
const int mod = 998244353;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  std::vector<int> dp(m + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ++dp[0];
    int a;
    std::cin >> a;
    if (a > m)
      continue; 
    for (int j = m; j >= a; --j)
      dp[j] = (dp[j] + dp[j - a]) % mod;
    ans = (ans + 1ll * (n - i + 1) * dp[m]) % mod;
    dp[m] = 0; 
  }
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 100+100;
const ll mod = 1e9+7;
int b[maxn];
int main() {
    ios::sync_with_stdio(0);
    int n,r;
    cin>>n>>r;
    if(n>=10)
        cout<<r<<endl;
    else
        cout<<r+(10-n)*100<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> A(K,vector<int>(N));
  int cnt = 0;
  for(int i = 0; i < K; i++){
    cin >> d[i];
    for(int j = 0; j < d[i]; j++){
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  
  bool flag = false;
  for(int a = 0; a < N; a++){
    flag = false;
    for(int b = 0; b < K; b++){
      for(int c = 0; c < d[b]; c++){
        if(a == A[b][c]){
          flag = true;
          break;
        }
      }
    }
    if(flag == false){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

int main(void)
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    
    int count = 0;
    
    while(a >= b){
        b *= 2;
        count++;
    }
    
    while(b >= c){
        c *= 2;
        count++;
    }
    
    string ans = "No";
    if(count <= k)
    {
        ans = "Yes";
    }
    
    cout << ans << endl;
}


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

void solve()
{
	int n,d;
	cin>>n>>d;
	int c=0;
	
	while(n--)
	{
		ll a,b;
		cin>>a>>b;
		
		double dis=sqrt(a*a+b*b);
		if(dis<=d)
		  c++;
	}
	cout<<c<<endl;
}
 
int main()
{
   solve();
  
}

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

N = INT()
x = []

for _ in range(N):
    X, L = MAP()
    x.append([X-L, X+L])

x.sort(key = lambda x: x[1])

ans = 0
tmp = -INF
for l, r in x:
    if tmp <= l:
        tmp = r
        ans += 1
   

print(ans)

Measured memory_bytes: 26920