akhauriyash/Code-Regression huggingface dataset:
n = int(input())
num = list(map(int, input().split()))

    
print(" ".join(map(str, num)))
for i in range(len(num)-1):
    key = num[i+1]
    j = i 
    while j >= 0 and num[j] > key:
        num[j+1] = num[j]
        j -= 1
    num[j+1] = key
    print(" ".join(map(str, num)))

Measured memory_bytes: 7664
def resolve():
    A,B=map(int,input().split())

    ans=0
    while True:
        if int(ans*0.08)==A and int(ans*0.1)==B:
            print(ans)
            break
        elif int(ans*0.08)>A or int(ans*0.1)>B:
            print(-1)
            break
        else:
            ans+=1

resolve()

Measured memory_bytes: 38384
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N = in.i();
        int[] A = in.ii(N);
        Arrays.sort(A);
        PriorityQueue<Long> q = new PriorityQueue<>((x, y) -> -f(x) + f(y));
        q.add(create(A[A.length - 1], A[A.length - 1]));
        long ans = 0;
        for (int i = A.length - 2; i >= 0; i--) {
            long n = q.poll();
            int l = l(n);
            int r = r(n);
            q.add(create(l, A[i]));
            q.add(create(A[i], r));
            ans += min(l, r);
        }
        out.println(ans);
    }

    static int min(int a, int b) {
        return a < b ? a : b;
    }

    static long create(long l, long r) {
        return (l << 30) + r;
    }

    static int l(long n) {
        return (int)(n >> 30);
    }

    static int r(long n) {
        return (int)(n & ((1 << 30) - 1));
    }

    static int f(long n) {
        return min(l(n), r(n));
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
map<ll,vector<ll>> mp;
ll mod;
ll mns(ll x,ll y){
  if(x>y) return (x-y)%mod;
  else{
    ll ret=x-y;
    ll r2=y-x;
    r2/=mod;
    r2++;
    return (ret+mod*r2)%mod;
  }
}

int main(){
  ll n;
  cin>>n>>mod;
  vector<ll> rsum;
  rsum.push_back(0);
  vector<ll> use;
  mp[0].push_back(0);
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    a%=mod;
    a+=rsum[i-1];
    a%=mod;
    rsum.push_back(a);
    a=mns(a,i);
//    cout<<a<<endl;
    use.push_back(a);
    mp[a].push_back(i);
  }
  sort(use.begin(),use.end());
  use.erase(unique(use.begin(),use.end()),use.end());

  ll ans=0;
  for(int k=0;k<use.size();k++){
    int i=use[k];
    ll siz=mp[i].size();
    ans+=siz*(siz-1)/2;
    for(int j=0;j<mp[i].size();j++){
      int lb=lower_bound(mp[i].begin(),mp[i].end(),mp[i][j]+mod)-mp[i].begin();
      ans-=siz-lb;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 25312
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string S;
    cin >> S;

    bool flg_1 = true, flg_2 = true, flg_3 = true;
    if(S.at(0) != 'A') flg_1 = false;
    int cnt = 0;
    repi(i, 2, S.size() - 1) {
        if(S.at(i) == 'C') cnt++;
    }
    if(cnt != 1) flg_2 = false;
    cnt = 0;
    rep(i, S.size()) {
        if(isupper(S.at(i))) cnt++;
    }
    if(cnt != 2) flg_3 = false;

    if(flg_1 && flg_2 && flg_3) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i, n) rep(j, n-1) cin >> a[i][j];
    rep(i, n) rep(j, n-1) a[i][j]--;
    
    vector<int> col(n, 0);
    vector<P> possible;
    rep(i, n) {
        int match = a[i][0];
        if (match < i) continue;
        if (a[match][col[match]] == i) {
            possible.push_back(make_pair(i, match));
        }
    }

    bool update = true;
    int cnt = 0;
    while (update) {
        update = false;
        vector<P> candidate;
        for (auto q: possible) {
            int i1 = q.first;
            int i2 = q.second;
            col[i1]++;
            col[i2]++;
            if (col[i1] < n-1) {
                int m1 = a[i1][col[i1]];
                if (a[m1][col[m1]] == i1) candidate.push_back(make_pair(i1, m1));
            }
            int m2 = a[i2][col[i2]];
            if (col[i2] == n-1) continue;
            if (m2 == i1) continue;
            if (a[m2][col[m2]] == i2) candidate.push_back(make_pair(i2, m2));
        }
        possible = candidate;
        if (possible.size() > 0) update = true;
        cnt++;
    }

    rep(i, n) {
        if (col[i] != n-1) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << cnt << endl;


    return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool ans = true;
  for (int i = 0; i < N; i++) {
  int x;
  cin >> x;
  if(x%2 == 0 && x%3 != 0 && x%5 != 0) ans = false;
  
  }
  puts(ans ? "APPROVED":"DENIED");
}


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

using namespace std;

typedef long long ll;

string s;
const int N = 1e5;
int a[N];
int n, i1, i2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    int n = s.length();
    s += ' ';
    bool r = true;
    int rcnt = 0, lcnt = 0;
    for (int i = 0; i <= n; ++i) {
        if (r) {
            if (s[i] == 'R') {
                ++rcnt;
            } else { // 'L'
                i1 = i - 1;
                i2 = i;
                r = false;
                lcnt = 1;
            }
        } else {
            if (s[i] == 'L') {
                ++lcnt;
            } else {
                // do sth
                int ct = rcnt + lcnt;
                a[i1] = ct / 2;
                a[i2] = ct / 2;
                if (ct & 1) {
                    if (rcnt > lcnt) {
                        if (rcnt & 1)
                            ++a[i1];
                        else
                            ++a[i2];
                    } else if (rcnt < lcnt) {
                        if (lcnt & 1)
                            ++a[i2];
                        else
                            ++a[i1];
                    }
                }
                lcnt = 0;
                rcnt = 1;
                r = true;
            }
        }
    }

    for (int j = 0; j < n; ++j) {
        cout << a[j] << ' ';
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 4068
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		if (a * b * c == 175)
			System.out.print("YES");
		else
			System.out.print("NO");
	}
}

Measured memory_bytes: 20948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt(); //長方形X軸
		int H = sc.nextInt(); //長方形Y軸
		int x = sc.nextInt(); //円の中心X軸
		int y = sc.nextInt(); //円の中心Y軸
		int r = sc.nextInt(); //円の半径

		if ((r * 2) > W || (r * 2) > H) {//半径の倍≦辺
			System.out.println("No");

		} else if ((0 >= x || x > W) || (0 >= y || y > H)) {//円の中心が正の値
			System.out.println("No");

		} else if (((x + r) > W) || ((y + r) > H)) {//円の中心＋半径＜辺
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}



Measured memory_bytes: 26228
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;


int main(){
	int n;
	cin >> n;
	double value[n];
	for(int i = 0;i < n;i++){
		cin >> value[i];
	}
	sort(value,value + n);
	for(int i = 0;i < n-1;i++){
		double k = value[i] + value[i+1];
		value[i+1] = k / 2.0;
	}
	cout << value[n-1];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    int a,b;
    cin  >> a >> b;
    int x = a+b;
    int y = a-b;
    int z =a*b;
    x= max(x,y);
    cout << max(x,z)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final boolean DEBUG = false;

	class Node {
		Node p;
		int[] child;
		int id;
		
		Node(int id) {
			this.id = id;
		}

		void print() {
			System.out.print("node " + this.id + ": ");
			System.out.print("parent = " + (this.p == null ? -1 : this.p.id) + ", ");
			int d = 0;
			Node p = this.p;
			while (p != null) {
				d++;
				p = p.p;
			}
			System.out.print("depth = " + d + ", ");
			System.out.print((this.p == null         ? "root" :
							  this.child.length != 0 ? "internal node" :
													   "leaf") + ", ");
			System.out.print("[");
			for (int i = 0; i < this.child.length; i++)
				System.out.print(this.child[i] + (i != this.child.length - 1 ? ", " : ""));
			System.out.println("]");
		}
	}
	
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++)
			nodes[i] = new Node(i);

		for (int i = 0; i < n; i++) {
			int id = scan.nextInt();
			int k = scan.nextInt();
			nodes[id].child = new int[k];
			for (int j = 0; j < k; j++) {
				int c = scan.nextInt();
				nodes[id].child[j] = nodes[c].id;
				nodes[c].p = nodes[id];
			}
		}
		for (int i = 0; i < n; i++)
			nodes[i].print();
	}

	public static void main(String[] args) {
		new Main().run();
	}
}



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

int main() {
  string number;
  int N=0,fN=0;
  cin >> number;
  
  for(int i=0;i<(int)number.size();i++){
    N = N*10 + (int)number[i] - 48;
    fN += (int)number[i] - 48;
  }
  if(N % fN == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long a, b;
    scan(a, b);
    if (a + b == 15)
    {
        writeln("+");
    }
    else if (a * b == 15)
    {
        writeln("*");
    }
    else
    {
        writeln("x");
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000

int main(void){
	int n,a,b,c,x,y[MAX];
	int f,cr;
	int i;
	while(1){
		scanf("%d%d%d%d%d",&n,&a,&b,&c,&x);
		if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0){
			break;
		}
		for(i = 0; i < n; i++){
			scanf("%d",y+i);
		}
		cr = 0;
		if(x == y[cr]){
			cr++;
		}
		if(cr != n){
			for(f = 1; f <= 10000; f++){
				x = (a * x + b) % c;
				if(x == y[cr]){
					cr++;
					if(cr == n){
						break;
					}
				}
			}
		}else{
			f = 0;
		}
		printf("%d\n", f <= 10000 ? f : -1);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS (10e-7)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int A[3];
int main(int argc, char **argv) {
    cin >> A[0] >> A[1] >> A[2];
    sort(A, A + 3);

    int rest = A[2] - A[0] + A[2] - A[1];
    int res = rest % 2 == 0 ? rest / 2 : rest / 2 + 2;
    cout << res << endl;
    
}

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

public class Main{
	int h,w,n;
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	
	private void doit(){
		//Scanner sc = new Scanner(System.in);
		
		int [][] dp = new int[1000+1][1000+1];
		while(true){
			String [] input = read();
			h = Integer.parseInt(input[0]);
			w = Integer.parseInt(input[1]);
			n = Integer.parseInt(input[2]);
			if((h|w|n) == 0) break;
			n--;
			int [][] inputroad = new int[h+1][w+1];
			for(int i = 0; i < h; i++){
				input = read();
				for(int j = 0; j < w; j++){
					inputroad[i][j] = Integer.parseInt(input[j]);
					
				}
				inputroad[i][w] = -1;
				Arrays.fill(dp[i], 0);
			}
			Arrays.fill(inputroad[h], -1);
			Arrays.fill(dp[h], 0);
			
			dp[0][0] = n;
			int indI = 0, indJ = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					int temp = dp[i][j] / 2;
					dp[i][j+1] += temp;
					dp[i+1][j] += temp;
					if((dp[i][j] & 1) != 0){
						if(inputroad[i][j] == 0){
							dp[i+1][j]++;
						}
						else{
							dp[i][j+1]++;
						}
						inputroad[i][j] = inputroad[i][j] ^ 1;
					}
					
					if(i == indI && j == indJ){
						if(inputroad[i][j] == 0){
							indI++;
						}
						else{
							indJ++;
						}
					}
				}
			}
			System.out.println((indI + 1) + " " + (indJ + 1));
			
			//debug
//			for(int i = 0; i <= h; i++){
//				for(int j = 0; j <= w; j++){
//					System.out.print(dp[i][j] + " " );
//				}
//				System.out.println();
//			}
		}
	}
	
	private String[] read() {
		String[] res = null;
		try {
			res = in.readLine().split(" ");
		} catch (IOException e) {
		}
		return res;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 19000
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <stack>
using namespace std;

int main()
{
	int n, k, q;
	int an;
	cin >> n >> k >> q;
	vector<int> point(n,k);
	for (int i = 0; i < q; i++) {
		cin >> an;
		point[an - 1]++;
	}

	for (int i = 0; i < n; i++) {
		if (point[i] -q > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
//        String[] array = str.split("");

        StringBuffer sb = new StringBuffer(str);
        String reverse = sb.reverse().toString();

//        boolean flg1, flg2, flg3;
        int n = str.length();
        String str2 = str.substring(0, (n-1)/2);
        String str3 = str.substring((n+3)/2 -1);

        StringBuffer sb2 = new StringBuffer(str2);
        String reverse2 = sb2.reverse().toString();

        StringBuffer sb3 = new StringBuffer(str3);
        String reverse3 = sb3.reverse().toString();
//
//        System.out.println(str);
//        System.out.println(reverse);
        if (str.equals(reverse)){
//            System.out.println(str2);
//            System.out.println(reverse2);
            if (str2.equals(reverse2)){
//                System.out.println(str3);
//                System.out.println(reverse3);
                if (str3.equals(reverse3)){
                    System.out.println("Yes");
                }else {
                    System.out.println("No");
                }
            }else{
                System.out.println("No");
            }
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

bool gone[100010];
ll iku[100010];
vector<pai> e[100010];

void dfs(int s)
{
	rep(i, e[s].size())
	{
		int t=e[s][i].first;
		ll w=(ll) e[s][i].second;
		if(gone[t]==0)
		{
			gone[t]=1;
			iku[t]=iku[s]+w;
			dfs(t);
		}
	}
}

int main()
{
	int n;
	cin >> n;
	int a, b, c;
	rep(i, n-1)
	{
		cin >> a >> b >> c;
		e[a].push_back(pai(b, c));
		e[b].push_back(pai(a, c));
	}
	int q, k;
	cin >> q >> k;
	gone[k]=1;
	dfs(k);
	int x, y;
	rep(i, q)
	{
		cin >> x >> y;
		cout << (iku[x]+iku[y]) << endl;
	}
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= 2*b) cout << 0 << endl;
    else cout << a-b-b << endl;
    return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M, R;
ll d[200][200];
int r[8];

void warshall_floyd()
{
    REP(k, N){
        REP(i, N){
            REP(j, N){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

void init()
{
}

void solve()
{
    warshall_floyd();
    sort(r, r+R);
    ll ans = LINF;
    do{
        ll sum = 0;
        REP(i, R-1) sum += d[r[i]][r[i+1]];
        ans = min(ans, sum);
    }while(next_permutation(r, r+R));
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> R;
    REP(i, N){
        REP(j, N){
            d[i][j] = LINF;
        }
        d[i][i] = 0;
    }
    REP(i, R){
        cin >> r[i];
        r[i]--;
    }
    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    ll N;
    cin >> N;

    ll ans = 0;
    for(ll i = 1; i*(i+1) < N; i++){
		if(N%i == 0) ans += N/i - 1;
	}

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab = []
for _ in range(M):
    ab.append(tuple(map(int, input().split())))

edges = [0] * N
for el in ab:
    a = min(el)
    b = max(el)
    edges[a - 1] += 1
    edges[b - 1] -= 1
# print(edges)
for i in range(1, N):
    edges[i] = edges[i] + edges[i - 1]

# print(edges)
if all([x % 2 == 0 for x in edges]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 67288
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int R;
  cin >> R;

  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3572
N, = map(int, input().split())
M = 10**9+7
s = input().strip()
dp = [[0]*N for _ in range(N)]
for i in range(N):
    dp[0][i] = 1
ss = N
for i, c in enumerate(s):
    bs = 0
    if c == ">":
        for j in range(N-i):
            ss -= dp[i][j]
            dp[i+1][j] = ss%M
#            dp[i+1][j] = sum(dp[i][j+1:])
            bs = (bs+ss)%M
    else:
        ss = 0
        for j in range(N-i-1):
            ss += dp[i][j]
            dp[i+1][j] = ss%M
            bs = (bs+ss)%M
#            dp[i+1][j] = sum(dp[i][:j+1])
    ss = bs%M
print(dp[-1][0]%M)


Measured memory_bytes: 112604
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	ll x;
	cin >> x;
	ll c = 100;
	int ans = 0;
	while(1){
		if(x <= c){
			break;
		}else{
			c = floor(c*1.01);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define endl '\n'
#define pb push_back
#define ll long long
#define len(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define deb(X) cout << #X << " " << X << '\n'

const int mod = 1e9 + 7;

void solve(int test_case) {
    int s;
    cin >> s;
    vector<int> dp(s+1, 1);
    for(int i = 0; i < 3; ++i) dp[i] = 0;
    for(int i = 6; i <= s ; ++i) {
        for(int j = 0; j <= i-3; ++j) {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
    }
    cout << dp[s] << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    for(int tc = 1; tc <= t; ++tc) solve(tc);
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const long long INF = 1ll << 50;
int n, m;
long long l;
vector<vector<long long>> edge, edge2;

int main(){
    cin >> n >> m >> l;
    edge.resize(n, vector<long long>(n, INF));
    edge2.resize(n, vector<long long>(n, INF));
    for(int i = 0; i < n; i++){
        edge[i][i] = edge2[i][i] = 0;
    }
    for(int i = 0; i < m; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        if(l < c){
            continue;
        }
        edge[--a][--b] = c;
        edge[b][a] = c;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                edge[j][k] = min(edge[j][k], edge[j][i] + edge[i][k]);
            }
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i == j || l < edge[i][j]) continue;
            edge2[i][j] = 1;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                edge2[j][k] = min(edge2[j][k], edge2[j][i] + edge2[i][k]);
            }
        }
    }
    int q;
    cin >> q;
    while(q--){
        int s, t;
        cin >> s >> t;
        if(edge2[s - 1][t - 1] == INF){
            cout << "-1\n";
            continue;
        }
        cout << edge2[s - 1][t - 1] - 1 << "\n";
    }
}

Measured memory_bytes: 1920
N = int(input())

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

N_avg = sum(N_list)/N
N_avg_list=[]
for i in range(N):
  N_avg_list.append(abs(N_list[i]-N_avg))
  
print(N_avg_list.index(min(N_avg_list)))

Measured memory_bytes: 9108
from collections import deque as dq
n,q=map(int,input().split())
queue=dq([])
time=0
for i in range(n):
	a,b=input().split()
	queue.append([a,int(b)])
while queue:
	p=queue.popleft()
	if p[1]>q:
		p[1]-=q
		time+=q
		queue.append(p)
	else:
		time+=p[1]
		print(p[0],time)



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

int main()
{

	int w, n;
	cin >> w >> n;
	int A[30];
	for (int i = 0; i < w; i++) {
		A[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b;
		char kannma;
		cin >> a >> kannma >> b;
		swap(A[a - 1], A[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << A[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
import sys

N = next(sys.stdin.buffer)
X = tuple(map(int, next(sys.stdin.buffer).split()))

min_x = min(X)
max_x = max(X)

stamina = min(sum((p - x) ** 2 for x in X) for p in range(min_x, max_x + 1))

print(stamina)


Measured memory_bytes: 9180
#include<stdio.h>

int main()
{
	double x1,y1,x2,y2,xp,yp,xq,yq,x,y;
	double vx,vy,t;

	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF)
	{
		vx=x2-x1;
		vy=y2-y1;
		t=(vx*(xq-x1)+vy*(yq-y1))/(vx*vx+vy*vy);
		xp=x1+t*vx;
		yp=y1+t*vy;
		x=2*xp-xq;
		y=2*yp-yq;
		printf("%lf %lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
import sys

def solve(n, d):
  ans = 0
  for i, d_i in enumerate(d):
    for j, d_j in enumerate(d):
      if i == j:
        continue
      ans += d_i * d_j
        
  print(ans // 2)

if __name__ == '__main__':
  n = sys.stdin.readline().strip()
  d = list(map(int, sys.stdin.readline().strip().split(" ")))
  solve(n, d)

Measured memory_bytes: 38896
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a - 2 * b < 0)
			System.out.println(0);
		else
			System.out.println(a - 2 * b);
	}

}


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

using namespace std;

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

	int ans=0;

	// +1のカードの枚数だけ引く
	if(a<=k){
		ans+=a;
		k-=a;
	}
	else{
		ans+=k;
		k=0;
	}

	// 0のカードを引く
	k-=b;

	// -1のカードを引く
	if(0<k){
		ans-=k;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

bool chk(string a, string b){
    rep(i,a.size()){
        bool ok=true;
        rep(j,b.size()){
            //cout << b[j] << " " << a[(i+j)%a.size()] << endl;
            if(b[j]!=a[(i+j)%a.size()])ok=false;
        }
        if(ok)return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        string t; cin >> t;
        ans += chk(t,s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1208
// Triple Dots
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
using namespace std;

int main() {
    int K;
    string S;
    cin >> K >> S;
    int mi = min(K, int(S.size()));
    for (int i = 0; i < mi; i++) cout << S[i];
    if (S.size() > K) cout << "..." << endl;
    return 0;
}

Measured memory_bytes: 3620
import itertools
n=int(input())
table=[0 for i in range(100003)]
table[0]=1
for i in range(n):
    a,b=map(int,input().split())
    table[a]+=1
    table[b+1]-=1
table=list(itertools.accumulate(table))
for i in range(len(table)):
    if table[i]>=i:
        ans=i
print(ans-1)


Measured memory_bytes: 10412
A, B, C, X, Y = map(int, input().split())

ans1 = A * X + B * Y

if X > Y:
    ans2 = 2 * C * Y + A * (X - Y)
else:
    ans2 = 2 * C * X + B * (Y - X)

ans3 = 2 * C * max(X, Y)

print(min(ans1, ans2, ans3))
    

Measured memory_bytes: 2940
def main():
  n = int(input())
  mydict = {}

  for i in range(n):
    temp = list(input())
    temp.sort()
    temp = ''.join(temp)
    
    if temp not in mydict:
      mydict[temp] = 1
    else:
      mydict[temp] =  mydict[temp] + 1
      
  ans = 0
  for i in mydict.values():
    if i >= 2:
      ans = ans + i*(i-1)//2
    
  print(ans)
  
if __name__ == '__main__':
    main()

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

int main(){
  int n,i,j,cnt=0,m=0;
  string s;
  cin>>n;
  cin>>s;
  for(i=0;i<s.size();i++){
    if(s[i]=='I'){
      cnt++;
      m=max(m,cnt);
    }else{
      cnt--;
    }
  }
  cout<<m;
}

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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> grid(h+2, vector<char>(w+2));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>grid.at(i).at(j);
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w+1;j++){
      if(j==w+1){cout<<"\n";break;}
      if(grid.at(i).at(j)=='#'){cout<<'#';continue;}
      int count=0;
      if(grid.at(i-1).at(j-1)=='#'){count++;}
      if(grid.at(i-1).at(j)=='#'){count++;}
      if(grid.at(i-1).at(j+1)=='#'){count++;}
      if(grid.at(i).at(j-1)=='#'){count++;}
      if(grid.at(i).at(j+1)=='#'){count++;}
      if(grid.at(i+1).at(j-1)=='#'){count++;}
      if(grid.at(i+1).at(j)=='#'){count++;}
      if(grid.at(i+1).at(j+1)=='#'){count++;}
      cout<<count;
    }
  }
}

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

using namespace std;
using ll = long long;
using pii = std::pair<int, int>;

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pb push_back

const int mod = 1e6 + 3;
const int mn = 1e6 + 10;

int x, d, n;

ll powmod(ll a, ll b, ll P) {
    ll t = 1;
    for (; b; b >>= 1, a = a * a % P) {
        if (b & 1) t = t * a % P;
    }
    return t;
}

ll inv(ll d) {
    return powmod(d, mod - 2, mod);
}

ll fact[mn];

int main() {
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    int T;
    cin >> T;

    fact[0] = 1;
    for (int i = 1; i <= mod; i++) {
        fact[i] = fact[i - 1] * i % mod;
    }
    while (T--) {
        scanf("%d%d%d", &x, &d, &n);
        if (d == 0) {
            printf("%lld\n", powmod(x, n, mod));
        } else {
            if (x == 0) {
                n--;
                x += d;
            }
            int k = x * inv(d) % mod;
            ll ans = 0;
            if (k + n - 1 >= mod) ans = 0;
            else {
                //printf("%lld %lld %lld\n", fact[k + n - 1], inv(fact[k - 1]), ans);
                ans = fact[k + n - 1] * inv(fact[k - 1]) % mod;
                ans = ans * powmod(d, n, mod) % mod;
            }
            printf("%lld\n", ans);
        }

    }
    return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

using namespace std;
#define N 100010
ll d[N],x[N],n,m;
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>x[i];
    sort(x,x+m);
    for(int i=0;i<m-1;i++)d[i]=x[i+1]-x[i];
    sort(d,d+m-1);
    ll ans=0;
    for(int i=0;i<m-n;i++)ans+=d[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=2*1e5+10;
int a[maxn],b[maxn];
int k,n;
int main()
{
    int m=-1;
    scanf("%d%d",&k,&n);
    for(int i=0;i<n;++i){
        scanf("%d",&a[i]);
        a[i]%=k;
    }
    sort(a,a+n);
    for(int i=1;i<n;++i){
        m=max(m,a[i]-a[i-1]);
    }
    m=max(m,k+a[0]-a[n-1]);
    printf("%d\n",k-m);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main () {
    long k, n, max, maxIdx;
    long *a;
    long ret = 0;
    cin >> k >> n;

    a = (long*)calloc(n, sizeof(long));
    for (long i = 0; i < n; i++ ) {
        cin >> a[i];
    }

    maxIdx = 1;
    max = a[1] - a[0];
    for ( long i = 2; i < n; i++ ) {
        if ( max < ( a[i] - a[i - 1] ) ) {
            max = a[i] - a[i - 1];
            maxIdx = i;
        }
    }
    if ( max < (k - a[n - 1] + a[0])) {
        maxIdx = n;
    }

    if ( maxIdx == n ) {
        ret = a[n - 1] - a[0];
    }
    else {
        ret = (k - a[maxIdx]) + a[maxIdx - 1];
    }

    cout << ret << endl;   

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#define Mod(x) ((x)<md?(x):(x)-md)
using namespace std;
const int md=998244353;
int n,x,sum,ans,mi[310],f[310][90010],g[310][90010];
int main() {
	//n=300;
	scanf("%d",&n);
	f[0][0]=g[0][0]=1;
	for (int i=1;i<=n;i++) {
		scanf("%d",&x); sum+=x;
		for (int j=0;j<x;j++) f[i][j]=2ll*f[i-1][j]%md, g[i][j]=g[i-1][j];
		for (int j=x;j<=sum;j++) {
			f[i][j]=(f[i-1][j]*2ll+f[i-1][j-x])%md;
			g[i][j]=(g[i-1][j]+g[i-1][j-x])%md;
		}
	}
	//for (int i=0;i<=sum;i++) printf("%d ",f[n][i]); puts("");
	ans=1; for (int i=1;i<=n;i++) ans=3ll*ans%md;
	for (int i=(sum+1)>>1;i<=sum;i++) ans=(ans-3ll*f[n][i]+md)%md;
	if (!(sum&1)) ans=(ans+3ll*g[n][sum>>1])%md;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 211200
#include <cstdio>

int main(){
    int N, Q;
    scanf("%d %d", &N, &Q);
    char S[N + 1];
    scanf("%s", S);
    int l[Q], r[Q];
    for(int i = 0; i < Q; i++){
        scanf("%d %d", &l[i], &r[i]);
    }

    int T[N];
    for(int i = 0; i < N; i++){
        T[i] = 0;
    }
    for(int i = 1; i < N; i++){
        T[i] += T[i-1];
        if(S[i - 1] == 'A' && S[i] == 'C'){
                T[i]++;
        }
    }

    for(int i = 0; i < Q; i++){
        printf("%d\n", T[r[i] - 1] - T[l[i] - 1]);
    }

    return 0;
}

Measured memory_bytes: 2048
while 1:
    n,m=list(map(int,input().split()))
    if n==0 and m==0:break
    l=[i for i in range(1,1+n)]
    st=m-1
    while len(l)!=1:
        del l[st]
        st+=(m-1)
        while 1:
            if st>=len(l):
                st=st-len(l)
            if st<len(l):break  
    print(l[0])


Measured memory_bytes: 5600
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
  node(node* r,node* l,node* p,int k){
      right = r;
      left = l;
      parent = p;
      key = k;
  }
};

typedef struct node*  Node ;
class BinaryTree{
    private: Node NIL = NULL;
    public: Node root = NIL;
    
    Node treeMinimum(Node x){
        Node min = x -> left;
        while((min != NIL) && (min = x -> left));
        return min;
    }
    
    Node treeMaximum(Node x){
        Node max = x -> right;
        while((max != NIL) && (max = x -> right));
        return max;
    }
    
    Node treeSearch(Node u, int k){
        Node r = root;
        while(r != NIL){
            if(r -> key == k) return r;
            if(k < r -> key){
                r = r -> left;
            } else{
                r = r -> right;
            }
        }
        return NIL;
    }
    
    bool isExist(Node u,int k){
        if(treeSearch(u,k) != NIL){
            return 1;
        } else{
            return 0;
        }
    }
    
    Node treeSuccessor(Node x){
    
    
    }
    
    void treeDelete(Node z){
      Node min;
      Node c;
      if(z -> right != NIL){
          min = treeMinimum(z -> right);
          if(min != z){
              swap(z -> key,min -> key);
              free(min);
          } else{
              min -> right = NIL;
          }
      } else{
          z -> left -> parent = z -> parent;
          z -> parent -> left = z -> left;
          free(z);
      }
    }
    
    void insert(int k){
      Node y = NIL;
      Node x = root;
      Node z;
    
      z = new node(NIL,NIL,NIL,k);
      while(x != NIL){
          y = x;
          if(k < x -> key){
              x = x -> left;
          } else{
              x = x -> right;
          }
      }
      z-> parent = y;
      
      if(y != NIL){
          if(k < y -> key){
              y -> left = z;
          } else{
              y -> right = z;
          }
        } else{
              root = z;
          }
      }
    
    
    void inorder(Node u){
        if(u -> left != NIL) inorder(u -> left);
        printf(" %d",u -> key);
        if(u -> right != NIL) inorder(u -> right);
    }
    void preorder(Node u){
        printf(" %d",u -> key);
        if(u -> left != NIL) preorder(u -> left);
        if(u -> right != NIL) preorder(u -> right);
    }
};

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  BinaryTree bt;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
        scanf("%d", &x);
        if(bt.isExist(bt.root, x) == 1){
            printf("yes\n");
        } else{
            printf("no\n");
        }
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      bt.insert(x);
    } else if ( com[0] == 'p' ){
      bt.inorder(bt.root);
      printf("\n");
      bt.preorder(bt.root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      bt.treeDelete(bt.treeSearch(bt.root, x));
    }
  }

  return 0;
}




Measured memory_bytes: 21888
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

a1 = (a + 9) // 10 * 10
b1 = (b + 9) // 10 * 10
c1 = (c + 9) // 10 * 10
d1 = (d + 9) // 10 * 10
e1 = (e + 9) // 10 * 10

tmax = 0
if tmax < a1 - a:
	tmax = a1 - a
if tmax < b1 - b:
	tmax = b1 - b
if tmax < c1 - c:
	tmax = c1 - c
if tmax < d1 - d:
	tmax = d1 - d
if tmax < e1 - e:
	tmax = e1 - e

print(a1+b1+c1+d1+e1-tmax)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> botton(N);
  for (int i=0; i<N; i++) {
    cin >> botton.at(i);
  }
  
  int l=1;
  int l2;
  int count;
  while (true) {
    l2 = l;
    l = botton.at(l-1);
    botton.at(l2-1) = 0;
    count++;
    
    if (l==2) {
      cout << count << endl;
      break;
    }
    else if (l==0) {
      cout << -1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> dp(n + 1, 0);
    int cnt = 0;
    for(int i = 0; i < n; i++) {
        dp[a[i]] = dp[a[i] - 1] + 1;
        chmax(cnt, dp[a[i]]);
    }
    cout << n - cnt << endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 1; i < s.length(); i++)
		if (s[i - 1] != s[i])
			goto pnz;
	cout << 1 << endl;
	return 0;
pnz:
	int mod = 998244353;
	long x = 0, y[3][3] = {}, yy[3][3];
	long(*p)[3] = y, (*q)[3] = yy;
	p[0][0] = p[1][1] = p[2][2] = 1;
	int f = 1, n = s[0] - 'a';
	for (int i = 1;; i++) {
		if (s[i - 1] == s[i])
			f = 0;
		n += s[i] - 'a';
		if (i + 1 == s.length()) {
			if (n % 3 == 0 && s.length() == 3)
				f = 0;
			for (int i = 0; i < 3; i++)
				x += p[i][(n + 3 - i) % 3];
			x += f, x %= mod;
			break;
		}
		swap(p, q);
		x *= 3;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				x += q[i][j];
				p[(i + j) % 3][j] = (q[i][(j + 1) % 3] + q[i][(j + 2) % 3]) % mod;
			}
		}
		x %= mod;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) {
        cin >> a[i];
        a[i]-=(i+1);
    }

    sort(a.begin(), a.end());
    ll mid = a[n/2];
    ll ans = 0;

    REP(i,n) {
        ans += abs(mid-a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
nl = 1
while True:
	try:
		line = input()
		if nl==1:
			nl = nl + 1
		else:
			nums = line.split(' ')
			nums = list(map(int, nums))
			print('{} {} {}'.format(min(nums), max(nums), sum(nums)))
		
	except EOFError:
		break



Measured memory_bytes: 6516
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
const int N  = 5e5+5;
const LL mod = 1e9+7;
int a[105],n;
int main(){
  scanf("%d",&n);
  n<<=1;
  for(int i=1;i<=n;++i)scanf("%d",&a[i]);
  sort(a+1,a+1+n);
  int ret=0;
  for(int i=1;i<=n;i+=2)ret+=a[i];
  printf("%d\n",ret);
  return 0;
}

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

int main()
{
  int array[100][100];
  int brray[100];
  int n,m;
  
  cin >> n >> m;

  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++)
      cin >> array[i][j];
  }
  for(i=0;i<m;i++)
    cin >> brray[i];

  int crray[100]={0};
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      crray[i] += array[i][j] * brray[j];
    }
    cout << crray[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int a[10],k,i;
    for(i=0; i<5; i++)
        cin>>a[i];
    cin>>k;
    sort(a,a+5);
    if(a[4]-a[0]>k)
        printf(":(");
    else
        printf("Yay!");
    return 0;
}


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

if N % 2 == 1:
    for i in range(1, M + 1):
        l = i
        r = N - i
        print(l, r)
else:
    flag = False
    l = 1
    r = N - 1
    cnt = 0
    while cnt < M:
        if not flag and r - l <= N // 2:
            r -= 1
            flag = True
        print(l, r)
        l += 1
        r -= 1
        cnt += 1

Measured memory_bytes: 9184
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;
typedef long long int ll;

int main(){
    vector<queue<int>> v;
    int n, q, c, t, x;
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++){
        v.push_back(queue<int>());
    }
    for (int i = 0; i < q; i++){
        scanf("%d %d", &c, &t);
        if(c == 0){
            scanf("%d", &x);
            v.at(t).push(x);
        }else if(c == 1){
            if(!v.at(t).empty()){
                printf("%d\n", v.at(t).front());
            }
        }else{
            if(!v.at(t).empty()){
                v.at(t).pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3876
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int X[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int mx = -1;
  rep(i, N) cin >> X[i], mx = max(mx, X[i]);
  P cand = P(INF, INF);
  rep(i, N) if (X[i] != mx) cand = min(cand, P(abs(2*X[i]-mx), X[i]));
  cout << mx << " " << cand._2 << "\n";
  return 0;
}


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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int n;
int x;
map<int,int>mp;
int ans;
int a[100100];

int main()
{
    cin>>n;
    F(i,1,n)
    {
        cin>>x;
        a[i]=x;
        if(mp[x]) mp[x]=0;else mp[x]=1;
    }
    F(i,1,n)
    {
        x=a[i];
        ans+=mp[x];
        mp[x]=0;
    }
    cout<<ans;
    return 0;
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i];
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i];
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" ";
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" ";
#define manu            cout<<(checkerCounter++)<<endl;
int checkerCounter = 1;
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int h1,m1,h2,m2,tm;cin>>h1>>m1>>h2>>m2>>tm;
    int st=(h2-h1)*60+(m2-m1);
    cout<<max(st-tm,(ll)0);
}


Measured memory_bytes: 3636