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

int main() {
	int n,m,l;cin>>n>>m>>l;
	long long int a[100][100]={},b[100][100]={},c[100][100]={};
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
	for(int i=0;i<m;i++)for(int j=0;j<l;j++)cin>>b[i][j];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<l;j++)
		{
			for(int k=0;k<m;k++)c[i][j]+=a[i][k]*b[k][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<l;j++)
		{
			if(j)cout<<" ";
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

namespace {

#define VEVE(i, a, b) for (ll i = a, __##i = b; i < __##i; ++i)
#define DYDY(i, a, b) for (ll i = a, __##i = b; i > __##i; --i)
#define RARA(x, seq) for (auto &x : seq)
#define SIZE(x) ((ll)(x.size()))
#define ALL(x) x.begin(), x.end()

typedef int ll;
typedef double dd;

void Solve(ll) {
  ll n, d1, d2;
  cin >> n >> d1 >> d2;
  auto oob = [&](ll x, ll y) {
    return min(x, y) < 0 or max(x, y) >= 2 * n;
  };
  auto make_graph = [&](ll dist) {
    vector<pair<ll, ll>> diffs;
    VEVE(i, -2 * n, 2 * n + 1) VEVE(j, -2 * n, 2 * n + 1) if (i * i + j * j == dist)
          diffs.emplace_back(i, j);
    vector<vector<ll>> color(2 * n, vector<ll>(2 * n, -1));
    queue<pair<ll, ll>> que;
    auto go = [&](ll sx, ll sy) {
      if (~color[sx][sy])
        return;
      que.emplace(sx, sy);
      color[sx][sy] = 0;
      while (not que.empty()) {
        ll x, y;
        tie(x, y) = que.front();
        que.pop();
        RARA(di, diffs) {
          const ll nx = x + di.first, ny = y + di.second;
          if (not oob(nx, ny) and color[nx][ny] == -1) {
            color[nx][ny] = color[x][y] ^ 1;
            que.emplace(nx, ny);
          }
        }
      }
    };
    VEVE(i, 0, 2 * n) VEVE(j, 0, 2 * n) go(i, j);
    return color;
  };
  auto color1 = make_graph(d1);
  auto color2 = make_graph(d2);
  map<pair<ll, ll>, ll> freq;
  VEVE(i, 0, 2 * n) VEVE(j, 0, 2 * n) ++freq[{color1[i][j], color2[i][j]}];
  RARA(f, freq) if (f.second >= n * n) {
      ll rem = n * n;
      VEVE(x, 0, 2 * n) VEVE(y, 0, 2 * n) if (f.first == make_pair(color1[x][y], color2[x][y])) {
            cout << x << " " << y << "\n";
            if (--rem == 0)
              return;
          }
    }
  assert(false);
}

void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}

int32_t main() {
#ifdef AZN
  freopen("input.txt", "r", stdin);
#endif
  Init();
  ll tests = 1;
  VEVE(test, 1, tests + 1) Solve(test);
  return 0;
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 200005

int main(){
sp;
int n;
cin>>n;
int x;
int y=0;
for(int i=1; i<=n; ++i){
    cin>>x;
    y+=(x%2);
}
if(y==0)cout<<"second";
else cout<<"first";
return 0;}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine().split(" ").map(_.toInt))
      .takeWhile {
        case Array(0, 0) => false
        case _ => true
      }
      .foreach { case Array(x, y) =>
        val output =
          if (x < y) s"$x $y"
          else       s"$y $x"

        println(output)
      }
  }
}

Measured memory_bytes: 49444
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long



void solve()
{
   
    int x;
    cin>>x;
    if(!x)cout<<1;
    else cout<<0;
    
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    vector<int> c(n);
    vector<vector<int> > a(200010);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        a[c[i]].push_back(i);
    }

    vector<int> id(200010, 0);
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++){

        //取らない
        dp[i + 1] += dp[i];
        dp[i + 1] %= MOD;

        int num = c[i];
        id[num]++;
        if(id[num] < a[num].size()){
            if(a[num][id[num]] == i + 1) continue;
            dp[a[num][id[num]]] += dp[i];
        }
    }

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

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

int main(){
  string s, ret="", tmp="";
  cin >> s;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')tmp.push_back(s[i]);
    else tmp="";
    if(ret.size()<tmp.size()){
      ret=tmp;
    }
  }
  cout << ret.length();
  return 0;
}
  
  


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    int n, q, t, b, c;
    ll tol = 0;
    map<int, int> ans;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        ans[t]++;
        tol += t;
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> b >> c;
        tol -= b * ans[b];
        tol += c * ans[b];
        ans[c] += ans[b];
        ans[b] = 0;
        cout << tol << "\n";
    }

    return 0;
}

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

int main()
{
    int n,count=0;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++) {
        if(i>1) {
            if((s[i]=='C' && s[i-1]=='B' && s[i-2]=='A')) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define scan(n)     scanf("%lld", &n);
#define print(n)    printf("%lld\n", n);
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        100005
#define LOG         19
#define mod         1000000007
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    scan(n);
    ll a[n],dp[n];
    for(ll i=0;i<n;i++){
        scan(a[i]);        
    }
    for(i=0;i<n;i++){
        dp[i]=0;
    }
    dp[0]=0;
    for(i=0;i<n;i++){
        if(i==1){
            dp[i]=abs(a[i]-a[i-1]);
        }
        else if(i>=2){
            dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));
        }
        // cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 5268
from collections import deque
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
INF = 10**9
to = [ [] for _ in range(n) ]
dist = [ [INF]*n for _ in range(3) ]
for _ in range(m):
    u, v = map(int, input().split())
    to[u-1].append(v-1)
s, t = map(int, input().split())
s -= 1; t -= 1

dist[0][s] = 0
que = deque([(s, 0)])
while que:
    u, prv = que.popleft()
    d = dist[prv][u]
    cur = (prv+1) % 3
    if prv == 2:
        d += 1
    for v in to[u]:
        if dist[cur][v] != INF:
            continue
        que.append((v, cur))
        dist[cur][v] = d
print( dist[0][t] if dist[0][t] < INF else -1 )

Measured memory_bytes: 57776
void main() {
	auto K = ri;
	((K/2) * ceil(K/2.)).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(std::string S, long long K){
  string s=S;
  ll ans=0;
  char prev=0;
  REP(S.size()){
    if(prev==S[i]){
      ++ans;
      S[i]=-1;
    }
    prev=S[i];
  }
  if(K==1){
    cout<<ans<<endl;
    return;
  }
  ll ans2=0;
  S=s;
  REP(S.size()){
    if(prev==S[i]){
      ++ans2;
      S[i]=-1;
    }
    prev=S[i];
  }
  ll num=S.size();
  if(S[num-1]==s[num-1]){
    cout<<ans+ans2*(K-1)<<endl;
    return;
  }
  if(S[0]!=s[0]){
    cout<<ans*(K/2+K%2)+ans2*(K/2)<<endl;
    return;
  }
  cout<<ans+ans2*(K-1)<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0){
		int i;
		boolean key = false; //falseテ」ツ?ェテ」ツつ嘉ヲツ鳴ステゥツ個?」ツ?陛」ツつ古」ツ?ヲテ」ツ??」ツつ?
		String[] id = new String[n];
		for(i=0; i<n; i++){
		    id[i] = kbd.next();
		}
		int m = kbd.nextInt();
		while(m>0){
		    String x = kbd.next(); // テヲツ督催、ツスツ愿」ツ?療」ツ?櫑D
		    boolean c = false; //trueテ」ツ?ェテ」ツつ嘉ヲツュツ」テ」ツ?療」ツ?ИD
		    for(i=0; i<n; i++){
			if(x.equals(id[i])) {
			    c = true; break;
			}
		    }
		    
		    if(c){
			if(!key){
			    System.out.println("Opened by "+x);
			    key = true;
			}
			else{
			    System.out.println("Closed by "+x);
			    key = false;
			}
		    }
		    else{
			System.out.println("Unknown "+x);
		    }
		    m--;
		}
	    }
	}
    }
}

Measured memory_bytes: 21544
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b;
  c=(a+b)/2;
  if(abs(a-c)==abs(b-c))
  {cout<<c;}
  else
  {cout<<"IMPOSSIBLE";}
 
 

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::HashSet;

#[allow(dead_code)]
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()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let hw = read_vec::<usize>();
    let h = hw[0];
    let w = hw[1];

    let mut masu : Vec<Vec<char>> = Vec::with_capacity(h);
    for _i in 0..h {
        let s : Vec<char> = read::<String>().chars().collect();
        masu.push(s);
    }

    let answer = solve(h, w, &masu);
    println!("{}", answer);
}

fn solve(h: usize, w: usize, masu: &[Vec<char>]) -> usize {
    let mut dp : Vec<Vec<(usize, usize)>> = vec![vec![(0, 0);w];2];
    let mut max = 0;
    
    for i in 0..h {
        let curr = i % 2;
        for j in 0..w {
            if masu[i][j] == '#' {
                dp[curr][j] = (0, 0);
                continue;
            }

            // yoko
            if j == 0 || masu[i][j-1] == '#' {
                let mut j1 = j + 1;
                while j1 < w && masu[i][j1] != '#' {
                    j1 += 1;
                }
                dp[curr][j].0 = j1 - j; 
            } else {
                dp[curr][j].0 = dp[curr][j-1].0;
            }

            // tate
            if i == 0 || masu[i-1][j] == '#' {
                let mut i1 = i + 1;
                while i1 < h && masu[i1][j] != '#' {
                    i1 += 1;
                }
                dp[curr][j].1 = i1 - i;
            } else {
                dp[curr][j].1 = dp[1-curr][j].1;
            }

            let val = dp[curr][j].0 + dp[curr][j].1;
            if val > max {
                max = val;
            }
        }
    }
    return max - 1;
}


Measured memory_bytes: 20732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			X[i] = sc.nextInt();
		}
		int R = Integer.MAX_VALUE;
		for(int x = 1 ;  x <= 100 ; ++x){
			int S = 0;
			for(int v : X){
				int power = (v - x) * (v - x);
				S += power;
			}
			R = Math.min(R, S);			
		}
		System.out.println(R);		
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  int N, n[3];
  cin >> N;
  for (int i; i < N; i++) {
    rep(i, 3) cin >> n[i];
    sort(n, n + 3);
    if (n[0] * n[0] + n[1] * n[1] - n[2] * n[2] == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int len = sc.nextInt();
        String[] strs = new String[n];
        for(int i = 0; i < n; i++)
            strs[i] = sc.next();

        Arrays.sort(strs);
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++)
            sb.append(strs[i]);
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22096
#include <iostream>

using namespace std;

int main()
{
   string s;
   cin>>s;
   int ans=0;
   int len =s.size();
   for(int i=0;i<len;i++)
   {
       if(s[i]=='o') ans++;
   }
   cout<<700+100*ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int MAXN = (int) 3e5 + 10;
const int mod = (int)998244353;

int n;
P a[MAXN];
int p[MAXN];

int CTR(int x, int y) {
    x += y;
    if ( x < 0) x += mod;
    if (x >= mod) x -= mod;
    return x;
}
void PL(int &x, int y) {
    x =CTR(x,y);
}

int t[MAXN];

int G(int i) {
    i=a[i].second;
    int cnt=0;
    while(i>=0){
        cnt+=t[i];
        i=(i&(i+1))-1;
    }
    return cnt;
}

void SCAN(int i){
    i=a[i].second;
    while(i<n){
        t[i]++;
        i|=i+1;
    }
}

int main() {
    cin >> n;
    vector<int> v;
    rep(i,n) {
        cin >> a[i].first >> a[i].second;
        v.push_back(a[i].second);
    }
    sort(all(v));
    rep(i,n) {
        a[i].second=lower_bound(all(v), a[i].second)-v.begin();
    }
    p[0]=1;
    rep(i,1,n+1) p[i]=CTR(p[i-1],p[i-1]);
    sort(a, a + n);
    int ans = 0;
    rep(i,n){
        PL(ans, CTR(p[n],-1));
    }
    rep(i,n){
        PL(ans, -CTR(p[i],-1));
        PL(ans, -CTR(p[n-i-1],-1));
    }
    rep(i,n){
        PL(ans, -CTR(p[i],-1));
        PL(ans, -CTR(p[n-i-1],-1));
    }
    rep(i,n){
        PL(ans, CTR(p[G(i)],-1));
        PL(ans, CTR(p[i-G(i)],-1));
        SCAN(i);
    }
    memset(t,0,sizeof(t));
    reverse(a,a+n);
    rep(i,n){
        PL(ans, CTR(p[G(i)],-1));
        PL(ans, CTR(p[i-G(i)],-1));
        SCAN(i);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << endl
using namespace std;
int input() {
    int r;
    cin >> r;
    //scanf("%lld", &r);
    return r;
}
int n, a, b, c; string s[123456], ans;
signed main() {
    cin >> n >> a >> b >> c;
    for1(i, n)cin >> s[i];
    for1(i, n) {
        if (s[i] == "AB") {
            if (a + b == 0) {
                puts("No"); return 0;
            }
            if (a > b) { ans += 'B'; a--; b++; }
            else if (a < b) { ans += 'A'; a++; b--; }
            else if (s[i + 1] == "BC") { ans += 'B'; a--; b++; }
            else { ans += 'A'; a++; b--; }
        }
        else if (s[i] == "AC") {
            if (a + c == 0) {
                puts("No"); return 0;
            }
            if (a > c) { ans += 'C'; a--; c++; }
            else if (a < c) { ans += 'A'; a++; c--; }
            else if (s[i + 1] == "BC") { ans += 'C'; a--; c++; }
            else { ans += 'A'; a++; c--; }
        }
        else  {
            if (b + c == 0) {
                puts("No"); return 0;
            }
            if (b > c) { ans += 'C'; b--; c++; }
            else if (b < c) { ans += 'B'; b++; c--; }
            else if (s[i + 1] == "AC") { ans += 'C'; b--; c++; }
            else { ans += 'B'; b++; c--; }
        }
    }
    puts("Yes"); for (char ch : ans)puts(ch);
}

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

typedef long long ll;
ll pts[200005][6]={0};

ll mnht(ll pt[200005][6], int kth, int idx, int d)
{
    ll dist=0;

    for(int i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[200005][6], int n, int d)
{
    ll pk=0;ll idx=0;

   for(int i=0;i<n;i++)
   {
       ll val=0;

       for(int j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}

int32_t main()
{
   int n, d = 2;
   cin>>n;

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

   ll pk[2<<d];

   for(int j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(int dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
   return 0;
}


Measured memory_bytes: 13004
import numpy as np
import sys

buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())

grid = np.frombuffer(buf.read(H*(W+1)), dtype='S1').reshape((H,W+1))
grid = grid[:,:-1]

select_col = (grid == b'#').any(axis = 0)
select_row = (grid == b'#').any(axis = 1)

grid = grid[select_row, :]
grid = grid[:, select_col]
grid = grid.astype(str)

print('\n'.join(''.join(row) for row in grid))


Measured memory_bytes: 12444
// clang-format off
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using G = vector<vector<ll>>;
#define G(i, j) i, vector<ll>(j)
#define Gv(i, j, k) i, vector<ll>(j, k)
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(std::string S, std::string T) {
  ll ans = 0;
  rep(i, S.size()) {
    if (S[i] != T[i])
      ans++;
  }
  ANS(ans);
}

// clang-format off
int main() {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 4028
# -*- coding: utf-8 -*-
from collections import Counter

n = int(input().strip())
v_list = list(map(int, input().rstrip().split()))
#-----

v_odd = [ v_list[i] for i in range(0,len(v_list),2) ]
v_even  = [ v_list[i] for i in range(1,len(v_list),2) ]

sort_cnt_v_odd  = sorted( Counter(v_odd).items(), key=lambda x:x[1], reverse=True)
sort_cnt_v_even = sorted(Counter(v_even).items(), key=lambda x:x[1], reverse=True)


# カウント数最大の数値が、v_oddとv_evenで一致
# v_oddとv_evenそれぞれで、数値が1種類のとき
#   → v_oddを全書き換え
if sort_cnt_v_odd[0][0] == sort_cnt_v_even[0][0] and len(sort_cnt_v_odd)==len(sort_cnt_v_even)==1:
    ans = len(v_odd)
else:
# カウント数最大の数値が、v_oddとv_evenで異なるとき
# v_oddとv_evenそれぞれを、1種類の数値に書き換え
    ans = n
    for i_o, v_o  in sort_cnt_v_odd[:2]:
        for i_e, v_e in sort_cnt_v_even[:2]:
            if i_o != i_e:
                tmp = len(v_odd) - v_o + len(v_even) - v_e
                ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 21084
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A, B = LI()
print(A * B // math.gcd(A, B))

Measured memory_bytes: 10832
// -*- coding:utf-8-unix -*-

use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
    }

    let mut a_counter = HashMap::new();
    for _ in 0..n {
        input! {
            a: u64,
        }
        let counter = a_counter.entry(a).or_insert(0);
        *counter += 1;
    }

    let mut ans = 0;
    for (k, v) in a_counter.iter() {
        // println!("{} {}", k, v);
        if k < v {
            ans += v - k;
        } else if k > v {
            ans += v;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<string>x;
string y;
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
    cin>>y;
    x.push_back(y);
}
sort(x.begin(),x.end());
for(int i=0;i<n;i++){
    cout<<x[i];
}
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#include <atcoder/all>

#define FOR_LT(i, beg, end) for (decltype(end) i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (decltype(end) i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (decltype(beg) i = beg; end <= i; i--)
#define REP(n)              for (decltype(n) repeat_index = 0; repeat_index < n; repeat_index++)

using namespace std;

int64_t e() {
	return -1;
}

int64_t op(int64_t lhs, int64_t rhs)
{
	return max(lhs, rhs);
}

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

	int n, q; cin >> n >> q;
	atcoder::segtree<int64_t, op, e> segt(n);
	FOR_LT(i, 0, n) {
		int64_t a; cin >> a;
		segt.set(i, a);
	}

	REP(q) {
		int op; cin >> op;
		if (op == 1) {
			int64_t x, a; cin >> x >> a;
			x--;
			segt.set(x, a);
		}
		if (op == 2) {
			int l, r; cin >> l >> r;
			cout << segt.prod(l - 1, r) << endl;;
		}
		if (op == 3) {
			int64_t x, v; cin >> x >> v; x--;
			int64_t ans = segt.max_right(x, [&](int64_t val) { return (val < v); });
			cout << ans + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 9020
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int A, B;
int main() {
	cin >> A >> B;
	cout << (A - 3 + B) / (A - 1);
}

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

int main() {

  double sum = 0;
  double sum2 = 0;
  double input;
  int N;


  for(;;) {
    std::cin >> N;
    if( N == 0 ) {
      break;
    }
    
    sum = sum2 = 0;
    for(int i = 0; i < N; ++i) {
      std::cin >> input;
      sum += input;
      sum2 += input*input;
    }
    printf("%.10lf\n", sqrt(sum2/N - (sum/N)*(sum/N)));
  }
  
  return 0;
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;

  int ans = INF;
  for (char t = 'a'; t <= 'z'; t++) {
    string prev = s;
    int cnt = 0;

    while (true) {
      string next = "";

      bool all_same = true;
      for (int i = 0; i < prev.size() - 1; i++) {
        all_same = all_same && (prev[i] == prev[i+1]);
      }
      
      if (all_same) {
        ans = min(cnt, ans);
        break;
      }

      for (int i = 0; i < prev.size() - 1; i++) {
        if (prev[i] == t || prev[i+1] == t)
          next += t;
        else
          next += prev[i];
      }
      cnt++;

      prev = next;
    }
  }

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


Measured memory_bytes: 256
while True:
    ans = [0, 0]
    m, n1, n2 = map(int, input().split())
    if m == n1 == n2 == 0:
        quit()
    p = []
    for i in range(m):
        p.append(int(input()))
    p.sort(reverse=True)
    for i in range(n1 - 1, n2):
        if ans[0] <= p[i] - p[i + 1]:
            ans[0] = p[i] - p[i + 1]
            ans[1] = i + 1
    print(ans[1])



Measured memory_bytes: 5612
#include <stdio.h>
 
char c[256];
 
void clear() {
  int i; for (i = 0; i < 256; i++) c[i] = 0;
}
 
int main() {
  int n;
  char f, t;
  while (1) {
    scanf("%d\n", &n);
    if (!n) break;
     
    clear();
    while (n--) {
      scanf("%c %c\n", &f, &t);
      c[f] = t;
    }
     
    scanf("%d\n", &n);
    while (n--) {
      scanf("%c\n", &f);
      if (c[f]) printf("%c", c[f]);
      else printf("%c", f);
    }
    printf("\n");
  }
  return 0;
}
 

Measured memory_bytes: 576
#include <iostream>
#include <algorithm>
#include <queue>
#include <stdio.h>
using namespace std;

struct t
{
    char name[100];
    int id;
    int time;
    int used_time;
}task[100005];

bool cmp(t x,t y)
{
    return x.used_time<y.used_time;
}

bool all_finished(t a[],int n)
{
    for(int i=1;i<=n;i++)
        if(a[i].time!=0) return false;
    return true;
}

int main()
{
    queue<t> que;
    int n,q,cost_time=0;
    cin>>n>>q;

    for(int i=1;i<=n;i++)
    {
        scanf("%s %d",task[i].name,&task[i].time);
        task[i].id=i;
        cost_time+=task[i].time;
        task[i].used_time=0;
        que.push(task[i]);
    }

    //int start=clock();

    int x=0;

    while(x<cost_time)
    {
        if(que.front().time>q)
        {
            que.front().time-=q;
            que.push(que.front());
            que.pop();
            x+=q;
        }
        else if(que.front().time>0)
        {
            x+=que.front().time;
            que.front().time=0;
        }
        if(que.front().time==0)
        {
            task[que.front().id].used_time=x;
            que.pop();
        }
    }

    sort(task+1,task+n+1,cmp);

    for(int i=1;i<=n;i++)
    {
        cout<<task[i].name<<' '<<task[i].used_time<<endl;
    }

    //int endtime=clock();
    //cout<<(endtime-start)/(double)CLOCKS_PER_SEC<<"ms"<<endl;
}



Measured memory_bytes: 14272
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>


 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    ll x=a/b;
    if(a%b>0) x++;
    cout<<x*c;

return 0;    
 }  

Measured memory_bytes: 3632
#!/usr/bin/env python3

a, b, k = list(map(int, input().split()))

ans = set([])

for i in range(a, min(a+k, b)):
    ans.add(i)

for i in range(max(a, b-k+1), b+1):
    ans.add(i)

for i in sorted(list(ans)):
    print(i)


Measured memory_bytes: 9120
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 136 -C
#define MAX 100000
//#define MAX 101
static int f[MAX];
int main(void) {
	int i, n, h[MAX+2],t;
	h[0] = 0;

	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
		t = h[i] - h[i - 1];
		if (t >= 0)continue;
		if (t < -1) { printf("No\n"); return 0; }
		h[i]++;
	}
	
	for (i = n; i > 0; i--) {
		if ((h[i] - h[i - 1]) < 0)
		{printf("No\n"); return 0;}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 512
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, M = map(int, readline().split())
    if N == M == 0:
        return False
    G = [[] for i in range(N)]
    cs = [0]*N
    for i in range(M):
        u, v = map(int, readline().split())
        forward = [v-1, 1, None]
        backward = forward[2] = [u-1, 0, forward]

        G[u-1].append(forward)
        G[v-1].append(backward)
        cs[v-1] += 1
    prv = [0]*N
    while 1:
        que = deque()
        used = [0]*N
        mi = min(cs); ma = max(cs)
        for i in range(N):
            if mi < cs[i]:
                continue
            que.append(i)
            used[i] = 1
            prv[i] = None
        j = -1
        while que:
            v = que.popleft()
            if mi+2 <= cs[v]:
                j = v
                break
            for w, d, rev in G[v]:
                if d and not used[w]:
                    que.append(w)
                    prv[w] = rev
                    used[w] = 1
        if j == -1:
            break
        v = j
        while prv[v] is not None:
            e = prv[v]
            e[1] = 1; e[2][1] = 0
            v = prv[v][0]
        cs[v] += 1; cs[j] -= 1

    while 1:
        que = deque()
        used = [0]*N
        mi = min(cs); ma = max(cs)
        for i in range(N):
            if cs[i] < ma:
                continue
            que.append(i)
            used[i] = 1
            prv[i] = None
        j = -1
        while que:
            v = que.popleft()
            if cs[v] <= ma-2:
                j = v
                break
            for w, d, rev in G[v]:
                if not d and not used[w]:
                    que.append(w)
                    prv[w] = rev
                    used[w] = 1
        if j == -1:
            break
        v = j
        while prv[v] is not None:
            e = prv[v]
            e[1] = 0; e[2][1] = 1
            v = prv[v][0]
        cs[v] -= 1; cs[j] += 1

    write("%d %d\n" % (min(cs), max(cs)))

    return True
while solve():
    ...


Measured memory_bytes: 7096
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]
d = defaultdict(int)
for a in A:
  d[a] += 1
x = 1
cnt = 0
d = sorted(d.items(), key=lambda x:-x[0])
for i, j in d:
  if x == 1 and j >= 4:
    print(i**2)
    exit()
  if j >= 2:
    x *= i
    cnt += 1
    if cnt == 2:
      break
if cnt >= 1:
  print(x)
else:
  print(0)

Measured memory_bytes: 25508
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
		int W = sc.nextInt();

    String[] input = new String[H];
    for(int i=0; i<H; i++){
      input[i] = sc.next();
    }

    String[][] input_bunkatsu = new String[H][W];
    for(int i=0; i<H; i++){
      input_bunkatsu[i] = input[i].split("");
    }

    String[][] a = new String[H+2][W+2];
    for(int i=1; i<H+1; i++){
      for(int j=1; j<W+1; j++){
        a[i][j] = input_bunkatsu[i-1][j-1];
      }
    }

    for(int i=0; i<H+2; i++){
      a[i][0] = "#";
      a[i][W+1] = "#";
    }

    for(int j=1; j<W+1; j++){
      a[0][j] = "#";
      a[H+1][j] = "#";
    }

    for(int i=0; i<H+2; i++){
      for(int j=0; j<W+2; j++){
        System.out.print(a[i][j]);
      }
      System.out.println();
    }

	}

}


Measured memory_bytes: 22996
#include <stdio.h>
#include <string.h>

int main(){
  char a[]="6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9";
  char *b,*c,*d;
  int f,g,h,i;
  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d %d",&f,&g);
    b=strchr(a,'0'+f);
    c=strchr(b+1,'0'+f);
    d=strchr(b+1,'0'+g);
    if(c==NULL || c>d)c=b;
    for(;c<=d;c++) printf("%c",c[0]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
n, k = map(int,input().split())
p = [int(i) for i in input().split()]

psum = [0] * (n - k + 1)
psum[0] = sum(p[0:k])
for i in range(1, n - k + 1):
  psum[i] = psum[i-1] - p[i-1] + p[i + k - 1]
res = (max(psum)+k) / 2
print(res)

Measured memory_bytes: 25188
// ABC125_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）



int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, tmp, minimum = INF, num = 0;
    cin >> N;
    vector<ll> abs_vec(N);
    REP(i, N) {
        cin >> tmp;
        if (tmp < 0) num++;
        abs_vec[i] = abs(tmp);
        minimum = min(minimum, abs_vec[i]);
    }
    
    // calculation
    if (num%2 == 0) {
        cout << SUM(abs_vec) << "\n";
    } else {
        // N が奇数のとき
        // 一つがマイナスになる
        cout << SUM(abs_vec) - 2*minimum << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 1024
N=int(input())
Y=[]
for i in range(N):
  list=input().split()
  money=float(list[0])
  if list[1]=="JPY":
    Y.append(money)
  else:
    Y.append(380000.0*money)
all=0
for j in Y:
  all+=j
print(all)
    
  


Measured memory_bytes: 38384
import numpy as np
MOD = 10 ** 9 + 7

n = int(input())
a = np.array(list(map(int, input().split())))
l = len(bin(max(a))) - 2

ans = 0
for i in range(l):
    b = (a >> i) & 1
    x = np.count_nonzero(b)
    now = x * (n - x) * pow(2, i, MOD) % MOD
    ans += now

print(ans % MOD)


Measured memory_bytes: 48820
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n, m = MI()
bridge = sorted([LI() for _ in range(m)], key=lambda x: x[1])
ans = 0
endtime = 0
for i in range(m):
    if endtime <= bridge[i][0]:
        endtime = bridge[i][1]
        ans += 1 
print(ans)


Measured memory_bytes: 88848
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555;
const double PI = acos(-1.0);
ll dp[101101];
void solve()
{
	int n, m;
	cin >> n >> m;
	ll a[m], b[m], c[m][m];
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i];
		for(int j = 0; j < b[i]; ++j){
			cin >> c[i][j];
			c[i][j]--;
		}
	}
	for(int i = 0; i < 1 << n; ++i) dp[i] = inf * 1ll * inf;
	dp[0] = 0;
	for(int i = 0; i < 1 << n; ++i){
		for(int j = 0; j < m; ++j){
			int ni = i;
			for(int k = 0; k < b[j]; ++k){
				if(ni & (1 << c[j][k])) ni ^= (1 << c[j][k]);
			}
			dp[i] = min(dp[i], dp[ni] + a[j]);
		}
	}
	if(dp[(1 << n) - 1] == inf * 1ll * inf) cout << -1;
	else cout << dp[(1 << n) - 1];

}
  
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 7296
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long dp[1100000][3];
int main(){
	int a;scanf("%d",&a);
	init_C(1100000);
	long long ret=0;
	dp[0][0]=1;
	for(int i=0;i<a+1;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				dp[i+1][k]=(dp[i+1][k]+dp[i][j])%mod;
			}
		}
	}
	for(int i=1;i<=a;i++){
		long long ks=inv[3]*inv[a]%mod*inv[i]%mod;
		long long cnt=dp[i][1]*Comb(a,i)%mod;
		ret=(ret+ks*cnt)%mod;
	}
	ret=ret*pw(inv[3],a-1)%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 55424
n = int(input())
ans = 0
matrix = [[0 for _ in range(9)] for _ in range(9)]
for i in range(n):
    a = str(i+1)
    b = n
    x = int(a[0])-1
    y = int(a[-1])-1
    if y != -1:
        matrix[x][y] += 1
for i in range(9):
    for j in range(9):
        ans += matrix[i][j]*matrix[j][i]
print(ans)


Measured memory_bytes: 3188
import Control.Monad
import Data.List
import Data.Ord

g xs
 | rs == [0] = xs !! 0
 | otherwise = xs !! (head rs + 1)
 where
  ys = zipWith (-) (tail xs) xs
  z = head $ maximumBy (comparing length) $ group $ sort ys
  rs = findIndices (/=z) ys

main = do
 n <- getLine
 when (n /= "0") $ do
  l <- getLine
  print $ g $ map read $ words l
  main

Measured memory_bytes: 5476