akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	getline(cin, s);
	rep(i, SZ(s)) {
		if (islower(s[i])) {
			s[i] = (char)(s[i] - 32);
		}
		else if (isupper(s[i])) {
			s[i] = (char)(s[i] + 32);
		}
	}
	cout << s << endl;
}
/*
97 a
65 A
*/


Measured memory_bytes: 3168
using System;
using System.Linq;
using System.Numerics;

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            bool flg = false;
            if (s.Length == t.Length)
                flg = true;
            int ans = 10000;
            if (flg)
            {
                int m = 0;
                for(int i = 0; i < s.Length; i++)
                {
                    if (s[i] != t[i])
                        m++;
                }
                ans = Math.Min(ans, m);
            }
            else
            {
                for (int i = 0; i < s.Length - t.Length; i++)
                {
                    int m = 0;
                    for (int j = 0; j < t.Length; j++)
                    {
                        if (s[i + j] != t[j])
                        {
                            //Console.Write("{0} {1}", s[i + j], t[j]);
                            m++;
                        }
                    }
                    ans = Math.Min(ans, m);
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25952
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

const INF: i64 = 100000_000000000_00;

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut queries = vec![];
    for _ in 0..m {
        let v = read_vec::<i64>();
        let (l, r, c) = (v[0] as usize - 1, v[1] as usize - 1, v[2]);
        queries.push((l, r, c));
    }
    queries.sort();
    let mut seg = LazySegmentTree::new(n);
    seg.update(0, 1, 0, 0, 0, n);
    for (l, r, c) in queries {
        let start = seg.getmin(l, l + 1, 0, 0, n);
        seg.update(l, r + 1, start + c, 0, 0, n);
    }
    let ans = seg.getmin(n - 1, n, 0, 0, n);
    if ans == INF {
        println!("-1");
        return;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[derive(Debug)]
struct LazySegmentTree {
    n: usize,
    node: Vec<i64>,
    lazy: Vec<i64>,
}

impl LazySegmentTree {
    fn new(sz: usize) -> LazySegmentTree {
        let mut n = 1;
        while n < sz {
            n *= 2;
        }
        LazySegmentTree {
            n: n,
            node: vec![INF; n * 2],
            lazy: vec![INF; n * 2],
        }
    }

    fn eval(&mut self, k: usize, l: usize, r: usize) {
        if self.lazy[k] != INF {
            self.node[k] = min(self.node[k], self.lazy[k]);
            if r - l > 1 {
                self.lazy[2 * k + 1] = min(self.lazy[2 * k + 1], self.lazy[k]);
                self.lazy[2 * k + 2] = min(self.lazy[2 * k + 2], self.lazy[k]);
            }
            self.lazy[k] = INF;
        }
    }

    fn update(&mut self, a: usize, b: usize, x: i64, k: usize, l: usize, r: usize) {
        // update [l, r) k = 0, l = 0, r = n is default
        self.eval(k, l, r);

        // if out of range, do nothing.
        if b <= l || r <= a {
            return;
        }

        if a <= l && r <= b {
            self.lazy[k] = min(self.lazy[k], x);
            self.eval(k, l, r);
        } else {
            self.update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            self.update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            self.node[k] = min(self.node[2 * k + 1], self.node[2 * k + 2]);
        }
    }

    fn getmin(&mut self, a: usize, b: usize, k: usize, l: usize, r: usize) -> i64 {
        if b <= l || r <= a {
            return INF;
        }

        self.eval(k, l, r);
        if a <= l && r <= b {
            return self.node[k];
        }

        min(
            self.getmin(a, b, 2 * k + 1, l, (l + r) / 2),
            self.getmin(a, b, 2 * k + 2, (l + r) / 2, r),
        )
    }
}


Measured memory_bytes: 13432
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

vector< int > g[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int m;
    cin>>m;
    int start,end;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        if(i==0)
        {
            start = x;
            end = y;
        }
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<int> sleft;
    vector<int> eright;
    sleft.push_back(start);
    eright.push_back(end);
    bool vis[100005] = {0};
    vis[start] = 1;
    vis[end] = 1;
    int lp,rp;
    lp=0;
    rp = 0;
    while(lp<g[start].size())
    {
        bool poss = false;
        if(vis[g[start][lp]]==0)
        {
            vis[g[start][lp]] = 1;
            int temp =  g[start][lp];
            start = temp;
            poss = true;
            lp = 0;
            sleft.push_back(start);
        }
        if(!poss)
        lp++;
    }
    while(rp<g[end].size())
    {
        
        bool poss = false;
        if(vis[g[end][rp]]==0)
        {
            vis[g[end][rp]] = 1;
            int temp = g[end][rp];
            end = temp;
            poss = true;
            rp = 0;
            eright.push_back(end);
        }
        if(!poss)
            rp++;
    }
    cout<<sleft.size()+eright.size()<<endl;
    for(int i=sleft.size()-1;i>=0;i--)
    {
        cout<<sleft[i]+1<<" ";
    }
    for(int i=0;i<eright.size();i++)
    {
        cout<<eright[i]+1;
        if(i == eright.size()-1)
            cout<<endl;
        else
            cout<<" ";
    }
    return 0;
}

Measured memory_bytes: 6904
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
const ll INF = 1e18L + 5;
using namespace std;

void max_self(ll &a, ll b) {
    a = max(a, b);
}

void min_self(ll &a, ll b) {
    a = min(a, b);
}
int main()
{
    fast;
//    input;
//    output;

//    ll n, weight;
//    cin >> n >> weight;
//    vector<ll> dp(weight+1);
//    for (int i = 0; i < n; ++i) {
//        ll v, w;
//        cin >> w >> v;
//        for (ll weight_now = weight; weight_now - w >= 0; --weight_now) {
//            max_self(dp[weight_now], dp[weight_now - w] + v);
//        }
//    }
//    cout << dp[weight];

    ll n, weight;
    cin >> n >> weight;
    vector<ll> w(n), v(n);
    ll sum_v = 0;
    for (ll i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        sum_v += v[i];
    }
    vector<ll> dp (sum_v + 1, INF);
    dp[0] = 0;
    for (ll i = 0; i < n; ++i) {
        for (ll value_now = sum_v; value_now >= v[i]; --value_now) {
            min_self(dp[value_now], dp[value_now - v[i]] + w[i]);
        }
    }
    for (ll i = sum_v; i >= 0; --i) {
        if (dp[i] <= weight) {
            cout << i;
            return 0;
        }
    }
}

/*

*/


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

int main(){
    int n;
    string s;
    cin >> s;
    n = s.size();
    int r = 0,b = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '0')
        r++;
        else
        b++;
    }
    cout <<  min(r, b) * 2 ;
    return 0;
}

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

int W[300010],minv=INF,n;

int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++){
		char c;
		cin>>c;
		W[i]=W[i-1]+(c=='W');
	}
	for(int i=1;i<=n;i++){
		minv=min(minv,n-1-(i-1-W[i-1]+W[n]-W[i]));
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 1408
while True:
    n, m = map(int, raw_input().split())

    if n == 0 and m == 0:
        break

    taro = sorted([int(raw_input()) for _ in range(n)])
    hanako = sorted([int(raw_input()) for _ in range(m)])

    diff = sum(taro) - sum(hanako)

    flag = False

    def fnc():
        global flag
        for i in taro:
            for j in hanako:
                if (i - j) * 2 == diff:
                    print i, j
                    flag = True
                    return

    fnc()

    if not flag:
        print -1



Measured memory_bytes: 4656
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int temp;
	int k;
	int dame = 0;
	vector<int> v;
	for (int i = 0; i < 5; i++) {
		cin >> temp;
		v.push_back(temp);
	}
	cin >> k;
	if (v[4] - v[0] > k)
		dame = 1;
	if (dame)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split(' ')))

ans = True
if N % 3 != 0:
    for i in range(N):
        if a[i] != 0:   
            ans = False
else:
    first = a[0]
    i_second = -1
    for i in range(1, N):
        if a[i] != first:
            second = a[i]
            i_second = i
            break
        
    if i_second == -1:
        for i in range(N):
            if a[i] != 0:
                ans = False
    else:
        i_third = -1
        for i in range(i_second+1, N):
            if (a[i] != first) and (a[i] != second):
                third = a[i]
                i_third = i
                break
        if i_third == -1:
            ans = False
            cnt_first = 0
            cnt_second = 0
            for i in range(N):
                if a[i] == first:
                    cnt_first += 1
                elif a[i] == second:
                    cnt_second += 1
            if first ^ second == second:
                if (cnt_first == N/3) and (cnt_second == N*2/3):
                    ans = True
            if first ^ second == first:
                if (cnt_first == N*2/3) and (cnt_second == N/3):
                    ans = True
        else:
            if (first ^ second != third) or (second ^ third != first) or (third ^ first != second):
                ans = False
            else:
                cnt_first = 0
                cnt_second = 0
                cnt_third = 0
                for i in range(N):
                    if a[i] == first:
                        cnt_first += 1
                    elif a[i] == second:
                        cnt_second += 1
                    elif a[i] == third:
                        cnt_third += 1
                if (cnt_first != N/3) or (cnt_second != N/3) or (cnt_third != N/3):
                    ans = False

if ans is True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e6 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}



signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	int val = 0;
	while(t--)
	{
		int start = 1000;

		int n;
		cin>>n;
		int ans = 0;
		while(true)
		{
			if(start >=n)
			{
				ans += start - n;
				break;
			}

			start += 1000;
		}

		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T,A;
  cin >> N >> T >> A;

  int ans = 0;
  int cc = 99999999999;

  for ( int i = 1; i <= N ; ++ i ) {
    int X;
    cin >> X;
    int C = (1000 * T - X * 6) - A * 1000;
    if (C < 0) C = -C;
    if (cc > C) {
      cc = C;
      ans = i;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[100005];
map<int, int> cnt;
int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    int mn = 1e9, mx = 0;
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        if(a[i] > mn) mx = max(mx, a[i]-mn);
        mn = min(mn, a[i]);
    }   
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(cnt.find(a[i]-mx) != cnt.end()){
            ans += cnt[a[i]-mx];
            cnt.erase(a[i]-mx);
        }
        cnt[a[i]]++;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 8876
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m1,m2;
    char d[8];
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<8;j++)cin>>d[j];
        sort(d,d+8);
        m1=atoi(d);
        sort(d,d+8,greater<int>());
        m2=atoi(d);
        cout<<m2-m1<<endl;
    }
}

Measured memory_bytes: 1188
#include<cstdio>
#include<algorithm>

using namespace std;

using ll = long long;
const int mod = 1e9+7;
int a[(int)2e5 + 10];

void add(int &x,int y){
    x += y;
    x = x >= mod ? x - mod : x;
}
int subt(int x, int y){
    x -=y;
    x = x < 0 ? x + mod : x;
    return x;
}
int mult(int x,int y){
    return (1LL * x* y) %mod;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i= 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    int ans = 0,mul = 2,bi = 1;
    for(int i = 1;i<=n;i++){
        ans = mult(ans,4);
        add(ans , mult(mul, a[i]));
        bi = mult(4, bi);
        mul = mult(bi, i + 2);
    }
    printf("%d",ans);
}


Measured memory_bytes: 896
n, y = [int(i) for i in input().split()]

ans = [-1, -1, -1]
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j #1000円の枚数を決定
        total = 10000*i+5000*j+1000*k
        if total == y:
            ans = [i, j, k]
            break

print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
#include<stdio.h>
 int main(void)
 {
     char s[3];
     int i,j=0,k=0,l=0;

     scanf("%s",s);

     for(i=0;i<3;i++){
       if(s[i]=='a') j++;
       if(s[i]=='b') k++;
       if(s[i]=='c') l++;
     }

     if((j==1)&&(k==1)&&(l==1)) printf("Yes\n");
     else printf("No\n");

     return 0;
 }



Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
using namespace std;
//#define int long

signed main() 
{
	string S, T;
	cin >> S >> T;
	map<char, int>m1, m2;
	for (auto i : S)m1[i]++;
	for (auto i : T)m2[i]++;
	vector<int>v1, v2;
	for (auto i : m1)v1.push_back(i.second);
	for (auto i : m2)v2.push_back(i.second);
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	if (v1 == v2)cout << "Yes";
	else cout << "No";
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const int KS=8100;
array<bool, 2*KS+100> dp, np;

bool fnc(const VI& xs, int tx, bool xyx=false){
	dp.fill(false); dp[KS] = true;
	rep(i, sz(xs)){
		np.fill(false);
		if(xs[i]==0) continue;
		rep(j, KS*2) if(dp[j]){
			if(j + xs[i] < KS*2) np[j + xs[i]] = true;
			if(xyx && i==0) continue;
			if(j - xs[i] >= 0  )   np[j - xs[i]] = true;
		}
		swap(np, dp);
	}
	return dp[tx + KS];
}



int main()
{
 
	cin.tie(0); ios_base::sync_with_stdio(false);
	int x,y;
	string s;
	cin >> s >>x >>y;
	s +="T";
	int n=sz(s), cr=0;
	VI xs, ys;
	int sm =0;
	rep(i, n){
		if(s[i]=='F') sm++;
		else if(s[i]=='T'){
			(cr? ys:xs).push_back(sm);
			sm =0; cr ^=1;
		}
	}
	if(fnc(xs, x, true) && fnc(ys, y)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define S second
#define F first
#define pb push_back
#define mm make_pair
const int MX=2e5;
int N, M, k;
int arr[MX];
int main()
{
   int T;
   cin>>N>>T;
   int an=1e9+1;
   for(int i=1;i<=N;i++)
   {
       int c;
       int t;
       cin>>c>>t;
       if(t > T) continue;
       an=min(an, c);
   }
   if(an == 1e9+1) cout<<"TLE\n";
   else
   cout<<an;
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const Int32 mod = 1000000007;

        static void Main(string[] args)
        {
            string[] Reader = ReadLine().Split(' ');
            int A = int.Parse(Reader[0]);
            int B = int.Parse(Reader[1]);
            int C = int.Parse(Reader[2]);
            int D = int.Parse(Reader[3]);

            for (; ;) 
            {
                C -= B;

                if (C <= 0) 
                {
                    WriteLine("Yes");
                    break;
                }

                A -= D;

                if (A <= 0) 
                {
                    WriteLine("No");
                    break;
                }
            }

            ReadLine();
        }
    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value)
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion

        #region 拡張: List<string>
        public static string Sum(this List<string> THIS, string Split)
        {
            string RetValue = "";

            for (int loop = 0; loop < THIS.Count; loop++)
            {
                RetValue += THIS[loop];
            }

            return RetValue;
        }
        #endregion
    }
}


Measured memory_bytes: 17900
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

static const ULL M = 1000000007;

struct Mat {
	ULL E[50][50] = {};
	Mat operator*(const Mat& r) const {
		Mat tmp;
		rep(x, 50) rep(y, 50) {
			rep(i, 50) {
				tmp.E[x][y] += E[x][i] * r.E[i][y];
				tmp.E[x][y] %= M;
			}
		}
		return tmp;
	}
};

struct Problem {
public:

	UL N;
	ULL K;
	Mat mat, dp;

	void Solve() {
		scanf("%u", &N);
		scanf("%llu", &K);
		rep(i, N) rep(j, N) {
			scanf("%llu", &mat.E[i][j]);
		}
		rep(i, N) dp.E[i][i] = 1;
		for (int i = 63; i >= 0; i--) {
			dp = dp * dp;
			if (K & (1ull << i)) {
				dp = dp * mat;
			}
		}
		ULL ans = 0;
		rep(i, N) rep(j, N) ans += dp.E[i][j];
		ans %= M;
		printf("%llu", ans);
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}


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

using namespace std;

int func(int n) {
  return ((n % 2 == 0) ? n / 2 : 3 * n + 1);
}

int main() {
  int s; cin >> s;
  vector<int> v;
  v.push_back(s);
  for(int i = 1; i <= 1000000; i++) {
    int si = func(v.back());
    auto result = find(v.begin(), v.end(), si);
    if(result != v.end()) {
      cout << i + 1 << endl;
      return 0;
    } else {
      v.push_back(si);
    }
  }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int N, M, R;
int d[201][201];
int r[9];
int A, B, C;
int res;
bool used[9];

void dfs(int c, int las, int dist) {
    if (c == R) {
        if (res > dist) res = dist;
        return;
    }
    rep(i, R) {
        if (used[i]) continue;
        used[i] = true;
        if (las == -1) dfs(c + 1, i, 0);
        else dfs(c + 1, i, dist + d[r[las]][r[i]]);
        used[i] = false;
    }
}

int main() {
    cin >> N >> M >> R;
    rep(i, N) rep(j, N) if (i != j) d[i][j] = INF;
    rep(i, R) cin >> r[i], r[i]--;
    rep(i, M) {
        cin >> A >> B >> C;
        A--;
        B--;
        if (d[A][B] > C) d[A][B] = d[B][A] = C;
    }
    rep(k, N)rep(i, N)rep(j, N) chmin(d[i][j], d[i][k] + d[k][j]);

    res = INF;
    dfs(0, -1, 0);
    cout << res << endl;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
d=[[0 for i in range(n)]for i in range(m)]
for i in range(m):
    x=list(map(int,input().split()))
    for j in range(1,x[0]+1):
        d[i][x[j]-1]=1
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
    for j in range(m):
        tmp=0
        for k in range(n):
            if (1<<k)&i:
                tmp+=d[j][k]
        if tmp%2!=p[j]:
            break
    else:
        ans+=1
print(ans)


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

int main() {
  
  int a;
  
  cin >> a;
  
   int x , y ,z ;
  
    x = a/100 ;
    y =( a - (x * 100 )) / 10 ;
    z = a - (x* 100) -(y * 10) ;
  cin >> x >> y   >> z ;

  cout << x +  y + z << endl;
  
}





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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long				ll;
typedef pair <int, int> ii;

ll n;
vector <ll> d;
vector <vector <ii> > g;

bool BellmanFord(int s) {
	fill(d.begin(), d.end(), LLINF);
	d[s] = 0;
  int cnt = 0;
	for(;;) {
    cnt++;
		bool f = false;
		rep(i, n) rep(j, g[i].size()) {
			auto e = g[i][j];
			if(d[i] < LLINF && d[e.first] > d[i] + e.second) {
        if(cnt > n && e.first == n - 1) return false;
				d[e.first] = d[i] + e.second;
				f					 = true;
			}
		}
    if(cnt > 3 * n) break;
		if(!f) break;
	}
  return true;
}

int main() {
	ll m;
	cin >> n >> m;
	d.resize(n);
	g.resize(n);

	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
    c *= -1;
		g[a].push_back(make_pair(b, c));
	}

	bool f = BellmanFord(0);
  if(f) cout << -d[n-1] << endl;
  else cout << "inf" << endl;

	return 0;
}


Measured memory_bytes: 256
(w, h, x, y, r) = input().split(' ')
w = int(w)
h = int(h)
x = int(x)
y = int(y)
r = int(r)
 
if 0 + r <= x <= w - r and 0 + r <= y <= h - r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6724
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;


int main()
{
    int n;
    cin >> n;
    ll m = INF;
    ll num = 0;
    vector<ll> v(n);

    rep(i, n){
        ll tmp;
        cin >> tmp;
        v[i] = tmp;
        if(tmp < 0) num++;
        m = min(m, abs(tmp));
    }

    ll ans = 0;
    rep(i, n){
        ans += abs(v[i]);
    }
    if(num % 2 == 1){
        ans -= 2*m;
    }

    cout << ans;

}

Measured memory_bytes: 1024
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as IM
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:as)=IM.fold max 0.foldr(\a m->foldr f m[a-1,a,a+1])IM.empty$as
f a m
  |IM.member a m=IM.adjust succ a m
  |otherwise=IM.insert a 1 m

Measured memory_bytes: 30076
package main

import (
	"bufio"
	"container/heap"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner(os.Stdin)
	h, _ := sc.NextInt()
	w, _ := sc.NextInt()
	k, _ := sc.NextInt()
	x1, _ := sc.NextInt()
	y1, _ := sc.NextInt()
	x2, _ := sc.NextInt()
	y2, _ := sc.NextInt()
	stage := make([]string, h)
	for i := 0; i < h; i++ {
		sc.Scan()
		stage[i] = sc.Text()
	}
	ans := solve(h, w, k, x1-1, y1-1, x2-1, y2-1, stage)
	fmt.Println(ans)
}

type state struct {
	x, y, dist int
}

type priorityQueue []*state

func (p priorityQueue) Len() int            { return len(p) }
func (p priorityQueue) Less(i, j int) bool  { return p[i].dist < p[j].dist }
func (p priorityQueue) Swap(i, j int)       { p[i], p[j] = p[j], p[i] }
func (p *priorityQueue) Push(x interface{}) { *p = append(*p, x.(*state)) }
func (p *priorityQueue) Pop() interface{} {
	x := (*p)[len(*p)-1]
	*p = (*p)[:len(*p)-1]
	return x
}
func (p priorityQueue) String() string {
	out := ""
	for _, v := range p {
		out += fmt.Sprintf("%+v ", *v)
	}
	return strings.TrimSpace(out)
}

var inf = math.MaxInt64
var dxs, dys = []int{0, 0, -1, 1}, []int{-1, 1, 0, 0}

func solve(h, w, k, x1, y1, x2, y2 int, stage []string) int {
	dists := make([][]int, h)
	for x := range dists {
		dists[x] = make([]int, w)
		for y := range dists[x] {
			dists[x][y] = inf
		}
	}

	dists[x1][y1] = 0
	q := priorityQueue{}
	// q := []*state{}
	s := &state{x1, y1, 0}
	heap.Push(&q, s)
	// q = append(q, s)
	for len(q) > 0 {
		// for idx := 0; idx < len(q); idx++ {
		//fmt.Println(q.String())
		p := heap.Pop(&q).(*state)
		// p := q[idx]
		// if p.x == x2 && p.y == y2 {
		//	return p.dist
		// }
		for d := range dxs {
			for i := 1; i <= k; i++ {
				x, y := p.x+i*dxs[d], p.y+i*dys[d]
				if x < 0 || h <= x || y < 0 || w <= y {
					break
				}
				if stage[x][y] == '@' {
					break
				}
				dist := p.dist + 1
				if dist > dists[x][y] {
					break
				}
				if dist == dists[x][y] {
					continue
				}
				dists[x][y] = dist
				s := &state{x, y, dist}
				heap.Push(&q, s)
				// q = append(q, s)
			}

		}
	}
	if dists[x2][y2] == inf {
		return -1
	}
	return dists[x2][y2]
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}


Measured memory_bytes: 27768
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int s_size = s.size();
    bool kaibun = true;
    rep(i, (s_size-1)/2)
    {
        if (s[i] != s[s_size - i - 1])
        {
            kaibun = false;
        }
    }
    rep(i,(s_size-1)/2){
        if (s[i] != s[(s_size - 1) / 2 - i-1])
        {
            kaibun = false;
        }
    }
    for (int i = (s_size + 3) / 2; i < s_size;++i)
    {
        if (s[i] != s[s_size - i - 1])
        {
            kaibun = false;
        }
    }
    if(kaibun == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

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

    vl A(N);
    vl B(N);
    for(ll i=0; i<N; i++){
        cin >> A.at(i) >> B.at(i);
    }
    ll sum = 0;
    for(ll i=N-1; i>=0; i--){
        if((sum + A.at(i)) % B.at(i)==0){
            sum += 0;
        }
        else{
            sum += B.at(i) - ((sum + A.at(i)) % B.at(i));
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#define maxn 10005
using namespace std;
long long a[maxn],b[maxn],n,A,B;
int main()
{cin>>n;
 for(int i=1;i<=n;i++)
   cin>>a[i];
 for(int i=1;i<=n;i++)
   {cin>>b[i];
    if(a[i]>b[i]) B+=(a[i]-b[i]);
   	  else if(a[i]<b[i]) A+=(b[i]-a[i])/2;
   }
 if(A>=B) cout<<"Yes";
   else cout<<"No";
 return 0;
} 

Measured memory_bytes: 384
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  k,a,b=pM(split(readline()))
  ans=1
  if b-a<=1; print(ans+k); return 0; end
  while k>0
    if ans+k<=a || k==1; ans+=k; k=0
    elseif ans<a; k-=a-ans; ans+=a-ans
    else; ans+=b-a; k-=2
    end
  end
  print(ans)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 167184
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

int k;
i64 ans=0;
cin>>k;
for1(a,k)
{
  for1(b,k)
  {
    for1(c,k)
    {
int g=__gcd(a,b);
g=__gcd(g,c);
ans+=g;
      }
  }
}
cout<<ans;


    return 0;
  }


Measured memory_bytes: 3640
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n, m;
    cin >> n >> m;
    VV<int> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
    }
    using D = double;
    D ans = TEN(18);

    for (int v = 0; v < n - 1; v++) {
        V<D> dp(n);
        for (int i = n - 2; i >= 0; i--) {
            if (i != v || g[v].size() == 1) {
                for (int j: g[i]) {
                    dp[i] += 1 + dp[j];
                }
                dp[i] /= g[i].size();
            } else {
                D ma = 0;
                for (int j: g[i]) {
                    dp[i] += 1 + dp[j];
                    ma = max(ma, 1 + dp[j]);
                }
                dp[i] -= ma;
                dp[i] /= g[i].size() - 1;
            }
        }
        ans = min(ans, dp[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    bool k = true;
    rep(i, n) {
        int v; cin >> v;
        if(v%2 == 0) k = (v%3 == 0) || (v%5 == 0);
        if(!k) break;
    }
    if(k) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}



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

ma = []
for i in range(n):
    ma.append(0)

for i in range(m):
    a, b = map(int, input().split())
    if h[b-1] > ma[a-1]:
        ma[a-1] = h[b-1]
    if h[a-1] > ma[b-1]:
        ma[b-1] = h[a-1]

count = 0
for i in range(n):
    if h[i] > ma[i]:
        count+=1
print(count)

Measured memory_bytes: 19900
import java.util.*;

public 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();

int answer=A+B+C+9*Math.max(Math.max(A,B),C);

System.out.println(answer);
}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int n, ta, tb, sz = 262144;
complex<double> a[262155], b[262155], y[262155];
void dft(complex<double> *x, bool inv) {
    for(int i = sz >> 1; i >= 1; i >>= 1) {
        complex<double> bs = polar(1.0, 2.0 * acos(-1) * i / sz *
                                            (inv ? -1.0 : 1.0)),
                        w = 1;
        for(int j = 0; 2 * j < sz; j += i) {
            for(int k = 0; k < i; k++) {
                y[j + k] = x[2 * j + k] + w * x[2 * j + i + k];
                y[j + k + (sz >> 1)] = x[2 * j + k] - w * x[2 * j + i + k];
            }
            w *= bs;
        }
        for(int j = 0; j < sz; j++)
            x[j] = y[j];
    }
    if(inv)
        for(int i = 0; i < sz; i++)
            x[i] /= sz;
}
int main() {
    ll n, m;
    cin >> n >> m;
    ll x = 2 * 100000;
    for(int i = 0; i < n; i++) {
        ll c;
        cin >> c;
        a[c] += 1.0;
        b[c] += 1.0;
    }
    ll sub = 0;
    dft(a, false);
    dft(b, false);
    for(int i = 0; i < sz; i++)
        a[i] *= b[i];
    dft(a, true);
    for(ll i = x; i >= 1; i--) {
        if(m == 0) {
            break;
        }
        ll amt = (ll)(a[i].real() + 0.5);
        if(amt <= m) {
            m -= amt;
            sub += i * amt;
        } else {
            sub += i * m;
            m = 0;
        }
    }
    cout << sub << endl;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define FOR(i, n) for(ll i = 0; i < n; i++)
#define FORR(i, n) for(ll i = n; i >= 0; i--)
#define FORS(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) accumulate(v.begin(),v.end(),0)
#define SORT(v) sort(v.begin(),v.end())
#define OUT(n) (cout << n << endl)
#define IN1(a) (cin >> a)
#define IN2(a,b) (cin >> a >> b)
#define IN3(a,b,c) (cin >> a >> b >> c)
#define IN4(a,b,c,d) (cin >> a >> b >> c >> d)
using namespace std;
typedef long long ll;

int main(){
  int n;
  IN1(n);
  vector<double>aarray(n);
  FOR(i,n){
    cin >> aarray[i];
  }
  double ans = 0;
  FOR(i,n){
    ans += 1 / aarray[i];
  }
  ans = 1 / ans;
  cout << fixed << setprecision(10);
  OUT(ans);
}

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

typedef pair <int, int> ii;

int h, w, m;
map <int, int> r;
map <int, int> c;
vector <int> maxr, maxc;
int maxrval, maxcval;
map <ii, bool> istarget;

int main() {
	scanf("%d%d%d", &h, &w, &m);
	for (int i = 0; i < m; i++) {
		int curh, curw; scanf("%d%d", &curh, &curw);
		istarget[ii(curh, curw)] = true;
		if (++r[curh] > maxrval) {
			maxrval = r[curh];
			maxr.clear();
			maxr.push_back(curh);
		} else if (r[curh] == maxrval) maxr.push_back(curh);

		if (++c[curw] > maxcval) {
			maxcval = c[curw];
			maxc.clear();
			maxc.push_back(curw);
		} else if (c[curw] == maxcval) maxc.push_back(curw);
	}
	bool found = false;
	for (int r : maxr) {
		for (int c : maxc) {
			if (!istarget[ii(r, c)]) {
				found = true;
				break;
			}
		}
		if (found) break;
	}
	if (found) printf("%d\n", maxrval + maxcval);
	else printf("%d\n", maxrval + maxcval - 1);
	return 0;
}


Measured memory_bytes: 52456
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	string s;
	cin >> s;
	if (N >= 3200) {
		cout << s;
	}
	else {
		cout << "red";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
const long long mod=1000000000+7;
signed main()
{
	long long n,k;
	cin>>n>>k;
	long long ans=0;
	for (long long i=k;i<=n+1;i++){
		ans=(ans+i*(n-i+1)+1)%mod;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3640
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, q = map(int, input().split())
    comb = [list(map(int, input().split())) for _ in range(q)]
    max_ = 0
    for i in itertools.combinations_with_replacement(range(1,m+1), n):
        point = 0
        for j in comb:
            if i[j[1]-1] - i[j[0]-1] == j[2]:
                point += j[3]
        max_ = max(max_, point)
    print(max_)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll x; cin >> x;
    rng(i,0,10000){
        rng(j,0,10000){
            ll a = 1LL*i*i*i*i*i;
            ll b = 1LL*j*j*j*j*j;
            if(a - b == x){
                cout << i << " " << j << endl;
                return 0;
            } else if(a + b == x){
                cout << i << " " << j*-1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
	string days[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	string givenDay;
 	getline(cin, givenDay);

	for (int i = 0; i < 7; i++)
	{
		if((givenDay.compare(days[i])) == 0)
		{
			cout <<  7 - i;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cout << #x << " = " << x << endl;
 
template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}
 
template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}
 
template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}
 
template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();    
    return 0;
}
 
const int MOD = 998244353, MAXN = 5e5 + 10, INF = 1e18 + 10, BASE = 37; 

void solve() {
    int n;
    cin >> n;
    vec<int> f(n + 1);
    vec<int> min_p(n + 1);
    vec<int> pr;
    for (int i = 2; i <= n; ++i) {
        if (min_p[i] == 0) {
            pr.pb(i);
            min_p[i] = i;
        }
        for (int j = 0; j < $(pr) && pr[j] <= min_p[i] && pr[j] * i <= n; ++j) {
            min_p[pr[j] * i] = pr[j];
        }
    }

    int s = 1;
    for (int i = 2; i <= n; ++i) {
        if (min_p[i] == i) {
            s += 2 * i;
            f[i] = 2;
        }
        else {
            int el = 1;
            int x = i;
            int p = min_p[x];
            int k = 0;
            while (min_p[x] == p) {
                el *= min_p[x];
                x /= min_p[x];
                k++;
            }
            if (x == 1) {
                s += i * (k + 1);
                f[i] = k + 1;
            }
            else {
                f[i] = f[i / el] * f[el];
                s += i * f[i];
            }
        }
    }

    cout << s << endl;  
}

Measured memory_bytes: 167836
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  string s_ring;
  int n;
  string ring[101];
  
  cin >> s_ring;
  cin >> n;
  int ans = 0;
  for(int i = 0 ; i < n ; i++){
    cin >> ring[i];
    ring[i] += ring[i];
  
    for(int j = 0 ; j < ring[i].size() ; j++){
      if(s_ring == ring[i].substr(j, s_ring.size())){
	  ans++;
	  break;
	}
    } 
  }
  
  cout << ans << endl;
}

  
  
  

Measured memory_bytes: 0